feature: PDF export options (root place, depth, layout, theme grouping, table of contents) #42

Merged
Gilles merged 2 commits from feature/pdf-export-options into master 2026-11-02 12:06:46 +00:00
Owner

Closes #41

What

Export options on PdfExportJob, for every target (validated version, current state, spec extract):

Field Values Default
root_place a place of the exported project (rejected together with spec) project root / spec's place
max_depth integer >= 0, relative to the root place unlimited
layout tree / by_place tree
group_by_theme boolean false

The default template now always starts with a table of contents (page numbers via target-counter, internal links, PDF bookmarks), and renders both layouts with or without theme chapters. In by_place, each place section shows its full path and links to its parent and child places; in both layouts each spec links to the spec it refines and to its refinements. Targets cut from the document (by root place, depth, or another theme chapter) render as plain text.

How

  • New pure module apps/exports/context.py assembles the context from plain place/spec/theme rows; snapshot.py now only reads rows (frozen snapshot or live state), and fixtures.py builds the preview context with the same function, so the three can't drift apart.
  • Backward compatible: root (ungrouped tree) is unchanged for existing custom templates; new keys are export, places, themes, toc, and per node anchor/depth/path/parent/child_places, per spec anchor/refines/refined_by.
  • POST /api/pdf-templates/preview/ accepts layout/group_by_theme.
  • Download filename gets a -<place-slug> / -p<depth> suffix when those options are set.
  • Migration 0004_pdfexportjob_export_options.

Tests

234 passed (23 new: context assembly on the fixture rows, snapshot context options, API validation/defaults/filenames, and a real WeasyPrint render of all 4 layout x grouping combinations checking internal links and bookmarks). pylint 10/10, autopep8 clean, bandit clean. Also checked the rendered PDFs visually (TOC with page numbers, by-place sections with links).

Frontend dialog follows in thierryade/frontend.

🤖 Generated with Claude Code

https://claude.ai/code/session_01CrK5Cbdm97HrbhC9wPMLyu

Closes #41 ## What Export options on `PdfExportJob`, for every target (validated version, current state, spec extract): | Field | Values | Default | |---|---|---| | `root_place` | a place of the exported project (rejected together with `spec`) | project root / spec's place | | `max_depth` | integer >= 0, relative to the root place | unlimited | | `layout` | `tree` / `by_place` | `tree` | | `group_by_theme` | boolean | `false` | The default template now always starts with a **table of contents** (page numbers via `target-counter`, internal links, PDF bookmarks), and renders both layouts with or without theme chapters. In `by_place`, each place section shows its full path and links to its parent and child places; in both layouts each spec links to the spec it refines and to its refinements. Targets cut from the document (by root place, depth, or another theme chapter) render as plain text. ## How - New pure module `apps/exports/context.py` assembles the context from plain place/spec/theme rows; `snapshot.py` now only reads rows (frozen snapshot or live state), and `fixtures.py` builds the preview context with the same function, so the three can't drift apart. - Backward compatible: `root` (ungrouped tree) is unchanged for existing custom templates; new keys are `export`, `places`, `themes`, `toc`, and per node `anchor`/`depth`/`path`/`parent`/`child_places`, per spec `anchor`/`refines`/`refined_by`. - `POST /api/pdf-templates/preview/` accepts `layout`/`group_by_theme`. - Download filename gets a `-<place-slug>` / `-p<depth>` suffix when those options are set. - Migration `0004_pdfexportjob_export_options`. ## Tests 234 passed (23 new: context assembly on the fixture rows, snapshot context options, API validation/defaults/filenames, and a real WeasyPrint render of all 4 layout x grouping combinations checking internal links and bookmarks). pylint 10/10, autopep8 clean, bandit clean. Also checked the rendered PDFs visually (TOC with page numbers, by-place sections with links). Frontend dialog follows in thierryade/frontend. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01CrK5Cbdm97HrbhC9wPMLyu
feature: PDF export options (root place, depth, layout, theme grouping, table of contents)
Some checks failed
ci / test (pull_request) Failing after 3m52s
ci / e2e (pull_request) Has been skipped
ci / docker (pull_request) Has been skipped
ci / deploy (pull_request) Has been skipped
0f9a8f1ad0
PdfExportJob gains root_place, max_depth, layout (tree/by_place) and
group_by_theme, applied to validated versions, the current state and
spec extracts alike. The render context is now assembled by a pure
apps.exports.context module from plain place/spec/theme rows, shared by
the snapshot, the live state and the preview fixture; it keeps the
historical `root` tree and adds `export`, `places`, `themes` and `toc`,
plus anchors and in-export-aware links between places and between a
spec and its refinements. The default template renders a table of
contents with page numbers and PDF bookmarks, both layouts and theme
chapters.

Closes #41

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01CrK5Cbdm97HrbhC9wPMLyu
Author
Owner
<!-- argus-link-bot:thierryade/backend --> 📊 [Rapports Argus pour cette PR](https://reports.stationmyr.net/thierryade/backend/pr/42)
feature: wrap an overlong line flagged by pylint
All checks were successful
ci / test (pull_request) Successful in 4m0s
ci / e2e (pull_request) Has been skipped
ci / docker (pull_request) Has been skipped
ci / deploy (pull_request) Has been skipped
3e88db3228
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01CrK5Cbdm97HrbhC9wPMLyu
Gilles scheduled this pull request to auto merge when all checks succeed 2026-11-02 12:02:37 +00:00
Gilles merged commit 15709e2546 into master 2026-11-02 12:06:46 +00:00
Gilles deleted branch feature/pdf-export-options 2026-11-02 12:06:46 +00:00
Sign in to join this conversation.
No description provided.