Document the REST API and type the McritClient (#54) - #183
Conversation
- every responder carries a docstring describing the endpoint, its parameters and its answer; the timing decorator keeps the responder's identity with functools.wraps so tooling sees it - mcrit/server/api_reference.py generates docs/api_reference.md from the Falcon route table: method, path, description and the McritClient method calling the endpoint (private helpers and partialmethod-based search methods are attributed to their public names); --check reports a stale file - tests/testApiReference.py: every route documented, the client cross-reference correct, the committed reference current - McritClient: docstrings, parameter and return annotations for all 52 public methods and the constructor; the annotations describe the default mode, raw_responses is routed through one Any-typed helper - McritConsole: guard the four places that iterated a client answer that can be None Refs danielplohmann#54
|
Live check with this branch deployed (the Note for merge order: the "every route documented" test will flag responders added by other open PRs, so those branches (#31 recompute_family_stats, #37 repair_minhashes, the jobs count and the function rename) carry a docstring for their new responder now. |
Closes #54, which asks to look at falcon-apispec and to complete the docstrings and type hints of
McritClient.falcon-apispec, assessed
falcon-apispec 0.4.0 installs fine, but it only produces something useful when every responder carries an OpenAPI YAML block in its docstring and the request/response shapes are described as marshmallow schemas. MCRIT answers plain dicts and storage entry
toDict()shapes from 54 responders, so adopting it would mean writing and maintaining schemas for all of them plus two new runtime dependencies (apispec, marshmallow) for a document that nothing else consumes. Not adopted. Instead the reference is generated from what already exists: the route table and the responder docstrings.Changes
timingdecorator now usesfunctools.wraps, so responders keep their name and docstring.mcrit/server/api_reference.pyrendersdocs/api_reference.mdfromfalcon.inspectover the real app: method, path, description, and theMcritClientmethod that calls the endpoint (private helpers and thepartialmethod-basedsearch_*methods are attributed to their public names).--checkexits 1 when the committed file is stale. README links the reference.tests/testApiReference.py: every route is documented, the client cross-reference is right (spot checks plus the exact list of the four endpoints without a client method), and the committed reference equals the generated one, so the document cannot drift.McritClient: a class docstring, and docstrings plus parameter and return annotations for the constructor and all 52 public methods, naming the endpoint each one calls. Annotations describe the default mode;raw_responses=Trueis routed through oneAny-typed helper instead of being encoded into every return type.McritConsolethat iterate a client answer which can beNoneafter a failed request; they now fall back to an empty list/dict.Full suite: 206 passed. ruff, ruff format and ty (whole tree, as CI runs it) clean.