1# Copyright 2020 The Pigweed Authors 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. 14"""Pigweed's Sphinx configuration.""" 15 16from datetime import date 17import sphinx 18 19# The suffix of source filenames. 20source_suffix = ['.rst'] 21 22# The master toctree document. # inclusive-language: ignore 23master_doc = 'index' 24 25# General information about the project. 26project = 'Pigweed' 27copyright = f'{date.today().year} The Pigweed Authors' # pylint: disable=redefined-builtin 28 29# The version info for the project you're documenting, acts as replacement for 30# |version| and |release|, also used in various other places throughout the 31# built documents. 32# 33# The short X.Y version. 34version = '0.1' 35# The full version, including alpha/beta/rc tags. 36release = '0.1.0' 37 38# The name of the Pygments (syntax highlighting) style to use. 39pygments_style = 'pigweed-code-light' 40pygments_dark_style = 'pigweed-code' 41 42extensions = [ 43 'pw_docgen.sphinx.google_analytics', # Enables optional Google Analytics 44 'sphinx.ext.autodoc', # Automatic documentation for Python code 45 'sphinx.ext.napoleon', # Parses Google-style docstrings 46 'sphinxcontrib.mermaid', 47 'sphinx_design', 48] 49 50_DIAG_HTML_IMAGE_FORMAT = 'SVG' 51blockdiag_html_image_format = _DIAG_HTML_IMAGE_FORMAT 52nwdiag_html_image_format = _DIAG_HTML_IMAGE_FORMAT 53seqdiag_html_image_format = _DIAG_HTML_IMAGE_FORMAT 54actdiag_html_image_format = _DIAG_HTML_IMAGE_FORMAT 55rackdiag_html_image_format = _DIAG_HTML_IMAGE_FORMAT 56packetdiag_html_image_format = _DIAG_HTML_IMAGE_FORMAT 57 58# Tell m2r to parse links to .md files and add them to the build. 59m2r_parse_relative_links = True 60 61# The theme to use for HTML and HTML Help pages. See the documentation for 62# a list of builtin themes. 63html_theme = 'furo' 64 65# The name for this set of Sphinx documents. If None, it defaults to 66# "<project> v<release> documentation". 67html_title = 'Pigweed' 68 69# If true, SmartyPants will be used to convert quotes and dashes to 70# typographically correct entities. 71html_use_smartypants = True 72 73# If false, no module index is generated. 74html_domain_indices = True 75 76# If false, no index is generated. 77html_use_index = True 78 79# If true, the index is split into individual pages for each letter. 80html_split_index = False 81 82# If true, links to the reST sources are added to the pages. 83html_show_sourcelink = False 84 85# If true, "Created using Sphinx" is shown in the HTML footer. Default is True. 86html_show_sphinx = False 87 88# These folders are copied to the documentation's HTML output 89html_static_path = ['docs/_static'] 90 91# These paths are either relative to html_static_path 92# or fully qualified paths (eg. https://...) 93html_css_files = [ 94 'css/pigweed.css', 95 96 # Needed for Inconsolata font. 97 'https://fonts.googleapis.com/css2?family=Inconsolata&display=swap', 98] 99 100html_theme_options = { 101 'light_css_variables': { 102 # Make the logo text more amaranth-like 103 'color-sidebar-brand-text': '#b529aa', 104 'color-sidebar-search-border': '#b529aa', 105 'color-sidebar-link-text--top-level': '#85004d', 106 'color-sidebar-link-text': '#016074', 107 'color-sidebar-item-background--current': '#f0f0f0', 108 'color-sidebar-item-background--hover': '#ffe2f3', 109 'color-sidebar-item-expander-background--hover': '#ffe2f3', 110 # Function signature colors 111 'color-api-function-border': '#cccccc', 112 'color-api-function-background': '#f0f0f0', 113 'color-api-class-background': '#e7f2fa', 114 'color-api-class-foreground': '#2980b9', 115 'color-api-class-border': '#6ab0de', 116 # Namespace:: 117 'color-api-pre-name': '#2980b9', 118 # Function name 119 'color-api-name': '#2980b9', 120 'color-inline-code-background': '#fafafa', 121 'color-inline-code-border': '#cccccc', 122 'color-text-selection-background': '#1d5fad', 123 'color-text-selection-foreground': '#ffffff', 124 }, 125 'dark_css_variables': { 126 'color-sidebar-brand-text': '#e815a5', 127 'color-sidebar-search-border': '#e815a5', 128 'color-sidebar-link-text--top-level': '#ff79c6', 129 'color-sidebar-link-text': '#8be9fd', 130 'color-sidebar-item-background--current': '#575757', 131 'color-sidebar-item-background--hover': '#4c333f', 132 'color-sidebar-item-expander-background--hover': '#4c333f', 133 # Function signature colors 134 'color-api-function-border': '#575757', 135 'color-api-function-background': '#2b2b2b', 136 'color-api-class-background': '#222c35', 137 'color-api-class-foreground': '#87c1e5', 138 'color-api-class-border': '#5288be', 139 # Namespace:: 140 'color-api-pre-name': '#87c1e5', 141 # Function name 142 'color-api-name': '#87c1e5', 143 'color-inline-code-background': '#2b2b2b', 144 'color-inline-code-border': '#575757', 145 'color-text-selection-background': '#2674bf', 146 'color-text-selection-foreground': '#ffffff', 147 }, 148} 149 150# Output file base name for HTML help builder. 151htmlhelp_basename = 'Pigweeddoc' 152 153# One entry per manual page. List of tuples 154# (source start file, name, description, authors, manual section). 155man_pages = [('index', 'pigweed', 'Pigweed', ['Google'], 1)] 156 157# Grouping the document tree into Texinfo files. List of tuples 158# (source start file, target name, title, author, 159# dir menu entry, description, category) 160texinfo_documents = [ 161 ('index', 'Pigweed', 'Pigweed', 'Google', 'Pigweed', 'Firmware framework', 162 'Miscellaneous'), 163] 164 165 166def do_not_skip_init(app, what, name, obj, would_skip, options): 167 if name == "__init__": 168 return False # never skip __init__ functions 169 return would_skip 170 171 172# Problem: CSS files aren't copied after modifying them. Solution: 173# https://github.com/sphinx-doc/sphinx/issues/2090#issuecomment-572902572 174def env_get_outdated(app, env, added, changed, removed): 175 return ['index'] 176 177 178def setup(app): 179 app.add_css_file('css/pigweed.css') 180 app.connect('env-get-outdated', env_get_outdated) 181 app.connect("autodoc-skip-member", do_not_skip_init) 182