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 |
Anthony DiGirolamo | 56f4a2c | 2021-05-10 12:06:47 -0700 | [diff] [blame] | 17 | |
Alexei Frolov | 0efdb11 | 2019-11-14 17:22:08 -0800 | [diff] [blame] | 18 | # The suffix of source filenames. |
Keir Mierle | b191402 | 2021-04-12 09:08:33 -0700 | [diff] [blame] | 19 | source_suffix = ['.rst'] |
Alexei Frolov | 0efdb11 | 2019-11-14 17:22:08 -0800 | [diff] [blame] | 20 | |
Rob Mohr | 640c75c | 2021-05-26 07:22:54 -0700 | [diff] [blame] | 21 | # The master toctree document. # inclusive-language: ignore |
Alexei Frolov | 0efdb11 | 2019-11-14 17:22:08 -0800 | [diff] [blame] | 22 | master_doc = 'index' |
| 23 | |
| 24 | # General information about the project. |
Wyatt Hepler | 8635af9 | 2019-12-05 16:32:44 -0800 | [diff] [blame] | 25 | project = 'Pigweed' |
Wyatt Hepler | ab4eb7a | 2020-01-08 18:04:31 -0800 | [diff] [blame] | 26 | copyright = '2020 The Pigweed Authors' # pylint: disable=redefined-builtin |
Alexei Frolov | 0efdb11 | 2019-11-14 17:22:08 -0800 | [diff] [blame] | 27 | |
| 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. |
| 33 | version = '0.1' |
| 34 | # The full version, including alpha/beta/rc tags. |
| 35 | release = '0.1.0' |
| 36 | |
| 37 | # The name of the Pygments (syntax highlighting) style to use. |
Anthony DiGirolamo | 9130758 | 2021-08-13 13:12:14 -0700 | [diff] [blame] | 38 | pygments_style = 'pigweed-code-light' |
| 39 | pygments_dark_style = 'pigweed-code' |
Wyatt Hepler | 8635af9 | 2019-12-05 16:32:44 -0800 | [diff] [blame] | 40 | |
Wyatt Hepler | 5a4dc59 | 2020-04-29 15:56:01 -0700 | [diff] [blame] | 41 | extensions = [ |
| 42 | 'sphinx.ext.autodoc', # Automatic documentation for Python code |
| 43 | 'sphinx.ext.napoleon', # Parses Google-style docstrings |
Keir Mierle | bc5a269 | 2020-05-21 16:52:25 -0700 | [diff] [blame] | 44 | |
| 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 DiGirolamo | 389664e | 2021-05-06 16:57:20 -0700 | [diff] [blame] | 52 | 'sphinxcontrib.mermaid', |
Wyatt Hepler | 5a4dc59 | 2020-04-29 15:56:01 -0700 | [diff] [blame] | 53 | ] |
Alexei Frolov | 0efdb11 | 2019-11-14 17:22:08 -0800 | [diff] [blame] | 54 | |
Wyatt Hepler | 067dd7e | 2020-07-14 19:34:32 -0700 | [diff] [blame] | 55 | _DIAG_HTML_IMAGE_FORMAT = 'SVG' |
| 56 | blockdiag_html_image_format = _DIAG_HTML_IMAGE_FORMAT |
| 57 | nwdiag_html_image_format = _DIAG_HTML_IMAGE_FORMAT |
| 58 | seqdiag_html_image_format = _DIAG_HTML_IMAGE_FORMAT |
| 59 | actdiag_html_image_format = _DIAG_HTML_IMAGE_FORMAT |
| 60 | rackdiag_html_image_format = _DIAG_HTML_IMAGE_FORMAT |
| 61 | packetdiag_html_image_format = _DIAG_HTML_IMAGE_FORMAT |
Keir Mierle | bc5a269 | 2020-05-21 16:52:25 -0700 | [diff] [blame] | 62 | |
Armando Montanez | 1d00120 | 2020-03-04 11:51:32 -0800 | [diff] [blame] | 63 | # Tell m2r to parse links to .md files and add them to the build. |
| 64 | m2r_parse_relative_links = True |
| 65 | |
Alexei Frolov | 0efdb11 | 2019-11-14 17:22:08 -0800 | [diff] [blame] | 66 | # The theme to use for HTML and HTML Help pages. See the documentation for |
| 67 | # a list of builtin themes. |
Anthony DiGirolamo | 9130758 | 2021-08-13 13:12:14 -0700 | [diff] [blame] | 68 | html_theme = 'furo' |
Alexei Frolov | 0efdb11 | 2019-11-14 17:22:08 -0800 | [diff] [blame] | 69 | |
| 70 | # The name for this set of Sphinx documents. If None, it defaults to |
| 71 | # "<project> v<release> documentation". |
| 72 | html_title = 'Pigweed' |
| 73 | |
| 74 | # If true, SmartyPants will be used to convert quotes and dashes to |
| 75 | # typographically correct entities. |
| 76 | html_use_smartypants = True |
| 77 | |
| 78 | # If false, no module index is generated. |
| 79 | html_domain_indices = True |
| 80 | |
| 81 | # If false, no index is generated. |
| 82 | html_use_index = True |
| 83 | |
| 84 | # If true, the index is split into individual pages for each letter. |
| 85 | html_split_index = False |
| 86 | |
| 87 | # If true, links to the reST sources are added to the pages. |
| 88 | html_show_sourcelink = False |
| 89 | |
| 90 | # If true, "Created using Sphinx" is shown in the HTML footer. Default is True. |
| 91 | html_show_sphinx = False |
| 92 | |
Keir Mierle | b191402 | 2021-04-12 09:08:33 -0700 | [diff] [blame] | 93 | # These folders are copied to the documentation's HTML output |
| 94 | html_static_path = ['docs/_static'] |
| 95 | |
| 96 | # These paths are either relative to html_static_path |
| 97 | # or fully qualified paths (eg. https://...) |
| 98 | html_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 DiGirolamo | 9130758 | 2021-08-13 13:12:14 -0700 | [diff] [blame] | 105 | html_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 Frolov | 0efdb11 | 2019-11-14 17:22:08 -0800 | [diff] [blame] | 141 | # Output file base name for HTML help builder. |
| 142 | htmlhelp_basename = 'Pigweeddoc' |
| 143 | |
| 144 | # One entry per manual page. List of tuples |
| 145 | # (source start file, name, description, authors, manual section). |
Wyatt Hepler | 8635af9 | 2019-12-05 16:32:44 -0800 | [diff] [blame] | 146 | man_pages = [('index', 'pigweed', 'Pigweed', ['Google'], 1)] |
Alexei Frolov | 0efdb11 | 2019-11-14 17:22:08 -0800 | [diff] [blame] | 147 | |
| 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) |
| 151 | texinfo_documents = [ |
Wyatt Hepler | 8635af9 | 2019-12-05 16:32:44 -0800 | [diff] [blame] | 152 | ('index', 'Pigweed', 'Pigweed', 'Google', 'Pigweed', 'Firmware framework', |
| 153 | 'Miscellaneous'), |
Alexei Frolov | 0efdb11 | 2019-11-14 17:22:08 -0800 | [diff] [blame] | 154 | ] |
Armando Montanez | 4222532 | 2020-01-02 13:11:41 -0800 | [diff] [blame] | 155 | |
Wyatt Hepler | bea166e | 2021-04-08 10:56:31 -0700 | [diff] [blame] | 156 | |
| 157 | def do_not_skip_init(app, what, name, obj, would_skip, options): |
| 158 | if name == "__init__": |
| 159 | return False # never skip __init__ functions |
Wyatt Hepler | bea166e | 2021-04-08 10:56:31 -0700 | [diff] [blame] | 160 | return would_skip |
| 161 | |
| 162 | |
Keir Mierle | b191402 | 2021-04-12 09:08:33 -0700 | [diff] [blame] | 163 | # Problem: CSS files aren't copied after modifying them. Solution: |
| 164 | # https://github.com/sphinx-doc/sphinx/issues/2090#issuecomment-572902572 |
| 165 | def env_get_outdated(app, env, added, changed, removed): |
| 166 | return ['index'] |
| 167 | |
| 168 | |
Wyatt Hepler | bea166e | 2021-04-08 10:56:31 -0700 | [diff] [blame] | 169 | def setup(app): |
Keir Mierle | b191402 | 2021-04-12 09:08:33 -0700 | [diff] [blame] | 170 | app.add_css_file('css/pigweed.css') |
| 171 | app.connect('env-get-outdated', env_get_outdated) |
Wyatt Hepler | bea166e | 2021-04-08 10:56:31 -0700 | [diff] [blame] | 172 | app.connect("autodoc-skip-member", do_not_skip_init) |