Small cleaning
This commit is contained in:
parent
e0a2d2b83c
commit
ee69a8ddfa
2 changed files with 8 additions and 2 deletions
|
@ -10,7 +10,8 @@ logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
def cli_generate(source_dir: Path, build_dir: Path):
|
def cli_generate(source_dir: Path, build_dir: Path):
|
||||||
|
|
||||||
config = Config(source_dir.resolve(), build_dir.resolve())
|
config = Config(source_dir.resolve(),
|
||||||
|
build_dir.resolve())
|
||||||
|
|
||||||
generate(config)
|
generate(config)
|
||||||
|
|
||||||
|
@ -23,7 +24,10 @@ def main_cli():
|
||||||
help="Path to the build output",
|
help="Path to the build output",
|
||||||
)
|
)
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
"--source_dir", type=Path, default=Path(), help="Site source directory"
|
"--source_dir",
|
||||||
|
type=Path,
|
||||||
|
default=Path(),
|
||||||
|
help="Site source directory"
|
||||||
)
|
)
|
||||||
|
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
|
|
@ -28,6 +28,7 @@ def _replace_content(src: Path, dst: Path):
|
||||||
|
|
||||||
def _write_file(path: Path, content: str):
|
def _write_file(path: Path, content: str):
|
||||||
os.makedirs(path.parent, exist_ok=True)
|
os.makedirs(path.parent, exist_ok=True)
|
||||||
|
print("writing to:", path)
|
||||||
with open(path, "w", encoding="utf-8") as f:
|
with open(path, "w", encoding="utf-8") as f:
|
||||||
f.write(content)
|
f.write(content)
|
||||||
|
|
||||||
|
@ -54,6 +55,7 @@ def generate(config: Config):
|
||||||
parser = MarkdownIt()
|
parser = MarkdownIt()
|
||||||
sources = config.source_dir.glob("**/*.md")
|
sources = config.source_dir.glob("**/*.md")
|
||||||
for source in sources:
|
for source in sources:
|
||||||
|
print("processing source: ", source)
|
||||||
content = _read_file(source)
|
content = _read_file(source)
|
||||||
output = parser.render(content)
|
output = parser.render(content)
|
||||||
output_path = _get_transformed_path(config, source, "html")
|
output_path = _get_transformed_path(config, source, "html")
|
||||||
|
|
Loading…
Reference in a new issue