This revision was automatically updated to reflect the committed changes.
Closed by commit rG3c69ff4b03ab: [lldb][docs] Filter out 'thisown' 
attribute and inheritance boilerplate (authored by teemperor).
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D94967/new/

https://reviews.llvm.org/D94967

Files:
  lldb/docs/conf.py


Index: lldb/docs/conf.py
===================================================================
--- lldb/docs/conf.py
+++ lldb/docs/conf.py
@@ -298,3 +298,36 @@
 
 # How to display URL addresses: 'footnote', 'no', or 'inline'.
 #texinfo_show_urls = 'footnote'
+
+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. """
+    # Don't cleanup anything beside automodapi-generated sources.
+    if not automodapi_toctreedirnm in docname:
+      return
+    processed = source[0]
+
+    # Don't show the list of inheritance info as there is no inheritance in the
+    # SBI API. This avoids all the repeated text on all doc pages that a
+    # class inherits from 'object'.
+
+    processed = processed.replace(":show-inheritance:", "")
+    # Remove the SWIG generated 'thisown' attribute. It just bloats the 
generated
+    # documentation and users shouldn't fiddle with the value anyway.
+    processed = re.sub(r'~SB[a-zA-Z]+\.thisown', "", processed)
+    processed = processed.replace("  .. autoattribute:: thisown", "")
+
+    # After removing 'thisown', many objects don't have any attributes left.
+    # Remove all now empty attribute summary/documentation sections with
+    # some rather ugly regex.
+    processed = empty_attr_summary.sub('.. rubric::', processed)
+    processed = empty_attr_documentation.sub('.. rubric::', processed)
+
+    # Replace the original source with the processed one (source is a single
+    # element list).
+    source[0] = processed
+
+def setup(app):
+    app.connect('source-read', cleanup_source)


Index: lldb/docs/conf.py
===================================================================
--- lldb/docs/conf.py
+++ lldb/docs/conf.py
@@ -298,3 +298,36 @@
 
 # How to display URL addresses: 'footnote', 'no', or 'inline'.
 #texinfo_show_urls = 'footnote'
+
+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. """
+    # Don't cleanup anything beside automodapi-generated sources.
+    if not automodapi_toctreedirnm in docname:
+      return
+    processed = source[0]
+
+    # Don't show the list of inheritance info as there is no inheritance in the
+    # SBI API. This avoids all the repeated text on all doc pages that a
+    # class inherits from 'object'.
+
+    processed = processed.replace(":show-inheritance:", "")
+    # Remove the SWIG generated 'thisown' attribute. It just bloats the generated
+    # documentation and users shouldn't fiddle with the value anyway.
+    processed = re.sub(r'~SB[a-zA-Z]+\.thisown', "", processed)
+    processed = processed.replace("  .. autoattribute:: thisown", "")
+
+    # After removing 'thisown', many objects don't have any attributes left.
+    # Remove all now empty attribute summary/documentation sections with
+    # some rather ugly regex.
+    processed = empty_attr_summary.sub('.. rubric::', processed)
+    processed = empty_attr_documentation.sub('.. rubric::', processed)
+
+    # Replace the original source with the processed one (source is a single
+    # element list).
+    source[0] = processed
+
+def setup(app):
+    app.connect('source-read', cleanup_source)
_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to