[FEAT] Section-manifest grid page — profile-driven layout, numbering, and defect-visible stubs - #79
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Ports the grid report page onto the section-manifest system (model + resolver landed in #78). The grid page is now described by a declarative profile — an ordered list of sections, each naming the panels beneath it — and rendered by a single generic section loop, instead of a hand-maintained template where every figure had its own
{% if fig_x_b64 %}block, heading, and caption. Section numbering, the jump-nav, and the appendix lettering are all generated from the resolved profile, so the two can no longer drift.The visible payoff: regrouping a page is now data, not code.
GRID_DEFAULTgives T-S its own section;GRID_COMBINED_HYDROfolds T-S into Hydrography — a four-linereplace, no template edits. And an applicable-but-unavailable panel now renders a visible stub with a reason rather than silently vanishing, which is what surfaces metadata defects instead of hiding them.What changed
reports/_manifest.py(earlier commits on this branch):PanelGroup(panel-level data expansion, e.g. one panel per isopycnal, without inflating the section count);Panel.unavailable_if(a precondition checked before render — returns a reason string to stub with, distinct from a render that returnsNoneand gets the generic stub);resolve(..., drop_stub=).reports/_grid.py:GridContext+build_grid_context(computes latitude,ts_bounds, history and NetCDF metadata once);GRID_PANELSwrapping the unchanged_make_*figure adapters;GRID_SECTIONS,GRID_DEFAULT(8 content sections + appendix A),GRID_COMBINED_HYDRO; the Overflow per-isopycnalPanelGroup.GRID_CAPTIONS, keyed by panel id): plain text with Unicode scientific notation (σ₀, N², log₁₀, m s⁻¹, …), rendered escaped. This is deliberate: captions are slated to become user-editable via a futureconfig/report.yaml, and trusted HTML in user-editable data is an injection vector. The<code>/<strong>markup on ~6 tokens (CLI flags, "Left:"/"Right:") is dropped for now; restoring it via a safe Markdown-lite converter is tracked as a follow-up.applies_toper panel ("could this exist for this deployment?", not "did it render?"): velocity sections gate on eastward/northward velocity; hydrography and T-S on temperature plus salinity-or-conductivity; stratification and overflow on asigma*field; spectra on temperature/velocity. A section whose panels are all inapplicable is dropped and named in a new "Not applicable to this deployment" footer line.n2'sunavailable_ifreturns a reason when the mooring latitude cannot be parsed from the file attributes, so the page shows "Buoyancy frequency unavailable: mooring latitude could not be resolved" instead of silently computing N² at the equator. The temperature and rotary spectra still compute at lat=0 as before (a spectrum at lat=0 is defensible; N² is not).panel()macro (templates/_macros.html): the single placeclass="fig slot-*"is emitted, branching on panelkindso|safeapplies only to authored html/table payloads — a figure payload is always escaped into animg src, and captions are escaped. The figure collapse toggle is preserved (and now lives in the shared macro, ready to roll out to the other pages as they port)._grid_history.html,_grid_nc_variables.html,_grid_nc_scalars.html,_grid_nc_globals.html) whose markup is transcribed verbatim from the old inline template.tests/unit/test_grid_manifest.pygains render-based checks against the dune2 fixture — content numbering1..N, appendixA, no duplicate section id/title, every resolved slot is a realSLOTSkey, non-figure panels carry theirkind, and thets_bounds-independent-of-the-T-S-section coupling. The grid golden is re-baselined; only the grid page moved.Breaking changes
#hydro→#hydrography,#vel→#velocity,#ts→#ts_diagram,#strat→#stratification,#vars→#netcdf_variables, etc.). Headings are now numbered (2. Hydrography, appendixA. NetCDF variables). The jump-nav is generated from the resolved sections (one entry per section, not per figure). Figure captions are plain text (Unicode, no<code>/<strong>) and full-width figures now carry an explicitclass="fig slot-full". Migration: any external deep-link into a grid page anchor must use the new section-id anchors (an audit found no such links in this repo or the docs).generate_grid_pageno longer accepts the per-figure keyword arguments. It now builds aGridContextand resolves a profile internally; callers that invoked it withfig_*_b64=/sigma_sections=kwargs (there are none outsidereports/) must stop passing them.