Debian Codegraph @

docs_sphinx/conf.py

raw ◀ ▶
Source reconstructed at patch state 0 of 2 — not the installed (fully patched) source.
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 # Add any paths that contain templates here, relative to this directory.
116 templates_path = ["_templates"]
117
118 # The suffix of source filenames.
119 source_suffix = ".rst"
120
121 # The encoding of source files.
122 # source_encoding = 'utf-8-sig'
123
124 # The master toctree document.
125 master_doc = "index"
126
127 # General information about the project.
128 project = "Brian 2"
129 import datetime
130 import time
131
132 copyright = "2012–{}, Brian authors".format(
133 datetime.datetime.fromtimestamp(
134 int(os.environ.get("SOURCE_DATE_EPOCH", time.time())), tz=datetime.UTC
135 ).year
136 )
137
138 # The version info for the project you're documenting, acts as replacement for
139 # |version| and |release|, also used in various other places throughout the
140 # built documents.
141 #
142 from importlib.metadata import version
143
144 release = version("brian2")
145 # The short X.Y.Z version.
146 version = ".".join(release.split(".")[:3])
147
148 # The language for content autogenerated by Sphinx. Refer to documentation
149 # for a list of supported languages.
150 # language = None
151
152 # There are two options for replacing |today|: either, you set today to some
153 # non-false value, then it is used:
154 # today = ''
155 # Else, today_fmt is used as the format for a strftime call.
156 # today_fmt = '%B %d, %Y'
157
158 # List of patterns, relative to source directory, that match files and
159 # directories to ignore when looking for source files.
160 exclude_patterns = ["_build"]
161
162 # The reST default role (used for this markup: `text`) to use for all documents.
163 default_role = "brianobj"
164
165 # If true, '()' will be appended to :func: etc. cross-reference text.
166 # add_function_parentheses = True
167
168 # If true, the current module name will be prepended to all description
169 # unit titles (such as .. function::).
170 # add_module_names = True
171
172 # If true, sectionauthor and moduleauthor directives will be shown in the
173 # output. They are ignored by default.
174 # show_authors = False
175
176 # The name of the Pygments (syntax highlighting) style to use.
177 pygments_style = "sphinx"
178
179 # A list of ignored prefixes for module index sorting.
180 modindex_common_prefix = ["brian2."]
181
182 sphinx_tabs_disable_tab_closing = True
183
184 # -- Options for HTML output ---------------------------------------------------
185
186 # Theme options are theme-specific and customize the look and feel of a theme
187 # further. For a list of options available for each theme, see the
188 # documentation.
189 html_theme_options = {"style_external_links": True}
190
191
192 # The name for this set of Sphinx documents. If None, it defaults to
193 # "<project> v<release> documentation".
194 # html_title = None
195
196 # A shorter title for the navigation bar. Default is the same as html_title.
197 # html_short_title = None
198
199 # The name of an image file (relative to this directory) to place at the top
200 # of the sidebar.
201 html_logo = "_static/brian-logo.png"
202
203 # The name of an image file (within the static path) to use as favicon of the
204 # docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32
205 # pixels large.
206 # html_favicon = None
207
208 # Add any paths that contain custom static files (such as style sheets) here,
209 # relative to this directory. They are copied after the builtin static files,
210 # so a file named "default.css" will overwrite the builtin "default.css".
211 html_static_path = ["_static"]
212
213 # If not '', a 'Last updated on:' timestamp is inserted at every page bottom,
214 # using the given strftime format.
215 # html_last_updated_fmt = '%b %d, %Y'
216
217 # If true, SmartyPants will be used to convert quotes and dashes to
218 # typographically correct entities.
219 # html_use_smartypants = True
220
221 # Custom sidebar templates, maps document names to template names.
222 # html_sidebars = {}
223
224 # Additional templates that should be rendered to pages, maps page names to
225 # template names.
226 # html_additional_pages = {}
227
228 # If false, no module index is generated.
229 # html_domain_indices = True
230
231 # If false, no index is generated.
232 # html_use_index = True
233
234 # If true, the index is split into individual pages for each letter.
235 # html_split_index = False
236
237 # If true, links to the reST sources are added to the pages.
238 # html_show_sourcelink = True
239
240 # If true, "Created using Sphinx" is shown in the HTML footer. Default is True.
241 # html_show_sphinx = True
242
243 # If true, "(C) Copyright ..." is shown in the HTML footer. Default is True.
244 # html_show_copyright = True
245
246 # If true, an OpenSearch description file will be output, and all pages will
247 # contain a <link> tag referring to it. The value of this option must be the
248 # base URL from which the finished HTML is served.
249 # html_use_opensearch = ''
250
251 # This is the file name suffix for HTML files (e.g. ".xhtml").
252 # html_file_suffix = None
253
254 # Output file base name for HTML help builder.
255 htmlhelp_basename = "Brian2doc"
256
257 # Suppress warnings about the mybinder badges
258 suppress_warnings = ["image.nonlocal_uri"]
259
260 # -- Options for LaTeX output --------------------------------------------------
261 latex_engine = "xelatex"
262
263 latex_elements = {
264 # The paper size ('letterpaper' or 'a4paper').
265 #'papersize': 'letterpaper',
266 # The font size ('10pt', '11pt' or '12pt').
267 #'pointsize': '10pt',
268 # Additional stuff for the LaTeX preamble.
269 #'preamble': '',
270 }
271
272 # Grouping the document tree into LaTeX files. List of tuples
273 # (source start file, target name, title, author, documentclass [howto/manual]).
274 latex_documents = [
275 ("index", "Brian2.tex", "Brian 2 Documentation", "Brian authors", "manual"),
276 ]
277
278 # The name of an image file (relative to this directory) to place at the top of
279 # the title page.
280 # latex_logo = None
281
282 # For "manual" documents, if this is true, then toplevel headings are parts,
283 # not chapters.
284 # latex_use_parts = False
285
286 # If true, show page references after internal links.
287 # latex_show_pagerefs = False
288
289 # If true, show URL addresses after external links.
290 # latex_show_urls = False
291
292 # Documents to append as an appendix to all manuals.
293 # latex_appendices = []
294
295 # If false, no module index is generated.
296 # latex_domain_indices = True
297
298
299 # -- Options for manual page output --------------------------------------------
300
301 # One entry per manual page. List of tuples
302 # (source start file, name, description, authors, manual section).
303 man_pages = [("index", "brian2", "Brian 2 Documentation", ["Brian authors"], 1)]
304
305 # If true, show URL addresses after external links.
306 # man_show_urls = False
307
308
309 # -- Options for Texinfo output ------------------------------------------------
310
311 # Grouping the document tree into Texinfo files. List of tuples
312 # (source start file, target name, title, author,
313 # dir menu entry, description, category)
314 texinfo_documents = [
315 (
316 "index",
317 "Brian2",
318 "Brian 2 Documentation",
319 "Brian authors",
320 "Brian2",
321 "One line description of project.",
322 "Miscellaneous",
323 ),
324 ]
325
326 # Documents to append as an appendix to all manuals.
327 # texinfo_appendices = []
328
329 # If false, no module index is generated.
330 # texinfo_domain_indices = True
331
332 # How to display URL addresses: 'footnote', 'no', or 'inline'.
333 # texinfo_show_urls = 'footnote'
334
335
336 intersphinx_mapping = {
337 "python": ("https://docs.python.org/3", None),
338 "numpy": ("https://numpy.org/doc/stable", None),
339 "scipy": ("https://docs.scipy.org/doc/scipy", None),
340 "sympy": ("https://docs.sympy.org/dev/", None),
341 }
342 intersphinx_timeout = 10
343
344 autodoc_default_options = {"show-inheritance": True}
345
346 doctest_global_setup = "from brian2 import *"
347 highlight_language = "python" # instead of python3 (default for sphinx>=1.4)
348
349 # Configure linking to github
350 extlinks = {"issue": ("https://github.com/brian-team/brian2/issues/%s", "# %s")}