Skip to content

Commit fcc91f0

Browse files
committed
booklet: say how to check the flip when nothing on the sheet can (§ 12)
The report told the user to check that page 2 comes out behind page 1. On blank grid paper — the commonest thing this tool makes — no number is printed anywhere, so that instruction is not wrong but unperformable, and § 12 counts an instruction nobody can act on as a bug. It surfaced the moment a real booklet was handed over: the advice named a comparison the paper could not show. So the tool asks first. A band field holding `{page}` is the only way a blade's page gets a number on it, and when none does, the report names the one line that makes the check possible — `footer: {center: "{page}"}` for a test run — and adds the thing that makes the whole question moot: with genuinely identical pages the flip cannot be seen and does not matter. When a band does carry the number, the report stays quiet, because the sheet already answers it. Both directions are tested, which is the point: an advice line that always appears is noise, and one that never appears is the probe that proves nothing.
1 parent 82cf520 commit fcc91f0

4 files changed

Lines changed: 84 additions & 0 deletions

File tree

‎HANDBOOK.md‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1314,6 +1314,19 @@ on the **short** edge, fold the stack in half, staple through the fold. The run
13141314
report names the flip and the one thing to check on the first sheet: page 2 must
13151315
come out behind page 1.
13161316

1317+
If your pages carry no numbers — plain grid paper, say — nothing on the sheet
1318+
shows whether the flip was right, and the run says so. Add a footer for one test
1319+
run:
1320+
1321+
```yaml
1322+
footer:
1323+
height: 10mm
1324+
center: "{page}"
1325+
```
1326+
1327+
Then blank the footer again. With genuinely identical pages the flip makes no
1328+
visible difference anyway; it matters as soon as the pages differ.
1329+
13171330
Three things to know before the first run:
13181331

13191332
- **The sheet must be landscape.** Two portrait pages sit side by side, and

‎ctrlgrid/cli.py‎

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -436,6 +436,23 @@ def _page_count(document: Document, geometry: Geometry) -> int:
436436
return document.pages.count * sheet_plan(document).per_item
437437

438438

439+
def _shows_page_numbers(document: Document) -> bool:
440+
"""Whether a printed page says which page it is (§ 8.10).
441+
442+
A band field holding `{page}` is the only way a blade's page gets a number
443+
on it — document generators write their own, and they refuse imposition
444+
anyway (decision 52). Asked so that advice about page numbers is given only
445+
where the sheet cannot already answer it.
446+
"""
447+
for band in (document.header, document.footer):
448+
if band is None:
449+
continue
450+
for field in (band.left, band.center, band.right):
451+
if isinstance(field, str) and "{page}" in field:
452+
return True
453+
return False
454+
455+
439456
def _report(document: Document, path: Path, geometry: Geometry, *, quiet: bool) -> None:
440457
if quiet:
441458
typer.echo(str(path))
@@ -464,6 +481,16 @@ def _report(document: Document, path: Path, geometry: Geometry, *, quiet: bool)
464481
"sheet, page 2 must come out behind page 1 — if it does not, "
465482
"switch the flip"
466483
)
484+
if not _shows_page_numbers(document):
485+
# § 12: an instruction nobody can act on is a bug, and the one
486+
# above is exactly that on blank grid paper — the commonest
487+
# thing this tool makes, where no number is printed anywhere.
488+
# Said only when the sheet really cannot answer it.
489+
typer.echo(
490+
' these pages carry no numbers, so nothing shows the flip — add '
491+
'`footer: {center: "{page}"}` for one test run (with identical '
492+
"pages the flip makes no difference anyway)"
493+
)
467494
else:
468495
sheets = -(-pages // nup.per_sheet) # ceil
469496
typer.echo(

‎docs/pflichtenheft-vorlagengenerator.md‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2687,6 +2687,16 @@ kurzen Kanten. Der Laufbericht nennt die Einstellung *und* den einen Handgriff,
26872687
der sie prüft (Seite 2 muss hinter Seite 1 liegen), wie § 8.2 es für die
26882688
Skalierung verlangt. Kein Schalter: siehe § 15 Punkt 6.
26892689
2690+
**Und er merkt, wenn dieser Handgriff nicht geht** (ergänzt 2026-07-26, nach dem
2691+
ersten gedruckten Heft). Auf leerem Rasterpapier — dem häufigsten, was dieses
2692+
Werkzeug erzeugt — steht überhaupt keine Zahl, „Seite 2 hinter Seite 1" ist dort
2693+
also nicht falsch, sondern *unausführbar*, und § 12 zählt eine Anweisung, nach der
2694+
niemand handeln kann, als Fehler. Trägt kein Band `{page}`, nennt der Bericht
2695+
deshalb den einen Weg, es prüfbar zu machen (`footer: {center: "{page}"}` für
2696+
einen Probelauf) — und sagt dazu, dass die Wendekante bei völlig gleichen Seiten
2697+
ohnehin gleichgültig ist. Trägt ein Band die Zahl, schweigt er: das Blatt
2698+
beantwortet die Frage dann selbst.
2699+
26902700
**Abgelehnt wird, vor Seite eins:** `--booklet` neben `--nup` (zwei Wege für
26912701
dasselbe), `--booklet` an einem Dokument-Generator (wie `--nup`, Entscheidung
26922702
52), `--nup-sheet`/`--crop-marks` ohne beides, und ein Bogen, auf den zwei Seiten

‎tests/test_booklet.py‎

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,40 @@ def test_it_names_the_padding_the_sheets_and_the_turning_edge(
198198
assert "SHORT edge" in result.output
199199
assert "page 2" in result.output
200200

201+
def report_for(self, tmp_path: Path, definition: str) -> str:
202+
from typer.testing import CliRunner
203+
204+
from ctrlgrid.cli import app
205+
206+
path = tmp_path / "d.yaml"
207+
path.write_text(definition, encoding="utf-8")
208+
result = CliRunner().invoke(
209+
app,
210+
["-d", str(path), "--pages", "8", "--booklet",
211+
"--nup-sheet", "297x210mm", "-o", str(tmp_path / "b.pdf")],
212+
)
213+
assert result.exit_code == 0, result.output
214+
return result.output
215+
216+
def test_pages_without_numbers_are_told_how_to_check_the_flip(
217+
self, tmp_path: Path
218+
) -> None:
219+
# § 12: an instruction the user cannot act on is a bug. "Page 2 must be
220+
# behind page 1" is exactly that on blank grid paper, which is the
221+
# commonest thing this tool makes — no number is printed anywhere.
222+
output = self.report_for(tmp_path, A5_LINES)
223+
assert "{page}" in output
224+
225+
def test_pages_that_carry_their_number_are_not_told_twice(
226+
self, tmp_path: Path
227+
) -> None:
228+
# The sheet already answers it, so the advice would be noise. The tool
229+
# can tell: a band field holding `{page}` is the only way a blade's page
230+
# gets a number on it.
231+
output = self.report_for(tmp_path, NUMBERED)
232+
assert "SHORT edge" in output
233+
assert "{page}" not in output
234+
201235

202236
NUMBERED = (
203237
"version: 1\n"

0 commit comments

Comments
 (0)