(
out_dir: Path,
subdir: str | None = None,
linkcheck: bool = False,
pdf: bool = False,
html: bool = True,
clean_html: bool = False,
serve: bool = False,
)
| 137 | |
| 138 | |
| 139 | def main( |
| 140 | out_dir: Path, |
| 141 | subdir: str | None = None, |
| 142 | linkcheck: bool = False, |
| 143 | pdf: bool = False, |
| 144 | html: bool = True, |
| 145 | clean_html: bool = False, |
| 146 | serve: bool = False, |
| 147 | ) -> None: |
| 148 | static_dynamic_dir = (Path("docs") / "_static_dynamic").absolute() |
| 149 | |
| 150 | def clean_static_dynmaic_dir() -> None: |
| 151 | shutil.rmtree(static_dynamic_dir, ignore_errors=True) |
| 152 | |
| 153 | clean_static_dynmaic_dir() |
| 154 | static_dynamic_dir.mkdir(parents=True, exist_ok=True) |
| 155 | atexit.register(clean_static_dynmaic_dir) |
| 156 | |
| 157 | if linkcheck: |
| 158 | execute_sphinx_build(out_dir, "linkcheck") |
| 159 | |
| 160 | if pdf: |
| 161 | pdf_dir = execute_sphinx_build(out_dir, "simplepdf", out_dir="pdf") |
| 162 | (static_dynamic_dir / "pex.pdf").symlink_to(pdf_dir / "pex.pdf") |
| 163 | |
| 164 | if html: |
| 165 | html_defines: dict[str, str] = {} |
| 166 | if subdir: |
| 167 | html_defines["pex_site_subdir"] = f"/{subdir.lstrip('/')}" |
| 168 | html_dir = execute_sphinx_build(out_dir, "html", **html_defines) |
| 169 | if clean_html: |
| 170 | shutil.rmtree(html_dir / ".doctrees", ignore_errors=True) |
| 171 | (html_dir / ".buildinfo").unlink(missing_ok=True) |
| 172 | (html_dir / "objects.inv").unlink(missing_ok=True) |
| 173 | |
| 174 | page_find_args = ["--site", str(html_dir), "--output-subdir", "_pagefind"] |
| 175 | if serve: |
| 176 | page_find_args.append("--serve") |
| 177 | execute_pagefind(page_find_args) |
| 178 | |
| 179 | |
| 180 | if __name__ == "__main__": |
no test coverage detected