Skip to content

Commit

Permalink
Use autodoc2 for API docs
Browse files Browse the repository at this point in the history
  • Loading branch information
GDYendell committed Aug 9, 2024
1 parent 089b729 commit 6301a02
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 18 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ cov.xml

# Sphinx documentation
docs/_build/
docs/reference/_api

# PyBuilder
target/
Expand Down
34 changes: 30 additions & 4 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@
version = release

extensions = [
# Use this for generating API docs
"sphinx.ext.autodoc",
# Autodoc2 for generating API docs from docstrings
"autodoc2",
# This can parse google style docstrings
"sphinx.ext.napoleon",
# For linking to external sphinx documentation
Expand All @@ -49,7 +49,18 @@
]

# So we can use the ::: syntax
myst_enable_extensions = ["colon_fence"]
myst_enable_extensions = [
"colon_fence",
"fieldlist",
]

# Autodoc2 Config
autodoc2_packages = [
"../src/pvi",
]
autodoc2_render_plugin = "myst"
autodoc2_output_dir = "reference/_api"
# autodoc2_annotations = False

# If true, Sphinx will warn about all references where the target cannot
# be found.
Expand All @@ -67,7 +78,21 @@
("py:class", "'bool'"),
("py:class", "'object'"),
("py:class", "'id'"),
("py:class", "typing_extensions.Literal"),
("py:class", "typing.Literal"),
("py:class", f"{project}._version.VERSION_TUPLE"),
]
nitpick_ignore_regex = [
("py:obj", "pydantic.*"),
("py:class", "pydantic.*"),
("py:obj", "lxml.*"),
("py:class", "lxml.*"),
("py:class", "typing_extensions.*"),
("py:obj", r"typing.Annotated\[.*"),
("py:class", r".*\.T"),
("py:class", r"pvi\.device\..*Union"),
("py:class", ".*.?Tree"),
("py:class", ".*.PascalStr"),
("py:class", ".*.Cls"),
]

# Both the class’ and the __init__ method’s docstring are concatenated and
Expand Down Expand Up @@ -167,6 +192,7 @@
}
],
"navigation_with_keys": False,
"show_toc_level": 3,
}

# A dictionary of values to pass into the template engine’s context for all pages
Expand Down
13 changes: 3 additions & 10 deletions docs/reference/api.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,10 @@
# API

```{eval-rst}
.. automodule:: pvi
``pvi``
-------
```

This is the internal API reference for pvi

```{eval-rst}
.. data:: pvi.__version__
:type: str
.. toctree::
:maxdepth: 1
Version number as calculated by https://github.com/pypa/setuptools_scm
_api/index
```
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ dev = [
"sphinx-autobuild",
"sphinx-copybutton",
"sphinx-design",
"sphinx-autodoc2",
"tox-direct",
"types-mock",
]
Expand Down
8 changes: 4 additions & 4 deletions src/pvi/device.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@
def to_title_case(pascal_s: str) -> str:
"""Takes a PascalCaseFieldName and returns an Title Case Field Name
Args:
pascal_s: E.g. PascalCaseFieldName
Returns:
Title Case converted name. E.g. Pascal Case Field Name
:param pascal_s: e.g. PascalCaseFieldName
:returns: Title Case converted name. E.g. Pascal Case Field Name
"""
return PASCAL_CASE_REGEX.sub(lambda m: " " + m.group(), pascal_s)[1:]

Expand Down

0 comments on commit 6301a02

Please sign in to comment.