Jonathan Neuschäfer | 5e48c75 | 2018-04-19 16:23:56 +0200 | [diff] [blame] | 1 | # -*- coding: utf-8 -*- |
Patrick Georgi | 5ce4001 | 2018-06-06 17:03:21 +0200 | [diff] [blame] | 2 | import subprocess |
Patrick Rudolph | 3931598 | 2018-10-22 10:52:40 +0200 | [diff] [blame] | 3 | from recommonmark.parser import CommonMarkParser |
Patrick Rudolph | f664321 | 2020-05-17 20:04:12 +0200 | [diff] [blame] | 4 | import sphinx |
| 5 | |
| 6 | # Get Sphinx version |
| 7 | major = 0 |
| 8 | minor = 0 |
| 9 | patchlevel = 0 |
| 10 | version = sphinx.__version__.split(".") |
| 11 | if len(version) > 1: |
| 12 | major = int(version[0]) |
| 13 | minor = int(version[1]) |
| 14 | if len(version) > 2: |
| 15 | patchlevel = int(version[2]) |
Jonathan Neuschäfer | 5e48c75 | 2018-04-19 16:23:56 +0200 | [diff] [blame] | 16 | |
| 17 | # Add any paths that contain templates here, relative to this directory. |
| 18 | templates_path = ['_templates'] |
| 19 | |
| 20 | # The suffix(es) of source filenames. |
| 21 | source_suffix = ['.md'] |
| 22 | |
| 23 | # The master toctree document. |
| 24 | master_doc = 'index' |
| 25 | |
| 26 | # General information about the project. |
| 27 | project = u'coreboot' |
Patrick Rudolph | 93ffe83 | 2018-05-13 16:18:36 +0200 | [diff] [blame] | 28 | copyright = u'CC-by 4.0 the coreboot project' |
Jonathan Neuschäfer | 5e48c75 | 2018-04-19 16:23:56 +0200 | [diff] [blame] | 29 | author = u'the coreboot project' |
| 30 | |
| 31 | # The version info for the project you're documenting, acts as replacement for |
| 32 | # |version| and |release|, also used in various other places throughout the |
| 33 | # built documents. |
| 34 | # |
Jonathan Neuschäfer | 5e48c75 | 2018-04-19 16:23:56 +0200 | [diff] [blame] | 35 | # The full version, including alpha/beta/rc tags. |
Arthur Heymans | 5eb2115 | 2018-07-25 11:45:52 +0200 | [diff] [blame] | 36 | release = subprocess.check_output(('git', 'describe')).decode("utf-8") |
Patrick Georgi | 5ce4001 | 2018-06-06 17:03:21 +0200 | [diff] [blame] | 37 | # The short X.Y version. |
| 38 | version = release.split("-")[0] |
Jonathan Neuschäfer | 5e48c75 | 2018-04-19 16:23:56 +0200 | [diff] [blame] | 39 | |
Patrick Rudolph | f664321 | 2020-05-17 20:04:12 +0200 | [diff] [blame] | 40 | extensions = [] |
| 41 | # Load recommonmark, supported since 1.8+ |
| 42 | if major >= 2 or (major == 1 and minor >= 8): |
| 43 | extensions += ['recommonmark'] |
| 44 | |
| 45 | # Try to load DITAA |
| 46 | try: |
| 47 | import sphinxcontrib.ditaa |
| 48 | except ImportError: |
| 49 | print("Error: Please install sphinxcontrib.ditaa for ASCII art conversion\n") |
| 50 | else: |
Patrick Georgi | 20245aa | 2020-08-03 13:04:50 +0200 | [diff] [blame] | 51 | extensions += ['sphinxcontrib.ditaa'] |
Patrick Georgi | a73317e | 2019-12-10 20:27:38 +0100 | [diff] [blame] | 52 | |
Jonathan Neuschäfer | 5e48c75 | 2018-04-19 16:23:56 +0200 | [diff] [blame] | 53 | # The language for content autogenerated by Sphinx. Refer to documentation |
| 54 | # for a list of supported languages. |
| 55 | # |
| 56 | # This is also used if you do content translation via gettext catalogs. |
| 57 | # Usually you set "language" from the command line for these cases. |
| 58 | language = None |
| 59 | |
| 60 | # List of patterns, relative to source directory, that match files and |
| 61 | # directories to ignore when looking for source files. |
| 62 | # This patterns also effect to html_static_path and html_extra_path |
| 63 | exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store'] |
| 64 | |
| 65 | # The name of the Pygments (syntax highlighting) style to use. |
| 66 | pygments_style = 'sphinx' |
| 67 | |
| 68 | # A list of ignored prefixes for module index sorting. |
| 69 | # modindex_common_prefix = [] |
| 70 | |
| 71 | # If true, keep warnings as "system message" paragraphs in the built documents. |
| 72 | # keep_warnings = False |
| 73 | |
| 74 | # If true, `todo` and `todoList` produce output, else they produce nothing. |
| 75 | todo_include_todos = False |
| 76 | |
| 77 | |
| 78 | # -- Options for HTML output ---------------------------------------------- |
| 79 | |
| 80 | # The theme to use for HTML and HTML Help pages. See the documentation for |
| 81 | # a list of builtin themes. |
| 82 | # |
| 83 | html_theme = 'sphinx_rtd_theme' |
| 84 | |
| 85 | # Add any paths that contain custom static files (such as style sheets) here, |
| 86 | # relative to this directory. They are copied after the builtin static files, |
| 87 | # so a file named "default.css" will overwrite the builtin "default.css". |
Patrick Rudolph | a78e66e5 | 2018-05-13 16:06:51 +0200 | [diff] [blame] | 88 | html_static_path = ['_static'] |
| 89 | |
| 90 | html_context = { |
| 91 | 'css_files': [ |
| 92 | '_static/theme_overrides.css', # override wide tables in RTD theme |
| 93 | ], |
| 94 | } |
Jonathan Neuschäfer | 5e48c75 | 2018-04-19 16:23:56 +0200 | [diff] [blame] | 95 | |
| 96 | # Output file base name for HTML help builder. |
| 97 | htmlhelp_basename = 'corebootdoc' |
| 98 | |
| 99 | # -- Options for LaTeX output --------------------------------------------- |
| 100 | |
| 101 | latex_elements = { |
| 102 | # The paper size ('letterpaper' or 'a4paper'). |
| 103 | # |
| 104 | # 'papersize': 'letterpaper', |
| 105 | |
| 106 | # The font size ('10pt', '11pt' or '12pt'). |
| 107 | # |
| 108 | # 'pointsize': '10pt', |
| 109 | |
| 110 | # Additional stuff for the LaTeX preamble. |
| 111 | # |
| 112 | # 'preamble': '', |
| 113 | |
| 114 | # Latex figure (float) alignment |
| 115 | # |
| 116 | # 'figure_align': 'htbp', |
| 117 | } |
| 118 | |
| 119 | # Grouping the document tree into LaTeX files. List of tuples |
| 120 | # (source start file, target name, title, |
| 121 | # author, documentclass [howto, manual, or own class]). |
| 122 | latex_documents = [ |
| 123 | (master_doc, 'coreboot.tex', u'coreboot Documentation', |
| 124 | u'the coreboot project', 'manual'), |
| 125 | ] |
| 126 | |
| 127 | # The name of an image file (relative to this directory) to place at the top of |
| 128 | # the title page. |
| 129 | # |
| 130 | # latex_logo = None |
| 131 | |
| 132 | # For "manual" documents, if this is true, then toplevel headings are parts, |
| 133 | # not chapters. |
| 134 | # |
| 135 | # latex_use_parts = False |
| 136 | |
| 137 | # If true, show page references after internal links. |
| 138 | # |
| 139 | # latex_show_pagerefs = False |
| 140 | |
| 141 | # If true, show URL addresses after external links. |
| 142 | # |
| 143 | # latex_show_urls = False |
| 144 | |
| 145 | # Documents to append as an appendix to all manuals. |
| 146 | # |
| 147 | # latex_appendices = [] |
| 148 | |
Elyes HAOUAS | 89011be | 2018-05-29 08:31:10 +0200 | [diff] [blame] | 149 | # If false, will not define \strong, \code, itleref, \crossref ... but only |
Jonathan Neuschäfer | 5e48c75 | 2018-04-19 16:23:56 +0200 | [diff] [blame] | 150 | # \sphinxstrong, ..., \sphinxtitleref, ... To help avoid clash with user added |
| 151 | # packages. |
| 152 | # |
| 153 | # latex_keep_old_macro_names = True |
| 154 | |
| 155 | # If false, no module index is generated. |
| 156 | # |
| 157 | # latex_domain_indices = True |
| 158 | |
| 159 | |
| 160 | # -- Options for manual page output --------------------------------------- |
| 161 | |
| 162 | # One entry per manual page. List of tuples |
| 163 | # (source start file, name, description, authors, manual section). |
| 164 | man_pages = [ |
| 165 | (master_doc, 'coreboot', u'coreboot Documentation', |
| 166 | [author], 1) |
| 167 | ] |
| 168 | |
| 169 | # If true, show URL addresses after external links. |
| 170 | # |
| 171 | # man_show_urls = False |
| 172 | |
| 173 | |
| 174 | # -- Options for Texinfo output ------------------------------------------- |
| 175 | |
| 176 | # Grouping the document tree into Texinfo files. List of tuples |
| 177 | # (source start file, target name, title, author, |
| 178 | # dir menu entry, description, category) |
| 179 | texinfo_documents = [ |
| 180 | (master_doc, 'coreboot', u'coreboot Documentation', |
| 181 | author, 'coreboot', 'One line description of project.', |
| 182 | 'Miscellaneous'), |
| 183 | ] |
| 184 | |
Patrick Rudolph | 3931598 | 2018-10-22 10:52:40 +0200 | [diff] [blame] | 185 | enable_auto_toc_tree = True |
| 186 | |
| 187 | class MyCommonMarkParser(CommonMarkParser): |
Martin Roth | 6c3ece9 | 2021-10-01 14:10:19 -0600 | [diff] [blame] | 188 | # remove this hack once upstream RecommonMark supports inline code |
Patrick Rudolph | 3931598 | 2018-10-22 10:52:40 +0200 | [diff] [blame] | 189 | def visit_code(self, mdnode): |
| 190 | from docutils import nodes |
| 191 | n = nodes.literal(mdnode.literal, mdnode.literal) |
| 192 | self.current_node.append(n) |
Jonathan Neuschäfer | 5e48c75 | 2018-04-19 16:23:56 +0200 | [diff] [blame] | 193 | |
| 194 | # Documents to append as an appendix to all manuals. |
| 195 | # |
| 196 | # texinfo_appendices = [] |
| 197 | |
| 198 | # If false, no module index is generated. |
| 199 | # |
| 200 | # texinfo_domain_indices = True |
| 201 | |
| 202 | # How to display URL addresses: 'footnote', 'no', or 'inline'. |
| 203 | # |
| 204 | # texinfo_show_urls = 'footnote' |
| 205 | |
| 206 | # If true, do not generate a @detailmenu in the "Top" node's menu. |
| 207 | # |
| 208 | # texinfo_no_detailmenu = False |
| 209 | |
Jonathan Neuschäfer | 5e48c75 | 2018-04-19 16:23:56 +0200 | [diff] [blame] | 210 | |
| 211 | def setup(app): |
| 212 | from recommonmark.transform import AutoStructify |
Patrick Rudolph | f664321 | 2020-05-17 20:04:12 +0200 | [diff] [blame] | 213 | # Load recommonmark on old Sphinx |
| 214 | if major == 1 and minor < 8: |
| 215 | app.add_source_parser('.md', MyCommonMarkParser) |
Patrick Rudolph | 3931598 | 2018-10-22 10:52:40 +0200 | [diff] [blame] | 216 | |
Jonathan Neuschäfer | 5e48c75 | 2018-04-19 16:23:56 +0200 | [diff] [blame] | 217 | app.add_config_value('recommonmark_config', { |
| 218 | 'enable_auto_toc_tree': True, |
Tom Hiller | ffe6d54 | 2018-07-28 17:38:54 -0400 | [diff] [blame] | 219 | 'enable_auto_doc_ref': False, # broken in Sphinx 1.6+ |
Philipp Deppenwiese | 57df088 | 2018-05-09 12:07:38 +0200 | [diff] [blame] | 220 | 'enable_eval_rst': True, |
Jonathan Neuschäfer | 5e48c75 | 2018-04-19 16:23:56 +0200 | [diff] [blame] | 221 | 'url_resolver': lambda url: '/' + url |
| 222 | }, True) |
| 223 | app.add_transform(AutoStructify) |