Skip to content

Commit 7f217eb

Browse files
committed
autodoc for sphinx requires templates
1 parent 40e0d4c commit 7f217eb

File tree

5 files changed

+109
-2
lines changed

5 files changed

+109
-2
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,4 @@ htmlcov/*
2121

2222
# docs related
2323
docs/_build/
24+
docs/source/_autosummary/
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+
:show-inheritance:
8+
:inherited-members:
9+
:special-members: __call__, __add__, __mul__
10+
11+
{% block methods %}
12+
{% if methods %}
13+
.. rubric:: {{ _('Methods') }}
14+
15+
.. autosummary::
16+
:nosignatures:
17+
{% for item in methods %}
18+
{%- if not item.startswith('_') %}
19+
~{{ name }}.{{ item }}
20+
{%- endif -%}
21+
{%- endfor %}
22+
{% endif %}
23+
{% endblock %}
24+
25+
{% block attributes %}
26+
{% if attributes %}
27+
.. rubric:: {{ _('Attributes') }}
28+
29+
.. autosummary::
30+
{% for item in attributes %}
31+
~{{ name }}.{{ item }}
32+
{%- endfor %}
33+
{% endif %}
34+
{% endblock %}
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
{{ fullname | escape | underline}}
2+
3+
.. automodule:: {{ fullname }}
4+
5+
{% block attributes %}
6+
{% if attributes %}
7+
.. rubric:: Module attributes
8+
9+
.. autosummary::
10+
:toctree:
11+
{% for item in attributes %}
12+
{{ item }}
13+
{%- endfor %}
14+
{% endif %}
15+
{% endblock %}
16+
17+
{% block functions %}
18+
{% if functions %}
19+
.. rubric:: {{ _('Functions') }}
20+
21+
.. autosummary::
22+
:toctree:
23+
:nosignatures:
24+
{% for item in functions %}
25+
{{ item }}
26+
{%- endfor %}
27+
{% endif %}
28+
{% endblock %}
29+
30+
{% block classes %}
31+
{% if classes %}
32+
.. rubric:: {{ _('Classes') }}
33+
34+
.. autosummary::
35+
:toctree:
36+
:template: custom-class-template.rst
37+
:nosignatures:
38+
{% for item in classes %}
39+
{{ item }}
40+
{%- endfor %}
41+
{% endif %}
42+
{% endblock %}
43+
44+
{% block exceptions %}
45+
{% if exceptions %}
46+
.. rubric:: {{ _('Exceptions') }}
47+
48+
.. autosummary::
49+
:toctree:
50+
{% for item in exceptions %}
51+
{{ item }}
52+
{%- endfor %}
53+
{% endif %}
54+
{% endblock %}
55+
56+
{% block modules %}
57+
{% if modules %}
58+
.. autosummary::
59+
:toctree:
60+
:template: custom-module-template.rst
61+
:recursive:
62+
{% for item in modules %}
63+
{{ item }}
64+
{%- endfor %}
65+
{% endif %}
66+
{% endblock %}

docs/source/api.rst

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ API
22
===
33

44
.. autosummary::
5-
:toctree: generated
5+
:toctree: _autosummary
6+
:template: custom-module-template.rst
7+
:recursive:
68

79
sigmf

docs/source/conf.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
import datetime
99
import re
10+
import sys
1011
from pathlib import Path
1112

1213
# parse info from project files
@@ -16,7 +17,9 @@
1617
init = handle.read()
1718
toolversion = re.search(r'__version__\s*=\s*[\'"]([^\'"]*)[\'"]', init).group(1)
1819
specversion = re.search(r'__specification__\s*=\s*[\'"]([^\'"]*)[\'"]', init).group(1)
19-
print("DBUG", toolversion, specversion)
20+
21+
# autodoc needs special pathing
22+
sys.path.append(str(root))
2023

2124
# -- Project information
2225

@@ -35,6 +38,7 @@
3538
"sphinx.ext.autodoc",
3639
"sphinx.ext.autosummary",
3740
"sphinx.ext.intersphinx",
41+
"sphinx.ext.napoleon", # allows numpy-style docstrings
3842
]
3943

4044
intersphinx_mapping = {

0 commit comments

Comments
 (0)