xref: /llvm-project/lldb/docs/conf.py (revision 18cf14efe3e82b2343817fd174bcac48244c8f50)
1edb874b2SJonas Devlieghere# -*- coding: utf-8 -*-
2edb874b2SJonas Devlieghere#
3edb874b2SJonas Devlieghere# LLDB documentation build configuration file, created by
4edb874b2SJonas Devlieghere# sphinx-quickstart on Sun Dec  9 20:01:55 2012.
5edb874b2SJonas Devlieghere#
6edb874b2SJonas Devlieghere# This file is execfile()d with the current directory set to its containing dir.
7edb874b2SJonas Devlieghere#
8edb874b2SJonas Devlieghere# Note that not all possible configuration values are present in this
9edb874b2SJonas Devlieghere# autogenerated file.
10edb874b2SJonas Devlieghere#
11edb874b2SJonas Devlieghere# All configuration values have a default; values that are commented out
12edb874b2SJonas Devlieghere# serve to show the default.
13af6ec920SJonas Devlieghereimport sys, os, re, shutil
14edb874b2SJonas Devliegherefrom datetime import date
15edb874b2SJonas Devlieghere
1662db4349SDavid Spickett# Add path for llvm_slug module.
1762db4349SDavid Spickettsys.path.insert(0, os.path.abspath(os.path.join("..", "..", "llvm", "docs")))
1862db4349SDavid Spickett
192238dcc3SJonas Devliegherebuilding_man_page = tags.has("builder-man")
2075f97cdaSRaphael Isemann
2175f97cdaSRaphael Isemann# For the website we need to setup the path to the generated LLDB module that
2275f97cdaSRaphael Isemann# we can generate documentation for its API.
2375f97cdaSRaphael Isemannif not building_man_page:
24edb874b2SJonas Devlieghere    # If extensions (or modules to document with autodoc) are in another directory,
25edb874b2SJonas Devlieghere    # add these directories to sys.path here. If the directory is relative to the
26edb874b2SJonas Devlieghere    # documentation root, use os.path.abspath to make it absolute, like shown here.
27e7bc6c59SRaphael Isemann
28e7bc6c59SRaphael Isemann    # Add the current directory that contains the mock _lldb native module which
29e7bc6c59SRaphael Isemann    # is imported by the `lldb` module.
30e7bc6c59SRaphael Isemann    sys.path.insert(0, os.path.abspath("."))
31e7bc6c59SRaphael Isemann    # Add the build directory that contains the `lldb` module. LLDB_SWIG_MODULE is
32e7bc6c59SRaphael Isemann    # set by CMake.
33e7bc6c59SRaphael Isemann    sys.path.insert(0, os.getenv("LLDB_SWIG_MODULE"))
34e7bc6c59SRaphael Isemann
35e7bc6c59SRaphael Isemann# Put the generated Python API documentation in the 'python_api' folder. This
36e7bc6c59SRaphael Isemann# also defines the URL these files will have in the generated website.
372238dcc3SJonas Devlieghereautomodapi_toctreedirnm = "python_api"
38edb874b2SJonas Devlieghere
39edb874b2SJonas Devlieghere# -- General configuration -----------------------------------------------------
40edb874b2SJonas Devlieghere
41edb874b2SJonas Devlieghere# If your documentation needs a minimal Sphinx version, state it here.
42edb874b2SJonas Devlieghere# needs_sphinx = '1.0'
43edb874b2SJonas Devlieghere
44edb874b2SJonas Devlieghere# Add any Sphinx extension module names here, as strings. They can be extensions
45edb874b2SJonas Devlieghere# coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
462238dcc3SJonas Devlieghereextensions = ["sphinx.ext.todo", "sphinx.ext.mathjax", "sphinx.ext.intersphinx"]
4775f97cdaSRaphael Isemann
4862db4349SDavid Spickett# When building man pages, we do not use the markdown pages,
4962db4349SDavid Spickett# So, we can continue without the myst_parser dependencies.
5062db4349SDavid Spickett# Doing so reduces dependencies of some packaged llvm distributions.
5162db4349SDavid Spicketttry:
5262db4349SDavid Spickett    import myst_parser
5362db4349SDavid Spickett
5462db4349SDavid Spickett    extensions.append("myst_parser")
5562db4349SDavid Spickettexcept ImportError:
5662db4349SDavid Spickett    if not tags.has("builder-man"):
5762db4349SDavid Spickett        raise
5862db4349SDavid Spickett
5962db4349SDavid Spickett# Automatic anchors for markdown titles
6062db4349SDavid Spickettmyst_heading_anchors = 6
61*18cf14efSScott Lindermyst_heading_slug_func = "llvm_slug.make_slug"
6262db4349SDavid Spickett
63c8387a31SDavid Spickettautodoc_default_options = {"special-members": True}
643ebfeb25SRaphael Isemann
6543024a46SAlan Zhao# The suffix of source filenames.
6643024a46SAlan Zhaosource_suffix = {
6743024a46SAlan Zhao    ".rst": "restructuredtext",
6843024a46SAlan Zhao}
6943024a46SAlan Zhao
7075f97cdaSRaphael Isemann# Unless we only generate the basic manpage we need the plugin for generating
7175f97cdaSRaphael Isemann# the Python API documentation.
7275f97cdaSRaphael Isemannif not building_man_page:
735afa519cSJonas Devlieghere    try:
745afa519cSJonas Devlieghere        import sphinx_automodapi.automodapi
755afa519cSJonas Devlieghere    except ModuleNotFoundError:
765afa519cSJonas Devlieghere        print(
775afa519cSJonas Devlieghere            f"install sphinx_automodapi with {sys.executable} -m pip install sphinx_automodapi"
785afa519cSJonas Devlieghere        )
792238dcc3SJonas Devlieghere    extensions.append("sphinx_automodapi.automodapi")
80edb874b2SJonas Devlieghere
816a2552a1SMed Ismail Bennani    try:
826a2552a1SMed Ismail Bennani        import furo
836a2552a1SMed Ismail Bennani    except ModuleNotFoundError:
84c8387a31SDavid Spickett        print(f"install sphinx furo theme with {sys.executable} -m pip install furo")
856a2552a1SMed Ismail Bennani    # The theme to use for HTML and HTML Help pages.  See the documentation for
866a2552a1SMed Ismail Bennani    # a list of builtin themes.
876a2552a1SMed Ismail Bennani    html_theme = "furo"
886a2552a1SMed Ismail Bennani
8943024a46SAlan Zhao    # Since man pages do not use markdown, we do not need to register a markdown
9043024a46SAlan Zhao    # parser.
9143024a46SAlan Zhao    source_suffix[".md"] = "markdown"
9243024a46SAlan Zhao
93edb874b2SJonas Devlieghere# Add any paths that contain templates here, relative to this directory.
942238dcc3SJonas Devliegheretemplates_path = ["_templates"]
95edb874b2SJonas Devlieghere
96edb874b2SJonas Devlieghere# The encoding of source files.
97edb874b2SJonas Devlieghere# source_encoding = 'utf-8-sig'
98edb874b2SJonas Devlieghere
99edb874b2SJonas Devlieghere# The master toctree document.
1002238dcc3SJonas Devliegheremaster_doc = "index"
101edb874b2SJonas Devlieghere
102edb874b2SJonas Devlieghere# General information about the project.
1032238dcc3SJonas Devlieghereproject = "LLDB"
1042238dcc3SJonas Devliegherecopyright = "2007-%d, The LLDB Team" % date.today().year
105edb874b2SJonas Devlieghere
106edb874b2SJonas Devlieghere# The version info for the project you're documenting, acts as replacement for
107edb874b2SJonas Devlieghere# |version| and |release|, also used in various other places throughout the
108eddf59aeSDavide Italiano# built documents. These are currently set to zero because we don't use them.
109eddf59aeSDavide Italiano# Should somebody consider in the future to change them, they need to be updated
110eddf59aeSDavide Italiano# everytime a new release comes out.
111edb874b2SJonas Devlieghere#
112edb874b2SJonas Devlieghere# The short version.
113eddf59aeSDavide Italiano# version = '0'
114edb874b2SJonas Devlieghere# The full version, including alpha/beta/rc tags.
115eddf59aeSDavide Italiano# release = '0'
116edb874b2SJonas Devlieghere
117edb874b2SJonas Devlieghere# The language for content autogenerated by Sphinx. Refer to documentation
118edb874b2SJonas Devlieghere# for a list of supported languages.
119edb874b2SJonas Devlieghere# language = None
120edb874b2SJonas Devlieghere
121edb874b2SJonas Devlieghere# There are two options for replacing |today|: either, you set today to some
122edb874b2SJonas Devlieghere# non-false value, then it is used:
123edb874b2SJonas Devlieghere# today = ''
124edb874b2SJonas Devlieghere# Else, today_fmt is used as the format for a strftime call.
125edb874b2SJonas Devlieghere# today_fmt = '%B %d, %Y'
126edb874b2SJonas Devlieghere
127edb874b2SJonas Devlieghere# List of patterns, relative to source directory, that match files and
128edb874b2SJonas Devlieghere# directories to ignore when looking for source files.
1292238dcc3SJonas Devlieghereexclude_patterns = ["_build", "analyzer"]
13075f97cdaSRaphael Isemann# Ignore the generated Python documentation that is only used on the website.
13175f97cdaSRaphael Isemann# Without this we will get a lot of warnings about doc pages that aren't
13275f97cdaSRaphael Isemann# included by any doctree (as the manpage ignores those pages but they are
13375f97cdaSRaphael Isemann# potentially still around from a previous website generation).
13475f97cdaSRaphael Isemannif building_man_page:
13575f97cdaSRaphael Isemann    exclude_patterns.append(automodapi_toctreedirnm)
136a58aceffSRaphael Isemann# Use the recommended 'any' rule so that referencing SB API classes is possible
137a58aceffSRaphael Isemann# by just writing `SBData`.
1382238dcc3SJonas Devliegheredefault_role = "any"
139edb874b2SJonas Devlieghere
140edb874b2SJonas Devlieghere# If true, '()' will be appended to :func: etc. cross-reference text.
141edb874b2SJonas Devlieghere# add_function_parentheses = True
142edb874b2SJonas Devlieghere
143edb874b2SJonas Devlieghere# If true, the current module name will be prepended to all description
144edb874b2SJonas Devlieghere# unit titles (such as .. function::).
145edb874b2SJonas Devlieghere# add_module_names = True
146edb874b2SJonas Devlieghere
147edb874b2SJonas Devlieghere# If true, sectionauthor and moduleauthor directives will be shown in the
148edb874b2SJonas Devlieghere# output. They are ignored by default.
149edb874b2SJonas Devlieghere# show_authors = False
150edb874b2SJonas Devlieghere
151edb874b2SJonas Devlieghere# The name of the Pygments (syntax highlighting) style to use.
1522238dcc3SJonas Devliegherepygments_style = "friendly"
153edb874b2SJonas Devlieghere
154edb874b2SJonas Devlieghere# A list of ignored prefixes for module index sorting.
155edb874b2SJonas Devlieghere# modindex_common_prefix = []
156edb874b2SJonas Devlieghere
157edb874b2SJonas Devlieghere
158edb874b2SJonas Devlieghere# -- Options for HTML output ---------------------------------------------------
159edb874b2SJonas Devlieghere
160edb874b2SJonas Devlieghere# The theme to use for HTML and HTML Help pages.  See the documentation for
161edb874b2SJonas Devlieghere# a list of builtin themes.
1626a2552a1SMed Ismail Bennanihtml_theme = "furo"
163edb874b2SJonas Devlieghere
164edb874b2SJonas Devlieghere# Theme options are theme-specific and customize the look and feel of a theme
165edb874b2SJonas Devlieghere# further.  For a list of options available for each theme, see the
166edb874b2SJonas Devlieghere# documentation.
1672771ce80SDavid Spicketthtml_theme_options = {
1682771ce80SDavid Spickett    "source_repository": "https://github.com/llvm/llvm-project",
1692771ce80SDavid Spickett    "source_branch": "main",
1702771ce80SDavid Spickett    "source_directory": "lldb/docs/",
1712771ce80SDavid Spickett}
172edb874b2SJonas Devlieghere
173edb874b2SJonas Devlieghere# Add any paths that contain custom themes here, relative to this directory.
174edb874b2SJonas Devlieghere# html_theme_path = []
175edb874b2SJonas Devlieghere
176edb874b2SJonas Devlieghere# The name for this set of Sphinx documents.  If None, it defaults to
177edb874b2SJonas Devlieghere# "<project> v<release> documentation".
1786a2552a1SMed Ismail Bennanihtml_title = "�� LLDB"
179edb874b2SJonas Devlieghere
180edb874b2SJonas Devlieghere# A shorter title for the navigation bar.  Default is the same as html_title.
181edb874b2SJonas Devlieghere# html_short_title = None
182edb874b2SJonas Devlieghere
183edb874b2SJonas Devlieghere# The name of an image file (relative to this directory) to place at the top
184edb874b2SJonas Devlieghere# of the sidebar.
185edb874b2SJonas Devlieghere# html_logo = None
186edb874b2SJonas Devlieghere
187edb874b2SJonas Devlieghere# The name of an image file (within the static path) to use as favicon of the
188edb874b2SJonas Devlieghere# docs.  This file should be a Windows icon file (.ico) being 16x16 or 32x32
189edb874b2SJonas Devlieghere# pixels large.
190edb874b2SJonas Devlieghere# html_favicon = None
191edb874b2SJonas Devlieghere
192edb874b2SJonas Devlieghere# Add any paths that contain custom static files (such as style sheets) here,
193edb874b2SJonas Devlieghere# relative to this directory. They are copied after the builtin static files,
194edb874b2SJonas Devlieghere# so a file named "default.css" will overwrite the builtin "default.css".
1956813ef37SMed Ismail Bennani# html_static_path = ["_static"]
196edb874b2SJonas Devlieghere
1972238dcc3SJonas Devliegherehtml_extra_path = [".htaccess"]
198edb874b2SJonas Devlieghere
199edb874b2SJonas Devlieghere# If not '', a 'Last updated on:' timestamp is inserted at every page bottom,
200edb874b2SJonas Devlieghere# using the given strftime format.
2012238dcc3SJonas Devliegherehtml_last_updated_fmt = "%b %d, %Y"
202edb874b2SJonas Devlieghere
203edb874b2SJonas Devlieghere# If true, SmartyPants will be used to convert quotes and dashes to
204edb874b2SJonas Devlieghere# typographically correct entities.
205edb874b2SJonas Devlieghere# html_use_smartypants = True
206edb874b2SJonas Devlieghere
207edb874b2SJonas Devlieghere# Custom sidebar templates, maps document names to template names.
208edb874b2SJonas Devlieghere# html_sidebars = {}
209edb874b2SJonas Devlieghere
210edb874b2SJonas Devlieghere# Additional templates that should be rendered to pages, maps page names to
211edb874b2SJonas Devlieghere# template names.
212edb874b2SJonas Devlieghere# html_additional_pages = {}
213edb874b2SJonas Devlieghere
214edb874b2SJonas Devlieghere# If false, no module index is generated.
215edb874b2SJonas Devlieghere# html_domain_indices = True
216edb874b2SJonas Devlieghere
217edb874b2SJonas Devlieghere# If false, no index is generated.
218edb874b2SJonas Devlieghere# html_use_index = True
219edb874b2SJonas Devlieghere
220edb874b2SJonas Devlieghere# If true, the index is split into individual pages for each letter.
221edb874b2SJonas Devlieghere# html_split_index = False
222edb874b2SJonas Devlieghere
223edb874b2SJonas Devlieghere# If true, links to the reST sources are added to the pages.
224edb874b2SJonas Devlieghere# html_show_sourcelink = True
225edb874b2SJonas Devlieghere
226edb874b2SJonas Devlieghere# If true, "Created using Sphinx" is shown in the HTML footer. Default is True.
227edb874b2SJonas Devlieghere# html_show_sphinx = True
228edb874b2SJonas Devlieghere
229edb874b2SJonas Devlieghere# If true, "(C) Copyright ..." is shown in the HTML footer. Default is True.
230edb874b2SJonas Devlieghere# html_show_copyright = True
231edb874b2SJonas Devlieghere
232edb874b2SJonas Devlieghere# If true, an OpenSearch description file will be output, and all pages will
233edb874b2SJonas Devlieghere# contain a <link> tag referring to it.  The value of this option must be the
234edb874b2SJonas Devlieghere# base URL from which the finished HTML is served.
235edb874b2SJonas Devlieghere# html_use_opensearch = ''
236edb874b2SJonas Devlieghere
237edb874b2SJonas Devlieghere# This is the file name suffix for HTML files (e.g. ".xhtml").
238edb874b2SJonas Devlieghere# html_file_suffix = None
239edb874b2SJonas Devlieghere
240edb874b2SJonas Devlieghere# Output file base name for HTML help builder.
2412238dcc3SJonas Devliegherehtmlhelp_basename = "LLDBdoc"
242edb874b2SJonas Devlieghere
24339084ce3SAdrian Prantl# If true, the reST sources are included in the HTML build as
24439084ce3SAdrian Prantl# _sources/name. The default is True.
24539084ce3SAdrian Prantlhtml_copy_source = False
246edb874b2SJonas Devlieghere
247edb874b2SJonas Devlieghere# -- Options for LaTeX output --------------------------------------------------
248edb874b2SJonas Devlieghere
249edb874b2SJonas Devliegherelatex_elements = {
250edb874b2SJonas Devlieghere    # The paper size ('letterpaper' or 'a4paper').
251edb874b2SJonas Devlieghere    #'papersize': 'letterpaper',
252edb874b2SJonas Devlieghere    # The font size ('10pt', '11pt' or '12pt').
253edb874b2SJonas Devlieghere    #'pointsize': '10pt',
254edb874b2SJonas Devlieghere    # Additional stuff for the LaTeX preamble.
255edb874b2SJonas Devlieghere    #'preamble': '',
256edb874b2SJonas Devlieghere}
257edb874b2SJonas Devlieghere
258edb874b2SJonas Devlieghere# Grouping the document tree into LaTeX files. List of tuples
259edb874b2SJonas Devlieghere# (source start file, target name, title, author, documentclass [howto/manual]).
260edb874b2SJonas Devliegherelatex_documents = [
2612238dcc3SJonas Devlieghere    ("index", "LLDB.tex", "LLDB Documentation", "The LLDB Team", "manual"),
262edb874b2SJonas Devlieghere]
263edb874b2SJonas Devlieghere
264edb874b2SJonas Devlieghere# The name of an image file (relative to this directory) to place at the top of
265edb874b2SJonas Devlieghere# the title page.
266edb874b2SJonas Devlieghere# latex_logo = None
267edb874b2SJonas Devlieghere
268edb874b2SJonas Devlieghere# For "manual" documents, if this is true, then toplevel headings are parts,
269edb874b2SJonas Devlieghere# not chapters.
270edb874b2SJonas Devlieghere# latex_use_parts = False
271edb874b2SJonas Devlieghere
272edb874b2SJonas Devlieghere# If true, show page references after internal links.
273edb874b2SJonas Devlieghere# latex_show_pagerefs = False
274edb874b2SJonas Devlieghere
275edb874b2SJonas Devlieghere# If true, show URL addresses after external links.
276edb874b2SJonas Devlieghere# latex_show_urls = False
277edb874b2SJonas Devlieghere
278edb874b2SJonas Devlieghere# Documents to append as an appendix to all manuals.
279edb874b2SJonas Devlieghere# latex_appendices = []
280edb874b2SJonas Devlieghere
281edb874b2SJonas Devlieghere# If false, no module index is generated.
282edb874b2SJonas Devlieghere# latex_domain_indices = True
283edb874b2SJonas Devlieghere
284edb874b2SJonas Devlieghere
285edb874b2SJonas Devlieghere# -- Options for manual page output --------------------------------------------
286edb874b2SJonas Devlieghere
287edb874b2SJonas Devlieghere# One entry per manual page. List of tuples
288edb874b2SJonas Devlieghere# (source start file, name, description, authors, manual section).
2892238dcc3SJonas Devlieghereman_pages = [
2902238dcc3SJonas Devlieghere    ("man/lldb", "lldb", "LLDB Documentation", ["LLVM project"], 1),
2912238dcc3SJonas Devlieghere    ("man/lldb-server", "lldb-server", "LLDB Documentation", ["LLVM project"], 1),
29225c40a45SMichał Górny]
293edb874b2SJonas Devlieghere
294edb874b2SJonas Devlieghere# If true, show URL addresses after external links.
295edb874b2SJonas Devlieghere# man_show_urls = False
296edb874b2SJonas Devlieghere
297edb874b2SJonas Devlieghere# -- Options for Texinfo output ------------------------------------------------
298edb874b2SJonas Devlieghere
299edb874b2SJonas Devlieghere# Grouping the document tree into Texinfo files. List of tuples
300edb874b2SJonas Devlieghere# (source start file, target name, title, author,
301edb874b2SJonas Devlieghere#  dir menu entry, description, category)
302edb874b2SJonas Devliegheretexinfo_documents = [
3032238dcc3SJonas Devlieghere    (
3042238dcc3SJonas Devlieghere        "index",
3052238dcc3SJonas Devlieghere        "LLDB",
3062238dcc3SJonas Devlieghere        "LLDB Documentation",
3072238dcc3SJonas Devlieghere        "The LLDB Team",
3082238dcc3SJonas Devlieghere        "LLDB",
3092238dcc3SJonas Devlieghere        "One line description of project.",
3102238dcc3SJonas Devlieghere        "Miscellaneous",
3112238dcc3SJonas Devlieghere    ),
312edb874b2SJonas Devlieghere]
313edb874b2SJonas Devlieghere
314edb874b2SJonas Devlieghere# Documents to append as an appendix to all manuals.
315edb874b2SJonas Devlieghere# texinfo_appendices = []
316edb874b2SJonas Devlieghere
317edb874b2SJonas Devlieghere# If false, no module index is generated.
318edb874b2SJonas Devlieghere# texinfo_domain_indices = True
319edb874b2SJonas Devlieghere
320edb874b2SJonas Devlieghere# How to display URL addresses: 'footnote', 'no', or 'inline'.
321edb874b2SJonas Devlieghere# texinfo_show_urls = 'footnote'
3223c69ff4bSRaphael Isemann
3232238dcc3SJonas Devlieghereempty_attr_summary = re.compile(
3242238dcc3SJonas Devlieghere    r"\.\. rubric:: Attributes Summary\s*\.\. autosummary::\s*\.\. rubric::"
3252238dcc3SJonas Devlieghere)
3262238dcc3SJonas Devlieghereempty_attr_documentation = re.compile(
3272238dcc3SJonas Devlieghere    r"\.\. rubric:: Attributes Documentation\s*\.\. rubric::"
3282238dcc3SJonas Devlieghere)
3292238dcc3SJonas Devlieghere
3303c69ff4bSRaphael Isemann
331af6ec920SJonas Devliegheredef preprocess_source(app, docname, source):
332af6ec920SJonas Devlieghere    """Preprocesses source files generated by automodapi."""
3333c69ff4bSRaphael Isemann    # Don't cleanup anything beside automodapi-generated sources.
3343c69ff4bSRaphael Isemann    if not automodapi_toctreedirnm in docname:
3353c69ff4bSRaphael Isemann        return
3363c69ff4bSRaphael Isemann    processed = source[0]
3373c69ff4bSRaphael Isemann
3383c69ff4bSRaphael Isemann    # Don't show the list of inheritance info as there is no inheritance in the
3393c69ff4bSRaphael Isemann    # SBI API. This avoids all the repeated text on all doc pages that a
3403c69ff4bSRaphael Isemann    # class inherits from 'object'.
3413c69ff4bSRaphael Isemann
3423c69ff4bSRaphael Isemann    processed = processed.replace(":show-inheritance:", "")
3433c69ff4bSRaphael Isemann    # Remove the SWIG generated 'thisown' attribute. It just bloats the generated
3443c69ff4bSRaphael Isemann    # documentation and users shouldn't fiddle with the value anyway.
3452238dcc3SJonas Devlieghere    processed = re.sub(r"~SB[a-zA-Z]+\.thisown", "", processed)
3463c69ff4bSRaphael Isemann    processed = processed.replace("  .. autoattribute:: thisown", "")
3473c69ff4bSRaphael Isemann
3483c69ff4bSRaphael Isemann    # After removing 'thisown', many objects don't have any attributes left.
3493c69ff4bSRaphael Isemann    # Remove all now empty attribute summary/documentation sections with
3503c69ff4bSRaphael Isemann    # some rather ugly regex.
3512238dcc3SJonas Devlieghere    processed = empty_attr_summary.sub(".. rubric::", processed)
3522238dcc3SJonas Devlieghere    processed = empty_attr_documentation.sub(".. rubric::", processed)
3533c69ff4bSRaphael Isemann
3543c69ff4bSRaphael Isemann    # Replace the original source with the processed one (source is a single
3553c69ff4bSRaphael Isemann    # element list).
3563c69ff4bSRaphael Isemann    source[0] = processed
3573c69ff4bSRaphael Isemann
3582238dcc3SJonas Devlieghere
359af6ec920SJonas Devliegheredef cleanup_source(app, exception):
360af6ec920SJonas Devlieghere    """Remove files generated by automodapi in the source tree."""
3612238dcc3SJonas Devlieghere    if hasattr(app.config, "automodapi_toctreedirnm"):
362af6ec920SJonas Devlieghere        api_source_dir = os.path.join(app.srcdir, app.config.automodapi_toctreedirnm)
363af6ec920SJonas Devlieghere        shutil.rmtree(api_source_dir, ignore_errors=True)
364af6ec920SJonas Devlieghere
3652238dcc3SJonas Devlieghere
3663c69ff4bSRaphael Isemanndef setup(app):
3672238dcc3SJonas Devlieghere    app.connect("source-read", preprocess_source)
3682238dcc3SJonas Devlieghere    app.connect("build-finished", cleanup_source)
369