-
-
Notifications
You must be signed in to change notification settings - Fork 210
Open
Labels
Description
Problem Description
Currently pdoc generates docs from pydantic.Field descriptions, e.g.
class Foo(BaseModel):
x: int = Field(1, description="Important number")However, Pydantic also provides computed_field which is useful alongside functools.cached_property, such as:
class Foo(BaseModel):
@computed_field(description="Important number that takes ages to calculate")
@cached_property
def x(self) -> int:
return 1Proposal
I propose pdoc supports computed_field descriptions, since these are treated as attributes rather than methods, and it would provide consistency when documenting both Fields and computed_fields.
Alternatives
The alternative is to just use the standard documentation method, i.e.
class Foo(BaseModel):
@computed_field
@cached_property
def x(self) -> int:
"""Important number that takes ages to calculate"""
return 1Thanks for the great project !