pdoc3 / pdoc

:snake: :arrow_right: :scroll: Auto-generate API documentation for Python projects
https://pdoc3.github.io/pdoc/
GNU Affero General Public License v3.0
1.12k stars 145 forks source link

submodule containing a function or class of the same name as the submodule won't be identified #452

Open mivanit opened 3 weeks ago

mivanit commented 3 weeks ago

Expected Behavior/Steps to reproduce

if we have a submodule something with a function something inside that submodule, both the function and submodule should appear in the generated docs.

Actual Behavior

only the function appears in the docs. this is because in the self.doc dict of a pdoc.Module, they will have the same key and thus the module will never be added.

on line 755 we have:

for root in iter_modules(self.obj.__path__):
  # Ignore if this module was already doc'd.
  if root in self.doc:
    continue

but this erroneously skips adding the submodule.

the fix might be as simple as appending :module to the root key before we store it in the dict, but I'm not sure if this would break things downstream.

Additional info