Debian Codegraph @

docs/source/conf.py

raw
1 # -*- coding: utf-8 -*-
2 #
3 # datalad documentation build configuration file, created by
4 # sphinx-quickstart on Tue Oct 13 08:41:19 2015.
5 #
6 # This file is execfile()d with the current directory set to its
7 # containing dir.
8 #
9 # Note that not all possible configuration values are present in this
10 # autogenerated file.
11 #
12 # All configuration values have a default; values that are commented out
13 # serve to show the default.
14
15 import datetime
16 import os
17 import sys
18 from glob import glob
19 from os import pardir
20 from os.path import exists
21 from os.path import join as opj
22 from pathlib import Path
23 import subprocess
24
25
26 def setup(sphinx):
27 sys.path.insert(0, os.path.abspath('utils')) # travis
28 sys.path.insert(0, os.path.abspath(opj(pardir, 'utils'))) # RTD
29 # As of Sphinx v2.1, passing an instance is deprecated.
30 # TODO: Remove when minimum sphinx version is at least 2.1.
31 import sphinx as sphinx_mod
32 from pygments_ansi_color import AnsiColorLexer
33 sphinx_ver = int(sphinx_mod.__version__.split('.')[0])
34 if sphinx_ver < 3: # Check against 3 rather than 2.1 for simplicity.
35 AnsiColorLexer = AnsiColorLexer()
36 sphinx.add_lexer("ansi-color", AnsiColorLexer)
37
38
39 # If extensions (or modules to document with autodoc) are in another directory,
40 # add these directories to sys.path here. If the directory is relative to the
41 # documentation root, use os.path.abspath to make it absolute, like shown here.
42 #sys.path.insert(0, os.path.abspath('.'))
43
44 # generate missing pieces
45 for setup_py_path in (Path(pardir), # travis
46 Path(pardir, pardir)): # RTD
47 if (setup_py_path / 'setup.py').exists():
48 for cmd in 'manpage', 'cfginfo':
49 # ignore errors and do your best
50 subprocess.run(
51 ['python', 'setup.py', f'build_{cmd}'], cwd=setup_py_path, check=False
52 )
53
54 # if docs are build for a development version of datalad installed with
55 # `pip install -e`, add its location to the path
56 if 'VIRTUAL_ENV' in os.environ:
57 site_packages_glob = os.sep.join([
58 os.environ['VIRTUAL_ENV'],
59 'lib', 'python*', 'site-packages', 'datalad.*'])
60 for site_package in glob(site_packages_glob):
61 if site_package.endswith('.egg-link'):
62 sys.path.insert(0, open(site_package).read().strip('\n.'))
63
64 import datalad
65
66 # -- General configuration ------------------------------------------------
67
68 # If your documentation needs a minimal Sphinx version, state it here.
69 #needs_sphinx = '1.0'
70
71 # Add any Sphinx extension module names here, as strings. They can be
72 # extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
73 # ones.
74 extensions = [
75 'sphinx.ext.autodoc',
76 'sphinx.ext.autosummary',
77 'sphinx.ext.doctest',
78 'sphinx.ext.intersphinx',
79 'sphinx.ext.todo',
80 'sphinx.ext.coverage',
81 'sphinx.ext.mathjax',
82 'sphinx.ext.ifconfig',
83 'sphinx.ext.inheritance_diagram',
84 'sphinx.ext.viewcode',
85 'sphinx.ext.napoleon',
86 # github.com/readthedocs/sphinx_rtd_theme/issues/1452 (rm next line when fixed)
87 'sphinxcontrib.jquery',
88 'sphinx_autodoc_typehints',
89 ]
90
91 # for the module reference
92 autosummary_generate = True
93
94 # Add any paths that contain templates here, relative to this directory.
95 templates_path = ['_templates']
96
97 # The suffix(es) of source filenames.
98 # You can specify multiple suffix as a list of string:
99 # source_suffix = ['.rst', '.md']
100 source_suffix = '.rst'
101
102 # The encoding of source files.
103 #source_encoding = 'utf-8-sig'
104
105 # The master toctree document.
106 master_doc = 'index'
107
108 # General information about the project.
109 current_year = datetime.datetime.now().year
110 project = u'DataLad'
111 copyright = (u'2016-{}, DataLad team').format(current_year)
112 author = u'DataLad team'
113
114 # The version info for the project you're documenting, acts as replacement for
115 # |version| and |release|, also used in various other places throughout the
116 # built documents.
117 #
118 # The short X.Y version.
119 version = '.'.join(datalad.__version__.split('.')[:2])
120 # The full version, including alpha/beta/rc tags.
121 release = datalad.__version__
122
123 # The language for content autogenerated by Sphinx. Refer to documentation
124 # for a list of supported languages.
125 #
126 # This is also used if you do content translation via gettext catalogs.
127 # Usually you set "language" from the command line for these cases.
128 language = 'en'
129
130 # There are two options for replacing |today|: either, you set today to some
131 # non-false value, then it is used:
132 #today = ''
133 # Else, today_fmt is used as the format for a strftime call.
134 #today_fmt = '%B %d, %Y'
135
136 # List of patterns, relative to source directory, that match files and
137 # directories to ignore when looking for source files.
138 exclude_patterns = []
139
140 # The reST default role (used for this markup: `text`) to use for all
141 # documents.
142 #default_role = None
143
144 # If true, '()' will be appended to :func: etc. cross-reference text.
145 #add_function_parentheses = True
146
147 # If true, the current module name will be prepended to all description
148 # unit titles (such as .. function::).
149 #add_module_names = True
150
151 # If true, sectionauthor and moduleauthor directives will be shown in the
152 # output. They are ignored by default.
153 #show_authors = False
154
155 # The name of the Pygments (syntax highlighting) style to use.
156 pygments_style = 'sphinx'
157
158 # A list of ignored prefixes for module index sorting.
159 #modindex_common_prefix = []
160
161 # If true, keep warnings as "system message" paragraphs in the built documents.
162 #keep_warnings = False
163
164 # If true, `todo` and `todoList` produce output, else they produce nothing.
165 todo_include_todos = True
166
167
168 # -- Options for HTML output ----------------------------------------------
169
170 # The theme to use for HTML and HTML Help pages. See the documentation for
171 # a list of builtin themes.
172 #html_theme = 'alabaster'
173 html_theme = 'sphinx_rtd_theme'
174
175 # Theme options are theme-specific and customize the look and feel of a theme
176 # further. For a list of options available for each theme, see the
177 # documentation.
178 #html_theme_options = {}
179
180 # Add any paths that contain custom themes here, relative to this directory.
181 #html_theme_path = []
182
183 # The name for this set of Sphinx documents. If None, it defaults to
184 # "<project> v<release> documentation".
185 #html_title = None
186
187 # A shorter title for the navigation bar. Default is the same as html_title.
188 #html_short_title = None
189
190 # The name of an image file (relative to this directory) to place at the top
191 # of the sidebar.
192 html_logo = '_static/datalad_logo.png'
193
194 # The name of an image file (within the static path) to use as favicon of the
195 # docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32
196 # pixels large.
197 html_favicon = '_static/favicon.ico'
198
199 # Add any paths that contain custom static files (such as style sheets) here,
200 # relative to this directory. They are copied after the builtin static files,
201 # so a file named "default.css" will overwrite the builtin "default.css".
202 html_static_path = ['_static']
203
204 # Add any extra paths that contain custom files (such as robots.txt or
205 # .htaccess) here, relative to this directory. These files are copied
206 # directly to the root of the documentation.
207 html_extra_path = ['_extras']
208
209 # If not '', a 'Last updated on:' timestamp is inserted at every page bottom,
210 # using the given strftime format.
211 #html_last_updated_fmt = '%b %d, %Y'
212
213 # If true, SmartyPants will be used to convert quotes and dashes to
214 # typographically correct entities.
215 #html_use_smartypants = True
216
217 # Custom sidebar templates, maps document names to template names.
218 #html_sidebars = {}
219
220 # Additional templates that should be rendered to pages, maps page names to
221 # template names.
222 #html_additional_pages = {}
223
224 # If false, no module index is generated.
225 #html_domain_indices = True
226
227 # If false, no index is generated.
228 #html_use_index = True
229
230 # If true, the index is split into individual pages for each letter.
231 html_split_index = True
232
233 # If true, links to the reST sources are added to the pages.
234 html_show_sourcelink = False
235
236 # If true, "Created using Sphinx" is shown in the HTML footer. Default is True.
237 #html_show_sphinx = True
238
239 # If true, "(C) Copyright ..." is shown in the HTML footer. Default is True.
240 #html_show_copyright = True
241
242 # If true, an OpenSearch description file will be output, and all pages will
243 # contain a <link> tag referring to it. The value of this option must be the
244 # base URL from which the finished HTML is served.
245 #html_use_opensearch = ''
246
247 # This is the file name suffix for HTML files (e.g. ".xhtml").
248 #html_file_suffix = None
249
250 # Language to be used for generating the HTML full-text search index.
251 # Sphinx supports the following languages:
252 # 'da', 'de', 'en', 'es', 'fi', 'fr', 'hu', 'it', 'ja'
253 # 'nl', 'no', 'pt', 'ro', 'ru', 'sv', 'tr'
254 #html_search_language = 'en'
255
256 # A dictionary with options for the search language support, empty by default.
257 # Now only 'ja' uses this config value
258 #html_search_options = {'type': 'default'}
259
260 # The name of a javascript file (relative to the configuration directory) that
261 # implements a search results scorer. If empty, the default will be used.
262 #html_search_scorer = 'scorer.js'
263
264 # Output file base name for HTML help builder.
265 htmlhelp_basename = 'dataladdoc'
266
267 # see https://about.readthedocs.com/blog/2024/07/addons-by-default/ for the
268 # reasoning behind the following:
269 html_context = {}
270 # Set canonical URL from the Read the Docs Domain
271 html_baseurl = os.environ.get("READTHEDOCS_CANONICAL_URL", "")
272 # Tell Jinja2 templates the build is running on Read the Docs
273 if os.environ.get("READTHEDOCS", "") == "True":
274 html_context["READTHEDOCS"] = True
275
276 # -- Options for LaTeX output ---------------------------------------------
277
278 latex_elements = {
279 # The paper size ('letterpaper' or 'a4paper').
280 #'papersize': 'letterpaper',
281
282 # The font size ('10pt', '11pt' or '12pt').
283 #'pointsize': '10pt',
284
285 # Additional stuff for the LaTeX preamble.
286 #'preamble': '',
287
288 # Latex figure (float) alignment
289 #'figure_align': 'htbp',
290 }
291
292 # Grouping the document tree into LaTeX files. List of tuples
293 # (source start file, target name, title,
294 # author, documentclass [howto, manual, or own class]).
295 latex_documents = [
296 (master_doc, 'datalad.tex', u'datalad Documentation',
297 u'DataLad team', 'manual'),
298 ]
299
300 # The name of an image file (relative to this directory) to place at the top of
301 # the title page.
302 #latex_logo = None
303
304 # For "manual" documents, if this is true, then toplevel headings are parts,
305 # not chapters.
306 #latex_use_parts = False
307
308 # If true, show page references after internal links.
309 #latex_show_pagerefs = False
310
311 # If true, show URL addresses after external links.
312 #latex_show_urls = False
313
314 # Documents to append as an appendix to all manuals.
315 #latex_appendices = []
316
317 # If false, no module index is generated.
318 #latex_domain_indices = True
319
320
321 # -- Options for manual page output ---------------------------------------
322
323 # One entry per manual page. List of tuples
324 # (source start file, name, description, authors, manual section).
325 man_pages = [
326 (master_doc, 'datalad', u'datalad Documentation',
327 [author], 1)
328 ]
329
330 # If true, show URL addresses after external links.
331 #man_show_urls = False
332
333
334 # -- Options for Texinfo output -------------------------------------------
335
336 # Grouping the document tree into Texinfo files. List of tuples
337 # (source start file, target name, title, author,
338 # dir menu entry, description, category)
339 texinfo_documents = [
340 (master_doc, 'datalad', u'datalad Documentation',
341 author, 'datalad', 'One line description of project.',
342 'Miscellaneous'),
343 ]
344
345 # Documents to append as an appendix to all manuals.
346 #texinfo_appendices = []
347
348 # If false, no module index is generated.
349 #texinfo_domain_indices = True
350
351 # How to display URL addresses: 'footnote', 'no', or 'inline'.
352 #texinfo_show_urls = 'footnote'
353
354 # If true, do not generate a @detailmenu in the "Top" node's menu.
355 #texinfo_no_detailmenu = False
356
357
358 # Example configuration for intersphinx: refer to the Python standard library.
359 intersphinx_mapping = {
360 'handbook': (
361 # use handbook matching "major" release
362 'http://handbook.datalad.org/en/{version}/'.format(
363 #version='.'.join(datalad.__version__.split('.', maxsplit=2)[:2]),
364 version='latest',
365 ),
366 None),
367 }
368
369 # sphinx-autodoc-typehints config:
370 always_document_param_types = True
371
372
373 import sphinx
374
375 if sphinx.__version__ == '5.1.0':
376 # see https://github.com/sphinx-doc/sphinx/issues/10701
377 # hope is it would get fixed for the next release
378
379 # Although crash happens within NumpyDocstring, it is subclass of GoogleDocstring
380 # so we need to overload method there
381 from functools import wraps
382
383 from sphinx.ext.napoleon.docstring import GoogleDocstring
384
385
386 @wraps(GoogleDocstring._consume_inline_attribute)
387 def _consume_inline_attribute_safe(self):
388 try:
389 return self._consume_inline_attribute_safe()
390 except:
391 return "", []
392
393 GoogleDocstring._consume_inline_attribute = _consume_inline_attribute_safe