a b/docs/conf.py
1
# type: ignore
2
# This file is execfile()d with the current directory set to its containing dir.
3
#
4
# This file only contains a selection of the most common options. For a full
5
# list see the documentation:
6
# https://www.sphinx-doc.org/en/master/usage/configuration.html
7
#
8
# All configuration values have a default; values that are commented out
9
# serve to show the default.
10
11
import os
12
import sys
13
import inspect
14
import shutil
15
16
# -- Path setup --------------------------------------------------------------
17
18
__location__ = os.path.join(
19
    os.getcwd(), os.path.dirname(inspect.getfile(inspect.currentframe()))
20
)
21
22
# If extensions (or modules to document with autodoc) are in another directory,
23
# add these directories to sys.path here. If the directory is relative to the
24
# documentation root, use os.path.abspath to make it absolute, like shown here.
25
sys.path.insert(0, os.path.join(__location__, "../sybil"))
26
27
# -- Run sphinx-apidoc -------------------------------------------------------
28
# This hack is necessary since RTD does not issue `sphinx-apidoc` before running
29
# `sphinx-build -b html . _build/html`. See Issue:
30
# https://github.com/rtfd/readthedocs.org/issues/1139
31
# DON'T FORGET: Check the box "Install your project inside a virtualenv using
32
# setup.py install" in the RTD Advanced Settings.
33
# Additionally it helps us to avoid running apidoc manually
34
35
try:  # for Sphinx >= 1.7
36
    from sphinx.ext import apidoc
37
except ImportError:
38
    from sphinx import apidoc
39
40
output_dir = os.path.join(__location__, "api")
41
module_dir = os.path.join(__location__, "../sybil")
42
try:
43
    shutil.rmtree(output_dir)
44
except FileNotFoundError:
45
    pass
46
47
try:
48
    import sphinx
49
50
    cmd_line_template = (
51
        "sphinx-apidoc --implicit-namespaces -f -o {outputdir} {moduledir}"
52
    )
53
    cmd_line = cmd_line_template.format(outputdir=output_dir, moduledir=module_dir)
54
55
    args = cmd_line.split(" ")
56
    if tuple(sphinx.__version__.split(".")) >= ("1", "7"):
57
        # This is a rudimentary parse_version to avoid external dependencies
58
        args = args[1:]
59
60
    apidoc.main(args)
61
except Exception as e:
62
    print("Running `sphinx-apidoc` failed!\n{}".format(e))
63
64
# -- General configuration ---------------------------------------------------
65
66
# If your documentation needs a minimal Sphinx version, state it here.
67
# needs_sphinx = '1.0'
68
69
# Add any Sphinx extension module names here, as strings. They can be extensions
70
# coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
71
extensions = [
72
    "sphinx.ext.autodoc",
73
    "sphinx.ext.intersphinx",
74
    "sphinx.ext.todo",
75
    "sphinx.ext.autosummary",
76
    "sphinx.ext.viewcode",
77
    "sphinx.ext.coverage",
78
    "sphinx.ext.doctest",
79
    "sphinx.ext.ifconfig",
80
    "sphinx.ext.mathjax",
81
    "sphinx.ext.napoleon",
82
]
83
84
# Add any paths that contain templates here, relative to this directory.
85
templates_path = ["_templates"]
86
87
88
# Configure AutoStructify
89
# https://recommonmark.readthedocs.io/en/latest/auto_structify.html
90
def setup(app):
91
    from recommonmark.transform import AutoStructify
92
93
    params = {
94
        "enable_auto_toc_tree": True,
95
        "auto_toc_tree_section": "Contents",
96
        "auto_toc_maxdepth": 2,
97
        "enable_eval_rst": True,
98
        "enable_math": True,
99
        "enable_inline_math": True,
100
    }
101
    app.add_config_value("recommonmark_config", params, True)
102
    app.add_transform(AutoStructify)
103
104
105
# Enable markdown
106
extensions.append("recommonmark")
107
108
# The suffix of source filenames.
109
source_suffix = [".rst", ".md"]
110
111
# The encoding of source files.
112
# source_encoding = 'utf-8-sig'
113
114
# The master toctree document.
115
master_doc = "index"
116
117
# General information about the project.
118
project = "sybil"
119
copyright = "2021, Peter Mikhael & Jeremy Wohlwend"
120
121
# The version info for the project you're documenting, acts as replacement for
122
# |version| and |release|, also used in various other places throughout the
123
# built documents.
124
#
125
# The short X.Y version.
126
version = ""  # Is set by calling `setup.py docs`
127
# The full version, including alpha/beta/rc tags.
128
release = ""  # Is set by calling `setup.py docs`
129
130
# The language for content autogenerated by Sphinx. Refer to documentation
131
# for a list of supported languages.
132
# language = None
133
134
# There are two options for replacing |today|: either, you set today to some
135
# non-false value, then it is used:
136
# today = ''
137
# Else, today_fmt is used as the format for a strftime call.
138
# today_fmt = '%B %d, %Y'
139
140
# List of patterns, relative to source directory, that match files and
141
# directories to ignore when looking for source files.
142
exclude_patterns = ["_build", "Thumbs.db", ".DS_Store", ".venv"]
143
144
# The reST default role (used for this markup: `text`) to use for all documents.
145
# default_role = None
146
147
# If true, '()' will be appended to :func: etc. cross-reference text.
148
# add_function_parentheses = True
149
150
# If true, the current module name will be prepended to all description
151
# unit titles (such as .. function::).
152
# add_module_names = True
153
154
# If true, sectionauthor and moduleauthor directives will be shown in the
155
# output. They are ignored by default.
156
# show_authors = False
157
158
# The name of the Pygments (syntax highlighting) style to use.
159
pygments_style = "sphinx"
160
161
# A list of ignored prefixes for module index sorting.
162
# modindex_common_prefix = []
163
164
# If true, keep warnings as "system message" paragraphs in the built documents.
165
# keep_warnings = False
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
174
# Theme options are theme-specific and customize the look and feel of a theme
175
# further.  For a list of options available for each theme, see the
176
# documentation.
177
html_theme_options = {"sidebar_width": "300px", "page_width": "1200px"}
178
179
# Add any paths that contain custom themes here, relative to this directory.
180
# html_theme_path = []
181
182
# The name for this set of Sphinx documents.  If None, it defaults to
183
# "<project> v<release> documentation".
184
try:
185
    from sybil import __version__ as version
