Skip to content

Commit

Permalink
show source code of properties
Browse files Browse the repository at this point in the history
  • Loading branch information
tmeyier committed Dec 22, 2023
1 parent 28d394e commit ad1e04b
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
15 changes: 15 additions & 0 deletions bla.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
from functools import cached_property


class A:
"""An example class to be documented by pdoc."""

@property
def la(self):
"""Print la."""
print("la")

@cached_property
def li(self):
"""Print li."""
print("li")
4 changes: 4 additions & 0 deletions pdoc/doc.py
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,7 @@ def members(self) -> dict[str, Doc]:
annotation=doc_f.signature.return_annotation,
default_value=empty,
taken_from=taken_from,
source=doc_f.source,
)
elif inspect.isroutine(obj):
doc = Function(self.modulename, qualname, obj, taken_from) # type: ignore
Expand Down Expand Up @@ -1050,6 +1051,7 @@ def __init__(
docstring: str,
annotation: type | empty = empty,
default_value: Any | empty = empty,
source: str | empty = empty,
):
"""
Construct a variable doc object.
Expand All @@ -1064,6 +1066,8 @@ def __init__(
self.docstring = inspect.cleandoc(docstring)
self.annotation = annotation
self.default_value = default_value
if source is not empty:
self.source = source

@cache
@_include_fullname_in_traceback
Expand Down

0 comments on commit ad1e04b

Please sign in to comment.