diff --git a/doc/properties.toml b/doc/properties.toml index 8d8a3ac3..fd8d75b3 100644 --- a/doc/properties.toml +++ b/doc/properties.toml @@ -1,12 +1,9 @@ -# general properties/settings - modid = "hexcasting" book = "hexcasting:thehexbook" url = "https://gamma-delta.github.io/HexMod" default_lang = "en_us" -# top takes priority -resource_dirs = [ +resource_dirs = [ # top takes priority { path = "src/hexdoc/_export/resources", reexport = false }, "{_common.src}/main/resources", "{_common.src}/generated/resources", @@ -36,6 +33,7 @@ hexcasting = "https://raw.githubusercontent.com/gamma-delta/HexMod/main/Common/s [template] main = "main.html.jinja" +static_dir = "static" packages = [ "hexdoc", ] diff --git a/doc/src/hexdoc/__version__.py b/doc/src/hexdoc/__version__.py new file mode 100644 index 00000000..2c2b3e31 --- /dev/null +++ b/doc/src/hexdoc/__version__.py @@ -0,0 +1 @@ +__version__ = "1.0.dev0" diff --git a/doc/src/hexdoc/hexdoc.py b/doc/src/hexdoc/hexdoc.py index 0e10b6f9..665e56c4 100644 --- a/doc/src/hexdoc/hexdoc.py +++ b/doc/src/hexdoc/hexdoc.py @@ -150,8 +150,8 @@ def main(args: Args | None = None) -> None: 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(): + static_dir = props.template.static_dir + if static_dir and 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/properties.py b/doc/src/hexdoc/utils/properties.py index 4e3bc959..f41526fa 100644 --- a/doc/src/hexdoc/utils/properties.py +++ b/doc/src/hexdoc/utils/properties.py @@ -24,6 +24,7 @@ class PatternStubProps(StripHiddenModel): class TemplateProps(StripHiddenModel): main: str + static_dir: Path | None = None dirs: list[Path] = Field(default_factory=list) packages: list[tuple[str, Path]] args: dict[str, Any] @@ -49,12 +50,12 @@ class Properties(StripHiddenModel): the text color to the default.""" resource_dirs: list[ResourceDir] - export_dir: Path - - entry_id_blacklist: set[ResourceLocation] = Field(default_factory=set) + export_dir: Path | None = None pattern_stubs: list[PatternStubProps] + entry_id_blacklist: set[ResourceLocation] = Field(default_factory=set) + base_asset_urls: dict[str, NoTrailingSlashHttpUrl] """Mapping from modid to the url of that mod's `resources` directory on GitHub.""" diff --git a/doc/src/hexdoc/utils/resource_loader.py b/doc/src/hexdoc/utils/resource_loader.py index 2b473440..06332905 100644 --- a/doc/src/hexdoc/utils/resource_loader.py +++ b/doc/src/hexdoc/utils/resource_loader.py @@ -43,7 +43,8 @@ class ModResourceLoader: @contextmanager 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]) + if props.export_dir: + subprocess.run(["git", "clean", "-fdX", props.export_dir]) with ExitStack() as stack: loader = cls( @@ -328,6 +329,8 @@ class ModResourceLoader: decode: Callable[[str], _T] = decode_json_dict, export: ExportFn[_T] | None = None, ) -> None: + if not self.props.export_dir: + return out_path = self.props.export_dir / path logging.getLogger(__name__).debug(f"Exporting {path} to {out_path}") diff --git a/pyproject.toml b/pyproject.toml index 6aefe065..1332a7c1 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,5 +1,5 @@ [build-system] -requires = ["hatchling", "hatch-gradle-version>=0.2.1"] +requires = ["hatchling", "hatch-gradle-version>=0.3.0"] build-backend = "hatchling.build" # project metadata @@ -38,8 +38,9 @@ hexdoc = "hexdoc.hexdoc:main" # Gradle version/deps [tool.hatch.version] +scheme = "gradle" source = "gradle-properties" -py-version = "1.0" +py-path = "doc/src/hexdoc/__version__.py" # directory inclusion