diff --git a/CHANGELOG.md b/CHANGELOG.md index 408abbde..ed90e041 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,8 @@ - Remove support for Python 3.8, which has reached end-of-life on 2024-10-07 . ([#747](https://github.com/mitmproxy/pdoc/pull/747), @mhils) +- Inherited members are now hidden by default if the base class is not part of the documentation. + Please make yourself heard in https://github.com/mitmproxy/pdoc/issues/715 if you relied on the old behavior. ## 2024-09-11: pdoc 14.7.0 diff --git a/pdoc/render.py b/pdoc/render.py index c7f7410a..3fc524ea 100644 --- a/pdoc/render.py +++ b/pdoc/render.py @@ -177,7 +177,7 @@ def repr_module(module: pdoc.doc.Module) -> str: env = Environment( loader=FileSystemLoader(_default_searchpath), - extensions=[DefaultMacroExtension], + extensions=["jinja2.ext.loopcontrols", DefaultMacroExtension], autoescape=True, trim_blocks=True, lstrip_blocks=True, diff --git a/pdoc/templates/default/module.html.jinja2 b/pdoc/templates/default/module.html.jinja2 index d1acf56e..9c4b0153 100644 --- a/pdoc/templates/default/module.html.jinja2 +++ b/pdoc/templates/default/module.html.jinja2 @@ -266,6 +266,10 @@ See https://pdoc.dev/docs/pdoc/render_helpers.html#DefaultMacroExtension for an {# fmt: off #} {% defaultmacro inherited(cls) %} {% for base, members in cls.inherited_members.items() %} + {% if base[0] not in all_modules %} + {# hide inherited members from modules that are not in the documentation, https://github.com/mitmproxy/pdoc/issues/715 #} + {% continue %} + {% endif %} {% set m = None %}{# workaround for https://github.com/pallets/jinja/issues/1427 #} {% set member_html %} {% for m in members if is_public(m) | trim %} diff --git a/test/testdata/demo_long.html b/test/testdata/demo_long.html index 59cea137..ad4b73ea 100644 --- a/test/testdata/demo_long.html +++ b/test/testdata/demo_long.html @@ -1486,16 +1486,6 @@