Python Documentation Skill
Add RST-format docstrings to public entities in the specified Python files.
Rules
- Public only: Document classes, methods, functions, and properties that do NOT start with
_. Skip private/internal entities entirely.
- RST format: Use reStructuredText docstring syntax (
:param:, :returns:, :raises:, :type:, etc.).
- Concise: One short sentence for the summary. No filler, no restating the obvious from the signature. If the method name is self-explanatory (e.g.,
clear, append), the summary can be very brief.
- Document exceptions: Always include
:raises ExceptionType: for every exception the method can raise (including those from called helpers like _map_index). Check the implementation, not just the signature.
- Do not document:
__init__ that just raises TypeError (already has a docstring by convention), or dunder methods whose behavior is obvious from the protocol they implement (e.g., __len__, __iter__, __repr__, __contains__) — unless they have non-obvious behavior or raise specific exceptions worth noting.
- Preserve existing docstrings: If a method already has a docstring, update it to match these rules only if it is incomplete (e.g., missing
:raises:). Do not rewrite correct docstrings.
- No type annotations in docstrings: Types are already in the signature; do not duplicate them with
:type: or :rtype: fields.
Format Template
The opening """ goes on its own line, followed by the summary on the next line:
def method(self, param: Type) -> ReturnType:
"""
Short summary of what this does.
:param param: what this parameter means
:returns: what is returned
:raises ValueError: when param is invalid
"""
For multi-line descriptions (rare — prefer single line):
def method(self) -> ReturnType:
"""
Short summary.
Additional context only if the summary is insufficient.
:returns: description
:raises KeyError: when key is not found
"""
Procedure
- Read the file(s) passed as arguments (ARGUMENTS section below).
- Identify all public entities without docstrings or with incomplete docstrings.
- For each, trace through the implementation to find all possible exceptions.
- Add or update docstrings using the Edit tool. Do not rewrite the file.
- Do NOT add docstrings to private methods (starting with
_), internal descriptor classes, or non-public helpers.
ARGUMENTS: $ARGUMENTS
1---2name: pydoc3description: Add RST docstrings to public Python methods/classes. Use when asked to document Python code.4---56# Python Documentation Skill78Add RST-format docstrings to public entities in the specified Python files.910## Rules11121. **Public only**: Document classes, methods, functions, and properties that do NOT start with `_`. Skip private/internal entities entirely.132. **RST format**: Use reStructuredText docstring syntax (`:param:`, `:returns:`, `:raises:`, `:type:`, etc.).143. **Concise**: One short sentence for the summary. No filler, no restating the obvious from the signature. If the method name is self-explanatory (e.g., `clear`, `append`), the summary can be very brief.154. **Document exceptions**: Always include `:raises ExceptionType:` for every exception the method can raise (including those from called helpers like `_map_index`). Check the implementation, not just the signature.165. **Do not document**: `__init__` that just raises TypeError (already has a docstring by convention), or dunder methods whose behavior is obvious from the protocol they implement (e.g., `__len__`, `__iter__`, `__repr__`, `__contains__`) — unless they have non-obvious behavior or raise specific exceptions worth noting.176. **Preserve existing docstrings**: If a method already has a docstring, update it to match these rules only if it is incomplete (e.g., missing `:raises:`). Do not rewrite correct docstrings.187. **No type annotations in docstrings**: Types are already in the signature; do not duplicate them with `:type:` or `:rtype:` fields.1920## Format Template2122The opening `"""` goes on its own line, followed by the summary on the next line:2324```python25def method(self, param: Type) -> ReturnType:26 """27 Short summary of what this does.2829 :param param: what this parameter means30 :returns: what is returned31 :raises ValueError: when param is invalid32 """33```3435For multi-line descriptions (rare — prefer single line):3637```python38def method(self) -> ReturnType:39 """40 Short summary.4142 Additional context only if the summary is insufficient.4344 :returns: description45 :raises KeyError: when key is not found46 """47```4849## Procedure50511. Read the file(s) passed as arguments (ARGUMENTS section below).522. Identify all public entities without docstrings or with incomplete docstrings.533. For each, trace through the implementation to find all possible exceptions.544. Add or update docstrings using the Edit tool. Do not rewrite the file.555. Do NOT add docstrings to private methods (starting with `_`), internal descriptor classes, or non-public helpers.5657ARGUMENTS: $ARGUMENTS