blob: ed3c21e6831b3530a158f7f3257d7d3af93964d4 [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
Anthony DiGirolamo56f4a2c2021-05-10 12:06:47 -070017
Alexei Frolov0efdb112019-11-14 17:22:08 -080018# The suffix of source filenames.
Keir Mierleb1914022021-04-12 09:08:33 -070019source_suffix = ['.rst']
Alexei Frolov0efdb112019-11-14 17:22:08 -080020
Rob Mohr640c75c2021-05-26 07:22:54 -070021# The master toctree document. # inclusive-language: ignore
Alexei Frolov0efdb112019-11-14 17:22:08 -080022master_doc = 'index'
23
24# General information about the project.
Wyatt Hepler8635af92019-12-05 16:32:44 -080025project = 'Pigweed'
Wyatt Heplerab4eb7a2020-01-08 18:04:31 -080026copyright = '2020 The Pigweed Authors' # pylint: disable=redefined-builtin
Alexei Frolov0efdb112019-11-14 17:22:08 -080027
28# The version info for the project you're documenting, acts as replacement for
29# |version| and |release|, also used in various other places throughout the
30# built documents.
31#
32# The short X.Y version.
33version = '0.1'
34# The full version, including alpha/beta/rc tags.
35release = '0.1.0'
36
37# The name of the Pygments (syntax highlighting) style to use.
Anthony DiGirolamo91307582021-08-13 13:12:14 -070038pygments_style = 'pigweed-code-light'
39pygments_dark_style = 'pigweed-code'
Wyatt Hepler8635af92019-12-05 16:32:44 -080040
Wyatt Hepler5a4dc592020-04-29 15:56:01 -070041extensions = [
42 'sphinx.ext.autodoc', # Automatic documentation for Python code
43 'sphinx.ext.napoleon', # Parses Google-style docstrings
Keir Mierlebc5a2692020-05-21 16:52:25 -070044
45 # Blockdiag suite of diagram generators.
46 'sphinxcontrib.blockdiag',
47 'sphinxcontrib.nwdiag',
48 'sphinxcontrib.seqdiag',
49 'sphinxcontrib.actdiag',
50 'sphinxcontrib.rackdiag',
51 'sphinxcontrib.packetdiag',
Anthony DiGirolamo389664e2021-05-06 16:57:20 -070052 'sphinxcontrib.mermaid',
Wyatt Hepler5a4dc592020-04-29 15:56:01 -070053]
Alexei Frolov0efdb112019-11-14 17:22:08 -080054
Wyatt Hepler067dd7e2020-07-14 19:34:32 -070055_DIAG_HTML_IMAGE_FORMAT = 'SVG'
56blockdiag_html_image_format = _DIAG_HTML_IMAGE_FORMAT
57nwdiag_html_image_format = _DIAG_HTML_IMAGE_FORMAT
58seqdiag_html_image_format = _DIAG_HTML_IMAGE_FORMAT
59actdiag_html_image_format = _DIAG_HTML_IMAGE_FORMAT
60rackdiag_html_image_format = _DIAG_HTML_IMAGE_FORMAT
61packetdiag_html_image_format = _DIAG_HTML_IMAGE_FORMAT
Keir Mierlebc5a2692020-05-21 16:52:25 -070062
Armando Montanez1d001202020-03-04 11:51:32 -080063# Tell m2r to parse links to .md files and add them to the build.
64m2r_parse_relative_links = True
65
Alexei Frolov0efdb112019-11-14 17:22:08 -080066# The theme to use for HTML and HTML Help pages. See the documentation for
67# a list of builtin themes.
Anthony DiGirolamo91307582021-08-13 13:12:14 -070068html_theme = 'furo'
Alexei Frolov0efdb112019-11-14 17:22:08 -080069
70# The name for this set of Sphinx documents. If None, it defaults to
71# "<project> v<release> documentation".
72html_title = 'Pigweed'
73
74# If true, SmartyPants will be used to convert quotes and dashes to
75# typographically correct entities.
76html_use_smartypants = True
77
78# If false, no module index is generated.
79html_domain_indices = True
80
81# If false, no index is generated.
82html_use_index = True
83
84# If true, the index is split into individual pages for each letter.
85html_split_index = False
86
87# If true, links to the reST sources are added to the pages.
88html_show_sourcelink = False
89
90# If true, "Created using Sphinx" is shown in the HTML footer. Default is True.
91html_show_sphinx = False
92
Keir Mierleb1914022021-04-12 09:08:33 -070093# These folders are copied to the documentation's HTML output
94html_static_path = ['docs/_static']
95
96# These paths are either relative to html_static_path
97# or fully qualified paths (eg. https://...)
98html_css_files = [
99 'css/pigweed.css',
100
101 # Needed for Inconsolata font.
102 'https://fonts.googleapis.com/css2?family=Inconsolata&display=swap',
103]
104
Anthony DiGirolamo91307582021-08-13 13:12:14 -0700105html_theme_options = {
106 'light_css_variables': {
107 # Make the logo text more amaranth-like
108 'color-sidebar-brand-text': '#b529aa',
109 'color-sidebar-search-border': '#b529aa',
110 'color-sidebar-link-text--top-level': '#85004d',
111 'color-sidebar-link-text': '#016074',
112 'color-sidebar-item-background--current': '#f0f0f0',
113 'color-sidebar-item-background--hover': '#ffe2f3',
114 'color-sidebar-item-expander-background--hover': '#ffe2f3',
115 'color-api-function-border': '#cccccc',
116 'color-api-function-background': '#f0f0f0',
117 'color-api-class-background': '#e7f2fa',
118 'color-api-class-foreground': '#2980b9',
119 'color-api-class-border': '#6ab0de',
120 'color-inline-code-background': '#fafafa',
121 'color-inline-code-border': '#cccccc',
122 },
123 'dark_css_variables': {
124 'color-sidebar-brand-text': '#e815a5',
125 'color-sidebar-search-border': '#e815a5',
126 'color-sidebar-link-text--top-level': '#ff79c6',
127 'color-sidebar-link-text': '#8be9fd',
128 'color-sidebar-item-background--current': '#575757',
129 'color-sidebar-item-background--hover': '#4c333f',
130 'color-sidebar-item-expander-background--hover': '#4c333f',
131 'color-api-function-border': '#575757',
132 'color-api-function-background': '#2b2b2b',
133 'color-api-class-background': '#222c35',
134 'color-api-class-foreground': '#87c1e5',
135 'color-api-class-border': '#5288be',
136 'color-inline-code-background': '#2b2b2b',
137 'color-inline-code-border': '#575757',
138 },
139}
140
Alexei Frolov0efdb112019-11-14 17:22:08 -0800141# Output file base name for HTML help builder.
142htmlhelp_basename = 'Pigweeddoc'
143
144# One entry per manual page. List of tuples
145# (source start file, name, description, authors, manual section).
Wyatt Hepler8635af92019-12-05 16:32:44 -0800146man_pages = [('index', 'pigweed', 'Pigweed', ['Google'], 1)]
Alexei Frolov0efdb112019-11-14 17:22:08 -0800147
148# Grouping the document tree into Texinfo files. List of tuples
149# (source start file, target name, title, author,
150# dir menu entry, description, category)
151texinfo_documents = [
Wyatt Hepler8635af92019-12-05 16:32:44 -0800152 ('index', 'Pigweed', 'Pigweed', 'Google', 'Pigweed', 'Firmware framework',
153 'Miscellaneous'),
Alexei Frolov0efdb112019-11-14 17:22:08 -0800154]
Armando Montanez42225322020-01-02 13:11:41 -0800155
Wyatt Heplerbea166e2021-04-08 10:56:31 -0700156
157def do_not_skip_init(app, what, name, obj, would_skip, options):
158 if name == "__init__":
159 return False # never skip __init__ functions
Wyatt Heplerbea166e2021-04-08 10:56:31 -0700160 return would_skip
161
162
Keir Mierleb1914022021-04-12 09:08:33 -0700163# Problem: CSS files aren't copied after modifying them. Solution:
164# https://github.com/sphinx-doc/sphinx/issues/2090#issuecomment-572902572
165def env_get_outdated(app, env, added, changed, removed):
166 return ['index']
167
168
Wyatt Heplerbea166e2021-04-08 10:56:31 -0700169def setup(app):
Keir Mierleb1914022021-04-12 09:08:33 -0700170 app.add_css_file('css/pigweed.css')
171 app.connect('env-get-outdated', env_get_outdated)
Wyatt Heplerbea166e2021-04-08 10:56:31 -0700172 app.connect("autodoc-skip-member", do_not_skip_init)