Skip to content

Commit

Permalink
fix: Fix docstring getter
Browse files Browse the repository at this point in the history
  • Loading branch information
pawamoy committed Oct 14, 2021
1 parent cae85de commit 1442eba
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/griffe/visitor.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,15 @@ def visit(
return _MainVisitor(module_name, filepath, code, extensions or Extensions()).get_module()


# ==========================================================
# docstrings
def _get_docstring(node):
if not (node.body and isinstance(node.body[0], Expr)):
if isinstance(node, Expr):
doc = node.value
elif node.body and isinstance(node.body[0], Expr):
doc = node.body[0].value
else:
return None
doc = node.body[0].value
if isinstance(doc, Constant) and isinstance(doc.value, str):
return Docstring(doc.value, doc.lineno, doc.end_lineno)
if isinstance(doc, Str):
Expand Down

0 comments on commit 1442eba

Please sign in to comment.