xref: /llvm-project/llvm/docs/conf.py (revision b71edfaa4ec3c998aadb35255ce2f60bba2940b0)
1# -*- coding: utf-8 -*-
2#
3# LLVM documentation build configuration file.
4#
5# This file is execfile()d with the current directory set to its containing dir.
6#
7# Note that not all possible configuration values are present in this
8# autogenerated file.
9#
10# All configuration values have a default; values that are commented out
11# serve to show the default.
12from __future__ import print_function
13
14import sys, os, re
15from datetime import date
16
17# If extensions (or modules to document with autodoc) are in another directory,
18# add these directories to sys.path here. If the directory is relative to the
19# documentation root, use os.path.abspath to make it absolute, like shown here.
20# sys.path.insert(0, os.path.abspath('.'))
21
22# -- General configuration -----------------------------------------------------
23
24# If your documentation needs a minimal Sphinx version, state it here.
25# needs_sphinx = '1.0'
26
27# Add any Sphinx extension module names here, as strings. They can be extensions
28# coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
29extensions = ["sphinx.ext.intersphinx", "sphinx.ext.todo"]
30
31# Add any paths that contain templates here, relative to this directory.
32templates_path = ["_templates"]
33
34# The suffix of source filenames.
35source_suffix = {
36    ".rst": "restructuredtext",
37}
38
39try:
40    import recommonmark
41except ImportError:
42    # manpages do not use any .md sources
43    if not tags.has("builder-man"):
44        raise
45else:
46    import sphinx
47
48    if sphinx.version_info >= (3, 0):
49        # This requires 0.5 or later.
50        extensions.append("recommonmark")
51    else:
52        source_parsers = {".md": "recommonmark.parser.CommonMarkParser"}
53    source_suffix[".md"] = "markdown"
54
55# The encoding of source files.
56# source_encoding = 'utf-8-sig'
57
58# The master toctree document.
59master_doc = "index"
60
61# General information about the project.
62project = "LLVM"
63copyright = "2003-%d, LLVM Project" % date.today().year
64
65# The language for content autogenerated by Sphinx. Refer to documentation
66# for a list of supported languages.
67# language = None
68
69# There are two options for replacing |today|: either, you set today to some
70# non-false value, then it is used:
71# today = ''
72# Else, today_fmt is used as the format for a strftime call.
73today_fmt = "%Y-%m-%d"
74
75# List of patterns, relative to source directory, that match files and
76# directories to ignore when looking for source files.
77exclude_patterns = ["_build"]
78
79# The reST default role (used for this markup: `text`) to use for all documents.
80# default_role = None
81
82# If true, '()' will be appended to :func: etc. cross-reference text.
83# add_function_parentheses = True
84
85# If true, the current module name will be prepended to all description
86# unit titles (such as .. function::).
87# add_module_names = True
88
89# If true, sectionauthor and moduleauthor directives will be shown in the
90# output. They are ignored by default.
91show_authors = True
92
93# The name of the Pygments (syntax highlighting) style to use.
94pygments_style = "friendly"
95
96# A list of ignored prefixes for module index sorting.
97# modindex_common_prefix = []
98
99
100# -- Options for HTML output ---------------------------------------------------
101
102# The theme to use for HTML and HTML Help pages.  See the documentation for
103# a list of builtin themes.
104html_theme = "llvm-theme"
105
106# Theme options are theme-specific and customize the look and feel of a theme
107# further.  For a list of options available for each theme, see the
108# documentation.
109html_theme_options = {"nosidebar": False}
110
111# Add any paths that contain custom themes here, relative to this directory.
112html_theme_path = ["_themes"]
113
114# The name for this set of Sphinx documents.  If None, it defaults to
115# "<project> v<release> documentation".
116# html_title = None
117
118# A shorter title for the navigation bar.  Default is the same as html_title.
119# html_short_title = None
120
121# The name of an image file (relative to this directory) to place at the top
122# of the sidebar.
123# html_logo = None
124
125# The name of an image file (within the static path) to use as favicon of the
126# docs.  This file should be a Windows icon file (.ico) being 16x16 or 32x32
127# pixels large.
128# html_favicon = None
129
130# Add any paths that contain custom static files (such as style sheets) here,
131# relative to this directory. They are copied after the builtin static files,
132# so a file named "default.css" will overwrite the builtin "default.css".
133html_static_path = ["_static"]
134
135# If not '', a 'Last updated on:' timestamp is inserted at every page bottom,
136# using the given strftime format.
137html_last_updated_fmt = "%Y-%m-%d"
138
139# If true, SmartyPants will be used to convert quotes and dashes to
140# typographically correct entities.
141# html_use_smartypants = True
142
143# Custom sidebar templates, maps document names to template names.
144
145html_sidebars = {
146    "**": [
147        "indexsidebar.html",
148        "sourcelink.html",
149        "searchbox.html",
150    ]
151}
152
153# Additional templates that should be rendered to pages, maps page names to
154# template names.
155# html_additional_pages = {}
156
157# If false, no module index is generated.
158# html_domain_indices = True
159
160# If false, no index is generated.
161# html_use_index = True
162
163# If true, the index is split into individual pages for each letter.
164# html_split_index = False
165
166# If true, links to the reST sources are added to the pages.
167html_show_sourcelink = True
168
169# If true, "Created using Sphinx" is shown in the HTML footer. Default is True.
170# html_show_sphinx = True
171
172# If true, "(C) Copyright ..." is shown in the HTML footer. Default is True.
173# html_show_copyright = True
174
175# If true, an OpenSearch description file will be output, and all pages will
176# contain a <link> tag referring to it.  The value of this option must be the
177# base URL from which the finished HTML is served.
178# html_use_opensearch = ''
179
180# This is the file name suffix for HTML files (e.g. ".xhtml").
181# html_file_suffix = None
182
183# Output file base name for HTML help builder.
184htmlhelp_basename = "LLVMdoc"
185
186
187# -- Options for LaTeX output --------------------------------------------------
188
189latex_elements = {
190    # The paper size ('letterpaper' or 'a4paper').
191    #'papersize': 'letterpaper',
192    # The font size ('10pt', '11pt' or '12pt').
193    #'pointsize': '10pt',
194    # Additional stuff for the LaTeX preamble.
195    #'preamble': '',
196}
197
198# Grouping the document tree into LaTeX files. List of tuples
199# (source start file, target name, title, author, documentclass [howto/manual]).
200latex_documents = [
201    ("index", "LLVM.tex", "LLVM Documentation", "LLVM project", "manual"),
202]
203
204# The name of an image file (relative to this directory) to place at the top of
205# the title page.
206# latex_logo = None
207
208# For "manual" documents, if this is true, then toplevel headings are parts,
209# not chapters.
210# latex_use_parts = False
211
212# If true, show page references after internal links.
213# latex_show_pagerefs = False
214
215# If true, show URL addresses after external links.
216# latex_show_urls = False
217
218# Documents to append as an appendix to all manuals.
219# latex_appendices = []
220
221# If false, no module index is generated.
222# latex_domain_indices = True
223
224
225# -- Options for manual page output --------------------------------------------
226
227# One entry per manual page. List of tuples
228# (source start file, name, description, authors, manual section).
229man_pages = []
230
231# Automatically derive the list of man pages from the contents of the command
232# guide subdirectory.
233basedir = os.path.dirname(__file__)
234man_page_authors = "Maintained by the LLVM Team (https://llvm.org/)."
235command_guide_subpath = "CommandGuide"
236command_guide_path = os.path.join(basedir, command_guide_subpath)
237manpages_url = "{page}.html"
238
239
240def process_md(name):
241    file_subpath = os.path.join(command_guide_subpath, name)
242    with open(os.path.join(command_guide_path, name)) as f:
243        title = f.readline().rstrip("\n")
244
245        m = re.match(r"^# (\S+) - (.+)$", title)
246        if m is None:
247            print(
248                "error: invalid title in %r "
249                "(expected '# <name> - <description>')" % file_subpath,
250                file=sys.stderr,
251            )
252        else:
253            man_pages.append(
254                (
255                    file_subpath.replace(".md", ""),
256                    m.group(1),
257                    m.group(2),
258                    man_page_authors,
259                    1,
260                )
261            )
262
263
264def process_rst(name):
265    file_subpath = os.path.join(command_guide_subpath, name)
266    with open(os.path.join(command_guide_path, name)) as f:
267        title = f.readline().rstrip("\n")
268        header = f.readline().rstrip("\n")
269
270        if len(header) != len(title):
271            print(
272                "error: invalid header in %r (does not match title)" % file_subpath,
273                file=sys.stderr,
274            )
275        if " - " not in title:
276            print(
277                "error: invalid title in %r "
278                "(expected '<name> - <description>')" % file_subpath,
279                file=sys.stderr,
280            )
281        # Split the name out of the title.
282        name, description = title.split(" - ", 1)
283        man_pages.append(
284            (file_subpath.replace(".rst", ""), name, description, man_page_authors, 1)
285        )
286
287
288for name in os.listdir(command_guide_path):
289    # Process Markdown files
290    if name.endswith(".md"):
291        process_md(name)
292    # Process ReST files apart from the index page.
293    elif name.endswith(".rst") and name != "index.rst":
294        process_rst(name)
295
296# If true, show URL addresses after external links.
297# man_show_urls = False
298
299# FIXME: Define intersphinx configuration.
300intersphinx_mapping = {}
301
302# Pygment lexer are sometimes out of date (when parsing LLVM for example) or
303# wrong. Suppress the warning so the build doesn't abort.
304suppress_warnings = ["misc.highlighting_failure"]
305