Skip to content

Hand-written README and interactive API documentation - #96

Merged
Robbie1977 merged 5 commits into
mainfrom
api-docs-readme
Aug 30, 2026
Merged

Hand-written README and interactive API documentation#96
Robbie1977 merged 5 commits into
mainfrom
api-docs-readme

Conversation

@Robbie1977

@Robbie1977 Robbie1977 commented Aug 29, 2026

Copy link
Copy Markdown
Contributor

What changed

The README was a 2,800-line generated document because the examples CI executes and diffs lived inside it. Those examples are now a real test, src/test/test_example_queries.py: the same five canonical calls run live against the backend, the old structure assertions are preserved, and each result is compared shape-not-content against recordings in src/test/example_expected/ — content may change freely, a key or type disappearing fails, and python -m src.test.test_example_queries --record refreshes the recordings when a schema change is intentional. The whole old pipeline (the sed extraction, readme_parser.py, the generated modules, test_examples_diff.py — whose deepdiff comparison was never actually wired up, so the recordings had drifted unnoticed) is deleted, examples.yml just runs pytest, and python-test.yml ignores the file so the live load is not doubled. The README is replaced by a hand-written page: what VFBquery is, how it works, install, quick start, and where the deeper documentation lives.

The HA API now serves interactive documentation at its root, in the style of the hosted-CATMAID /apis/ pages and virtualflybrain.org: every endpoint with its parameters, pre-filled runnable examples, and live results fetched from the same origin, plus a machine-readable catalogue at /docs.json. The run_query query types and CATMAID command registry are injected from their own modules, and tests pin the docs to ALLOWED_PATHS in both directions so the page cannot drift from the server.

How to test

pytest tests/test_api_docs.py src/test/test_example_queries.py, then python -m vfbquery.ha_api and open http://localhost:8080/.

Follow-ups left

No proxy change is needed: the v3-cached nginx already passes / and /docs.json through (and does not cache the 404s the current release returns for them), so the page appears as soon as this release is deployed and is then cached like every other response. After each vfbquery upgrade the two URLs should be refreshed the same way other entries are — one whitelisted X-Force-Refresh request each, worth adding to the post-release precache list.

The README had grown into a 2,800-line generated document because the
examples CI executes and diffs lived inside it. They are a test asset,
so they now live at src/test/example_queries.md, verbatim, under a
header saying what consumes them. readme_parser and the (renamed)
update_examples.py/fix_examples.py point at the fixture; extraction
parity checked — 5 python and 4 json blocks, identical to the old
README, with the parser regenerating byte-identical test files.

The examples workflow's sed still reads README.md until the companion
.github/workflows/examples.yml change lands separately (the release PAT
cannot push workflow files); the new README's quick-start block is
runnable, so the job stays green either way.
What VFBquery is, the stores it fans out over, install, a short quick
start, the HTTP API with its interactive documentation page, and where
the deeper documentation lives. The worked examples it used to carry
are now the validated fixture in src/test/.
GET / is now a self-contained page in the style of the hosted-CATMAID
/apis/ pages and virtualflybrain.org (vfb-nova palette, light and dark):
every endpoint with its parameters, pre-filled runnable examples, and
live results fetched from the same origin. GET /docs.json is the
machine-readable catalogue; the run_query query types and the CATMAID
command registry are injected from their own modules so the page cannot
drift from the server. Tests pin the docs to ALLOWED_PATHS in both
directions and require an example on every required parameter.
Companion to the fixture move: the sed extraction and the step names now
read src/test/example_queries.md instead of README.md.
@github-actions

github-actions Bot commented Aug 30, 2026

Copy link
Copy Markdown

⚠️ 6 test(s) skipped — VFB backend was unreachable

The full suite ran, but 6 test(s) were skipped because the VFB backend (Neo4j / SOLR / Owlery) did not answer during this run.

These are not failures and not a problem with this branch — but those queries went unverified, so a green check here is an incomplete run.

To re-run: open this workflow run and click Re-run all jobs once the backend is healthy (re-running the “Run completeness” check itself does nothing — it has no job behind it).

728 passed, 6 skipped, 340 warnings in 934.31s (0:15:34)

Posted automatically. This comment is removed once a run completes with zero skips.

The fixture-markdown stopgap kept the whole old pipeline alive: a sed
extraction executing code blocks, readme_parser regenerating three
throwaway modules, and test_examples_diff — a script, not a pytest
module, whose deepdiff comparison was never actually wired up, so the
recorded JSON had drifted unnoticed (Synonyms left two term reports;
nobody was told).

src/test/test_example_queries.py replaces all of it: the same five
canonical calls run live, the old structure assertions preserved, and
each result compared shape-not-content against recordings in
src/test/example_expected/ — content may change freely, a key or type
disappearing fails. Integer dict keys survive the JSON round trip, and
'python -m src.test.test_example_queries --record' refreshes the
recordings (the successor to update_readme.py). Recordings re-recorded
from live as the new baseline.

examples.yml now just runs pytest on the file; python-test.yml ignores
it so the live load is not doubled; deepdiff/colorama leave
tests/requirements.txt; the markdown fixture, parser, generated
modules and orphaned one-off helpers are deleted.
@Robbie1977
Robbie1977 merged commit 06badad into main Aug 30, 2026
5 of 6 checks passed
Robbie1977 added a commit that referenced this pull request Aug 30, 2026
The examples workflow's move to pytest (PR #96) broke it on Python 3.8:
pytest resolves ignore::<class> filters at startup and exits 4 when the
class does not exist, and that job's older marshmallow predates
ChangedInMarshmallow4Warning. Both classes subclass DeprecationWarning,
so filter DeprecationWarning from the marshmallow module instead —
version-proof, and user-code DeprecationWarnings still show. Verified
the suite still runs with zero marshmallow warnings leaking.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant