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