11
11
# documentation root, use os.path.abspath to make it absolute, like shown here.
12
12
#
13
13
import os
14
+ from pathlib import Path
14
15
from m2r import MdInclude
15
16
from recommonmark .transform import AutoStructify
16
17
26
27
release = version
27
28
28
29
# HTML icons
29
- html_logo = "img/{}.svg" .format (project )
30
- html_favicon = "img/{}.ico" .format (project )
30
+ img_path = 'img'
31
+ html_logo = img_path + "/labscript_64x64.svg"
32
+ html_favicon = img_path + "/labscript.ico"
31
33
32
34
# -- General configuration (should be identical across all projects) ------------------
33
35
90
92
}
91
93
92
94
# list of all labscript suite components that have docs
93
- labscript_suite_programs = [
94
- 'labscript' ,
95
- 'runmanager' ,
96
- 'runviewer' ,
97
- 'blacs' ,
98
- 'lyse' ,
99
- 'labscript-utils' ,
100
- 'labscript-devices' ,
101
- ]
102
- # remove this current repo from the list
103
- if project in labscript_suite_programs :
104
- labscript_suite_programs .remove (project )
95
+ labscript_suite_programs = {
96
+ 'labscript' : {
97
+ 'desc' : 'Expressive composition of hardware-timed experiments' ,
98
+ 'img' : img_path + '/labscript_32nx32n.svg' ,
99
+ 'type' : 'lib' ,
100
+ },
101
+ 'labscript-devices' : {
102
+ 'desc' : 'Plugin architecture for controlling experiment hardware' ,
103
+ 'img' : img_path + '/labscript_32nx32n.svg' ,
104
+ 'type' : 'lib' ,
105
+ },
106
+ 'labscript-utils' : {
107
+ 'desc' : 'Shared modules used by the *labscript suite*' ,
108
+ 'img' : img_path + '/labscript_32nx32n.svg' ,
109
+ 'type' : 'lib' ,
110
+ },
111
+ 'runmanager' : {
112
+ 'desc' : 'Graphical and remote interface to parameterized experiments' ,
113
+ 'img' : img_path + '/runmanager_32nx32n.svg' ,
114
+ 'type' : 'gui' ,
115
+ },
116
+ 'blacs' : {
117
+ 'desc' : 'Graphical interface to scientific instruments and experiment supervision' ,
118
+ 'img' : img_path + '/blacs_32nx32n.svg' ,
119
+ 'type' : 'gui' ,
120
+ },
121
+ 'lyse' : {
122
+ 'desc' : 'Online analysis of live experiment data' ,
123
+ 'img' : img_path + '/lyse_32nx32n.svg' ,
124
+ 'type' : 'gui' ,
125
+ },
126
+ 'runviewer' : {
127
+ 'desc' : 'Visualize hardware-timed experiment instructions' ,
128
+ 'img' : img_path + '/runviewer_32nx32n.svg' ,
129
+ 'type' : 'gui' ,
130
+ },
131
+ }
105
132
106
133
# whether to use stable or latest version
107
134
labscript_suite_doc_version = os .environ .get ('READTHEDOCS_VERSION' , 'latest' )
111
138
# add intersphinx references for each component
112
139
for ls_prog in labscript_suite_programs :
113
140
intersphinx_mapping [ls_prog ] = (
114
- 'https://docs.labscript_suite .org/projects/{}/en/{}/' .format (
141
+ 'https://docs.labscriptsuite .org/projects/{}/en/{}/' .format (
115
142
ls_prog , labscript_suite_doc_version
116
143
),
117
144
None ,
120
147
# add intersphinx reference for the metapackage
121
148
if project != "the labscript suite" :
122
149
intersphinx_mapping ['labscript-suite' ] = (
123
- 'https://docs.labscript_suite .org/en/{}/' .format (labscript_suite_doc_version ),
150
+ 'https://docs.labscriptsuite .org/en/{}/' .format (labscript_suite_doc_version ),
124
151
None ,
125
152
)
126
153
160
187
# Customize the html_theme
161
188
html_theme_options = {'navigation_depth' : 3 }
162
189
190
+ # Template for generating the components.rst file
191
+ # fmt:off
192
+ components_rst_template = \
193
+ """
194
+ {metapackage_toctree}
195
+
196
+ *labscript suite* components
197
+ ============================
198
+
199
+ The *labscript suite* is modular by design, and is comprised of:
200
+
201
+ .. list-table:: Python libraries
202
+ :widths: 10 90
203
+ :header-rows: 0
204
+
205
+ {lib}
206
+
207
+ .. list-table:: Graphical applications
208
+ :widths: 10 90
209
+ :header-rows: 0
210
+
211
+ {gui}
212
+
213
+ .. toctree::
214
+ :maxdepth: 2
215
+ :hidden:
216
+
217
+ {toctree_entires}
218
+
219
+ {rst_defs}
220
+ """
221
+
222
+ components_rst_table_template = \
223
+ """ * - .. image:: {img}
224
+ :target: {target}
225
+ :class: labscript-suite-icon
226
+ - |{prog}|_ --- {desc}
227
+ """
228
+
229
+ components_rst_link_template = \
230
+ """.. |{prog}| replace:: **{prog}**
231
+ .. _{prog}: {target}
232
+ """
233
+
234
+ components_rst_metapackage_template = \
235
+ """.. toctree::
236
+ :maxdepth: 2
237
+ :hidden:
238
+
239
+ Metapackage documentation <{}>
240
+ """
241
+ # fmt:on
163
242
164
243
# Use m2r only for mdinclude and recommonmark for everything else
165
244
# https://github.com/readthedocs/recommonmark/issues/191#issuecomment-622369992
@@ -180,21 +259,45 @@ def setup(app):
180
259
app .add_directive ('mdinclude' , MdInclude )
181
260
app .add_stylesheet ('custom.css' )
182
261
183
- with open (
184
- os .path .join (os .path .dirname (os .path .realpath (__file__ )), 'component_docs.rst' ),
185
- 'w' ,
186
- ) as f :
187
- f .write ("labscript suite components\n " )
188
- f .write ("==========================\n " )
189
- f .write (" \n " )
190
- f .write (".. toctree::\n " )
191
- f .write (" :maxdepth: 2\n " )
192
- f .write (" \n " )
193
- if project != "the labscript suite" :
194
- f .write (
195
- " labscript suite (metapackage)<{}>\n " .format (
196
- intersphinx_mapping ['labscript-suite' ][0 ]
197
- )
262
+ # generate the components.rst file dynamically so it points to stable/latest
263
+ # of subprojects correctly
264
+ components_rst_table = {
265
+ "lib" : "" ,
266
+ "gui" : "" ,
267
+ }
268
+ components_rst_link = ""
269
+ components_rst_toctree = ""
270
+ components_rst_metapackage = ""
271
+ if project != 'the labscript suite' :
272
+ components_rst_metapackage = components_rst_metapackage_template .format (
273
+ intersphinx_mapping ['labscript-suite' ][0 ]
274
+ )
275
+ metapackage_img = img_path + "/labscript-suite-rectangular-transparent_138nx70n.svg"
276
+ for ls_prog , data in labscript_suite_programs .items ():
277
+ components_rst_table [data ['type' ]] += components_rst_table_template .format (
278
+ prog = ls_prog ,
279
+ labscript_suite_doc_version = labscript_suite_doc_version ,
280
+ target = intersphinx_mapping [ls_prog ][0 ],
281
+ ** data
282
+ )
283
+ components_rst_link += components_rst_link_template .format (
284
+ prog = ls_prog ,
285
+ labscript_suite_doc_version = labscript_suite_doc_version ,
286
+ target = intersphinx_mapping [ls_prog ][0 ],
287
+ )
288
+ for ls_prog in sorted (labscript_suite_programs ):
289
+ if ls_prog != project :
290
+ components_rst_toctree += " {} <{}>\n " .format (
291
+ ls_prog , intersphinx_mapping [ls_prog ][0 ]
198
292
)
199
- for ls_prog in labscript_suite_programs :
200
- f .write (" {} <{}>\n " .format (ls_prog , intersphinx_mapping [ls_prog ][0 ]))
293
+
294
+ components_rst = components_rst_template .format (
295
+ toctree_entires = components_rst_toctree ,
296
+ rst_defs = components_rst_link ,
297
+ labscript_suite_doc_version = labscript_suite_doc_version ,
298
+ metapackage_toctree = components_rst_metapackage ,
299
+ ** components_rst_table
300
+ )
301
+
302
+ with open (Path (__file__ ).resolve ().parent / 'components.rst' , 'w' ) as f :
303
+ f .write (components_rst )
0 commit comments