aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonas Devlieghere <jonas@devlieghere.com>2022-06-16 16:21:26 -0700
committerJonas Devlieghere <jonas@devlieghere.com>2022-06-16 16:30:49 -0700
commitaf6ec9200b09039573d85e349496c4f5b17c3d7f (patch)
treec12d687062c07e0e114cf6f53750dd6fba9bd1ec
parent2a2886160d80f285d7637f91133ded7bac0f9879 (diff)
downloadllvm-af6ec9200b09039573d85e349496c4f5b17c3d7f.zip
llvm-af6ec9200b09039573d85e349496c4f5b17c3d7f.tar.gz
llvm-af6ec9200b09039573d85e349496c4f5b17c3d7f.tar.bz2
[lldb] Cleanup Python API reference files after building the docs
The sphinx-automodapi extension requires that the generated RST files live next to the index file. This means that we generate them in the source directory rather than the build directory. This patch ensures these files are removed again when sphinx finishes its build. The proper solution to this problem would be to move everything in the doc folder from the source directory to the build directory before generating the docs. I believe that old RST files being kept around is the reason that the Python API references on the website isn't getting updated. This patch is meant as a speculative fix and a way to confirm that.
-rw-r--r--lldb/docs/conf.py15
1 files changed, 11 insertions, 4 deletions
diff --git a/lldb/docs/conf.py b/lldb/docs/conf.py
index cf3af56..c9e21fa 100644
--- a/lldb/docs/conf.py
+++ b/lldb/docs/conf.py
@@ -12,7 +12,7 @@
# serve to show the default.
from __future__ import print_function
-import sys, os, re
+import sys, os, re, shutil
from datetime import date
building_man_page = tags.has('builder-man')
@@ -293,8 +293,8 @@ texinfo_documents = [
empty_attr_summary = re.compile(r'\.\. rubric:: Attributes Summary\s*\.\. autosummary::\s*\.\. rubric::')
empty_attr_documentation = re.compile(r'\.\. rubric:: Attributes Documentation\s*\.\. rubric::')
-def cleanup_source(app, docname, source):
- """ Cleans up source files generated by automodapi. """
+def preprocess_source(app, docname, source):
+ """ Preprocesses source files generated by automodapi. """
# Don't cleanup anything beside automodapi-generated sources.
if not automodapi_toctreedirnm in docname:
return
@@ -320,5 +320,12 @@ def cleanup_source(app, docname, source):
# element list).
source[0] = processed
+def cleanup_source(app, exception):
+ """ Remove files generated by automodapi in the source tree. """
+ if hasattr(app.config, 'automodapi_toctreedirnm'):
+ api_source_dir = os.path.join(app.srcdir, app.config.automodapi_toctreedirnm)
+ shutil.rmtree(api_source_dir, ignore_errors=True)
+
def setup(app):
- app.connect('source-read', cleanup_source)
+ app.connect('source-read', preprocess_source)
+ app.connect('build-finished', cleanup_source)