Skip to content

Commit

Permalink
feat: ignore more pydantic methods and allow cleaning directory
Browse files Browse the repository at this point in the history
  • Loading branch information
antazoey authored Oct 3, 2024
2 parents 0086855 + 30e6cbc commit 3523d58
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 1 deletion.
6 changes: 5 additions & 1 deletion sphinx_ape/_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,13 @@ def __init__(self, base_path: Optional[Path] = None, name: Optional[str] = None)
def docs_path(self) -> Path:
return self._base_path / "docs"

@property
def root_build_path(self) -> Path:
return self.docs_path / "_build"

@property
def build_path(self) -> Path:
return self.docs_path / "_build" / self._name
return self.root_build_path / self._name

@property
def latest_path(self) -> Path:
Expand Down
10 changes: 10 additions & 0 deletions sphinx_ape/_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,16 @@ def publish(base_path, mode, repo, skip_push):
sys.exit(1)


@cli.command()
@click.argument("base_path", type=Path)
def clean(base_path):
"""
Delete build artifacts
"""
builder = _create_builder(base_path=base_path)
builder.clean()


def _create_builder(*args, **kwargs) -> DocumentationBuilder:
# Abstracted for testing purposes.
return DocumentationBuilder(*args, **kwargs)
Expand Down
3 changes: 3 additions & 0 deletions sphinx_ape/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,9 @@ def build(self):

self._setup_redirect()

def clean(self):
shutil.rmtree(self.root_build_path)

def publish(self, repository: Optional[str] = None, push: bool = True):
"""
Publish the documentation to GitHub pages.
Expand Down
11 changes: 11 additions & 0 deletions sphinx_ape/sphinx_ext/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,17 @@ def setup(app: Sphinx):
"model_fields",
"model_post_init",
"model_computed_fields",
"__class_vars__",
"__private_attributes__",
"__pydantic_complete__",
"__pydantic_core_schema__",
"__pydantic_custom_init__",
"__pydantic_decorators__",
"__pydantic_generic_metadata__",
"__pydantic_parent_namespace__",
"__pydantic_post_init__",
"__pydantic_serializer__",
"__pydantic_validator__",
# EthPydanticTypes.
"__ape_extra_attributes__",
)
Expand Down

0 comments on commit 3523d58

Please sign in to comment.