Skip to content

Commit 651b981

Browse files
authored
Merge pull request #111 from dihm/rtd_fixes
Sphinx autosummary fixes
2 parents af7a75c + 52006bf commit 651b981

3 files changed

Lines changed: 27 additions & 17 deletions

File tree

docs/source/_templates/autosummary-module.rst

Lines changed: 14 additions & 14 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,10 +49,10 @@
4949
{{ item }}
5050
{%- endfor %}
5151
{% endif %}
52-
{% endblock %}
52+
{%- endblock %}
5353

54-
{% block modules %}
55-
{% if modules %}
54+
{%- block modules %}
55+
{%- if modules %}
5656
.. rubric:: Modules
5757

5858
.. autosummary::
@@ -63,4 +63,4 @@
6363
{{ item }}
6464
{%- endfor %}
6565
{% endif %}
66-
{% endblock %}
66+
{%- endblock %}

docs/source/api/index.rst

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

44
.. autosummary::
55
:toctree: _autosummary
6+
:template: autosummary-module.rst
67
:recursive:
78

89
blacs.analysis_submission

docs/source/conf.py

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

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

175182
# add intersphinx reference for the metapackage
176183
if project != "the labscript suite":
177-
intersphinx_mapping['labscript-suite'] = (
184+
val = (
178185
'https://docs.labscriptsuite.org/en/{}/'.format(labscript_suite_doc_version),
179186
None,
180187
)
188+
intersphinx_mapping['labscript-suite'] = val
189+
labscript_intersphinx_mapping['labscript-suite'] = val
181190

182191
# Make `some code` equivalent to :code:`some code`
183192
default_role = 'code'
@@ -227,7 +236,7 @@ def setup(app):
227236
with open(Path(__file__).resolve().parent / 'components.rst', 'w') as f:
228237
f.write(
229238
template.render(
230-
intersphinx_mapping=intersphinx_mapping,
239+
intersphinx_mapping=labscript_intersphinx_mapping,
231240
programs=labscript_suite_programs,
232241
current_project=project,
233242
img_path=img_path

0 commit comments

Comments
 (0)