cytoflow.utility.docstring

Utility functions for operating on docstrings. They all assume that docstrings are formatted using the NumPy standard style:

https://numpydoc.readthedocs.io/en/latest/format.html

expand_class_attributes – take entries in the Attributes section of a class’s ancestors’ docstrings and adds them to the Attributes section of this class’s docstring.

expand_method_parameters – expand the Parameters section of a method’s docstring with Parameters from the overridden methods in the class’s ancestors.

find_section – find a named section in a numpy-formatted docstring.

get_class_attributes – get the entries from the Attributes section of a class’s docstring

get_method_parameters – get the entries from the Parameters section of a method’s docstring

cytoflow.utility.docstring.expand_class_attributes(cls)[source]

Takes entries in the Attributes section of a class’s ancestors’ docstrings and adds them to the Attributes section of this class’s docstring.

All the classes must have docstrings formatted with the using the numpy docstring style.

Parameters

cls (class) – The class whose docstring is to be expanded.

cytoflow.utility.docstring.expand_method_parameters(cls, method)[source]

Expand the Parameters section of a method’s docstring with Parameters from the overridden methods in the class’s ancestors.

All the methods must have docstrings formatted with the using the numpy docstring style.

Parameters
  • cls (class) – The class whose ancestors are to be parsed for more parameters.

  • method (callable) – The method whose docstring is to be expanded.

cytoflow.utility.docstring.find_section(section, lines)[source]

Find a named section in a numpy-formatted docstring.

Parameters
  • section (string) – The name of the section to find

  • lines (array of string) – The docstring, split into lines

Returns

The indices of the first and last lines of the section.

Return type

int, int

cytoflow.utility.docstring.get_class_attributes(cls)[source]

Gets the entries from the Attributes section of a class’s numpy-formated docstring.

Parameters

cls (class) – The class whose docstring to parse

Returns

  • name : the attribute’s name

  • type : the attribute’s type

  • body : the attribute’s description body

Return type

array of (name, type, body)

cytoflow.utility.docstring.get_method_parameters(method)[source]

Gets the entries from the Parameters section of a method’s numpy-formatted docstring.

Parameters

method (callable) – The method whose docstring to parse.

Returns

  • name : the attribute’s name

  • type : the attribute’s type

  • body : the attribute’s description body

Return type

array of (name, type, body)