mypy/fs,sphinx
This commit is contained in:
parent
3a8b239b9f
commit
e213285987
2 changed files with 11 additions and 6 deletions
|
@ -68,12 +68,12 @@ def read_file_text(file_path: str, charset: str = CHARSET) -> str:
|
||||||
return read_file_bytes(file_path).decode(charset)
|
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."""
|
"""Wipe provided path, whether directory or file."""
|
||||||
try:
|
try:
|
||||||
shutil.rmtree(path)
|
shutil.rmtree(path)
|
||||||
except NotADirectoryError:
|
except NotADirectoryError:
|
||||||
Path(path).unlink(missing_ok=True)
|
path.unlink(missing_ok=True)
|
||||||
except FileNotFoundError:
|
except FileNotFoundError:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,10 @@
|
||||||
"""Project consisting only of a Sphinx documentation."""
|
"""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 sphinx.cmd.build import build_main
|
||||||
|
|
||||||
from rwx.fs import wipe
|
from rwx.fs import wipe
|
||||||
|
@ -15,7 +20,7 @@ class SphinxProject(Project):
|
||||||
|
|
||||||
def build(self) -> None:
|
def build(self) -> None:
|
||||||
"""Build the project."""
|
"""Build the project."""
|
||||||
output_root: str = self.root / "out"
|
output_root: Path = self.root / "out"
|
||||||
wipe(output_root)
|
wipe(output_root)
|
||||||
arguments: list[str] = [
|
arguments: list[str] = [
|
||||||
"-E",
|
"-E",
|
||||||
|
@ -30,9 +35,9 @@ class SphinxProject(Project):
|
||||||
"-D",
|
"-D",
|
||||||
"html_theme={}".format("sphinx_rtd_theme"),
|
"html_theme={}".format("sphinx_rtd_theme"),
|
||||||
"-c",
|
"-c",
|
||||||
self.root,
|
str(self.root),
|
||||||
# "-C",
|
# "-C",
|
||||||
self.root / self.name,
|
str(self.root / self.name),
|
||||||
output_root / "web",
|
str(output_root / "web"),
|
||||||
]
|
]
|
||||||
build_main(arguments)
|
build_main(arguments)
|
||||||
|
|
Loading…
Reference in a new issue