Skip to content

Commit 0c5c8e9

Browse files
authored
docs: pysdk reference autogeneration (#1635)
* pysdk reference autogeneration * fix the lock file * fix build
1 parent 4b6e10b commit 0c5c8e9

File tree

8 files changed

+184
-178
lines changed

8 files changed

+184
-178
lines changed

.github/workflows/docs-build.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ jobs:
4545
- name: Configure poetry
4646
run: poetry config virtualenvs.in-project true
4747
- name: Install dependencies
48-
run: poetry install --only docs
48+
run: poetry install --with docs
4949
- name: Build documentation
5050
run: make docs
5151
- name: Delete unnecessary files

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,9 @@ local_cache
5757
docs/user_guides/llm/vertexai/config
5858
docs/**/config
5959

60+
# Ignore auto-generated API reference stubs
61+
docs/reference/python-api/generated/
62+
6063
# Ignoring this for now
6164
/scripts
6265

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
{{ fullname | escape | underline }}
2+
3+
.. currentmodule:: {{ module }}
4+
5+
.. autoclass:: {{ objname }}
6+
:members:
7+
:undoc-members:
8+
:show-inheritance:
9+
:inherited-members:
10+
11+
{% block methods %}
12+
{% if methods %}
13+
.. rubric:: Methods
14+
15+
.. autosummary::
16+
:nosignatures:
17+
18+
{% for item in methods %}
19+
~{{ name }}.{{ item }}
20+
{%- endfor %}
21+
{% endif %}
22+
{% endblock %}
23+
24+
{% block attributes %}
25+
{% if attributes %}
26+
.. rubric:: Attributes
27+
28+
.. autosummary::
29+
30+
{% for item in attributes %}
31+
~{{ name }}.{{ item }}
32+
{%- endfor %}
33+
{% endif %}
34+
{% endblock %}
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
{{ fullname | escape | underline }}
2+
3+
.. automodule:: {{ fullname }}
4+
:members:
5+
:undoc-members:
6+
:show-inheritance:
7+
8+
{% block classes %}
9+
{% if classes %}
10+
.. rubric:: Classes
11+
12+
.. autosummary::
13+
:toctree:
14+
:template: class.rst
15+
16+
{% for item in classes %}
17+
{{ item }}
18+
{%- endfor %}
19+
{% endif %}
20+
{% endblock %}
21+
22+
{% block functions %}
23+
{% if functions %}
24+
.. rubric:: Functions
25+
26+
.. autosummary::
27+
:toctree:
28+
29+
{% for item in functions %}
30+
{{ item }}
31+
{%- endfor %}
32+
{% endif %}
33+
{% endblock %}
34+
35+
{% block exceptions %}
36+
{% if exceptions %}
37+
.. rubric:: Exceptions
38+
39+
.. autosummary::
40+
:toctree:
41+
42+
{% for item in exceptions %}
43+
{{ item }}
44+
{%- endfor %}
45+
{% endif %}
46+
{% endblock %}

docs/conf.py

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@
2424
# Add local extensions to path
2525
sys.path.insert(0, str(Path(__file__).parent / "_extensions"))
2626

27+
# Add the project root to path so autodoc can import nemoguardrails
28+
sys.path.insert(0, str(Path(__file__).parent.parent))
29+
2730
project = "NVIDIA NeMo Guardrails Library Developer Guide"
2831
this_year = date.today().year
2932
copyright = f"2023-{this_year}, NVIDIA Corporation"
@@ -35,7 +38,12 @@
3538

3639
extensions = [
3740
"myst_parser",
41+
"sphinx.ext.autodoc",
42+
"sphinx.ext.autosummary",
43+
"sphinx.ext.napoleon",
44+
"sphinx.ext.viewcode",
3845
"sphinx.ext.intersphinx",
46+
"sphinx_autodoc_typehints",
3947
"sphinx_copybutton",
4048
"sphinx_reredirects",
4149
"sphinx_design",
@@ -44,6 +52,34 @@
4452
"search_assets", # Enhanced search assets extension
4553
]
4654

55+
# -- Autodoc configuration ---------------------------------------------------
56+
autodoc_default_options = {
57+
"members": True,
58+
"undoc-members": False,
59+
"show-inheritance": True,
60+
"member-order": "bysource",
61+
}
62+
autodoc_typehints = "description"
63+
autodoc_class_signature = "separated"
64+
65+
# Mock imports for optional dependencies that may not be installed
66+
autodoc_mock_imports = [
67+
"presidio_analyzer",
68+
"presidio_anonymizer",
69+
"spacy",
70+
"google.cloud",
71+
"yara",
72+
"fast_langdetect",
73+
"opentelemetry",
74+
"streamlit",
75+
"tqdm",
76+
]
77+
78+
# -- Autosummary configuration -----------------------------------------------
79+
autosummary_generate = True
80+
autosummary_generate_overwrite = True
81+
autosummary_imported_members = True
82+
4783
redirects = {
4884
"introduction": "index.html",
4985
"documentation": "index.html",

0 commit comments

Comments
 (0)