|
14 | 14 | # |
15 | 15 | import os |
16 | 16 | import sys |
| 17 | + |
| 18 | + |
| 19 | +os.environ.setdefault("MPLBACKEND", "Agg") |
| 20 | +os.environ.setdefault("QT_QPA_PLATFORM", "offscreen") |
| 21 | +try: |
| 22 | + import matplotlib; matplotlib.use("Agg") |
| 23 | +except Exception: |
| 24 | + pass |
| 25 | + |
| 26 | +autodoc_mock_imports = [ |
| 27 | + "tkinter","tkinter.ttk","tkinter.filedialog", |
| 28 | + "IPython","IPython.display", |
| 29 | + # add more if needed in your project: |
| 30 | + "PyQt5","PyQt6","PySide2","PySide6","OpenGL","OpenGL.GL","cv2", |
| 31 | + "PIL.ImageTk","wx","gi","kivy","vispy","glfw", |
| 32 | +] |
17 | 33 | sys.path.insert(0, os.path.abspath('..')) |
18 | | -sys.setrecursionlimit(1500) |
19 | 34 | # -- Project information ----------------------------------------------------- |
20 | 35 |
|
21 | 36 | project = 'gym-electric-motor' |
|
39 | 54 | # ones. |
40 | 55 | extensions = [ |
41 | 56 | 'sphinx.ext.autodoc', |
42 | | - 'sphinx.ext.coverage', |
| 57 | + 'sphinx.ext.autosummary', |
43 | 58 | 'sphinx.ext.mathjax', |
44 | 59 | 'sphinx.ext.viewcode', |
45 | 60 | 'sphinx.ext.napoleon', |
46 | 61 | 'sphinx_rtd_theme', |
47 | | - 'm2r2' |
| 62 | + 'myst_parser', |
| 63 | + 'sphinx.ext.intersphinx' |
48 | 64 | ] |
49 | | - |
| 65 | +html_theme = "sphinx_rtd_theme" |
50 | 66 | # Add any paths that contain templates here, relative to this directory. |
51 | 67 | templates_path = ['_templates'] |
| 68 | +suppress_warnings = ['autodoc.import_object'] |
52 | 69 |
|
53 | 70 | # The suffix(es) of source filenames. |
| 71 | +#source_suffix = ['.rst', '.md'] |
54 | 72 | # You can specify multiple suffix as a list of string: |
55 | | -# |
56 | | -source_suffix = ['.rst', '.md'] |
57 | 73 | # source_suffix = '.rst' |
| 74 | +source_suffix = { ".rst": "restructuredtext", ".md": "myst" } |
| 75 | + |
| 76 | +# MyST features |
| 77 | +myst_enable_extensions = ["colon_fence", "deflist", "dollarmath", "amsmath"] |
| 78 | +autosummary_generate = True |
| 79 | +autodoc_default_options = { |
| 80 | + "members": True, |
| 81 | + "undoc-members": True, |
| 82 | + "inherited-members": True, |
| 83 | + "show-inheritance": True, |
| 84 | + "member-order": "groupwise", |
| 85 | +} |
58 | 86 |
|
| 87 | +# Cross-link to external docs |
| 88 | +intersphinx_mapping = { |
| 89 | + "python": ("https://docs.python.org/3", {}), |
| 90 | + "gem_control": ("https://upb-lea.github.io/gem-control/", None), |
| 91 | +} |
59 | 92 | # The master toctree document. |
60 | 93 | master_doc = 'index' |
61 | 94 |
|
|
67 | 100 | # |
68 | 101 | # This is also used if you do content translation via gettext catalogs. |
69 | 102 | # Usually you set "language" from the command line for these cases. |
70 | | -language = None |
71 | | - |
| 103 | +language = "en" |
| 104 | +# Don't look for translation catalogs (avoids "locale_dir ... does not exist") |
| 105 | +locale_dirs = [] |
| 106 | +# (optional) keeps .po files ungrouped if you ever add i18n later |
| 107 | +gettext_compact = False |
72 | 108 | # List of patterns, relative to source directory, that match files and |
73 | 109 | # directories to ignore when looking for source files. |
74 | 110 | # This pattern also affects html_static_path and html_extra_path . |
|
83 | 119 | # The theme to use for HTML and HTML Help pages. See the documentation for |
84 | 120 | # a list of builtin themes. |
85 | 121 | # |
86 | | -html_theme = 'sphinx_rtd_theme' |
| 122 | + |
87 | 123 |
|
88 | 124 | # Theme options are theme-specific and customize the look and feel of a theme |
89 | 125 | # further. For a list of options available for each theme, see the |
90 | 126 | # documentation. |
91 | 127 | # |
92 | | -# html_theme_options = {} |
| 128 | +html_theme_options = { |
| 129 | + "collapse_navigation": False, # keep the tree expanded (optional) |
| 130 | + "navigation_depth": 4, # how deep the *page* tree goes |
| 131 | + "titles_only": True, |
| 132 | + } |
93 | 133 |
|
94 | 134 | # Add any paths that contain custom static files (such as style sheets) here, |
95 | 135 | # relative to this directory. They are copied after the builtin static files, |
|
110 | 150 | # -- Options for HTMLHelp output --------------------------------------------- |
111 | 151 |
|
112 | 152 | # Output file base name for HTML help builder. |
113 | | -htmlhelp_basename = 'LEA-RLdoc' |
| 153 | +htmlhelp_basename = 'GEM-doc' |
114 | 154 |
|
115 | 155 |
|
116 | 156 | # -- Options for LaTeX output ------------------------------------------------ |
|
129 | 169 |
|
130 | 170 | # Additional stuff for the LaTeX preamble. |
131 | 171 | # |
132 | | - # 'preamble': '', |
| 172 | + 'preamble': r''' |
| 173 | +\usepackage{amsmath} |
| 174 | +''', |
133 | 175 |
|
134 | 176 | # Latex figure (float) alignment |
135 | 177 | # |
136 | 178 | # 'figure_align': 'htbp', |
137 | | - 'packages': latex_packages |
| 179 | + #'packages': latex_packages |
138 | 180 | } |
139 | 181 |
|
140 | 182 | # Grouping the document tree into LaTeX files. List of tuples |
141 | 183 | # (source start file, target name, title, |
142 | 184 | # author, documentclass [howto, manual, or own class]). |
143 | 185 | latex_documents = [ |
144 | | - (master_doc, 'LEA-RL.tex', 'LEA-RL Documentation', |
145 | | - 'Arne Traue, Gerrit Book', 'manual'), |
| 186 | + (master_doc, 'gem-doc.tex', 'GEM Documentation', |
| 187 | + 'Praneeth Balakrishna, Gerrit Book, Felix Book, Darius Jakobeit, Wilhelm Kirchgässner, Maximilian Schenke, Arne Traue, Oliver Wallscheid', 'manual'), |
146 | 188 | ] |
147 | 189 |
|
148 | 190 |
|
|
151 | 193 | # One entry per manual page. List of tuples |
152 | 194 | # (source start file, name, description, authors, manual section). |
153 | 195 | man_pages = [ |
154 | | - (master_doc, 'lea-rl', 'LEA-RL Documentation', |
| 196 | + (master_doc, 'gem', 'GEM Documentation', |
155 | 197 | [author], 1) |
156 | 198 | ] |
| 199 | +# --- Patch broken upstream docstrings so the build doesn't fail --- |
| 200 | +BAD_DOCSTRINGS = { |
| 201 | + "gym_electric_motor.core.ElectricMotorEnvironment", |
| 202 | + "gym_electric_motor.core.ConstraintMonitor", |
| 203 | +} |
| 204 | +BAD_DOCSTRING_PREFIXES = ( |
| 205 | + "gym_electric_motor.physical_systems.electric_motors.", |
| 206 | + "gym_electric_motor.physical_systems.mechanical_loads.", |
| 207 | + # add more if needed: |
| 208 | + # "gym_electric_motor.envs.", |
| 209 | +) |
| 210 | + |
| 211 | +def _suppress_broken_docstrings(app, what, name, obj, options, lines): |
| 212 | + """Replace known-bad docstrings with a short stub so Sphinx won't error.""" |
| 213 | + if name in BAD_DOCSTRINGS or any(name.startswith(pfx) for pfx in BAD_DOCSTRING_PREFIXES): |
| 214 | + lines[:] = [ |
| 215 | + f"API for ``{name}``.", |
| 216 | + "", |
| 217 | + ".. note::", |
| 218 | + " The original docstring is temporarily suppressed due to formatting issues", |
| 219 | + " upstream. Once it’s cleaned, we’ll restore the full text here.", |
| 220 | + ] |
| 221 | + |
| 222 | +def setup(app): |
| 223 | + app.connect("autodoc-process-docstring", _suppress_broken_docstrings) |
| 224 | + return {"version": "1.0", "parallel_read_safe": True} |
157 | 225 |
|
158 | 226 |
|
159 | 227 | # -- Options for Texinfo output ---------------------------------------------- |
|
162 | 230 | # (source start file, target name, title, author, |
163 | 231 | # dir menu entry, description, category) |
164 | 232 | texinfo_documents = [ |
165 | | - (master_doc, 'LEA-RL', 'LEA-RL Documentation', |
166 | | - author, 'LEA-RL', 'One line description of project.', |
| 233 | + (master_doc, 'GEM', 'GEM Documentation', |
| 234 | + author, 'GEM', 'A package to simulate and control electrical drives.', |
167 | 235 | 'Miscellaneous'), |
168 | 236 | ] |
169 | | - |
170 | | - |
171 | 237 | # -- Extension configuration ------------------------------------------------- |
0 commit comments