Skip to content

Commit

Permalink
A test of doing docstring parsing in pinfo
Browse files Browse the repository at this point in the history
pinfo is the name of the magic command that gets called when you do object? in Jupyter or Ipython

This fork adds a couple experimental lines of code to parse the docstring from whatever it currently is, into the NUMPYDOC format which is a bit more readable than say ReStructuredText
  • Loading branch information
TomHodson committed May 15, 2022
1 parent 1893a8f commit afc9571
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
5 changes: 4 additions & 1 deletion IPython/core/oinspect.py
Original file line number Diff line number Diff line change
Expand Up @@ -835,7 +835,10 @@ def info(self, obj, oname="", info=None, detail_level=0) -> dict:

# Add docstring only if no source is to be shown (avoid repetitions).
if ds and not self._source_contains_docstring(out.get('source'), ds):
out['docstring'] = ds
import docstring_parser as dp
docstring = dp.parse(ds)
parsed_ds = dp.compose(docstring, style = dp.DocstringStyle.NUMPYDOC)
out['docstring'] = parsed_ds

# Constructor docstring for classes
if inspect.isclass(obj):
Expand Down
1 change: 1 addition & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ install_requires =
setuptools>=18.5
stack_data
traitlets>=5
docstring_parser

[options.extras_require]
black =
Expand Down

0 comments on commit afc9571

Please sign in to comment.