1

Is there a solution to extract function args signature from docstring?

Firstly, the parser should look for annotations and then fall back to docstring if there are no annotations. I found a similar question that works specifically for numpy docstring. I'd like to have a general solution that works for any docstring format. If you know how to do this with jedi, please let me know.

I'm also aware of typed_ast. But, once again, it tailored to the specific format of docstrings (rather a comment line).

Example.

def my_func(arg1):
    """
    Parameters
    ----------
    arg1: str
    """
    return arg1 + "1"

The result of the parse should be smth like {'arg1': str}.

dizcza
  • 630
  • 1
  • 7
  • 19
  • I don't know how to dot his. That's why I'm asking for help. I could have asked directly in jedi chat froup (if any), but I'm still not sure that jedi is the best and only approach. – dizcza Oct 29 '19 at 15:23
  • Jedi internally can deal with theses differences, but unfortunately at the moment no such API exists. You can obviously just work with Jedi's internal API's, but these might change at pretty much any point. – Dave Halter Nov 08 '19 at 14:54

0 Answers0