diff --git a/pdoc/render_helpers.py b/pdoc/render_helpers.py index b3672ca5..1497defc 100644 --- a/pdoc/render_helpers.py +++ b/pdoc/render_helpers.py @@ -212,10 +212,13 @@ def possible_sources( yield identifier, "" return - if len(set(s.partition(".")[0] for s in all_modules)) == 1: + # handle relative identifiers + if identifier.startswith("."): pkgname = next(iter(all_modules)).partition(".")[0] - if not identifier.startswith(pkgname): - identifier = f"{pkgname}.{identifier}" + # check that all modules reside within the same top-level module + if all(s.startswith(pkgname + ".") or s == pkgname for s in all_modules): + if not identifier.startswith(pkgname): + identifier = f"{pkgname}{identifier}" modulename = identifier qualname = None @@ -342,7 +345,7 @@ def linkify_repl(m: re.Match): r""" # Part 1: foo.bar or foo.bar() (without backticks) (? -
This class is defined in .child_c and inherits from .demopackage.B
+This class is defined in .child_c and inherits from demopackage.B
Test that submodules are linked to when documenting a single module.
-Do helpers.something
with a types.BigThing
Do .helpers.something
with a .types.BigThing