fastai / fastcore

Python supercharged for the fastai library
http://fastcore.fast.ai
Apache License 2.0
964 stars 275 forks source link

Expand docscrape to support more numpy sections #534

Open dsm-72 opened 1 year ago

dsm-72 commented 1 year ago

Please see numpy format

class NumpyDocString(Mapping):
    """Parses a numpydoc string to an abstract representation """
    sections = { 'Summary': [''], 'Extended': [], 'Parameters': [], 'Returns': [] }

    def __init__(self, docstring, config=None):
        docstring = textwrap.dedent(docstring).split('\n')
        self._doc = Reader(docstring)
        self._parsed_data = copy.deepcopy(self.sections)
        self._parse()
        self['Parameters'] = {o.name:o for o in self['Parameters']}
        if self['Returns']: self['Returns'] = self['Returns'][0]
        self['Summary'] = dedent_lines(self['Summary'], split=False)
        self['Extended'] = dedent_lines(self['Extended'], split=False)        
jph00 commented 5 months ago

Feel free to do a PR with any additions you need.

dsm-72 commented 5 months ago

@jph00 okie