Wyatt Hepler | ab4eb7a | 2020-01-08 18:04:31 -0800 | [diff] [blame] | 1 | # Copyright 2020 The Pigweed Authors |
Wyatt Hepler | 1a96094 | 2019-11-26 14:13:38 -0800 | [diff] [blame] | 2 | # |
| 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 Hepler | 8635af9 | 2019-12-05 16:32:44 -0800 | [diff] [blame] | 14 | """Pigweed's Sphinx configuration.""" |
Wyatt Hepler | 1a96094 | 2019-11-26 14:13:38 -0800 | [diff] [blame] | 15 | |
Anthony DiGirolamo | 56f4a2c | 2021-05-10 12:06:47 -0700 | [diff] [blame] | 16 | import sphinx |
Wyatt Hepler | 8635af9 | 2019-12-05 16:32:44 -0800 | [diff] [blame] | 17 | import sphinx_rtd_theme |
Alexei Frolov | 0efdb11 | 2019-11-14 17:22:08 -0800 | [diff] [blame] | 18 | |
Anthony DiGirolamo | 56f4a2c | 2021-05-10 12:06:47 -0700 | [diff] [blame] | 19 | # 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. |
| 22 | if sphinx.version_info[0] >= 4: |
| 23 | import errno |
| 24 | import sphinx.util.osutil |
| 25 | sphinx.util.osutil.ENOENT = errno.ENOENT |
| 26 | |
Alexei Frolov | 0efdb11 | 2019-11-14 17:22:08 -0800 | [diff] [blame] | 27 | # The suffix of source filenames. |
Keir Mierle | b191402 | 2021-04-12 09:08:33 -0700 | [diff] [blame] | 28 | source_suffix = ['.rst'] |
Alexei Frolov | 0efdb11 | 2019-11-14 17:22:08 -0800 | [diff] [blame] | 29 | |
Rob Mohr | 640c75c | 2021-05-26 07:22:54 -0700 | [diff] [blame] | 30 | # The master toctree document. # inclusive-language: ignore |
Alexei Frolov | 0efdb11 | 2019-11-14 17:22:08 -0800 | [diff] [blame] | 31 | master_doc = 'index' |
| 32 | |
| 33 | # General information about the project. |
Wyatt Hepler | 8635af9 | 2019-12-05 16:32:44 -0800 | [diff] [blame] | 34 | project = 'Pigweed' |
Wyatt Hepler | ab4eb7a | 2020-01-08 18:04:31 -0800 | [diff] [blame] | 35 | copyright = '2020 The Pigweed Authors' # pylint: disable=redefined-builtin |
Alexei Frolov | 0efdb11 | 2019-11-14 17:22:08 -0800 | [diff] [blame] | 36 | |
| 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. |
| 42 | version = '0.1' |
| 43 | # The full version, including alpha/beta/rc tags. |
| 44 | release = '0.1.0' |
| 45 | |
| 46 | # The name of the Pygments (syntax highlighting) style to use. |
Wyatt Hepler | 8635af9 | 2019-12-05 16:32:44 -0800 | [diff] [blame] | 47 | pygm = 'sphinx' |
| 48 | |
Wyatt Hepler | 5a4dc59 | 2020-04-29 15:56:01 -0700 | [diff] [blame] | 49 | extensions = [ |
| 50 | 'sphinx.ext.autodoc', # Automatic documentation for Python code |
| 51 | 'sphinx.ext.napoleon', # Parses Google-style docstrings |
Keir Mierle | bc5a269 | 2020-05-21 16:52:25 -0700 | [diff] [blame] | 52 | |
| 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 DiGirolamo | 389664e | 2021-05-06 16:57:20 -0700 | [diff] [blame] | 60 | 'sphinxcontrib.mermaid', |
Wyatt Hepler | 5a4dc59 | 2020-04-29 15:56:01 -0700 | [diff] [blame] | 61 | ] |
Alexei Frolov | 0efdb11 | 2019-11-14 17:22:08 -0800 | [diff] [blame] | 62 | |
Wyatt Hepler | 067dd7e | 2020-07-14 19:34:32 -0700 | [diff] [blame] | 63 | _DIAG_HTML_IMAGE_FORMAT = 'SVG' |
| 64 | blockdiag_html_image_format = _DIAG_HTML_IMAGE_FORMAT |
| 65 | nwdiag_html_image_format = _DIAG_HTML_IMAGE_FORMAT |
| 66 | seqdiag_html_image_format = _DIAG_HTML_IMAGE_FORMAT |
| 67 | actdiag_html_image_format = _DIAG_HTML_IMAGE_FORMAT |
| 68 | rackdiag_html_image_format = _DIAG_HTML_IMAGE_FORMAT |
| 69 | packetdiag_html_image_format = _DIAG_HTML_IMAGE_FORMAT |
Keir Mierle | bc5a269 | 2020-05-21 16:52:25 -0700 | [diff] [blame] | 70 | |
Armando Montanez | 1d00120 | 2020-03-04 11:51:32 -0800 | [diff] [blame] | 71 | # Tell m2r to parse links to .md files and add them to the build. |
| 72 | m2r_parse_relative_links = True |
| 73 | |
Alexei Frolov | 0efdb11 | 2019-11-14 17:22:08 -0800 | [diff] [blame] | 74 | # The theme to use for HTML and HTML Help pages. See the documentation for |
| 75 | # a list of builtin themes. |
| 76 | html_theme = 'sphinx_rtd_theme' |
| 77 | |
| 78 | # Add any paths that contain custom themes here, relative to this directory. |
Wyatt Hepler | becb431 | 2019-12-04 09:12:15 -0800 | [diff] [blame] | 79 | html_theme_path = [ |
| 80 | '_themes', |
| 81 | ] |
Wyatt Hepler | 8635af9 | 2019-12-05 16:32:44 -0800 | [diff] [blame] | 82 | |
Alexei Frolov | 0efdb11 | 2019-11-14 17:22:08 -0800 | [diff] [blame] | 83 | html_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". |
| 87 | html_title = 'Pigweed' |
| 88 | |
| 89 | # If true, SmartyPants will be used to convert quotes and dashes to |
| 90 | # typographically correct entities. |
| 91 | html_use_smartypants = True |
| 92 | |
| 93 | # If false, no module index is generated. |
| 94 | html_domain_indices = True |
| 95 | |
| 96 | # If false, no index is generated. |
| 97 | html_use_index = True |
| 98 | |
| 99 | # If true, the index is split into individual pages for each letter. |
| 100 | html_split_index = False |
| 101 | |
| 102 | # If true, links to the reST sources are added to the pages. |
| 103 | html_show_sourcelink = False |
| 104 | |
| 105 | # If true, "Created using Sphinx" is shown in the HTML footer. Default is True. |
| 106 | html_show_sphinx = False |
| 107 | |
Keir Mierle | b191402 | 2021-04-12 09:08:33 -0700 | [diff] [blame] | 108 | # These folders are copied to the documentation's HTML output |
| 109 | html_static_path = ['docs/_static'] |
| 110 | |
| 111 | # These paths are either relative to html_static_path |
| 112 | # or fully qualified paths (eg. https://...) |
| 113 | html_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 Frolov | 0efdb11 | 2019-11-14 17:22:08 -0800 | [diff] [blame] | 120 | # Output file base name for HTML help builder. |
| 121 | htmlhelp_basename = 'Pigweeddoc' |
| 122 | |
| 123 | # One entry per manual page. List of tuples |
| 124 | # (source start file, name, description, authors, manual section). |
Wyatt Hepler | 8635af9 | 2019-12-05 16:32:44 -0800 | [diff] [blame] | 125 | man_pages = [('index', 'pigweed', 'Pigweed', ['Google'], 1)] |
Alexei Frolov | 0efdb11 | 2019-11-14 17:22:08 -0800 | [diff] [blame] | 126 | |
| 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) |
| 130 | texinfo_documents = [ |
Wyatt Hepler | 8635af9 | 2019-12-05 16:32:44 -0800 | [diff] [blame] | 131 | ('index', 'Pigweed', 'Pigweed', 'Google', 'Pigweed', 'Firmware framework', |
| 132 | 'Miscellaneous'), |
Alexei Frolov | 0efdb11 | 2019-11-14 17:22:08 -0800 | [diff] [blame] | 133 | ] |
Armando Montanez | 4222532 | 2020-01-02 13:11:41 -0800 | [diff] [blame] | 134 | |
Wyatt Hepler | bea166e | 2021-04-08 10:56:31 -0700 | [diff] [blame] | 135 | |
| 136 | def do_not_skip_init(app, what, name, obj, would_skip, options): |
| 137 | if name == "__init__": |
| 138 | return False # never skip __init__ functions |
Wyatt Hepler | bea166e | 2021-04-08 10:56:31 -0700 | [diff] [blame] | 139 | return would_skip |
| 140 | |
| 141 | |
Keir Mierle | b191402 | 2021-04-12 09:08:33 -0700 | [diff] [blame] | 142 | # Problem: CSS files aren't copied after modifying them. Solution: |
| 143 | # https://github.com/sphinx-doc/sphinx/issues/2090#issuecomment-572902572 |
| 144 | def env_get_outdated(app, env, added, changed, removed): |
| 145 | return ['index'] |
| 146 | |
| 147 | |
Wyatt Hepler | bea166e | 2021-04-08 10:56:31 -0700 | [diff] [blame] | 148 | def setup(app): |
Keir Mierle | b191402 | 2021-04-12 09:08:33 -0700 | [diff] [blame] | 149 | app.add_css_file('css/pigweed.css') |
| 150 | app.connect('env-get-outdated', env_get_outdated) |
Wyatt Hepler | bea166e | 2021-04-08 10:56:31 -0700 | [diff] [blame] | 151 | app.connect("autodoc-skip-member", do_not_skip_init) |