Modify docs auto-gen rules to remove duplicate parameters listing
This commit is contained in:
@@ -41,36 +41,76 @@ We use Ruff for code linting and formatting. Please ensure your code passes all
|
|||||||
|
|
||||||
We follow Google-style docstrings with these specific conventions:
|
We follow Google-style docstrings with these specific conventions:
|
||||||
|
|
||||||
- Class docstrings should fully document all parameters used in `__init__`
|
**Regular Classes:**
|
||||||
- We don't require separate docstrings for `__init__` methods when parameters are documented in the class docstring
|
|
||||||
- Property methods should have docstrings explaining their purpose and return value
|
|
||||||
|
|
||||||
Example of correctly documented class:
|
- Class docstring describes the class purpose and documents all `__init__` parameters in an `Args:` section
|
||||||
|
- No separate `__init__` docstring needed
|
||||||
|
- All public methods must have docstrings with `Args:` and `Returns:` sections as appropriate
|
||||||
|
|
||||||
|
**Dataclasses:**
|
||||||
|
|
||||||
|
- Class docstring describes the purpose and documents all fields in a `Parameters:` section
|
||||||
|
- No `__init__` docstring (auto-generated)
|
||||||
|
|
||||||
|
**Properties:**
|
||||||
|
|
||||||
|
- Must have docstrings with `Returns:` section
|
||||||
|
|
||||||
|
**Abstract Methods:**
|
||||||
|
|
||||||
|
- Must have docstrings explaining what subclasses should implement
|
||||||
|
|
||||||
|
#### Examples:
|
||||||
|
|
||||||
```python
|
```python
|
||||||
class MyClass:
|
# Regular class
|
||||||
"""Class description.
|
class MyService(BaseService):
|
||||||
|
"""Description of what the service does.
|
||||||
Additional details about the class.
|
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
param1: Description of first parameter.
|
param1: Description of param1.
|
||||||
param2: Description of second parameter.
|
param2: Description of param2. Defaults to True.
|
||||||
|
**kwargs: Additional arguments passed to parent.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self, param1, param2):
|
def __init__(self, param1: str, param2: bool = True, **kwargs):
|
||||||
# No docstring required here as parameters are documented above
|
# No docstring - parameters documented above
|
||||||
self.param1 = param1
|
super().__init__(**kwargs)
|
||||||
self.param2 = param2
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def some_property(self) -> str:
|
def sample_rate(self) -> int:
|
||||||
"""Get the formatted property value.
|
"""Get the current sample rate.
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
A string representation of the property.
|
The sample rate in Hz.
|
||||||
"""
|
"""
|
||||||
return f"Property: {self.param1}"
|
return self._sample_rate
|
||||||
|
|
||||||
|
async def process_data(self, data: str) -> bool:
|
||||||
|
"""Process the provided data.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
data: The data to process.
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
True if processing succeeded.
|
||||||
|
"""
|
||||||
|
pass
|
||||||
|
|
||||||
|
# Dataclass
|
||||||
|
@dataclass
|
||||||
|
class ConfigParams:
|
||||||
|
"""Configuration parameters for the service.
|
||||||
|
|
||||||
|
Parameters:
|
||||||
|
host: The host address.
|
||||||
|
port: The port number. Defaults to 8080.
|
||||||
|
timeout: Connection timeout in seconds.
|
||||||
|
"""
|
||||||
|
|
||||||
|
host: str
|
||||||
|
port: int = 8080
|
||||||
|
timeout: float = 30.0
|
||||||
```
|
```
|
||||||
|
|
||||||
# Contributor Covenant Code of Conduct
|
# Contributor Covenant Code of Conduct
|
||||||
|
|||||||
@@ -27,13 +27,12 @@ extensions = [
|
|||||||
# Napoleon settings
|
# Napoleon settings
|
||||||
napoleon_google_docstring = True
|
napoleon_google_docstring = True
|
||||||
napoleon_numpy_docstring = False
|
napoleon_numpy_docstring = False
|
||||||
napoleon_include_init_with_doc = True
|
napoleon_include_init_with_doc = False
|
||||||
|
|
||||||
# AutoDoc settings
|
# AutoDoc settings
|
||||||
autodoc_default_options = {
|
autodoc_default_options = {
|
||||||
"members": True,
|
"members": True,
|
||||||
"member-order": "bysource",
|
"member-order": "bysource",
|
||||||
"special-members": "__init__",
|
|
||||||
"undoc-members": True,
|
"undoc-members": True,
|
||||||
"exclude-members": "__weakref__",
|
"exclude-members": "__weakref__",
|
||||||
"no-index": True,
|
"no-index": True,
|
||||||
|
|||||||
@@ -123,8 +123,7 @@ select = [
|
|||||||
"D", # Docstring rules
|
"D", # Docstring rules
|
||||||
"I", # Import rules
|
"I", # Import rules
|
||||||
]
|
]
|
||||||
# We ignore D107 because class docstrings already document __init__ parameters
|
# Ignore requirement for __init__ docstrings
|
||||||
# and our Sphinx configuration uses napoleon_include_init_with_doc=True
|
|
||||||
ignore = ["D107"]
|
ignore = ["D107"]
|
||||||
|
|
||||||
[tool.ruff.lint.pydocstyle]
|
[tool.ruff.lint.pydocstyle]
|
||||||
|
|||||||
Reference in New Issue
Block a user