Skip to content

Commit

Permalink
Don't show sip.wrapper as base class, just show object
Browse files Browse the repository at this point in the history
Fixes #16
  • Loading branch information
nyalldawson authored and 3nids committed Aug 6, 2024
1 parent 85f2990 commit 93fb247
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 21 deletions.
4 changes: 3 additions & 1 deletion conf.in.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@

templates_path = ["_templates"]

autodoc_default_options = {'show-inheritance': True}

# If false, no module index is generated.
html_domain_indices = True
Expand Down Expand Up @@ -241,11 +242,12 @@ def linkcode_resolve(domain, info):
def setup(app):
try:
from autoautosummary import AutoAutoSummary
from process_links import process_docstring, process_signature, skip_member
from process_links import process_docstring, process_signature, skip_member, process_bases

app.add_directive("autoautosummary", AutoAutoSummary)
app.connect("autodoc-process-signature", process_signature)
app.connect("autodoc-process-docstring", process_docstring)
app.connect("autodoc-skip-member", skip_member)
app.connect("autodoc-process-bases", process_bases)
except BaseException as e:
raise e
29 changes: 9 additions & 20 deletions process_links.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,20 +31,6 @@
)


def show_inheritance(obj):
# handle inheritance printing to patch qgis._core with qgis.core
# https://github.com/sphinx-doc/sphinx/blob/685e3fdb49c42b464e09ec955e1033e2a8729fff/sphinx/ext/autodoc/__init__.py#L1103-L1109
if hasattr(obj, "__bases__") and len(obj.__bases__):
bases = [
b.__module__ in ("__builtin__", "builtins")
and ":class:`%s`" % b.__name__
or f":class:`{b.__module__}.{b.__name__}`"
for b in obj.__bases__
]
return "Bases: %s" % ", ".join(bases)
return None


def create_links(doc: str) -> str:
# fix inheritance
doc = re.sub(r"qgis\._(core|gui|analysis|processing)\.", r"", doc)
Expand All @@ -55,11 +41,6 @@ def create_links(doc: str) -> str:

def process_docstring(app, what, name, obj, options, lines):
# print('d', what, name, obj, options)
bases = show_inheritance(obj)
if bases:
lines.insert(0, "")
lines.insert(0, bases)

for i in range(len(lines)):

# fix seealso
Expand Down Expand Up @@ -132,6 +113,14 @@ def skip_member(app, what, name, obj, skip, options):
if name == "baseClass":
return True
if hasattr(obj, "is_monkey_patched") and obj.is_monkey_patched:
print(f"skipping monkey patched enum {name}")
# print(f"skipping monkey patched enum {name}")
return True
return skip


def process_bases(app, name, obj, option, bases: list) -> None:
"""Here we fine tune how the base class's classes are displayed."""
for i, base in enumerate(bases):
# replace 'sip.wrapper' base class with 'object'
if base.__name__ == 'wrapper':
bases[i] = object

0 comments on commit 93fb247

Please sign in to comment.