186
except ImportError:
187
    pass
188
else:
189
    release = version
190
191
# A shorter title for the navigation bar.  Default is the same as html_title.
192
# html_short_title = None
193
194
# The name of an image file (relative to this directory) to place at the top
195
# of the sidebar.
196
# html_logo = ""
197
198
# The name of an image file (within the static path) to use as favicon of the
199
# docs.  This file should be a Windows icon file (.ico) being 16x16 or 32x32
200
# pixels large.
201
# html_favicon = None
202
203
# Add any paths that contain custom static files (such as style sheets) here,
204
# relative to this directory. They are copied after the builtin static files,
205
# so a file named "default.css" will overwrite the builtin "default.css".
206
html_static_path = ["_static"]
207
208
# If not '', a 'Last updated on:' timestamp is inserted at every page bottom,
209
# using the given strftime format.
210
# html_last_updated_fmt = '%b %d, %Y'
211
212
# If true, SmartyPants will be used to convert quotes and dashes to
213
# typographically correct entities.
214
# html_use_smartypants = True
215
216
# Custom sidebar templates, maps document names to template names.
217
# html_sidebars = {}
218
219
# Additional templates that should be rendered to pages, maps page names to
220
# template names.
221
# html_additional_pages = {}
222
223
# If false, no module index is generated.
224
# html_domain_indices = True
225
226
# If false, no index is generated.
227
# html_use_index = True
228
229
# If true, the index is split into individual pages for each letter.
230
# html_split_index = False
231
232
# If true, links to the reST sources are added to the pages.
233
# html_show_sourcelink = True
234
235
# If true, "Created using Sphinx" is shown in the HTML footer. Default is True.
236
# html_show_sphinx = True
237
238
# If true, "(C) Copyright ..." is shown in the HTML footer. Default is True.
239
# html_show_copyright = True
240
241
# If true, an OpenSearch description file will be output, and all pages will
242
# contain a <link> tag referring to it.  The value of this option must be the
243
# base URL from which the finished HTML is served.
244
# html_use_opensearch = ''
245
246
# This is the file name suffix for HTML files (e.g. ".xhtml").
247
# html_file_suffix = None
248
249
# Output file base name for HTML help builder.
250
htmlhelp_basename = "sybil-doc"
251
252
# -- Options for LaTeX output ------------------------------------------------
253
254
latex_elements = {
255
    # The paper size ("letterpaper" or "a4paper").
256
    # "papersize": "letterpaper",
257
    # The font size ("10pt", "11pt" or "12pt").
258
    # "pointsize": "10pt",
259
    # Additional stuff for the LaTeX preamble.
260
    # "preamble": "",
261
}
262
263
# Grouping the document tree into LaTeX files. List of tuples
264
# (source start file, target name, title, author, documentclass [howto/manual]).
265
latex_documents = [
266
    ("index", "user_guide.tex", "sybil Documentation", "Peter Mikhael", "manual")
267
]
268
269
# The name of an image file (relative to this directory) to place at the top of
270
# the title page.
271
# latex_logo = ""
272
273
# For "manual" documents, if this is true, then toplevel headings are parts,
274
# not chapters.
275
# latex_use_parts = False
276
277
# If true, show page references after internal links.
278
# latex_show_pagerefs = False
279
280
# If true, show URL addresses after external links.
281
# latex_show_urls = False
282
283
# Documents to append as an appendix to all manuals.
284
# latex_appendices = []
285
286
# If false, no module index is generated.
287
# latex_domain_indices = True
288
289
# -- External mapping --------------------------------------------------------
290
python_version = ".".join(map(str, sys.version_info[0:2]))
291
intersphinx_mapping = {
292
    "sphinx": ("http://www.sphinx-doc.org/en/stable", None),
293
    "python": ("https://docs.python.org/" + python_version, None),
294
    "matplotlib": ("https://matplotlib.org", None),
295
    "numpy": ("https://docs.scipy.org/doc/numpy", None),
296
    "sklearn": ("https://scikit-learn.org/stable", None),
297
    "pandas": ("https://pandas.pydata.org/pandas-docs/stable", None),
298
    "scipy": ("https://docs.scipy.org/doc/scipy/reference", None),
299
}