Make it possible to ignore class members based on wildcard strings
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 1.2k
- Forks
- 146
- PR merge metrics
- No merged PRs in 30d
Description
I have a module that defines big nested data structure that is based on Pydantic. For the examples below, I use pydantic as an example even though this happens with any base-class. Minimal version is like this.
from pydantic import BaseModel
class ConfA(BaseModel):
a_value: int
class ConfB(BaseModel):
b_value: str
class Configuration(BaseModel):
a: ConfA
b: ConfB
I would want to use __pdoc__ variable to ignore the BaseModel's methods from the documentation, as they appear under each of these classes.
However, I don't want to disable inheritance altogether with the --config flag, as this is the only case where inherited members are not desired.
Expected Behavior
Something like the following removes the documentation for these inherited members from all the classes in the module where this is defined.
__pdoc__ = {
'*.model_fields': False,
'*.model_computed_fields': False,
'*.model_config': False,
}
Actual Behavior
__pdoc__ = {
'*.model_fields': False,
'*.model_computed_fields': False,
'*.model_config': False,
}
Produces the following:
UserWarning: __pdoc__-overriden key '*.model_fields' does not exist in module 'MY_MODULE'
And there is no change in documentation.
Steps to Reproduce
- Install pydantic
pip install pydantic - Create module as described in the example with the
__pdoc__parameter as defined in the expected behaviour - pdoc3 --http MODULE
- BaseModel's members are shown under
Configuration,ConfAandConfB
Additional info
- pdoc3==0.11.1
- pydantic==2.6.1
- pydantic_core==2.16.2
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the issue with the Pydantic example, the pdoc mapping, and pdoc3 --http MODULE. Trace how pdoc keys are matched against documented members; done means wildcard entries suppress the selected inherited members without disabling inheritance globally.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- documentation
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100