Should I Document Parameters For Similar Function Signatures?
Solution 1:
The best, and easiest, way to do this is using Python Sphinx docstring sections from the sphinx.ext.napoleon
extension.
Only arguments unique to the helper function need to be explicitly documented, you can remit with a cross-reference to the function/method defining the shared parameters. The Google style guide for Python advises the same reasoning for overloading inherited methods from a base class :
A method that overrides a method from a base class may have a simple docstring sending the reader to its overridden method’s docstring, such as """See base class.""". The rationale is that there is no need to repeat in many places documentation that is already present in the base method’s docstring. However, if the overriding method’s behavior is substantially different from the overridden method, or details need to be provided (e.g., documenting additional side effects), a docstring with at least those differences is required on the overriding method.
Args:
List each parameter by name. A description should follow the name, and be separated by a colon and a space.
The following example:
defcore(param0, param1=3, param2=8):
"""Core function with thorough documentation.
Parameters
----------
param0 : ndarray
Description.
param1 : int
Long description.
param2 : int
Long description.
Returns
-------
param_out : ndarray
Long description
"""passdefhelper(param3, param1=3, param2=8):
"""Remaining
Parameters
----------
param3 : int
Description.
Other Parameters
A short string remitting reader to :py:func:`core` function.
See Also
A short string remitting reader to :py:func:`core` function.
Note
A short string remitting reader to :py:func:`core` function.
"""pass
Would give this result:
Post a Comment for "Should I Document Parameters For Similar Function Signatures?"