Docstrings are mandatory for any function that is part of the public API, has non-trivial size, or contains non-obvious logic.
Special Sections
Use the following sections for detailed documentation. Each section heading must end with a colon, and content must be indented by 4 spaces.
Args:
- List each parameter by name.
- Do not document the expected type (use type hints instead).
- Format:
name: description. - If a description exceeds the line length, indent the next line by an additional 4 spaces.
- Include
*args and **kwargs if present. - Omit unnecessary prepositions like
The or A at the start of descriptions.
Returns: (or Yields: for generators)
- Describe the semantics of the return value.
- Do not document the expected return type.
- Do not include this section if the function returns
None. - For tuples, use:
Returns: A tuple (a, b) where a is....
Raises:
- List and describe all exceptions relevant to the interface.
- Do not document exceptions raised if the API is violated (e.g., invalid argument types).
Example
"""Fetches rows from a Smalltable.
Retrieves rows pertaining to the given keys from the Table instance
represented by table_handle. String keys will be UTF-8 encoded.
Example:
```python
rows = fetch_rows(handle, keys)
```
Args:
table_handle: Open `smalltable.Table` instance.
keys: Sequence of strings representing the key of each table row to
fetch. String keys will be UTF-8 encoded.
require_all_keys: If `True`, only rows with values set for all keys
will be returned.
Returns:
Dict mapping keys to the corresponding table row data fetched. Each row
is represented as a tuple of strings.
Raises:
IOError: An error occurred accessing the smalltable.
"""