Detect too-wide content and add overflow_action to downgrade to a warning#31
Merged
Conversation
…ning
Previously several width-overflow conditions were either silent (single
column wider than the page, group cols + any data col wider than the page,
raw user grobs wider than the content viewport) or fired a hard abort with
no escape hatch (allow_col_split = FALSE total-width). This made narrow
pages ship clipped output with no signal, and made diagnosing a too-wide
table impossible without recompiling.
Add a single user-facing knob `overflow_action = c("error", "warn")` on
export_tfl_page() (default "error", forwarded via @inheritDotParams to
export_tfl()). Three sites share the knob:
- page-level grob check in export_tfl_page() validation phase, for
non-ggplot, non-character, non-tfl_table_grob content
- tfl_table per-column / group-aware check (data col j signals when
grp_w + widths_in[j] > content_width; group col j signals when its
own width exceeds the page)
- tfl_table total-width check (existing allow_col_split = FALSE abort,
now downgrade-able)
Every overflow message ends with the literal hint pointing at
`overflow_action = "warn"` so the diagnostic-mode escape hatch is always
discoverable. Centralized in a small private .overflow_signal() helper.
The per-column check lives in compute_col_widths(), reached from
.tfl_table_to_pagelist_default() *after* .strip_sub_tfl_cols() runs, so
sub_tfl-driven group_var stripping is honored. The second cw_adj pass for
col_cont_msg layout passes validate_overflow = FALSE to avoid re-emitting
the same warning twice. The page-level grob check skips tfl_table_grob
since compute_col_widths() already validated more precisely.
Switch export_tfl()'s @param ... to @inheritDotParams export_tfl_page so
new top-level args propagate without manual doc edits.
Decision rationale captured in design/DECISIONS.md as D-39, with
companion notes in DESIGN.md, ARCHITECTURE.md, TESTING.md, and a
troubleshooting section in v04-troubleshooting.Rmd.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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
Closes #30. Adds a single user-facing knob
overflow_action = c("error", "warn")(default"error") onexport_tfl_page(), forwarded automatically toexport_tfl()via@inheritDotParams. Three width-overflow detection sites share the knob:tfl_table_grobcontent (gt/rtables/gridExtra/raw user grobs) is measured against the content viewport. Previously silent.tfl_tableper-column / group-aware check — for each data column j, signals whengrp_w + widths_in[j] > content_width_in(group columns repeat on every column-paginated page, so a data col that doesn't fit alongside the row headers is unrenderable). Previously silent.tfl_tabletotal-width check — existingallow_col_split = FALSEabort, now downgrade-able.Every overflow message ends with the literal hint
Set `overflow_action = "warn"` to convert this error to a warning and still produce output for diagnosis.Centralized in a private.overflow_signal()helper so the hint stays consistent across all three sites.Why error by default
Issue #30 explicitly asks for an error that's convertible to a warning. Silent overflow was the bug — defaulting to
"error"surfaces it;"warn"is the diagnostic escape hatch (PDF still produced, overflow visibly clipped bygrid). No"silent"third level: that would re-open the bug.sub_tfl ordering
The per-column check lives in
compute_col_widths(), reached from.tfl_table_to_pagelist_default()after.strip_sub_tfl_cols()runs. So atfl_tablewhose originalgroup_varswould overflow only because one is later stripped bysub_tflis correctly accepted. New regression test intest-sub_tfl.Rlocks the ordering in.Implementation notes
compute_col_widths()second pass (thecw_adjrecompute forcol_cont_msglayout) passesvalidate_overflow = FALSEto avoid re-emitting the same warning twice.tfl_table_grobsincecompute_col_widths()already validated more precisely.export_tfl()'s@param ...switched to@inheritDotParams export_tfl_pageso future top-level args propagate without manual doc edits. Verified withdevtools::document():overflow_actionshows up inexport_tfl.Rdautomatically.Decision log
Full rationale in
design/DECISIONS.mdas D-39, with companion entries inDESIGN.md,ARCHITECTURE.md,TESTING.md, and a troubleshooting section invignettes/v04-troubleshooting.Rmd.Test plan
devtools::document()regeneratesNAMESPACEand Rd files cleanlydevtools::test()— 991/991 pass, WARN = 1 (pre-existing ggplot2 R-version mismatch intest-draw.R:6, unrelated)devtools::check()— clean for everything I touched (R code OK, Rd OK, examples OK, tests OK). The only check failure is a pre-existinggt::as_gtable()/vctrsbug invignettes/v05-gt_tables.Rmd, confirmed identical onmain.test-layout.R(7),test-export_tfl_page.R(5),test-tfl_table.R(9),test-sub_tfl.R(1)overflow_action = "warn"hint🤖 Generated with Claude Code