blob: 143e60d4ad718b99cbae7b7901d800ed4a4d5581 [file] [log] [blame]
Jonathan Neuschäfer5e48c752018-04-19 16:23:56 +02001# -*- coding: utf-8 -*-
Patrick Georgi5ce40012018-06-06 17:03:21 +02002import subprocess
Patrick Rudolph39315982018-10-22 10:52:40 +02003from recommonmark.parser import CommonMarkParser
Patrick Rudolphf6643212020-05-17 20:04:12 +02004import sphinx
5
6# Get Sphinx version
7major = 0
8minor = 0
9patchlevel = 0
10version = sphinx.__version__.split(".")
11if 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äfer5e48c752018-04-19 16:23:56 +020016
17# Add any paths that contain templates here, relative to this directory.
18templates_path = ['_templates']
19
20# The suffix(es) of source filenames.
21source_suffix = ['.md']
22
23# The master toctree document.
24master_doc = 'index'
25
26# General information about the project.
27project = u'coreboot'
Patrick Rudolph93ffe832018-05-13 16:18:36 +020028copyright = u'CC-by 4.0 the coreboot project'
Jonathan Neuschäfer5e48c752018-04-19 16:23:56 +020029author = 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äfer5e48c752018-04-19 16:23:56 +020035# The full version, including alpha/beta/rc tags.
Arthur Heymans5eb21152018-07-25 11:45:52 +020036release = subprocess.check_output(('git', 'describe')).decode("utf-8")
Patrick Georgi5ce40012018-06-06 17:03:21 +020037# The short X.Y version.
38version = release.split("-")[0]
Jonathan Neuschäfer5e48c752018-04-19 16:23:56 +020039
Patrick Rudolphf6643212020-05-17 20:04:12 +020040extensions = []
41# Load recommonmark, supported since 1.8+
42if major >= 2 or (major == 1 and minor >= 8):
43 extensions += ['recommonmark']
44
45# Try to load DITAA
46try:
47 import sphinxcontrib.ditaa
48except ImportError:
49 print("Error: Please install sphinxcontrib.ditaa for ASCII art conversion\n")
50else:
Patrick Georgi20245aa2020-08-03 13:04:50 +020051 extensions += ['sphinxcontrib.ditaa']
Patrick Georgia73317e2019-12-10 20:27:38 +010052
Jonathan Neuschäfer5e48c752018-04-19 16:23:56 +020053# 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.
Nicholas Chinb61ee162023-05-27 16:20:50 -060058language = 'en'
Jonathan Neuschäfer5e48c752018-04-19 16:23:56 +020059
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
63exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store']
64
65# The name of the Pygments (syntax highlighting) style to use.
66pygments_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.
75todo_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#
83html_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 Rudolpha78e66e52018-05-13 16:06:51 +020088html_static_path = ['_static']
89
Nicholas Chinb61ee162023-05-27 16:20:50 -060090html_css_files = [
91 'theme_overrides.css', # override wide tables in RTD theme
92]
Jonathan Neuschäfer5e48c752018-04-19 16:23:56 +020093
94# Output file base name for HTML help builder.
95htmlhelp_basename = 'corebootdoc'
96
Patrick Rudolph39315982018-10-22 10:52:40 +020097enable_auto_toc_tree = True
98
99class MyCommonMarkParser(CommonMarkParser):
Martin Roth6c3ece92021-10-01 14:10:19 -0600100 # remove this hack once upstream RecommonMark supports inline code
Patrick Rudolph39315982018-10-22 10:52:40 +0200101 def visit_code(self, mdnode):
102 from docutils import nodes
103 n = nodes.literal(mdnode.literal, mdnode.literal)
104 self.current_node.append(n)
Jonathan Neuschäfer5e48c752018-04-19 16:23:56 +0200105
Jonathan Neuschäfer5e48c752018-04-19 16:23:56 +0200106def setup(app):
107 from recommonmark.transform import AutoStructify
Patrick Rudolphf6643212020-05-17 20:04:12 +0200108 # Load recommonmark on old Sphinx
109 if major == 1 and minor < 8:
110 app.add_source_parser('.md', MyCommonMarkParser)
Patrick Rudolph39315982018-10-22 10:52:40 +0200111
Jonathan Neuschäfer5e48c752018-04-19 16:23:56 +0200112 app.add_config_value('recommonmark_config', {
113 'enable_auto_toc_tree': True,
Tom Hillerffe6d542018-07-28 17:38:54 -0400114 'enable_auto_doc_ref': False, # broken in Sphinx 1.6+
Philipp Deppenwiese57df0882018-05-09 12:07:38 +0200115 'enable_eval_rst': True,
Jonathan Neuschäfer5e48c752018-04-19 16:23:56 +0200116 'url_resolver': lambda url: '/' + url
117 }, True)
118 app.add_transform(AutoStructify)