Skip to content

# [FEAT] Report section-manifest model and resolver - #78

Merged
eleanorfrajka merged 1 commit into
mainfrom
rep/05-section-manifest
Aug 16, 2026
Merged

# [FEAT] Report section-manifest model and resolver #78
eleanorfrajka merged 1 commit into
mainfrom
rep/05-section-manifest

Conversation

@eleanorfrajka

Copy link
Copy Markdown
Collaborator

Summary

First step of the report section-numbering refactor: a data-driven section manifest so headings, numbers, inclusion, and jump-nav stop being hand-typed and inconsistent across report pages. This PR is infrastructure only — the model and resolver plus unit tests. No page generator is wired to it yet, so no rendered output changes and there is no golden re-baseline. The grid pilot that consumes it follows on a later branch.

What's here

oceanarray/reports/_manifest.py (package-neutral — it names no variable, page, or science — so it is vendored byte-identical to the sister repos):

  • Panel / Section / Expand / Profile dataclasses describing a page as an ordered list of sections, each naming panel ids that render figures or tables.
  • Panel.kind ("figure" / "html" / "table") — a discriminator so the eventual render macro applies |safe only to markup panels and never to a base64 figure payload, keeping the autoescape=True boundary to one branch.
  • Panel.slot accepts a str or a ctx -> str callable, so a page that derives a panel's width from its aspect ratio can compute the slot at resolution time; the resolver calls it when callable.
  • resolve(profile, ctx, panels) — one pass: splice Expand entries, drop sections whose applies_to is false (collected into a not-applicable list), resolve each kept section's panels (a None render becomes a .warn stub; a kept section whose panels all return None keeps its heading with one stub), then number the survivors — content sections 1..N, appendix sections A... Numbering is compact (over the rendered subset), so an absent section leaves no gap; identity is the section id (a stable slug), not the integer.

tests/unit/test_manifest.py — 18 tests covering flat/none numbering, appendix lettering rollover, Expand splicing, applies_to dropping to the not-applicable list, None-render stubs, the kept-but-empty case, silent panel omission, kind carry-through, and callable-slot resolution.

Why compact numbering

A gap (1, 2, 4) reads as a rendering bug. Reserved numbering does not deliver stability either — inserting one section renumbers every downstream heading on every page and breaks every golden — whereas compaction leaves a page unchanged when a section it never had is added elsewhere. Cross-page comparability comes from the profile fixing the order (hydrography always before velocity) and from stable anchors, not from the integers.

Tests

18 new unit tests, all passing; full suite green; ruff clean. No existing code touched, so nothing else moves.

@eleanorfrajka
eleanorfrajka merged commit b3b34ba into main Aug 16, 2026
5 checks passed
@eleanorfrajka
eleanorfrajka deleted the rep/05-section-manifest branch August 16, 2026 17:43
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