ADR Suggestion Docstring Style Standardization
#66
Replies: 1 comment 6 replies
-
|
I understand the reasoning for def insert(self, index: int, value: BasedBase) -> None:
"""
Parameters
----------
index : int # redundant
The index.
value : BasedBase # redundant
The object.
"""Obviously the tooling will help with maintaining correspondence between args and docstrings but the maintenance cost of all those tools is constantly growing. |
Beta Was this translation helpful? Give feedback.

Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
This ADR proposes standardizing docstrings across all repositories in the EasyScience GitHub organization using the NumPy-style.
The decision is based on a comparison of the three main docstring styles currently relevant to our tooling and documentation workflow:
Sphinx-style,Google-style, andNumPy-style. All three styles are supported by our documentation build tools (MkDocs + mkdocstrings) and produce equivalent user-facing API reference documentation. Therefore, the main differences is in developer experience and tooling support.NumPy-style is the suggested choice for the following reasons:
Sphinx-style is less readable in source code than bothGoogle-style andNumPy-style, as it relies on inline:param:and:rtype:fields, which add visual noise.Google-style is more readable, but tooling and formatter support is weaker. In practice, tools struggle to correctly parse and reformat sections such as "Args" and "Returns". In addition, the commonly used tooldocformatterhas dependency limitations that currently block Python 3.14 support.NumPy-style remains readable in code while offering strong tooling and formatter support. The toolformat-docstringprovides nice automatic formatting for NumPy-style docstrings. In addition, the toolpydoclint, which we use for docstring linting and which supports all three styles, provides more advanced checks forNumPy-style docstrings, namely, ensuring that type hints in the docstring are consistent with default values in the function signature.For these reasons,
NumPy-style provides the best balance between readability in source code, maintainability, and tooling support, while preserving the same rendered API documentation quality in our documentation pipeline.Examples
From the
insertmethod in theCollectionBaseclass (easysciencepackage).Sphinx-style:
Google-style:
NumPy-style:
Beta Was this translation helpful? Give feedback.
All reactions