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. 20sys.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# When building man pages, we do not use the markdown pages, 32# So, we can continue without the myst_parser dependencies. 33# Doing so reduces dependencies of some packaged llvm distributions. 34try: 35 import myst_parser 36 37 extensions.append("myst_parser") 38except ImportError: 39 if not tags.has("builder-man"): 40 raise 41 42# Automatic anchors for markdown titles 43myst_heading_anchors = 6 44myst_heading_slug_func = "llvm_slug.make_slug" 45 46 47# Add any paths that contain templates here, relative to this directory. 48templates_path = ["_templates"] 49 50source_suffix = [".rst", ".md"] 51 52import sphinx 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 = "LLVM" 62copyright = "2003-%d, LLVM Project" % date.today().year 63 64# The language for content autogenerated by Sphinx. Refer to documentation 65# for a list of supported languages. 66# language = None 67 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. 72today_fmt = "%Y-%m-%d" 73 74# List of patterns, relative to source directory, that match files and 75# directories to ignore when looking for source files. 76exclude_patterns = ["_build"] 77 78# The reST default role (used for this markup: `text`) to use for all documents. 79# default_role = None 80 81# If true, '()' will be appended to :func: etc. cross-reference text. 82# add_function_parentheses = True 83 84# If true, the current module name will be prepended to all description 85# unit titles (such as .. function::). 86# add_module_names = True 87 88# If true, sectionauthor and moduleauthor directives will be shown in the 89# output. They are ignored by default. 90show_authors = True 91 92# The name of the Pygments (syntax highlighting) style to use. 93pygments_style = "friendly" 94 95# A list of ignored prefixes for module index sorting. 96# modindex_common_prefix = [] 97 98 99# -- Options for HTML output --------------------------------------------------- 100 101# The theme to use for HTML and HTML Help pages. See the documentation for 102# a list of builtin themes. 103html_theme = "llvm-theme" 104 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. 108html_theme_options = {"nosidebar": False} 109 110# Add any paths that contain custom themes here, relative to this directory. 111html_theme_path = ["_themes"] 112 113# The name for this set of Sphinx documents. If None, it defaults to 114# "<project> v<release> documentation". 115# html_title = None 116 117# A shorter title for the navigation bar. Default is the same as html_title. 118# html_short_title = None 119 120# The name of an image file (relative to this directory) to place at the top 121# of the sidebar. 122# html_logo = None 123 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 128 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". 132html_static_path = ["_static"] 133 134# If not '', a 'Last updated on:' timestamp is inserted at every page bottom, 135# using the given strftime format. 136html_last_updated_fmt = "%Y-%m-%d" 137 138# If true, SmartyPants will be used to convert quotes and dashes to 139# typographically correct entities. 140# html_use_smartypants = True 141 142# Custom sidebar templates, maps document names to template names. 143 144html_sidebars = { 145 "**": [ 146 "indexsidebar.html", 147 "sourcelink.html", 148 "searchbox.html", 149 ] 150} 151 152# Additional templates that should be rendered to pages, maps page names to 153# template names. 154# html_additional_pages = {} 155 156# If false, no module index is generated. 157# html_domain_indices = True 158 159# If false, no index is generated. 160# html_use_index = True 161 162# If true, the index is split into individual pages for each letter. 163# html_split_index = False 164 165# If true, links to the reST sources are added to the pages. 166html_show_sourcelink = True 167 168# If true, "Created using Sphinx" is shown in the HTML footer. Default is True. 169# html_show_sphinx = True 170 171# If true, "(C) Copyright ..." is shown in the HTML footer. Default is True. 172# html_show_copyright = True 173 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 = '' 178 179# This is the file name suffix for HTML files (e.g. ".xhtml"). 180# html_file_suffix = None 181 182# Output file base name for HTML help builder. 183htmlhelp_basename = "LLVMdoc" 184 185 186# -- Options for LaTeX output -------------------------------------------------- 187 188latex_elements = { 189 # The paper size ('letterpaper' or 'a4paper'). 190 #'papersize': 'letterpaper', 191 # The font size ('10pt', '11pt' or '12pt'). 192 #'pointsize': '10pt', 193 # Additional stuff for the LaTeX preamble. 194 #'preamble': '', 195} 196 197# Grouping the document tree into LaTeX files. List of tuples 198# (source start file, target name, title, author, documentclass [howto/manual]). 199latex_documents = [ 200 ("index", "LLVM.tex", "LLVM Documentation", "LLVM project", "manual"), 201] 202 203# The name of an image file (relative to this directory) to place at the top of 204# the title page. 205# latex_logo = None 206 207# For "manual" documents, if this is true, then toplevel headings are parts, 208# not chapters. 209# latex_use_parts = False 210 211# If true, show page references after internal links. 212# latex_show_pagerefs = False 213 214# If true, show URL addresses after external links. 215# latex_show_urls = False 216 217# Documents to append as an appendix to all manuals. 218# latex_appendices = [] 219 220# If false, no module index is generated. 221# latex_domain_indices = True 222 223# If true, figures, tables and code-blocks are automatically numbered if they 224# have a caption. 225numfig = True 226 227# -- Options for manual page output -------------------------------------------- 228 229# One entry per manual page. List of tuples 230# (source start file, name, description, authors, manual section). 231man_pages = [] 232 233# Automatically derive the list of man pages from the contents of the command 234# guide subdirectory. 235basedir = os.path.dirname(__file__) 236man_page_authors = "Maintained by the LLVM Team (https://llvm.org/)." 237command_guide_subpath = "CommandGuide" 238command_guide_path = os.path.join(basedir, command_guide_subpath) 239manpages_url = "{page}.html" 240 241 242def process_md(name): 243 file_subpath = os.path.join(command_guide_subpath, name) 244 with open(os.path.join(command_guide_path, name)) as f: 245 title = f.readline().rstrip("\n") 246 247 m = re.match(r"^# (\S+) - (.+)$", title) 248 if m is None: 249 print( 250 "error: invalid title in %r " 251 "(expected '# <name> - <description>')" % file_subpath, 252 file=sys.stderr, 253 ) 254 else: 255 man_pages.append( 256 ( 257 file_subpath.replace(".md", ""), 258 m.group(1), 259 m.group(2), 260 man_page_authors, 261 1, 262 ) 263 ) 264 265 266def process_rst(name): 267 file_subpath = os.path.join(command_guide_subpath, name) 268 with open(os.path.join(command_guide_path, name)) as f: 269 title = f.readline().rstrip("\n") 270 header = f.readline().rstrip("\n") 271 272 if len(header) != len(title): 273 print( 274 "error: invalid header in %r (does not match title)" % file_subpath, 275 file=sys.stderr, 276 ) 277 if " - " not in title: 278 print( 279 "error: invalid title in %r " 280 "(expected '<name> - <description>')" % file_subpath, 281 file=sys.stderr, 282 ) 283 # Split the name out of the title. 284 name, description = title.split(" - ", 1) 285 man_pages.append( 286 (file_subpath.replace(".rst", ""), name, description, man_page_authors, 1) 287 ) 288 289 290for name in os.listdir(command_guide_path): 291 # Process Markdown files 292 if name.endswith(".md"): 293 process_md(name) 294 # Process ReST files apart from the index page. 295 elif name.endswith(".rst") and name != "index.rst": 296 process_rst(name) 297 298# If true, show URL addresses after external links. 299# man_show_urls = False 300 301# FIXME: Define intersphinx configuration. 302intersphinx_mapping = {} 303 304# Pygment lexer are sometimes out of date (when parsing LLVM for example) or 305# wrong. Suppress the warning so the build doesn't abort. 306suppress_warnings = ["misc.highlighting_failure"] 307