mypy/fs,sphinx

This commit is contained in:
Marc Beninca 2024-09-13 23:17:09 +02:00
parent 3a8b239b9f
commit e213285987
Signed by: marc.beninca
GPG key ID: 9C7613450C80C24F
2 changed files with 11 additions and 6 deletions

View file

@ -68,12 +68,12 @@ def read_file_text(file_path: str, charset: str = CHARSET) -> str:
return read_file_bytes(file_path).decode(charset)
def wipe(path: str) -> None:
def wipe(path: Path) -> None:
"""Wipe provided path, whether directory or file."""
try:
shutil.rmtree(path)
except NotADirectoryError:
Path(path).unlink(missing_ok=True)
path.unlink(missing_ok=True)
except FileNotFoundError:
pass

View file

@ -1,5 +1,10 @@
"""Project consisting only of a Sphinx documentation."""
from typing import TYPE_CHECKING
if TYPE_CHECKING:
from pathlib import Path
from sphinx.cmd.build import build_main
from rwx.fs import wipe
@ -15,7 +20,7 @@ class SphinxProject(Project):
def build(self) -> None:
"""Build the project."""
output_root: str = self.root / "out"
output_root: Path = self.root / "out"
wipe(output_root)
arguments: list[str] = [
"-E",
@ -30,9 +35,9 @@ class SphinxProject(Project):
"-D",
"html_theme={}".format("sphinx_rtd_theme"),
"-c",
self.root,
str(self.root),
# "-C",
self.root / self.name,
output_root / "web",
str(self.root / self.name),
str(output_root / "web"),
]
build_main(arguments)