Skip to content

docs: promote the typed-data flow and reframe it end-to-end#7

Merged
IanMayo merged 7 commits into
mainfrom
claude/promote-typed-data-examples-avidnu
Jun 16, 2026
Merged

docs: promote the typed-data flow and reframe it end-to-end#7
IanMayo merged 7 commits into
mainfrom
claude/promote-typed-data-examples-avidnu

Conversation

@IanMayo

@IanMayo IanMayo commented Jun 15, 2026

Copy link
Copy Markdown
Contributor

Why

When reading the published docs, the page that actually shows how to write Python against the new typed data structuresconcepts/typed-vs-dicts.md — was buried: last in the Concepts nav and the 4th item in every reading order. This raises its prominence and reframes it around the realisation that if you start from a set of parameters in a structure, the whole flow should be typed data — end to end, not just at the storage boundary.

What changed

Content reframe — concepts/typed-vs-dicts.md → "Typed data, end to end"

  • Leads with the end-to-end typed flow: a structured parameter set → CalculationResult (typed dataclass) → to_model → generated models (Platform, Sector, …) → XML. The only loosely-typed moment is the raw JSON at the very edge, parsed once at a single boundary.
  • Keeps the dict-vs-typed contrast as supporting material (why typed wins), plus the construction-time TypeError, the mypy type check, and the MappingError range gate.
  • All code examples stay bound to the real APIs and remain backed by tests/unit/test_typed_vs_dict.py — no behavioural claims were invented.

Navigation promotion

  • mkdocs.yml: moved the page to second in Concepts (after Schema as the contract, which grounds its "generated from the schema" claims) and retitled it Typed data, end to end.
  • docs/index.md: the one-paragraph mental model now calls out the typed-end-to-end flow and links the page.
  • docs/tutorials/01-start-here.md: added it to the Step 4 reading order (now item 2).
  • docs/onboarding.md: bumped it up the "build the mental model" reading order (now item 2).

Verification

mkdocs build --strict passes with no warnings — nav entries and all cross-links resolve.

Note / follow-up

This PR is docs only. It advocates the typed-from-the-start pattern; the shipped acoustic seams still read the raw input as a dict (spec["baseFrequencyHz"], etc.) before producing the typed CalculationResult. If you'd like the code to also start from a typed parameter structure (so the dict never appears past the parse boundary), that's a natural next change — happy to follow up.

https://claude.ai/code/session_01Fzbw6tx6MM6Ffk4LUaFYSP


Generated by Claude Code

The "Typed objects vs dictionaries" concept is the page that shows how to
write Python against the generated data structures, yet it sat last in the
Concepts nav and was the 4th item in every reading order.

Reframe it as "Typed data, end to end" — leading with the insight that once
you are in Python the data starts from a structured set of parameters and
stays in typed objects all the way to XML (CalculationResult -> to_model ->
generated models -> XML), with the dict contrast as supporting material. All
code examples stay bound to the real APIs and remain backed by
tests/unit/test_typed_vs_dict.py.

Promote it in the navigation: move it to second in Concepts (after
schema-as-contract) and surface it from the home mental-model paragraph, the
zero-to-green tutorial reading order, and the onboarding reading order.
@github-actions

github-actions Bot commented Jun 15, 2026

Copy link
Copy Markdown
PR Preview Action v1.8.1
Preview removed because the pull request was closed.
2026-06-16 21:57 UTC

@IanMayo

IanMayo commented Jun 16, 2026

Copy link
Copy Markdown
Contributor Author

this is what the preview page looks like for me Screenshot_20260616-071839.png

claude added 6 commits June 16, 2026 19:35
Reaching the page still took too many steps (open menu -> Concepts ->
the entry). Promote it further:

- Add it as a top-level nav item (after Onboarding), so it is one tap from
  the navigation drawer rather than nested under Concepts. It remains listed
  under Concepts too, for the Diataxis grouping.
- Add a prominent tip callout near the top of the home page linking straight
  to it, so it is reachable in one click from the landing page.
The aligned trailing comments (padding the -> annotations into columns) made
the lines wide enough to clip off-screen on a phone, hiding the right-hand
side of the first sample. Reformat so every Python line stays narrow:

- Replace the aligned inline annotations in the end-to-end sample with a
  short code block plus an "expression -> type" table.
- Put TypeError / mypy / MappingError notes on their own short comment lines
  instead of long trailing comments, and wrap the dataclasses.replace call.
- Bind the example path to a short `input_path` variable so the
  calculate_from_file lines stay narrow while keeping the real filename.
Two changes from review:

1. Make the first typed-data sample persuasive without going wide. Replace the
   short block + type table with a taller, narrow, runnable drill-down: print
   statements walk the structure at increasing depth (CalculationResult ->
   ActiveSonarResult -> SectorResult, then the schema-generated Platform and
   Sector), each followed by its real output. Every printed value was captured
   by running the pipeline, and tests/unit/test_typed_vs_dict.py still passes.

2. Remove the ADRs and the "Add a decision record" how-to from the published
   site while keeping them in the repo. They are excluded from the MkDocs build
   via exclude_docs (still browsable on GitHub under docs/decisions/). In-text
   ADR citations are kept as plain text (unlinked); the few navigation pointers
   that targeted the removed section now point at docs/decisions/ in the repo.
Clarify that the example explores only typed structures, never the raw JSON.
calculate_from_file returns a typed CalculationResult (not the parsed dict),
so the walkthrough now says so explicitly and leads with the payoff: you use
attributes rather than string keys, the IDE autocompletes each step, and a
typo fails immediately. The JSON is parsed once internally and never indexed
by key. Printed outputs are unchanged and still captured from a real run.
The jump to "platform = to_model(result)" was unexplained. Expand the inline
comment so it is self-describing — to_model copies the calculation result into
the schema-generated classes, converts to the schema's types, and range-checks
each value before serialisation — and name to_model in the intro prose so the
reader meets it before the code.
…diate

Interim trim ahead of the planned refactor that removes the intermediate
CalculationResult. The headline example no longer teaches the
result -> to_model -> platform two-step; it collapses production into a single
"produce the schema's data object" line and explores only that object (a
Platform generated from the XSD) with IDE autocomplete and the schema's
Decimal types. Output values are captured from a real run. The page now tells
the defensible story: we build one data object that meets the schema.
@IanMayo IanMayo merged commit 3f13c62 into main Jun 16, 2026
3 checks passed
@IanMayo IanMayo deleted the claude/promote-typed-data-examples-avidnu branch June 16, 2026 21:57
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.

2 participants