Skip to content

Document a submodule that shares its name with a member - #487

Open
Cherith1222 wants to merge 1 commit into
pdoc3:masterfrom
Cherith1222:cursor/same-name-submodule-9dca
Open

Cherith1222 wants to merge 1 commit into
pdoc3:masterfrom
Cherith1222:cursor/same-name-submodule-9dca

Conversation

@Cherith1222

Copy link
Copy Markdown

What changed

Module.doc is keyed by short name. When a function, class, or variable already used that name, iter_modules treated root in self.doc as already documented and skipped the submodule.

A submodule is now skipped only when that submodule is already present. The member keeps the short-name key. The submodule is stored as name:module. submodules() selects by type, so both appear. The existing member keeps the refname, so short-name links still resolve to the member. When there is no name clash, the submodule stays at doc[short name].

Fixes #452

Tests

Python 3.12.3:

python -m unittest -v pdoc.test — 84 tests, OK. 2 skipped (parser is gone on 3.10+, and PDOC_TEST_PANDOC was unset). 1 expected failure.

flake8 pdoc setup.py passed. mypy -p pdoc succeeded (61 source files). doc/build.sh was not run.

Before the change, the new test only kept pdoc_issue_452.plain and dropped the same-named widget and gadget submodules.

These tests ran in the environment that prepared the branch. They were not re-run on the machine that opened this pull request.

AI usage

This change was drafted with AI assistance (Cursor Grok).

A function, class, or variable already stored in Module.doc used the
same key as a child module, so that submodule was skipped. Keep the
member and record the submodule beside it.

Fixes pdoc3#452

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

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

1 participant