blob: 05da9730effb71076a372759d68407148b5164f7 [file] [log] [blame]
Wyatt Heplerab4eb7a2020-01-08 18:04:31 -08001# Copyright 2020 The Pigweed Authors
Wyatt Hepler1a960942019-11-26 14:13:38 -08002#
3# Licensed under the Apache License, Version 2.0 (the "License"); you may not
4# use this file except in compliance with the License. You may obtain a copy of
5# the License at
6#
7# https://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12# License for the specific language governing permissions and limitations under
13# the License.
Wyatt Hepler8635af92019-12-05 16:32:44 -080014"""Pigweed's Sphinx configuration."""
Wyatt Hepler1a960942019-11-26 14:13:38 -080015
Anthony DiGirolamo56f4a2c2021-05-10 12:06:47 -070016import sphinx
Wyatt Hepler8635af92019-12-05 16:32:44 -080017import sphinx_rtd_theme
Alexei Frolov0efdb112019-11-14 17:22:08 -080018
Anthony DiGirolamo56f4a2c2021-05-10 12:06:47 -070019# TODO(pwbug/376): Remove this when this PR is merged:
20# https://github.com/mgaitan/sphinxcontrib-mermaid/pull/71
21# Needed for sphinxcontrib-mermaid compatibility with sphinx 4.0.0.
22if sphinx.version_info[0] >= 4:
23 import errno
24 import sphinx.util.osutil
25 sphinx.util.osutil.ENOENT = errno.ENOENT
26
Alexei Frolov0efdb112019-11-14 17:22:08 -080027# The suffix of source filenames.
Keir Mierleb1914022021-04-12 09:08:33 -070028source_suffix = ['.rst']
Alexei Frolov0efdb112019-11-14 17:22:08 -080029
Rob Mohr640c75c2021-05-26 07:22:54 -070030# The master toctree document. # inclusive-language: ignore
Alexei Frolov0efdb112019-11-14 17:22:08 -080031master_doc = 'index'
32
33# General information about the project.
Wyatt Hepler8635af92019-12-05 16:32:44 -080034project = 'Pigweed'
Wyatt Heplerab4eb7a2020-01-08 18:04:31 -080035copyright = '2020 The Pigweed Authors' # pylint: disable=redefined-builtin
Alexei Frolov0efdb112019-11-14 17:22:08 -080036
37# The version info for the project you're documenting, acts as replacement for
38# |version| and |release|, also used in various other places throughout the
39# built documents.
40#
41# The short X.Y version.
42version = '0.1'
43# The full version, including alpha/beta/rc tags.
44release = '0.1.0'
45
46# The name of the Pygments (syntax highlighting) style to use.
Wyatt Hepler8635af92019-12-05 16:32:44 -080047pygm = 'sphinx'
48
Wyatt Hepler5a4dc592020-04-29 15:56:01 -070049extensions = [
50 'sphinx.ext.autodoc', # Automatic documentation for Python code
51 'sphinx.ext.napoleon', # Parses Google-style docstrings
Keir Mierlebc5a2692020-05-21 16:52:25 -070052
53 # Blockdiag suite of diagram generators.
54 'sphinxcontrib.blockdiag',
55 'sphinxcontrib.nwdiag',
56 'sphinxcontrib.seqdiag',
57 'sphinxcontrib.actdiag',
58 'sphinxcontrib.rackdiag',
59 'sphinxcontrib.packetdiag',
Anthony DiGirolamo389664e2021-05-06 16:57:20 -070060 'sphinxcontrib.mermaid',
Wyatt Hepler5a4dc592020-04-29 15:56:01 -070061]
Alexei Frolov0efdb112019-11-14 17:22:08 -080062
Wyatt Hepler067dd7e2020-07-14 19:34:32 -070063_DIAG_HTML_IMAGE_FORMAT = 'SVG'
64blockdiag_html_image_format = _DIAG_HTML_IMAGE_FORMAT
65nwdiag_html_image_format = _DIAG_HTML_IMAGE_FORMAT
66seqdiag_html_image_format = _DIAG_HTML_IMAGE_FORMAT
67actdiag_html_image_format = _DIAG_HTML_IMAGE_FORMAT
68rackdiag_html_image_format = _DIAG_HTML_IMAGE_FORMAT
69packetdiag_html_image_format = _DIAG_HTML_IMAGE_FORMAT
Keir Mierlebc5a2692020-05-21 16:52:25 -070070
Armando Montanez1d001202020-03-04 11:51:32 -080071# Tell m2r to parse links to .md files and add them to the build.
72m2r_parse_relative_links = True
73
Alexei Frolov0efdb112019-11-14 17:22:08 -080074# The theme to use for HTML and HTML Help pages. See the documentation for
75# a list of builtin themes.
76html_theme = 'sphinx_rtd_theme'
77
78# Add any paths that contain custom themes here, relative to this directory.
Wyatt Heplerbecb4312019-12-04 09:12:15 -080079html_theme_path = [
80 '_themes',
81]
Wyatt Hepler8635af92019-12-05 16:32:44 -080082
Alexei Frolov0efdb112019-11-14 17:22:08 -080083html_theme_path = [sphinx_rtd_theme.get_html_theme_path()]
84
85# The name for this set of Sphinx documents. If None, it defaults to
86# "<project> v<release> documentation".
87html_title = 'Pigweed'
88
89# If true, SmartyPants will be used to convert quotes and dashes to
90# typographically correct entities.
91html_use_smartypants = True
92
93# If false, no module index is generated.
94html_domain_indices = True
95
96# If false, no index is generated.
97html_use_index = True
98
99# If true, the index is split into individual pages for each letter.
100html_split_index = False
101
102# If true, links to the reST sources are added to the pages.
103html_show_sourcelink = False
104
105# If true, "Created using Sphinx" is shown in the HTML footer. Default is True.
106html_show_sphinx = False
107
Keir Mierleb1914022021-04-12 09:08:33 -0700108# These folders are copied to the documentation's HTML output
109html_static_path = ['docs/_static']
110
111# These paths are either relative to html_static_path
112# or fully qualified paths (eg. https://...)
113html_css_files = [
114 'css/pigweed.css',
115
116 # Needed for Inconsolata font.
117 'https://fonts.googleapis.com/css2?family=Inconsolata&display=swap',
118]
119
Alexei Frolov0efdb112019-11-14 17:22:08 -0800120# Output file base name for HTML help builder.
121htmlhelp_basename = 'Pigweeddoc'
122
123# One entry per manual page. List of tuples
124# (source start file, name, description, authors, manual section).
Wyatt Hepler8635af92019-12-05 16:32:44 -0800125man_pages = [('index', 'pigweed', 'Pigweed', ['Google'], 1)]
Alexei Frolov0efdb112019-11-14 17:22:08 -0800126
127# Grouping the document tree into Texinfo files. List of tuples
128# (source start file, target name, title, author,
129# dir menu entry, description, category)
130texinfo_documents = [
Wyatt Hepler8635af92019-12-05 16:32:44 -0800131 ('index', 'Pigweed', 'Pigweed', 'Google', 'Pigweed', 'Firmware framework',
132 'Miscellaneous'),
Alexei Frolov0efdb112019-11-14 17:22:08 -0800133]
Armando Montanez42225322020-01-02 13:11:41 -0800134
Wyatt Heplerbea166e2021-04-08 10:56:31 -0700135
136def do_not_skip_init(app, what, name, obj, would_skip, options):
137 if name == "__init__":
138 return False # never skip __init__ functions
Wyatt Heplerbea166e2021-04-08 10:56:31 -0700139 return would_skip
140
141
Keir Mierleb1914022021-04-12 09:08:33 -0700142# Problem: CSS files aren't copied after modifying them. Solution:
143# https://github.com/sphinx-doc/sphinx/issues/2090#issuecomment-572902572
144def env_get_outdated(app, env, added, changed, removed):
145 return ['index']
146
147
Wyatt Heplerbea166e2021-04-08 10:56:31 -0700148def setup(app):
Keir Mierleb1914022021-04-12 09:08:33 -0700149 app.add_css_file('css/pigweed.css')
150 app.connect('env-get-outdated', env_get_outdated)
Wyatt Heplerbea166e2021-04-08 10:56:31 -0700151 app.connect("autodoc-skip-member", do_not_skip_init)