autodoc_pydantic
autodoc_pydantic copied to clipboard
Generate output with nonvalidation methods
For a class such as the following, the print_something
non-validation method does not get generated into the documentation. I think I've checked thoroughly in the configurationdocumentation and can't see an option that enables the standard documentation output for that method:
class AutoModuleSettings(BaseSettings):
"""Document your project settings very conveniently. Applies like wise
to pydantic models.
"""
field_without_default: str
"""Shows the *[Required]* marker in the signature."""
field_plain_with_validator: int = 100
"""Show standard field with type annotation."""
field_with_validator_and_alias: str = Field("FooBar",
alias="BarFoo",
env="BarFoo")
"""Shows corresponding validator with link/anchor."""
field_with_constraints_and_description: int = Field(
default=5,
ge=0,
le=100,
description="Shows constraints within doc string."
)
@validator("field_with_validator_and_alias", "field_plain_with_validator")
def check_max_length_ten(cls, v):
"""Show corresponding field with link/anchor.
"""
if len(v) >= 10:
raise ValueError("No more than 10 characters allowed")
return v
def print_something():
"""Show corresponding field with link/anchor.
"""
print("Hey there is something here")
I was looking further into your actual API documentation, and found that it should be implemented already ie from source.
I am looking into exactly the configuration
Make sure :members:
is specified as the default is False
Hi @daquinteroflex, by default, showing members is enabled for documenters provided by autodoc_pydantic, see docs here. Perhaps you've overwritten the global config to hide members? If not, then this might be a bug for methods that are not pydantic validators. Could you please check your setup?
Hi @mansenfranzen thanks so much! I realised actually that we were using the pydantic-v1 interface layer underneath and that led to all the weird behaviour I was seeing.
Looking forward to contribute to this project whenever we migrate to v2 properly, thanks again!