Debian Codegraph @

docs_sphinx/conf.py

raw ◀ ▶
2 Debian patches touch this file
1 #
2 # Brian 2 documentation build configuration file, created by
3 # sphinx-quickstart on Tue Aug 14 14:57:16 2012.
4 #
5 # This file is execfile()d with the current directory set to its containing dir.
6 #
7 # Note that not all possible configuration values are present in this
8 # autogenerated file.
9 #
10 # All configuration values have a default; values that are commented out
11 # serve to show the default.
12
13 import os
14 import shutil
15 import sys
16
17 # If extensions (or modules to document with autodoc) are in another directory,
18 # add these directories to sys.path here. If the directory is relative to the
19 # documentation root, use os.path.abspath to make it absolute, like shown here.
20 # sys.path.insert(0, os.path.abspath('.'))
21
22
23 # Mock the scipy module
24 class Mock:
25 def __init__(self, *args, **kwargs):
26 pass
27
28 def __call__(self, *args, **kwargs):
29 return Mock()
30
31 @classmethod
32 def __getattr__(cls, name):
33 if name in ("__file__", "__path__"):
34 return "/dev/null"
35 elif name[0] == name[0].upper():
36 mockType = type(name, (), {})
37 mockType.__module__ = __name__
38 return mockType
39 else:
40 return Mock()
41
42
43 MOCK_MODULES = [
44 "brian",
45 "brian.hears", # mock Brian1 for the bridge
46 # Mock additional packages to reduce installation time on
47 # readthedocs
48 "Cython",
49 "Cython.Compiler",
50 "Cython.Build",
51 "scipy",
52 ]
53 for mod_name in MOCK_MODULES:
54 sys.modules[mod_name] = Mock()
55
56 # Store the examples and tutorials directory in an environment variable,
57 # used by the "example finder" that is called as part of the autoclass documentation
58 os.environ["BRIAN2_DOCS_EXAMPLE_DIR"] = root_dir = os.path.abspath("../examples")
59 os.environ["BRIAN2_DOCS_TUTORIALS_DIR"] = root_dir = os.path.abspath("../tutorials")
60
61 if "BRIAN2_DOCS_QUICK_REBUILD" not in os.environ:
62 # -- Automatically generate the reference documentation ------------------------
63 import brian2.sphinxext.generate_reference as generate_reference
64
65 # first generate the reference documentation
66 target_dir = "./reference"
67 if os.path.exists(target_dir):
68 shutil.rmtree(target_dir)
69 os.makedirs(target_dir)
70 abs_root = os.path.abspath("../brian2")
71 generate_reference.main(
72 abs_root,
73 exclude_dirs=["tests", "sphinxext"],
74 exclude_files=["conftest.py"],
75 destdir=target_dir,
76 )
77
78 # -- Automatically generate the examples documentation -------------------------
79 import brian2.sphinxext.generate_examples as generate_examples
80
81 target_dir = "./examples"
82 root_dir = os.path.abspath("../examples")
83 generate_examples.main(root_dir, target_dir)
84
85 # -- General configuration -----------------------------------------------------
86
87 # If your documentation needs a minimal Sphinx version, state it here.
88 needs_sphinx = "7.0"
89
90 # Add any Sphinx extension module names here, as strings. They can be extensions
91 # coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
92 extensions = [
93 "sphinx.ext.autodoc",
94 "sphinx.ext.doctest",
95 "sphinx.ext.intersphinx",
96 "sphinx.ext.todo",
97 "sphinx.ext.coverage",
98 "sphinx.ext.mathjax",
99 "sphinx.ext.viewcode",
100 "brian2.sphinxext.briandoc",
101 "sphinx.ext.autosummary",
102 "sphinx.ext.extlinks",
103 "sphinx_tabs.tabs",
104 ]
105
106 # Set readthedocs theme if available
107 try:
108 import sphinx_rtd_theme
109
110 extensions += ["sphinx_rtd_theme"]
111 html_theme = "sphinx_rtd_theme"
112 except ImportError:
113 pass
114
•115 mathjax_path = '/usr/share/javascript/mathjax/MathJax.js'
116
117 # Add any paths that contain templates here, relative to this directory.
118 templates_path = ["_templates"]
119
120 # The suffix of source filenames.
121 source_suffix = ".rst"
122
123 # The encoding of source files.
124 # source_encoding = 'utf-8-sig'
125
126 # The master toctree document.
127 master_doc = "index"
128
129 # General information about the project.
130 project = "Brian 2"
131 import datetime
132 import time
133
134 copyright = "2012–{}, Brian authors".format(
135 datetime.datetime.fromtimestamp(
136 int(os.environ.get("SOURCE_DATE_EPOCH", time.time())), tz=datetime.UTC
137 ).year
138 )
139
140 # The version info for the project you're documenting, acts as replacement for
141 # |version| and |release|, also used in various other places throughout the
142 # built documents.
143 #
144 from importlib.metadata import version
145
146 release = version("brian2")
147 # The short X.Y.Z version.
148 version = ".".join(release.split(".")[:3])
149
150 # The language for content autogenerated by Sphinx. Refer to documentation
151 # for a list of supported languages.
152 # language = None
153
154 # There are two options for replacing |today|: either, you set today to some
155 # non-false value, then it is used:
156 # today = ''
157 # Else, today_fmt is used as the format for a strftime call.
158 # today_fmt = '%B %d, %Y'
159
160 # List of patterns, relative to source directory, that match files and
161 # directories to ignore when looking for source files.
162 exclude_patterns = ["_build"]
163
164 # The reST default role (used for this markup: `text`) to use for all documents.
165 default_role = "brianobj"
166
167 # If true, '()' will be appended to :func: etc. cross-reference text.
168 # add_function_parentheses = True
169
170 # If true, the current module name will be prepended to all description
171 # unit titles (such as .. function::).
172 # add_module_names = True
173
174 # If true, sectionauthor and moduleauthor directives will be shown in the
175 # output. They are ignored by default.
176 # show_authors = False
177
178 # The name of the Pygments (syntax highlighting) style to use.
179 pygments_style = "sphinx"
180
181 # A list of ignored prefixes for module index sorting.
182 modindex_common_prefix = ["brian2."]
183
184 sphinx_tabs_disable_tab_closing = True
185
186 # -- Options for HTML output ---------------------------------------------------
187
188 # Theme options are theme-specific and customize the look and feel of a theme
189 # further. For a list of options available for each theme, see the
190 # documentation.
191 html_theme_options = {"style_external_links": True}
192
193
194 # The name for this set of Sphinx documents. If None, it defaults to
195 # "<project> v<release> documentation".
196 # html_title = None
197
198 # A shorter title for the navigation bar. Default is the same as html_title.
199 # html_short_title = None
200
201 # The name of an image file (relative to this directory) to place at the top
202 # of the sidebar.
203 html_logo = "_static/brian-logo.png"
204
205 # The name of an image file (within the static path) to use as favicon of the
206 # docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32
207 # pixels large.
208 # html_favicon = None
209
210 # Add any paths that contain custom static files (such as style sheets) here,
211 # relative to this directory. They are copied after the builtin static files,
212 # so a file named "default.css" will overwrite the builtin "default.css".
213 html_static_path = ["_static"]
214
215 # If not '', a 'Last updated on:' timestamp is inserted at every page bottom,
216 # using the given strftime format.
217 # html_last_updated_fmt = '%b %d, %Y'
218
219 # If true, SmartyPants will be used to convert quotes and dashes to
220 # typographically correct entities.
221 # html_use_smartypants = True
222
223 # Custom sidebar templates, maps document names to template names.
224 # html_sidebars = {}
225
226 # Additional templates that should be rendered to pages, maps page names to
227 # template names.
228 # html_additional_pages = {}
229
230 # If false, no module index is generated.
231 # html_domain_indices = True
232
233 # If false, no index is generated.
234 # html_use_index = True
235
236 # If true, the index is split into individual pages for each letter.
237 # html_split_index = False
238
239 # If true, links to the reST sources are added to the pages.
240 # html_show_sourcelink = True
241
242 # If true, "Created using Sphinx" is shown in the HTML footer. Default is True.
243 # html_show_sphinx = True
244
245 # If true, "(C) Copyright ..." is shown in the HTML footer. Default is True.
246 # html_show_copyright = True
247
248 # If true, an OpenSearch description file will be output, and all pages will
249 # contain a <link> tag referring to it. The value of this option must be the
250 # base URL from which the finished HTML is served.
251 # html_use_opensearch = ''
252
253 # This is the file name suffix for HTML files (e.g. ".xhtml").
254 # html_file_suffix = None
255
256 # Output file base name for HTML help builder.
257 htmlhelp_basename = "Brian2doc"
258
259 # Suppress warnings about the mybinder badges
260 suppress_warnings = ["image.nonlocal_uri"]
261
262 # -- Options for LaTeX output --------------------------------------------------
263 latex_engine = "xelatex"
264
265 latex_elements = {
266 # The paper size ('letterpaper' or 'a4paper').
267 #'papersize': 'letterpaper',
268 # The font size ('10pt', '11pt' or '12pt').
269 #'pointsize': '10pt',
270 # Additional stuff for the LaTeX preamble.
271 #'preamble': '',
272 }
273
274 # Grouping the document tree into LaTeX files. List of tuples
275 # (source start file, target name, title, author, documentclass [howto/manual]).
276 latex_documents = [
277 ("index", "Brian2.tex", "Brian 2 Documentation", "Brian authors", "manual"),
278 ]
279
280 # The name of an image file (relative to this directory) to place at the top of
281 # the title page.
282 # latex_logo = None
283
284 # For "manual" documents, if this is true, then toplevel headings are parts,
285 # not chapters.
286 # latex_use_parts = False
287
288 # If true, show page references after internal links.
289 # latex_show_pagerefs = False
290
291 # If true, show URL addresses after external links.
292 # latex_show_urls = False
293
294 # Documents to append as an appendix to all manuals.
295 # latex_appendices = []
296
297 # If false, no module index is generated.
298 # latex_domain_indices = True
299
300
301 # -- Options for manual page output --------------------------------------------
302
303 # One entry per manual page. List of tuples
304 # (source start file, name, description, authors, manual section).
305 man_pages = [("index", "brian2", "Brian 2 Documentation", ["Brian authors"], 1)]
306
307 # If true, show URL addresses after external links.
308 # man_show_urls = False
309
310
311 # -- Options for Texinfo output ------------------------------------------------
312
313 # Grouping the document tree into Texinfo files. List of tuples
314 # (source start file, target name, title, author,
315 # dir menu entry, description, category)
316 texinfo_documents = [
317 (
318 "index",
319 "Brian2",
320 "Brian 2 Documentation",
321 "Brian authors",
322 "Brian2",
323 "One line description of project.",
324 "Miscellaneous",
325 ),
326 ]
327
328 # Documents to append as an appendix to all manuals.
329 # texinfo_appendices = []
330
331 # If false, no module index is generated.
332 # texinfo_domain_indices = True
333
334 # How to display URL addresses: 'footnote', 'no', or 'inline'.
335 # texinfo_show_urls = 'footnote'
336
337
338 intersphinx_mapping = {
•339 "python": ("/usr/share/doc/python3-doc/html/", None),
340 "numpy": ("/usr/share/doc/python-numpy/html/", None),
341 "scipy": ("/usr/share/doc/python-scipy-doc/html/", None),
342 "sympy": ("/usr/share/doc/python-sympy-doc/html/", None),
343 }
344 intersphinx_timeout = 10
345
346 autodoc_default_options = {"show-inheritance": True}
347
348 doctest_global_setup = "from brian2 import *"
349 highlight_language = "python" # instead of python3 (default for sphinx>=1.4)
350
351 # Configure linking to github
352 extlinks = {"issue": ("https://github.com/brian-team/brian2/issues/%s", "# %s")}