1111# documentation root, use os.path.abspath to make it absolute, like shown here.
1212#
1313import os
14+ from pathlib import Path
1415from m2r import MdInclude
1516from recommonmark .transform import AutoStructify
17+ from jinja2 import FileSystemLoader , Environment
1618
1719# -- Project information (unique to each project) -------------------------------------
1820
2628release = version
2729
2830# HTML icons
29- html_logo = "img/{}.svg" .format (project )
30- html_favicon = "img/{}.ico" .format (project )
31+ img_path = 'img'
32+ html_logo = img_path + "/labscript_64x64.svg"
33+ html_favicon = img_path + "/labscript.ico"
3134
3235# -- General configuration (should be identical across all projects) ------------------
3336
7982 'matplotlib' : ('https://matplotlib.org/' , None ),
8083 'h5py' : ('http://docs.h5py.org/en/stable/' , None ),
8184 'pydaqmx' : ('https://pythonhosted.org/PyDAQmx/' , None ),
82- # from https://github.com/MSLNZ/msl-qt/blob/master/docs/create_pyqt_objects.py
83- # under MIT License
8485 'qt' : (
8586 '' ,
8687 'pyqt5-modified-objects.inv' ,
87- )
88+ ) # from https://github.com/MSLNZ/msl-qt/blob/master/docs/create_pyqt_objects.py
89+ # under MIT License
8890 # TODO
8991 # desktop-app
9092 # spinapi/pynivision/etc
9193}
9294
9395# list of all labscript suite components that have docs
94- labscript_suite_programs = [
95- 'labscript' ,
96- 'runmanager' ,
97- 'runviewer' ,
98- 'blacs' ,
99- 'lyse' ,
100- 'labscript-utils' ,
101- 'labscript-devices' ,
102- ]
103- # remove this current repo from the list
104- if project in labscript_suite_programs :
105- labscript_suite_programs .remove (project )
96+ labscript_suite_programs = {
97+ 'labscript' : {
98+ 'desc' : 'Expressive composition of hardware-timed experiments' ,
99+ 'icon' : 'labscript_32nx32n.svg' ,
100+ 'type' : 'lib' ,
101+ },
102+ 'labscript-devices' : {
103+ 'desc' : 'Plugin architecture for controlling experiment hardware' ,
104+ 'icon' : 'labscript_32nx32n.svg' ,
105+ 'type' : 'lib' ,
106+ },
107+ 'labscript-utils' : {
108+ 'desc' : 'Shared modules used by the *labscript suite*' ,
109+ 'icon' : 'labscript_32nx32n.svg' ,
110+ 'type' : 'lib' ,
111+ },
112+ 'runmanager' : {
113+ 'desc' : 'Graphical and remote interface to parameterized experiments' ,
114+ 'icon' : 'runmanager_32nx32n.svg' ,
115+ 'type' : 'gui' ,
116+ },
117+ 'blacs' : {
118+ 'desc' : 'Graphical interface to scientific instruments and experiment supervision' ,
119+ 'icon' : 'blacs_32nx32n.svg' ,
120+ 'type' : 'gui' ,
121+ },
122+ 'lyse' : {
123+ 'desc' : 'Online analysis of live experiment data' ,
124+ 'icon' : 'lyse_32nx32n.svg' ,
125+ 'type' : 'gui' ,
126+ },
127+ 'runviewer' : {
128+ 'desc' : 'Visualize hardware-timed experiment instructions' ,
129+ 'icon' : 'runviewer_32nx32n.svg' ,
130+ 'type' : 'gui' ,
131+ },
132+ }
106133
107134# whether to use stable or latest version
108- labscript_suite_doc_version = 'stable' # 'stable' or 'latest'
135+ labscript_suite_doc_version = os .environ .get ('READTHEDOCS_VERSION' , 'latest' )
136+ if labscript_suite_doc_version not in ['stable' , 'latest' ]:
137+ labscript_suite_doc_version = 'stable'
109138
110139# add intersphinx references for each component
111140for ls_prog in labscript_suite_programs :
112141 intersphinx_mapping [ls_prog ] = (
113- 'https://docs.labscript_suite .org/projects/{}/en/{}/' .format (
142+ 'https://docs.labscriptsuite .org/projects/{}/en/{}/' .format (
114143 ls_prog , labscript_suite_doc_version
115144 ),
116145 None ,
119148# add intersphinx reference for the metapackage
120149if project != "the labscript suite" :
121150 intersphinx_mapping ['labscript-suite' ] = (
122- 'https://docs.labscript_suite .org/en/{}/' .format (labscript_suite_doc_version ),
151+ 'https://docs.labscriptsuite .org/en/{}/' .format (labscript_suite_doc_version ),
123152 None ,
124153 )
125154
137166 todo_include_todos = False
138167else :
139168 todo_include_todos = True
169+
140170# -- Options for HTML output -------------------------------------------------
141171
142172# The theme to use for HTML and HTML Help pages. See the documentation for
158188# Customize the html_theme
159189html_theme_options = {'navigation_depth' : 3 }
160190
161-
162191# Use m2r only for mdinclude and recommonmark for everything else
163192# https://github.com/readthedocs/recommonmark/issues/191#issuecomment-622369992
164193def setup (app ):
@@ -177,3 +206,18 @@ def setup(app):
177206 app .add_config_value ('m2r_disable_inline_math' , False , 'env' )
178207 app .add_directive ('mdinclude' , MdInclude )
179208 app .add_stylesheet ('custom.css' )
209+
210+ # generate the components.rst file dynamically so it points to stable/latest
211+ # of subprojects correctly
212+ loader = FileSystemLoader (Path (__file__ ).resolve ().parent / templates_path [0 ])
213+ env = Environment (loader = loader )
214+ template = env .get_template ('components.rst' )
215+ with open (Path (__file__ ).resolve ().parent / 'components.rst' , 'w' ) as f :
216+ f .write (
217+ template .render (
218+ intersphinx_mapping = intersphinx_mapping ,
219+ programs = labscript_suite_programs ,
220+ current_project = project ,
221+ img_path = img_path
222+ )
223+ )
0 commit comments