Files
AnyImage/tools/docs.py
nan e7aeeb21d4 Add tools and tests for AnyImage model management and documentation
- Implement sync_models.py for preparing and uploading ONNX artifacts.
- Create build_node.py for building and validating Blender scripts.
- Add docs.py for building and previewing documentation with Mike or MkDocs.
- Introduce model_exports.py for exporting PyTorch models to ONNX format.
- Develop pack.py for packaging the project with dependencies for different platforms.
- Add test_sync_models.py to validate sync_models functionality.
- Add test_tool_commands.py to ensure repository tools have correct command scripts.
- Initialize tools package with __init__.py.
2026-08-31 15:15:33 +08:00

49 lines
1.1 KiB
Python

import argparse
import subprocess
import tomllib
from pathlib import Path
PROJECT_ROOT = Path(__file__).resolve().parents[1]
def project_version():
"""Return the documentation version declared by the project."""
project = tomllib.loads(
(PROJECT_ROOT / "pyproject.toml").read_text(encoding="utf-8")
)["project"]
return project["version"]
def documentation_command(dev=False):
"""Return the Mike or MkDocs command for the requested mode."""
if dev:
return ["mkdocs", "serve"]
return [
"mike",
"deploy",
"--update-aliases",
project_version(),
"latest",
]
def main(argv=None):
parser = argparse.ArgumentParser(description="Build or preview documentation.")
parser.add_argument(
"-dev",
"--dev",
action="store_true",
help="preview the current documentation with live reload",
)
args = parser.parse_args(argv)
subprocess.run(
documentation_command(args.dev),
cwd=PROJECT_ROOT,
check=True,
)
if __name__ == "__main__":
main()