get_sections

DocstringProcessor.get_sections(s, base=None, sections=['Parameters', 'Other Parameters'])[source]

Exctract sections out of a docstring.

This method extracts the specified sections out of the given string if (and only if) the docstring follows the numpy documentation guidelines [1]. Note that the section either must appear in the param_like_sections or the text_sections attribute.

Parameters
  • s (str) – Docstring to split

  • base (str) – base to use in the sections attribute

  • sections (list of str) – sections to look for. Each section must be followed by a newline character (’n’) and a bar of ‘-’ (following the numpy (napoleon) docstring conventions).

Returns

A mapping from section identifier to section string

Return type

dict

References

1

https://github.com/numpy/numpy/blob/master/doc/HOWTO_DOCUMENT.rst.txt

See also

delete_params, keep_params, delete_types, keep_types, delete_kwargs

save_docstring

for saving an entire docstring