Skip to content

Commit

Permalink
fixes for getting docstrings of Procedures
Browse files Browse the repository at this point in the history
  • Loading branch information
newville committed Aug 27, 2024
1 parent 7e2050d commit 300d6c1
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions asteval/astutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -520,7 +520,13 @@ def __setattr__(self, attr, val):
self.__dict__[attr] = val

def __dir__(self):
return ['name']
return ['_getdoc', 'argnames', 'kwargs', 'name', 'vararg', 'varkws']

def _getdoc(self):
doc = self.__doc__
if isinstance(doc, ast.Constant):
doc = doc.s
return doc

def __repr__(self):
"""TODO: docstring in magic method."""
Expand All @@ -538,8 +544,9 @@ def __repr__(self):
if self.varkws is not None:
sig = f"%sig, **{self.varkws}"
sig = f"<Procedure {self.name}({sig})>"
if self.__doc__ is not None:
sig = f"{sig}\n {self.__doc__}"
doc = self._getdoc()
if doc is not None:
sig = f"{sig}\n {doc}"
return sig

def __call__(self, *args, **kwargs):
Expand Down

0 comments on commit 300d6c1

Please sign in to comment.