📝 GSDFC Docstrings
khata-app adheres to the GSDFC docstring conventions (see the doc-forge GSDFC guide). The rules below are the ones enforced in this repo.
🏗 Core Rules
- Modules — start with a Markdown
# Summaryheading, then a---separator, then prose. Long modules follow withNotes:/Example:sections. - Classes — use
Attributes:for fields,Notes:for invariants,Example:when a snippet clarifies usage. - Functions/methods — imperative summary line, then
Args:/Returns:/Raises:/Yields:in that conventional order, then optionalNotes:/Example:. - Prose types must match the signature verbatim — no modernization. If the source says
str | None, the docstring and the stub saystr | None; do not writeOptional[str].
📄 Format Cheat-Sheet
A typical module docstring:
🗃 Stub Files
Every module gets a sibling .pyi stub mirroring the public surface only:
- exact signatures and return annotations,
...bodies,- no docstrings (the source carries them),
- no private helpers, no imports of implementation-only symbols.
Generate/validate conveniently with doc-forge's stub tooling, and always run py_compile + ruff on new stubs.
❌ Anti-Patterns
- Docstrings that contradict annotations (typed vs untyped mismatch).
- Forward-refs as strings in stubs (use a real
importinstead — e.g.from dagpipe import Pipeline). - Documenting private / underscored members in stubs (public surface only).