Documentation style guide
How documentation is written and enforced in the sasvi SDK. Two layers:
docstrings (in code, the source of truth for the API reference) and
prose docs (the narrative under website/docs/).
Docstrings
Every public symbol in src/sasvi carries a Google-style docstring. This is
gate-enforced by ruff D (Google convention) and by tools.check_docstrings
(the authoritative AST checker, because ruff's D rules silently skip some
large modules). tests/, tools/, scripts/, and the sasvi.types
re-export shims are exempt.
What every symbol needs
| Symbol | Requirement |
|---|---|
| Module | One-line (or short) summary of the module's role. |
| Class | One sentence on what the object represents. |
| Function / method | Summary line; an Args: entry for every parameter, *args and **kwargs included; Returns: for anything non-trivial. |
@property | Describe the value, not the type. Write """The alert's Data Hub id.""", never """The id.""". |
__init__ | Args: documenting each parameter. |
| Magic methods | A brief real sentence ("""Return a debug representation."""). |
@overload stub | No docstring (ruff D418 forbids it); document the implementation. |
tests/test_handwritten_contracts.py enforces the Args: rule on every public
handwritten function and method in src/sasvi. Each parameter needs its own
name: entry in the Args: section; a name that only appears in the prose does
not count, and there is no list of exceptions. When a **kwargs is passed on to
another call, its entry names that call. The CLI is exempt because Typer
commands document their options in help= strings.
Raises: is required
The SDK's contract is that failures surface as typed sasvi.errors subclasses.
Every public method that raises must document it, naming the concrete type:
def create(self, *, body: Any) -> DataStoreRecord | None:
"""Create a data store from a raw payload.
Args:
body: Raw or generated data-store create payload.
Returns:
The created data-store record, or ``None`` when the server returns no body.
Raises:
AdminOperationError: If the server rejects the payload.
"""
Only document raises the method actually produces. Trace the raise sites, and
never fabricate a Raises: for an error that cannot occur.
Style rules
- Imperative mood for the summary line ("Return...", "Create...", not "Returns...").
- Line length 100 (ruff-enforced); wrap long docstrings.
- No
F-<n>fix numbers in a public docstring. The API reference is generated from docstrings, and a reader cannot follow the number anywhere. Say what the code does in plain words and put the history in a# F-<n>:comment directly below the docstring.tools.check_docstringsfails the gate on a public module, class, callable or attribute docstring that contains one. Private names are exempt. - Match the surrounding file's idiom; don't introduce a second style in one file.
Prose docs (website/docs/)
The narrative layer. The information architecture:
| Kind | Location | Purpose |
|---|---|---|
| Quickstart / concepts | website/docs/, website/docs/concepts/ | Orientation and mental models. |
| Guides | website/docs/Guides/ | Task-oriented, per-domain how-tos with runnable examples. |
| Recipes | website/docs/Guides/recipes/ | Short, single-task snippets. |
| API reference | website/docs/api/generated/ | Generated from docstrings. Never hand-edited. |
Rules
- Do not hand-write API pages. The reference under
website/docs/api/generated/is produced byscripts/build_docs.sh. Write narrative in a guide and link to the generated page. - Every public module goes in
pydoc-markdown.yml. Packages belong underpackages:, single-file modules undermodules:. Listing a package undermodules:renders its__init__.pyalone, so every re-exported class comes out as a bare heading with no signature and no members. That is how the whole feature layer came to be published as a list of names. - A private module that defines a public export also goes under
modules:.RequestPreviewis exported fromsasvi.searchbut defined insasvi._preview, so without an entry it renders nowhere.tests/test_docs_coverage.py::test_every_public_export_appears_in_the_referencefails when a name in an__all__has no heading. - Use current API in every example. The async convention is the
_asyncsuffix (never the olda-prefix); the admin namespace isclient.admin(neverclient.config). Verify method names against the source. - Link to generated reference pages at
../api/generated/sasvi/<pkg>/, not to hand-written API pages. - Docusaurus builds with
onBrokenLinks: "throw"andonBrokenAnchors: "throw", so a link to a missing page or a missing heading fails CI. Keep both valid. - Every new page goes in
website/sidebars.ts. Docusaurus routes a page whether or not the sidebar names it, so an unlisted page is built, indexed and in the sitemap while no navigation reaches it. Add it there, or to theexcludelist inwebsite/docusaurus.config.tsif it is internal.tests/test_docs_coverage.py::test_every_docs_page_is_reachable_or_excludedfails otherwise. - No em dashes in prose. End the sentence, or use a comma for a subordinate
clause. In a list item, write
**Term.** Detail. - Headings are sentence case.
## Working with alerts, not## Working With Alerts. - Nothing checks those last two automatically; they are enforced in review.
Writing a new guide
Mirror an existing strong guide (website/docs/Guides/documents.md,
website/docs/Guides/alerts.md): a short intro, task-oriented sections with fenced
python examples, a note on sync-only vs async surfaces where relevant, an
error-behavior subsection, and a "Go further" footer linking to the generated
reference and the related guides. Recipes and concept pages end the same way. Add the new guide to the "How-to Guides" category in
website/sidebars.ts.
Python snippets are checked
tests/test_docs_snippets.py parses every ```python block under website/docs/ and
holds it to the real package: the block must parse, from sasvi... imports must
resolve, and SVIClient(...) / SVIConfig(...) keywords must match the actual
signature. A backticked name ending in Error, Report, Record, Handle,
Service, Manager, Policy, Provider or Config must exist in the SDK, so
prose cannot invent a type either.
Two escapes:
- A block whose first line is
# Beforeshows an API that is gone. It is skipped, because it is meant not to work any more. SVIClient(...)with a literal ellipsis is read as a placeholder, not a call.
A block can also be run, not only parsed. Put <!-- executed: <group> --> on the line
before the fence and tests/test_docs_executed_snippets.py executes every fence in
that group in order, in one namespace, against an httpx2.MockTransport; the recipe
Mock the SDK in pytest uses the
mock-transport group. Opt an example in when its output is part of the claim the
page makes.