Skip to content

Commit de8eb4d

Browse files
authored
Merge pull request #125 from dihm/sphinx_updates
Sphinx autosummary updates
2 parents df64c61 + fcd0dc7 commit de8eb4d

3 files changed

Lines changed: 38 additions & 14 deletions

File tree

docs/source/_templates/autosummary-module.rst

Lines changed: 25 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
.. automodule:: {{ fullname }}
44

55
{% block attributes %}
6-
{% if attributes %}
6+
{%- if attributes %}
77
.. rubric:: {{ _('Module Attributes') }}
88

99
.. autosummary::
@@ -12,10 +12,10 @@
1212
{{ item }}
1313
{%- endfor %}
1414
{% endif %}
15-
{% endblock %}
15+
{%- endblock %}
1616

17-
{% block functions %}
18-
{% if functions %}
17+
{%- block functions %}
18+
{%- if functions %}
1919
.. rubric:: {{ _('Functions') }}
2020

2121
.. autosummary::
@@ -24,10 +24,10 @@
2424
{{ item }}
2525
{%- endfor %}
2626
{% endif %}
27-
{% endblock %}
27+
{%- endblock %}
2828

29-
{% block classes %}
30-
{% if classes %}
29+
{%- block classes %}
30+
{%- if classes %}
3131
.. rubric:: {{ _('Classes') }}
3232

3333
.. autosummary::
@@ -37,10 +37,10 @@
3737
{{ item }}
3838
{%- endfor %}
3939
{% endif %}
40-
{% endblock %}
40+
{%- endblock %}
4141

42-
{% block exceptions %}
43-
{% if exceptions %}
42+
{%- block exceptions %}
43+
{%- if exceptions %}
4444
.. rubric:: {{ _('Exceptions') }}
4545

4646
.. autosummary::
@@ -49,4 +49,18 @@
4949
{{ item }}
5050
{%- endfor %}
5151
{% endif %}
52-
{% endblock %}
52+
{%- endblock %}
53+
54+
{%- block modules %}
55+
{%- if modules %}
56+
.. rubric:: Modules
57+
58+
.. autosummary::
59+
:toctree:
60+
:template: autosummary-module.rst
61+
:recursive:
62+
{% for item in modules %}
63+
{{ item }}
64+
{%- endfor %}
65+
{% endif %}
66+
{%- endblock %}

docs/source/api/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ API Reference
44

55
.. autosummary::
66
:toctree: _autosummary
7+
:template: autosummary-module.rst
78
:recursive:
89

910
lyse

docs/source/conf.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -163,20 +163,29 @@
163163
labscript_suite_doc_version = 'latest'
164164

165165
# add intersphinx references for each component
166+
labscript_intersphinx_mapping = {}
166167
for ls_prog in labscript_suite_programs:
167-
intersphinx_mapping[ls_prog] = (
168+
val = (
168169
'https://docs.labscriptsuite.org/projects/{}/en/{}/'.format(
169170
ls_prog, labscript_suite_doc_version
170171
),
171172
None,
172173
)
174+
labscript_intersphinx_mapping[ls_prog] = val
175+
if ls_prog != project:
176+
# don't add intersphinx for current project
177+
# if internal links break, they can silently be filled by links to existing online docs
178+
# this is confusing and difficult to detect
179+
intersphinx_mapping[ls_prog] = val
173180

174181
# add intersphinx reference for the metapackage
175182
if project != "the labscript suite":
176-
intersphinx_mapping['labscript-suite'] = (
183+
val = (
177184
'https://docs.labscriptsuite.org/en/{}/'.format(labscript_suite_doc_version),
178185
None,
179186
)
187+
intersphinx_mapping['labscript-suite'] = val
188+
labscript_intersphinx_mapping['labscript-suite'] = val
180189

181190
# Make `some code` equivalent to :code:`some code`
182191
default_role = 'code'
@@ -226,7 +235,7 @@ def setup(app):
226235
with open(Path(__file__).resolve().parent / 'components.rst', 'w') as f:
227236
f.write(
228237
template.render(
229-
intersphinx_mapping=intersphinx_mapping,
238+
intersphinx_mapping=labscript_intersphinx_mapping,
230239
programs=labscript_suite_programs,
231240
current_project=project,
232241
img_path=img_path

0 commit comments

Comments
 (0)