Add optional static dir
This commit is contained in:
parent
d2ca57720b
commit
e242e2e046
3 changed files with 11 additions and 2 deletions
|
@ -1,6 +1,8 @@
|
||||||
import io
|
import io
|
||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
|
import shutil
|
||||||
|
import subprocess
|
||||||
import sys
|
import sys
|
||||||
from argparse import ArgumentParser
|
from argparse import ArgumentParser
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
@ -99,7 +101,7 @@ def main(args: Args | None = None) -> None:
|
||||||
|
|
||||||
# load the book
|
# load the book
|
||||||
props = Properties.load(args.properties_file)
|
props = Properties.load(args.properties_file)
|
||||||
with ModResourceLoader.load_all(props) as loader:
|
with ModResourceLoader.clean_and_load_all(props) as loader:
|
||||||
_, book_data = Book.load_book_json(loader, props.book)
|
_, book_data = Book.load_book_json(loader, props.book)
|
||||||
|
|
||||||
with init_context(book_data):
|
with init_context(book_data):
|
||||||
|
@ -144,7 +146,14 @@ def main(args: Args | None = None) -> None:
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# write docs
|
||||||
|
subprocess.run(["git", "clean", "-fdX", args.output_dir])
|
||||||
args.output_dir.mkdir(parents=True, exist_ok=True)
|
args.output_dir.mkdir(parents=True, exist_ok=True)
|
||||||
|
|
||||||
|
static_dir = Path("static")
|
||||||
|
if static_dir.is_dir():
|
||||||
|
shutil.copytree(static_dir, args.output_dir, dirs_exist_ok=True)
|
||||||
|
|
||||||
(args.output_dir / "index.html").write_text(docs, "utf-8")
|
(args.output_dir / "index.html").write_text(docs, "utf-8")
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -41,7 +41,7 @@ class ModResourceLoader:
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
@contextmanager
|
@contextmanager
|
||||||
def load_all(cls, props: Properties) -> Iterator[Self]:
|
def clean_and_load_all(cls, props: Properties) -> Iterator[Self]:
|
||||||
# clear the export dir so we start with a clean slate
|
# clear the export dir so we start with a clean slate
|
||||||
subprocess.run(["git", "clean", "-fdX", props.export_dir])
|
subprocess.run(["git", "clean", "-fdX", props.export_dir])
|
||||||
|
|
||||||
|
|
BIN
doc/static/logo.png
vendored
Normal file
BIN
doc/static/logo.png
vendored
Normal file
Binary file not shown.
After Width: | Height: | Size: 37 KiB |
Loading…
Reference in a new issue