github.com/containers/podman/v5@v5.1.0-rc1/docs/source/conf.py (about)

     1  # Configuration file for the Sphinx documentation builder.
     2  #
     3  # This file only contains a selection of the most common options. For a full
     4  # list see the documentation:
     5  # https://www.sphinx-doc.org/en/master/usage/configuration.html
     6  
     7  # -- Path setup --------------------------------------------------------------
     8  
     9  # If extensions (or modules to document with autodoc) are in another directory,
    10  # add these directories to sys.path here. If the directory is relative to the
    11  # documentation root, use os.path.abspath to make it absolute, like shown here.
    12  #
    13  # import os
    14  # import sys
    15  # sys.path.insert(0, os.path.abspath('.'))
    16  
    17  import re
    18  import os
    19  import subprocess
    20  
    21  # We have to run the preprocessor to create the actual markdown files from .in files.
    22  # Do it here so the it can work on readthedocs as well.
    23  path = os.path.join(os.path.abspath(os.path.dirname(
    24      __file__)), "../../hack/markdown-preprocess")
    25  p = subprocess.Popen(path,
    26                       stdout=subprocess.PIPE, stderr=subprocess.PIPE)
    27  out, err = p.communicate()
    28  if p.returncode != 0:
    29      raise Exception("failed to run markdown-preprocess", out, err)
    30  
    31  
    32  # -- Project information -----------------------------------------------------
    33  
    34  project = "Podman"
    35  copyright = "2019, team"
    36  author = "team"
    37  
    38  
    39  # -- General configuration ---------------------------------------------------
    40  
    41  # Add any Sphinx extension module names here, as strings. They can be
    42  # extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
    43  # ones.
    44  extensions = ["myst_parser"]
    45  
    46  # Add any paths that contain templates here, relative to this directory.
    47  templates_path = ["_templates"]
    48  
    49  # List of patterns, relative to source directory, that match files and
    50  # directories to ignore when looking for source files.
    51  # This pattern also affects html_static_path and html_extra_path.
    52  exclude_patterns = ["markdown/options"]
    53  
    54  master_doc = "index"
    55  
    56  # Configure smartquotes to only transform quotes and ellipses, not dashes
    57  smartquotes_action = "qe"
    58  
    59  locale_dirs = ["locale/"]
    60  
    61  # -- Options for HTML output -------------------------------------------------
    62  
    63  # The theme to use for HTML and HTML Help pages.  See the documentation for
    64  # a list of builtin themes.
    65  #
    66  html_theme = "alabaster"
    67  
    68  # Add any paths that contain custom static files (such as style sheets) here,
    69  # relative to this directory. They are copied after the builtin static files,
    70  # so a file named "default.css" will overwrite the builtin "default.css".
    71  html_static_path = ["_static"]
    72  
    73  html_css_files = [
    74      "custom.css",
    75  ]
    76  
    77  # -- Extension configuration -------------------------------------------------
    78  
    79  # IMPORTANT: explicitly unset the extensions, by default dollarmath is enabled.
    80  # We use the dollar sign as text and do not want it to be interpreted as math expression.
    81  myst_enable_extensions = []
    82  
    83  
    84  def convert_markdown_title(app, docname, source):
    85      # Process markdown files only
    86      docpath = app.env.doc2path(docname)
    87      if docpath.endswith(".md"):
    88          # Convert pandoc title line into eval_rst block for myst_parser
    89          #
    90          # Remove the ending " 1" (section) to avoid it from being displayed
    91          # in the web tab. Often such a text indicates that
    92          # a web page got an update. For instance GitHub issues
    93          # shows the number of new comments that have been written
    94          # after the user's last visit.
    95          source[0] = re.sub(r"^% (.*)\s(\d)", r"```{title} \g<1>\n```", source[0])
    96  
    97  def setup(app):
    98      app.connect("source-read", convert_markdown_title)