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