docstring_parser icon indicating copy to clipboard operation
docstring_parser copied to clipboard

NumpyDoc: Default value can be specified as part of the type

Open lars-reimann opened this issue 2 years ago • 0 comments

At the moment, the NumpydocParser only looks at the description of a parameter to find its default value (relevant code).

However, the numpydoc style guide also allows specifying the default value as part of the type (source):

Optional keyword parameters have default values, which are displayed as part of the function signature. They can also be detailed in the description: [...] or as part of the type, instead of optional. If the default value would not be used as a value, optional is preferred. These are all equivalent:

copy : bool, default True
copy : bool, default=True
copy : bool, default: True

This is, for example, used by scikit-learn.

Moreover, the default value should be removed from the type_name property of DocstringParam, just like optional.

lars-reimann avatar Jul 15 '22 09:07 lars-reimann