Author: Jonas Devlieghere Date: 2022-06-16T16:30:49-07:00 New Revision: af6ec9200b09039573d85e349496c4f5b17c3d7f
URL: https://github.com/llvm/llvm-project/commit/af6ec9200b09039573d85e349496c4f5b17c3d7f DIFF: https://github.com/llvm/llvm-project/commit/af6ec9200b09039573d85e349496c4f5b17c3d7f.diff LOG: [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. Added: Modified: lldb/docs/conf.py Removed: ################################################################################ diff --git a/lldb/docs/conf.py b/lldb/docs/conf.py index cf3af568572b..c9e21fa8b8d5 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 @@ 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) _______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits