-
-
Notifications
You must be signed in to change notification settings - Fork 190
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Any way to hide Pydantic 2.0 class internals? #715
Comments
This seems to work (with a caveat re #714 ) if you add it to the superclass: def model_fields(self):
"""@private"""
pass |
My suggestion here would be to use a custom template that overrides pdoc/examples/custom-template/module.html.jinja2 Lines 21 to 32 in 8939754
|
I've found that this example syntax is not quite right. The inline comments of default_is_public state that false is given by an empty string rather than a literal boolean. {#
We can also adjust which members are documented by overriding the is_public macro.
#}
{% macro is_public(doc) %}
{% if doc.name.startswith("model_") %}
{# False #}
{% else %}
{{ default_is_public(doc) }}
{% endif %}
{% endmacro %} I'm not sure what's right, but this is what finally worked for me. |
Problem Description
My class declaration has no members declared explicitly. However, the
pdoc
text generated includes some garbage internals from the Pydantic class, while not actually documenting any of the superclass's members. I would like to just globally suppress these:model_config
model_post_init
model_fields
model_computed_fields
My class documentation index looks like this since migrating to Pydantic 2.0:
Since I'm not declaring these directly in my own code, I don't have a way to suppress them with a
@private
annotation or similar.Steps to reproduce the behavior:
Create a class from Pydantic 2.0
BaseModel
.System Information
Paste the output of "pdoc --version" here.
The text was updated successfully, but these errors were encountered: