]> git.proxmox.com Git - mirror_frr.git/blame - doc/developer/conf.py
Merge pull request #13332 from LabNConsulting/chopps/new-opts
[mirror_frr.git] / doc / developer / conf.py
CommitLineData
2a6a7a65
DL
1# -*- coding: utf-8 -*-
2#
3# FRR documentation build configuration file, created by
4# sphinx-quickstart on Tue Jan 31 16:00:52 2017.
5#
6# This file is execfile()d with the current directory set to its
7# containing dir.
8#
9# Note that not all possible configuration values are present in this
10# autogenerated file.
11#
12# All configuration values have a default; values that are commented out
13# serve to show the default.
14
15import sys
16import os
17import re
d5403d4f
QY
18import pygments
19from sphinx.highlighting import lexers
19b1a1c6
DL
20from sphinx.util import logging
21logger = logging.getLogger(__name__)
2a6a7a65
DL
22
23# If extensions (or modules to document with autodoc) are in another directory,
24# add these directories to sys.path here. If the directory is relative to the
25# documentation root, use os.path.abspath to make it absolute, like shown here.
701a0192 26# sys.path.insert(0, os.path.abspath('.'))
2a6a7a65
DL
27
28# -- General configuration ------------------------------------------------
29
30# If your documentation needs a minimal Sphinx version, state it here.
701a0192 31needs_sphinx = "1.0"
7bd01bd4
QY
32
33# prolog for various variable substitutions
701a0192 34rst_prolog = ""
2a6a7a65
DL
35
36# Add any Sphinx extension module names here, as strings. They can be
37# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
38# ones.
701a0192 39extensions = ["sphinx.ext.todo", "sphinx.ext.graphviz"]
2a6a7a65
DL
40
41# Add any paths that contain templates here, relative to this directory.
701a0192 42templates_path = ["_templates"]
2a6a7a65
DL
43
44# The suffix(es) of source filenames.
45# You can specify multiple suffix as a list of string:
7bd01bd4 46# source_suffix = ['.rst']
701a0192 47source_suffix = ".rst"
2a6a7a65
DL
48
49# The encoding of source files.
701a0192 50# source_encoding = 'utf-8-sig'
2a6a7a65
DL
51
52# The master toctree document.
701a0192 53master_doc = "index"
2a6a7a65
DL
54
55# General information about the project.
701a0192 56project = u"FRR"
57copyright = u"2017, FRR"
58author = u"FRR authors"
2a6a7a65
DL
59
60# The version info for the project you're documenting, acts as replacement for
61# |version| and |release|, also used in various other places throughout the
62# built documents.
63
64# The short X.Y version.
701a0192 65version = u"?.?"
2a6a7a65 66# The full version, including alpha/beta/rc tags.
701a0192 67release = u"?.?-?"
2a6a7a65 68
7bd01bd4
QY
69
70# -----------------------------------------------------------------------------
71# Extract values from codebase for substitution into docs.
72# -----------------------------------------------------------------------------
73
aef62d25
QY
74# Various installation prefixes. Values are extracted from config.status.
75# Reasonable defaults are set in case that file does not exist.
7bd01bd4 76replace_vars = {
701a0192 77 "AUTHORS": author,
78 "COPYRIGHT_YEAR": "1999-2005",
79 "COPYRIGHT_STR": "Copyright (c) 1999-2005",
80 "PACKAGE_NAME": project.lower(),
81 "PACKAGE_TARNAME": project.lower(),
82 "PACKAGE_STRING": project.lower() + " latest",
83 "PACKAGE_URL": "https://frrouting.org/",
84 "PACKAGE_VERSION": "latest",
85 "INSTALL_PREFIX_ETC": "/etc/frr",
86 "INSTALL_PREFIX_SBIN": "/usr/lib/frr",
87 "INSTALL_PREFIX_STATE": "/var/run/frr",
88 "INSTALL_PREFIX_MODULES": "/usr/lib/frr/modules",
89 "INSTALL_USER": "frr",
90 "INSTALL_GROUP": "frr",
91 "INSTALL_VTY_GROUP": "frrvty",
92 "GROUP": "frr",
93 "USER": "frr",
7bd01bd4
QY
94}
95
96# extract version information, installation location, other stuff we need to
97# use when building final documents
2a6a7a65 98val = re.compile('^S\["([^"]+)"\]="(.*)"$')
aef62d25 99try:
701a0192 100 with open("../../config.status", "r") as cfgstatus:
aef62d25
QY
101 for ln in cfgstatus.readlines():
102 m = val.match(ln)
701a0192 103 if not m or m.group(1) not in replace_vars.keys():
104 continue
aef62d25
QY
105 replace_vars[m.group(1)] = m.group(2)
106except IOError:
107 # if config.status doesn't exist, just ignore it
108 pass
7bd01bd4
QY
109
110# manually fill out some of these we can't get from config.status
701a0192 111replace_vars["COPYRIGHT_STR"] = "Copyright (c)"
112replace_vars["COPYRIGHT_STR"] += " {0}".format(replace_vars["COPYRIGHT_YEAR"])
113replace_vars["COPYRIGHT_STR"] += " {0}".format(replace_vars["AUTHORS"])
114release = replace_vars["PACKAGE_VERSION"]
115version = release.split("-")[0]
7bd01bd4
QY
116
117# add substitutions to prolog
118for key, value in replace_vars.items():
701a0192 119 rst_prolog += ".. |{0}| replace:: {1}\n".format(key, value)
7bd01bd4 120
2a6a7a65
DL
121# There are two options for replacing |today|: either, you set today to some
122# non-false value, then it is used:
701a0192 123# today = ''
2a6a7a65 124# Else, today_fmt is used as the format for a strftime call.
701a0192 125# today_fmt = '%B %d, %Y'
2a6a7a65
DL
126
127# List of patterns, relative to source directory, that match files and
128# directories to ignore when looking for source files.
701a0192 129exclude_patterns = [
130 "_build",
afb8fe93 131 "building-libunwind-note.rst",
701a0192 132 "building-libyang.rst",
133 "topotests-snippets.rst",
e8713b62 134 "topotests-markers.rst",
701a0192 135 "include-compile.rst",
136]
2a6a7a65
DL
137
138# The reST default role (used for this markup: `text`) to use for all
139# documents.
701a0192 140# default_role = None
2a6a7a65
DL
141
142# If true, '()' will be appended to :func: etc. cross-reference text.
701a0192 143# add_function_parentheses = True
2a6a7a65
DL
144
145# If true, the current module name will be prepended to all description
146# unit titles (such as .. function::).
701a0192 147# add_module_names = True
2a6a7a65
DL
148
149# If true, sectionauthor and moduleauthor directives will be shown in the
150# output. They are ignored by default.
701a0192 151# show_authors = False
2a6a7a65
DL
152
153# The name of the Pygments (syntax highlighting) style to use.
701a0192 154pygments_style = "sphinx"
2a6a7a65
DL
155
156# A list of ignored prefixes for module index sorting.
701a0192 157# modindex_common_prefix = []
2a6a7a65
DL
158
159# If true, keep warnings as "system message" paragraphs in the built documents.
701a0192 160# keep_warnings = False
2a6a7a65
DL
161
162# If true, `todo` and `todoList` produce output, else they produce nothing.
163todo_include_todos = True
164
165
166# -- Options for HTML output ----------------------------------------------
167
168# The theme to use for HTML and HTML Help pages. See the documentation for
169# a list of builtin themes.
701a0192 170html_theme = "default"
2a6a7a65 171
856d02a5
DL
172try:
173 import sphinx_rtd_theme
174
701a0192 175 html_theme = "sphinx_rtd_theme"
856d02a5
DL
176except ImportError:
177 pass
178
2a6a7a65
DL
179# Theme options are theme-specific and customize the look and feel of a theme
180# further. For a list of options available for each theme, see the
181# documentation.
701a0192 182# html_theme_options = {
856d02a5 183# 'sidebarbgcolor': '#374249'
701a0192 184# }
2a6a7a65
DL
185
186# Add any paths that contain custom themes here, relative to this directory.
701a0192 187# html_theme_path = []
2a6a7a65
DL
188
189# The name for this set of Sphinx documents. If None, it defaults to
190# "<project> v<release> documentation".
701a0192 191# html_title = None
2a6a7a65
DL
192
193# A shorter title for the navigation bar. Default is the same as html_title.
701a0192 194# html_short_title = None
2a6a7a65
DL
195
196# The name of an image file (relative to this directory) to place at the top
197# of the sidebar.
701a0192 198html_logo = "../figures/frr-icon.svg"
2a6a7a65
DL
199
200# The name of an image file (within the static path) to use as favicon of the
201# docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32
202# pixels large.
701a0192 203html_favicon = "../figures/frr-logo-icon.png"
2a6a7a65
DL
204
205# Add any paths that contain custom static files (such as style sheets) here,
206# relative to this directory. They are copied after the builtin static files,
207# so a file named "default.css" will overwrite the builtin "default.css".
701a0192 208html_static_path = ["_static"]
2a6a7a65
DL
209
210# Add any extra paths that contain custom files (such as robots.txt or
211# .htaccess) here, relative to this directory. These files are copied
212# directly to the root of the documentation.
701a0192 213# html_extra_path = []
2a6a7a65
DL
214
215# If not '', a 'Last updated on:' timestamp is inserted at every page bottom,
216# using the given strftime format.
701a0192 217# html_last_updated_fmt = '%b %d, %Y'
2a6a7a65
DL
218
219# If true, SmartyPants will be used to convert quotes and dashes to
220# typographically correct entities.
701a0192 221# html_use_smartypants = True
2a6a7a65
DL
222
223# Custom sidebar templates, maps document names to template names.
701a0192 224# html_sidebars = {}
2a6a7a65
DL
225
226# Additional templates that should be rendered to pages, maps page names to
227# template names.
701a0192 228# html_additional_pages = {}
2a6a7a65
DL
229
230# If false, no module index is generated.
701a0192 231# html_domain_indices = True
2a6a7a65
DL
232
233# If false, no index is generated.
701a0192 234# html_use_index = True
2a6a7a65
DL
235
236# If true, the index is split into individual pages for each letter.
701a0192 237# html_split_index = False
2a6a7a65
DL
238
239# If true, links to the reST sources are added to the pages.
701a0192 240# html_show_sourcelink = True
2a6a7a65
DL
241
242# If true, "Created using Sphinx" is shown in the HTML footer. Default is True.
701a0192 243# html_show_sphinx = True
2a6a7a65
DL
244
245# If true, "(C) Copyright ..." is shown in the HTML footer. Default is True.
701a0192 246# html_show_copyright = True
2a6a7a65
DL
247
248# If true, an OpenSearch description file will be output, and all pages will
249# contain a <link> tag referring to it. The value of this option must be the
250# base URL from which the finished HTML is served.
701a0192 251# html_use_opensearch = ''
2a6a7a65
DL
252
253# This is the file name suffix for HTML files (e.g. ".xhtml").
701a0192 254# html_file_suffix = None
2a6a7a65
DL
255
256# Language to be used for generating the HTML full-text search index.
257# Sphinx supports the following languages:
258# 'da', 'de', 'en', 'es', 'fi', 'fr', 'hu', 'it', 'ja'
259# 'nl', 'no', 'pt', 'ro', 'ru', 'sv', 'tr'
701a0192 260# html_search_language = 'en'
2a6a7a65
DL
261
262# A dictionary with options for the search language support, empty by default.
263# Now only 'ja' uses this config value
701a0192 264# html_search_options = {'type': 'default'}
2a6a7a65
DL
265
266# The name of a javascript file (relative to the configuration directory) that
267# implements a search results scorer. If empty, the default will be used.
701a0192 268# html_search_scorer = 'scorer.js'
2a6a7a65
DL
269
270# Output file base name for HTML help builder.
701a0192 271htmlhelp_basename = "FRRdoc"
2a6a7a65
DL
272
273# -- Options for LaTeX output ---------------------------------------------
274
275latex_elements = {
701a0192 276 # The paper size ('letterpaper' or 'a4paper').
277 #'papersize': 'letterpaper',
278 # The font size ('10pt', '11pt' or '12pt').
279 #'pointsize': '10pt',
280 # Additional stuff for the LaTeX preamble.
281 #'preamble': '',
282 # Latex figure (float) alignment
283 #'figure_align': 'htbp',
2a6a7a65
DL
284}
285
286# Grouping the document tree into LaTeX files. List of tuples
287# (source start file, target name, title,
288# author, documentclass [howto, manual, or own class]).
289latex_documents = [
701a0192 290 (master_doc, "FRR.tex", u"FRR Developer's Manual", u"FRR", "manual"),
2a6a7a65
DL
291]
292
293# The name of an image file (relative to this directory) to place at the top of
294# the title page.
701a0192 295latex_logo = "../figures/frr-logo-medium.png"
2a6a7a65
DL
296
297# For "manual" documents, if this is true, then toplevel headings are parts,
298# not chapters.
701a0192 299# latex_use_parts = False
2a6a7a65
DL
300
301# If true, show page references after internal links.
701a0192 302# latex_show_pagerefs = False
2a6a7a65
DL
303
304# If true, show URL addresses after external links.
701a0192 305# latex_show_urls = False
2a6a7a65
DL
306
307# Documents to append as an appendix to all manuals.
701a0192 308# latex_appendices = []
2a6a7a65
DL
309
310# If false, no module index is generated.
701a0192 311# latex_domain_indices = True
2a6a7a65
DL
312
313
314# -- Options for manual page output ---------------------------------------
315
316# One entry per manual page. List of tuples
317# (source start file, name, description, authors, manual section).
701a0192 318man_pages = [(master_doc, "frr", u"FRR Developer's Manual", [author], 1)]
2a6a7a65
DL
319
320# If true, show URL addresses after external links.
701a0192 321# man_show_urls = False
2a6a7a65
DL
322
323
324# -- Options for Texinfo output -------------------------------------------
325
326# Grouping the document tree into Texinfo files. List of tuples
327# (source start file, target name, title, author,
328# dir menu entry, description, category)
329texinfo_documents = [
701a0192 330 (
331 master_doc,
332 "frr",
333 u"FRR Developer's Manual",
334 author,
335 "FRR",
336 "One line description of project.",
337 "Miscellaneous",
338 ),
2a6a7a65
DL
339]
340
341# Documents to append as an appendix to all manuals.
701a0192 342# texinfo_appendices = []
2a6a7a65
DL
343
344# If false, no module index is generated.
701a0192 345# texinfo_domain_indices = True
2a6a7a65
DL
346
347# How to display URL addresses: 'footnote', 'no', or 'inline'.
701a0192 348# texinfo_show_urls = 'footnote'
2a6a7a65
DL
349
350# If true, do not generate a @detailmenu in the "Top" node's menu.
701a0192 351# texinfo_no_detailmenu = False
7bd01bd4 352
524ada7f
QY
353# contents of ../extra/frrlexer.py.
354# This is read here to support VPATH build. Since this section is execfile()'d
355# with the file location, we can safely use a relative path here to save the
356# contents of the lexer file for later use even if our relative path changes
357# due to VPATH.
701a0192 358with open("../extra/frrlexer.py", "rb") as lex:
524ada7f
QY
359 frrlexerpy = lex.read()
360
19b1a1c6
DL
361frrfmt_re = re.compile(r'^\s*%(?P<spec>[^\s]+)\s+\((?P<types>.*)\)\s*$')
362
363def parse_frrfmt(env, text, node):
364 from sphinx import addnodes
365
366 m = frrfmt_re.match(text)
367 if not m:
368 logger.warning('could not parse frrfmt:: %r' % (text), location=node)
369 node += addnodes.desc_name(text, text)
370 return text
371
372 spec, types = m.group('spec'), m.group('types')
373
374 node += addnodes.desc_sig_operator('%', '%')
375 node += addnodes.desc_name(spec + ' ', spec + ' ')
376 plist = addnodes.desc_parameterlist()
377 for typ in types.split(','):
378 typ = typ.strip()
379 plist += addnodes.desc_parameter(typ, typ)
380 node += plist
381 return '%' + spec
382
7bd01bd4
QY
383# custom extensions here
384def setup(app):
385 # object type for FRR CLI commands, can be extended to document parent CLI
386 # node later on
701a0192 387 app.add_object_type("clicmd", "clicmd")
19b1a1c6
DL
388
389 # printfrr extensions
390 app.add_object_type("frrfmt", "frrfmt", parse_node=parse_frrfmt)
391
d6ba203d
QY
392 if "add_css_file" in dir(app):
393 app.add_css_file("overrides.css")
394 else:
395 app.add_stylesheet("overrides.css")
396
dff213a9
QY
397 # load Pygments lexer for FRR config syntax
398 #
399 # NB: in Pygments 2.2+ this can be done with `load_lexer_from_file`, but we
400 # do it manually since not all of our supported build platforms have 2.2
401 # yet.
402 #
403 # frrlexer = pygments.lexers.load_lexer_from_file('../extra/frrlexer.py', lexername="FRRLexer")
404 custom_namespace = {}
524ada7f 405 exec(frrlexerpy, custom_namespace)
701a0192 406 lexers["frr"] = custom_namespace["FRRLexer"]()