diff --git a/doc/src/hexdoc/hexdoc.py b/doc/src/hexdoc/hexdoc.py index 2ba7177f..0e10b6f9 100644 --- a/doc/src/hexdoc/hexdoc.py +++ b/doc/src/hexdoc/hexdoc.py @@ -1,6 +1,8 @@ import io import logging import os +import shutil +import subprocess import sys from argparse import ArgumentParser from pathlib import Path @@ -99,7 +101,7 @@ def main(args: Args | None = None) -> None: # load the book 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) 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) + + 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") diff --git a/doc/src/hexdoc/utils/resource_loader.py b/doc/src/hexdoc/utils/resource_loader.py index b1db0a3e..2b473440 100644 --- a/doc/src/hexdoc/utils/resource_loader.py +++ b/doc/src/hexdoc/utils/resource_loader.py @@ -41,7 +41,7 @@ class ModResourceLoader: @classmethod @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 subprocess.run(["git", "clean", "-fdX", props.export_dir]) diff --git a/doc/static/logo.png b/doc/static/logo.png new file mode 100644 index 00000000..bb610902 Binary files /dev/null and b/doc/static/logo.png differ