Skip to content

Commit cb2b362

Browse files
authored
Make the docstring a property on the DocstringNode (#35)
1 parent 5cf1403 commit cb2b362

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

src/docstringify/nodes/base.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,15 @@ def __init__(
4040
) = node
4141
self.name: str = getattr(node, 'name', self.module_name)
4242

43-
docstring = ast.get_docstring(node)
44-
self.docstring = docstring if docstring is None else docstring.strip()
45-
4643
self.get_source_segment: Callable[[ast.AST], str | None] = partial(
4744
ast.get_source_segment, source_code
4845
)
4946

47+
@property
48+
def docstring(self) -> str | None:
49+
docstring = ast.get_docstring(self.ast_node)
50+
return docstring if docstring is None else docstring.strip()
51+
5052
@property
5153
def fully_qualified_name(self) -> str:
5254
return (

0 commit comments

Comments
 (0)