Home | History | Annotate | Line # | Download | only in manual
      1 # -*- coding: utf-8 -*-
      2 #
      3 # Configuration file for the Sphinx documentation builder.
      4 #
      5 # This file does only contain a selection of the most common options. For a
      6 # full list see the documentation:
      7 # http://www.sphinx-doc.org/en/master/config
      8 
      9 # -- Path setup --------------------------------------------------------------
     10 
     11 # If extensions (or modules to document with autodoc) are in another directory,
     12 # add these directories to sys.path here. If the directory is relative to the
     13 # documentation root, use os.path.abspath to make it absolute, like shown here.
     14 #
     15 # import os
     16 # import sys
     17 # sys.path.insert(0, os.path.abspath('.'))
     18 
     19 import os
     20 import datetime
     21 import sphinx_rtd_theme
     22 import requests
     23 
     24 # -- Project information -----------------------------------------------------
     25 
     26 project = '@project@'
     27 year = datetime.datetime.now().year
     28 copyright = f'2001{year}, NLnet Labs'
     29 author = 'NLnet Labs'
     30 
     31 # The short X.Y version
     32 version = '@version@'
     33 # The full version, including alpha/beta/rc tags
     34 release = '@version@'
     35 
     36 try:
     37     response_versions = requests.get(
     38         f"https://readthedocs.org/api/v2/version/?project__slug=nsd&active=true",
     39         timeout=2,
     40     ).json()
     41     versions = [
     42         (version["slug"], f"/{version['project']['language']}/{version['slug']}/")
     43         for version in response_versions["results"]
     44     ]
     45 except Exception:
     46     versions = []
     47 
     48 # -- General configuration ---------------------------------------------------
     49 
     50 # If your documentation needs a minimal Sphinx version, state it here.
     51 #
     52 # needs_sphinx = '1.0'
     53 
     54 # Add any Sphinx extension module names here, as strings. They can be
     55 # extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
     56 # ones.
     57 extensions = [
     58     'sphinx.ext.todo',
     59     'sphinx.ext.ifconfig',
     60     'sphinx_tabs.tabs',
     61     'sphinx_copybutton',
     62     'sphinx.ext.intersphinx',
     63     'sphinx.ext.autosectionlabel',
     64     'notfound.extension',
     65     'sphinxcontrib.jquery',
     66     'sphinx_rtd_theme',
     67     'sphinx_substitution_extensions',
     68 ]
     69 
     70 intersphinx_mapping = {
     71     'nsd': ('https://nsd.docs.nlnetlabs.nl/en/latest/', None)
     72 }
     73 
     74 autosectionlabel_prefix_document = True
     75 
     76 # -- Sphinx Tabs configuration -----------------------------------------------
     77 
     78 sphinx_tabs_disable_tab_closing = True
     79 sphinx_tabs_disable_css_loading = True
     80 
     81 # Add any paths that contain templates here, relative to this directory.
     82 templates_path = ['../templates']
     83 
     84 # The suffix(es) of source filenames.
     85 # You can specify multiple suffix as a list of string:
     86 #
     87 # source_suffix = ['.rst', '.md']
     88 source_suffix = '.rst'
     89 
     90 # The master toctree document.
     91 master_doc = 'index'
     92 
     93 # The language for content autogenerated by Sphinx. Refer to documentation
     94 # for a list of supported languages.
     95 #
     96 # This is also used if you do content translation via gettext catalogs.
     97 # Usually you set "language" from the command line for these cases.
     98 language = "en"
     99 
    100 # List of patterns, relative to source directory, that match files and
    101 # directories to ignore when looking for source files.
    102 # This pattern also affects html_static_path and html_extra_path .
    103 exclude_patterns = []
    104 
    105 # The name of the Pygments (syntax highlighting) style to use.
    106 pygments_style = 'sphinx'
    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.
    112 #
    113 html_theme = 'sphinx_rtd_theme'
    114 html_logo = 'resources/nsd-duotone-white.png'
    115 html_favicon = 'resources/favicon.ico'
    116 html_theme_options = {
    117     'logo_only': True,
    118 }
    119 
    120 # Theme options are theme-specific and customize the look and feel of a theme
    121 # further.  For a list of options available for each theme, see the
    122 # documentation.
    123 #
    124 # html_theme_options = {}
    125 
    126 # Add any paths that contain custom static files (such as style sheets) here,
    127 # relative to this directory. They are copied after the builtin static files,
    128 # so a file named "default.css" will overwrite the builtin "default.css".
    129 html_static_path = ['resources']
    130 
    131 # Custom sidebar templates, must be a dictionary that maps document names
    132 # to template names.
    133 #
    134 # The default sidebars (for documents that don't match any pattern) are
    135 # defined by theme itself.  Builtin themes are using these templates by
    136 # default: ``['localtoc.html', 'relations.html', 'sourcelink.html',
    137 # 'searchbox.html']``.
    138 #
    139 # html_sidebars = {}
    140 
    141 
    142 # Set canonical URL from the Read the Docs Domain
    143 html_baseurl = os.environ.get("READTHEDOCS_CANONICAL_URL", "")
    144 scheme = "https"
    145 
    146 html_context = {
    147         'html_theme': html_theme,
    148         'current_version': version,
    149         'version_slug': version,
    150 
    151         'PRODUCTION_DOMAIN': "readthedocs.org",
    152         'versions': versions,
    153         # "downloads": downloads,
    154         # "subprojects": subprojects,
    155 
    156         'slug': "nsd",
    157         'rtd_language': language,
    158         'canonical_url': html_baseurl,
    159 
    160         'conf_py_path': "/doc/manual/",
    161 
    162         'github_user': "NLnetLabs",
    163         'github_repo': "nsd",
    164         'github_version': os.environ.get("READTHEDOCS_GIT_IDENTIFIER", "main"),
    165         'display_github': True,
    166         'READTHEDOCS': True,
    167         'using_theme': False,
    168         'new_theme': True,
    169         'source_suffix': ".rst",
    170         'docsearch_disabled': False,
    171     }
    172 
    173 # -- Options for HTMLHelp output ---------------------------------------------
    174 
    175 # Output file base name for HTML help builder.
    176 htmlhelp_basename = 'NSDUserManualdoc'
    177 
    178 
    179 # -- Options for LaTeX output ------------------------------------------------
    180 
    181 latex_elements = {
    182     # The paper size ('letterpaper' or 'a4paper').
    183     #
    184     # 'papersize': 'letterpaper',
    185 
    186     # The font size ('10pt', '11pt' or '12pt').
    187     #
    188     # 'pointsize': '10pt',
    189 
    190     # Additional stuff for the LaTeX preamble.
    191     #
    192     # 'preamble': '',
    193 
    194     # Latex figure (float) alignment
    195     #
    196     # 'figure_align': 'htbp',
    197 }
    198 
    199 # Grouping the document tree into LaTeX files. List of tuples
    200 # (source start file, target name, title,
    201 #  author, documentclass [howto, manual, or own class]).
    202 latex_documents = [
    203     (master_doc, 'NSDUserManual.tex', 'NSD User Manual',
    204      'NLnet Labs', 'manual'),
    205 ]
    206 
    207 
    208 # -- Options for manual page output ------------------------------------------
    209 
    210 # Manual pages are generated from the actual manual pages using mandoc.
    211 
    212 # One entry per manual page. List of tuples
    213 # (source start file, name, description, authors, manual section).
    214 #man_pages = [
    215 #    ('manpages/nsd', 'nsd', 'Name Server Daemon (NSD)',
    216 #     "NSD was written by NLnet Labs and RIPE NCC joint team. Please see CREDITS file in the distribution for further details.", 8),
    217 #    ('manpages/nsd-checkconf', 'nsd-checkconf', 'NSD configuration file checker.',
    218 #     "NSD was written by NLnet Labs and RIPE NCC joint team. Please see CREDITS file in the distribution for further details.", 8),
    219 #    ('manpages/nsd-checkzone', 'nsd-checkzone', 'NSD zone file syntax checker.',
    220 #     "NSD was written by NLnet Labs and RIPE NCC joint team. Please see CREDITS file in the distribution for further details.", 8),
    221 #    ('manpages/nsd.conf', 'nsd.conf', 'NSD configuration file.',
    222 #     "NSD was written by NLnet Labs and RIPE NCC joint team. Please see CREDITS file in the distribution for further details.", 5),
    223 #    ('manpages/nsd-control', 'nsd-control', 'NSD remote server control utility.',
    224 #     "NSD was written by NLnet Labs and RIPE NCC joint team. Please see CREDITS file in the distribution for further details.", 8)
    225 #]
    226 #manpages_url = '{page}.html'
    227 
    228 # -- Options for Texinfo output ----------------------------------------------
    229 
    230 # Grouping the document tree into Texinfo files. List of tuples
    231 # (source start file, target name, title, author,
    232 #  dir menu entry, description, category)
    233 texinfo_documents = [
    234     (master_doc, 'NSDUserManual', 'NSD User Manual',
    235      author, 'NSDUserManual', 'One line description of project.',
    236      'Miscellaneous'),
    237 ]
    238 
    239 
    240 # -- Options for Epub output -------------------------------------------------
    241 
    242 # Bibliographic Dublin Core info.
    243 epub_title = project
    244 epub_author = author
    245 epub_publisher = author
    246 epub_copyright = copyright
    247 
    248 # The unique identifier of the text. This can be a ISBN number
    249 # or the project homepage.
    250 #
    251 # epub_identifier = ''
    252 
    253 # A unique identification for the text.
    254 #
    255 # epub_uid = ''
    256 
    257 # A list of files that should not be packed into the epub file.
    258 epub_exclude_files = ['search.html']
    259 
    260 
    261 # -- Extension configuration -------------------------------------------------
    262 
    263 # -- Options for todo extension ----------------------------------------------
    264 
    265 # If true, `todo` and `todoList` produce output, else they produce nothing.
    266 todo_include_todos = True
    267 
    268 # -- Extension interface --------------------------------------------------
    269 from sphinx import addnodes
    270 def parse_cmd_args_node(env, sig, signode):
    271     try:
    272         cmd, args = sig.strip().split(' ', 1)
    273     except ValueError:
    274         cmd, args = sig, None
    275     # distinguish cmd from its args
    276     signode += addnodes.desc_name(cmd, cmd)
    277     if args:
    278         args = ' ' + args
    279         signode += addnodes.desc_addname(args, args)
    280     return cmd
    281 # define new directive/role that can be used as .. subcmd::/:subcmd:
    282 def setup(app):
    283     app.add_object_type('subcmd', 'subcmd',
    284                         objname='module sub-command',
    285                         indextemplate='pair: %s; module sub-command',
    286                         parse_node=parse_cmd_args_node)
    287     app.add_css_file('css/dark.css')
    288     app.add_css_file('css/light.css')
    289 
    290 
    291 # -- Export variables to be used in RST --------------------------------------
    292 
    293 rst_epilog = ".. |pidfile| replace:: @pidfile@\n" \
    294              ".. |configdir| replace:: @configdir@\n" \
    295              ".. |configfile| replace:: @nsdconfigfile@\n" \
    296              ".. |logfile| replace:: @logfile@\n" \
    297              ".. |xfrdfile| replace:: @xfrdfile@\n" \
    298              ".. |zonelistfile| replace:: @zonelistfile@\n"
    299 
    300 
    301 # -- Options for substitution extension --------------------------------------
    302 
    303 rst_prolog = ".. |version| replace:: @version@"
    304