Repository navigation
Book parts: section: parts dividers with Roman labels - #26
Merged
Merged
Conversation
Extends BookSection with 'parts' and wires the structural-divider
behaviour through fromTOC:
- `section: parts` ParentEntry emits a LocalProjectFolder at part level
(-1) with a pre-formatted title ("Part I — Theory")
- Children of a parts subtree default to `section: chapters` (the dp2
convention) and bump to chapter level (0)
- Project-level `numbering.parts.{format,label}` override the Roman /
"Part %s" defaults
- TOC auto-detects parts and starts at level=-1 so chapter pages land
at heading_1, not heading_2
- Existing TOCs without parts keep their level=1 start (regression
test included)
Chapter counter continues across part boundaries (Ch 5 → Part II →
Ch 6) — verified end-to-end in quantecon/demo-book-parts. This is the
LaTeX `book` default and matches dp2's numbering.
Co-Authored-By: Claude Opus 4.7 <[email protected]>
There was a problem hiding this comment.
Pull request overview
This PR extends the book-numbering / book-section TOC feature to support section: parts, enabling “Part I — …” divider folders (Roman-numbered by default) that wrap chapter groups while keeping chapter numbering continuous across part boundaries (LaTeX book-style).
Changes:
- Added
'parts'toBookSectionand TOC validation choices inmyst-toc. - Updated
projectFromTOC/ TOC-to-pages conversion to emit structural part divider folders and default part children tosection: chapters. - Added a dedicated unit test suite covering part emission, formatting overrides, section inheritance, and regression behavior.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/myst-toc/tests/examples.spec.ts | Extends section parsing tests to include parts. |
| packages/myst-toc/src/types.ts | Adds parts to the BookSection union and documents semantics. |
| packages/myst-toc/src/toc.ts | Updates validation choices to accept section: parts. |
| packages/myst-cli/src/project/fromTOC.ts | Emits part divider folders, threads a part counter, defaults part children to chapters, and auto-adjusts base level when parts are present. |
| packages/myst-cli/src/project/fromTOC.parts.spec.ts | Adds unit tests for section: parts behavior and configuration overrides. |
| .changeset/book-parts.md | Declares patch releases for myst-toc and myst-cli describing the new feature. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Three review findings, all fixed: 1. types.ts: "Roman-numeralled" → "Roman-numbered" (typo in doc comment) 2. fromTOC.ts hasPartsSubtree(): restrict detection to non-file ParentEntry so it matches the emission predicate exactly. A FileEntry/URLEntry tagged with section: parts is malformed (a divider can't be a file) and gets downgraded to section: chapters without emitting a folder — previously this still shifted the top- level start level to -1, producing off-by-one levels for the rest of the TOC. Added a regression test asserting the rogue file stays at level 1 and no parts folder is emitted. 3. fromTOC.parts.spec.ts basename(): use path.basename from node:path instead of splitting on '/' so the test passes on Windows where memfs/resolveExtension use backslash separators. Co-Authored-By: Claude Opus 4.7 <[email protected]>
mmcky
added a commit
that referenced
this pull request
May 15, 2026
…ERSION.yml Two tracker files now record orthogonal facts, cross-referenced by squash-commit SHA: - VERSION.yml answers "what's in our main?" — diagnostic identifier for the integration build. Drops its `upstream:` block (was an always-`pending` placeholder). - UPSTREAM-PRS.yml answers "how do we plan to ship those squash commits upstream?" — bundles related squashes into logical upstream PR candidates (so a feature spanning multiple commits, or two features that form one upstream story, can be tracked as a single unit), records dependency order for cherry-pick, tracks status. Seeds UPSTREAM-PRS.yml with three candidates: myst-to-ipynb (#16), book-mode-with-section-scope (#22 + #28, bundled — they form one coherent upstream story since #28 builds on #22's auto-prefix hooks), and book-parts (#26, planned). Adds the missing book-proof-scope entry to VERSION.yml's merged_features. README updated to partition the two files' roles and reference UPSTREAM-PRS.yml from the cherry-pick workflow. Co-Authored-By: Claude Opus 4.7 <[email protected]>
4 tasks done
mmcky
added a commit
that referenced
this pull request
May 15, 2026
* docs(quantecon): cherry-pick upstream model, batched tags
Replace the "preserve feature branch, push as upstream PR" workflow
with "delete feature branch after merge; cherry-pick main squash
commits onto a fresh branch off upstream/main when upstreaming."
Why:
- Feature branches that depend on prior QuantEcon-only features were
awkward to branch from upstream/main (had to carry the dependency
inline or wait for it to upstream first).
- Branching from main lets dependencies just work; the squash commit
on main is already the upstream-ready artifact.
- Cherry-picking at upstream-PR time lets us bundle related squashes
into a coherent story ("book mode + section scope") when that's the
right unit for upstream review, or split them.
Tagging also moves from per-PR to batched: a `qe-vN` tag is cut at a
checkpoint covering multiple features, not on each merge.
Updates the diagram, branching-model table, "Develop a new feature",
"Opening an upstream PR" (now cherry-pick-driven), "When upstream
merges", "Resolving merge conflicts between features", and the
VERSION.yml comment block. Adds an `upstream/<topic>` branch type to
the branching model.
Co-Authored-By: Claude Opus 4.7 <[email protected]>
* docs(quantecon): add UPSTREAM-PRS.yml; split upstream tracking from VERSION.yml
Two tracker files now record orthogonal facts, cross-referenced by
squash-commit SHA:
- VERSION.yml answers "what's in our main?" — diagnostic identifier
for the integration build. Drops its `upstream:` block (was an
always-`pending` placeholder).
- UPSTREAM-PRS.yml answers "how do we plan to ship those squash
commits upstream?" — bundles related squashes into logical upstream
PR candidates (so a feature spanning multiple commits, or two
features that form one upstream story, can be tracked as a single
unit), records dependency order for cherry-pick, tracks status.
Seeds UPSTREAM-PRS.yml with three candidates: myst-to-ipynb (#16),
book-mode-with-section-scope (#22 + #28, bundled — they form one
coherent upstream story since #28 builds on #22's auto-prefix hooks),
and book-parts (#26, planned). Adds the missing book-proof-scope
entry to VERSION.yml's merged_features.
README updated to partition the two files' roles and reference
UPSTREAM-PRS.yml from the cherry-pick workflow.
Co-Authored-By: Claude Opus 4.7 <[email protected]>
* docs(quantecon): address Copilot feedback on PR #30
- VERSION.yml header: remove double-accounting in the tag-cut steps.
Per-PR landing already appends each feature to merged_features with
tag: null; the tag-cut workflow just *sets* the tag field on those
pre-existing entries and bumps qe_version. The old wording said
"Append each newly-included feature" which contradicted the
per-PR-landing description below it.
- README "About this folder": the allow-list now contains README.md,
VERSION.yml, UPSTREAM-PRS.yml, and .gitignore itself — the original
text only mentioned the first two.
Co-Authored-By: Claude Opus 4.7 <[email protected]>
---------
Co-authored-by: Claude Opus 4.7 <[email protected]>
Smoke test confirming PR #26 and PR #28 operate at independent layers: parts are a TOC artefact (fromTOC.ts); scope is an in-page counter (enumerate.ts). The two features have no file overlap and no shared state, so they should compose naturally. A future change that accidentally couples them (e.g. by reading scope from inside fromTOC) would silently regress book-dp2-style projects — pin the expected output now so any such regression is caught at the TOC layer. Co-Authored-By: Claude Opus 4.7 <[email protected]>
mmcky
added a commit
that referenced
this pull request
May 15, 2026
Bumps qe_version to qe-v4 and adds the book-parts entry (id: 4) to merged_features with its squash sha 5edc040. The git tag qe-v4 will be cut on the squash commit of this PR. Also moves the book-parts entry in UPSTREAM-PRS.yml from `status: planned` → `pending` and fills in its `commits` list with the now-known squash sha. Also syncs the VERSION.yml header comment to the new tag-cut workflow (metadata PR first, then tag) so it matches README §"Maintaining VERSION.yml". Previous comment text still described the legacy "tag-then-update" order and the "batched not per-PR" convention. Co-Authored-By: Claude Opus 4.7 <[email protected]>
mmcky
added a commit
that referenced
this pull request
May 15, 2026
Bumps qe_version to qe-v4 and adds the book-parts entry (id: 4) to merged_features with its squash sha 5edc040. The git tag qe-v4 will be cut on the squash commit of this PR. Also moves the book-parts entry in UPSTREAM-PRS.yml from `status: planned` → `pending` and fills in its `commits` list with the now-known squash sha. Also syncs the VERSION.yml header comment to the new tag-cut workflow (metadata PR first, then tag) so it matches README §"Maintaining VERSION.yml". Previous comment text still described the legacy "tag-then-update" order and the "batched not per-PR" convention. Co-authored-by: Claude Opus 4.7 <[email protected]>
This was referenced May 21, 2026
This was referenced Jun 3, 2026
mmcky
added a commit
that referenced
this pull request
Nov 4, 2026
…11-04 Conflicts resolved: - packages/myst-toc/src/types.ts, packages/myst-toc/src/toc.ts, packages/myst-cli/src/project/types.ts: keep both sides. Upstream's new `searchable` entry key (jupyter-book#2976) sits next to the fork's book-mode `section` key (#22, #26); upstream's lines come first so the fork's stay a pure addition after them. - packages/mystmd/tests/endToEnd.spec.ts, packages/mystmd/tests/exports.yml: take upstream's `args` + APP_PATH invocation (jupyter-book#3106), keep the fork's per-case `retry` loop and the two retried Jupyter execution cases (#62). - packages/mystmd/package.json: take upstream's removal of `npm link` (jupyter-book#3106), keep the fork's `copy:qe-version` steps (#42). - packages/myst-cli/package.json: take upstream's 1.12.0 release ranges, keep the fork's myst-to-ipynb dependency. - packages/myst-to-jats/package.json: take upstream's release ranges, keep the fork's katex ^0.16.21 bump (#81). - bun.lock: take upstream's refreshed workspace ranges, keep the fork's myst-to-ipynb and katex ^0.16.21 lines. Co-Authored-By: Claude Opus 5.5 <[email protected]>
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
Adds
section: partsto the book-numbering feature. Asection: partsParentEntry emits a Roman-numbered divider folder ("Part I — Theory") and wraps a group of chapters. The chapter counter continues across part boundaries — Ch 5 → Part II → Ch 6 — matching the LaTeXbookdefault and unblocking dp2-style books.This extends
qe-v2(book-numbering) to cover the part-divider structure flagged as the one remaining gap for dp2.Behaviour
section: partsParentEntryLocalProjectFolderat level -1, title"Part I — <title>",section: 'parts'section: chapters(overridable per child); land at level 0numbering.parts.formatarabic→Part 1 …)numbering.parts.label"Part %s"template (e.g.,"Book %s"→Book I …)numbering.bookunsetleveldefaults to 1 unchanged (regression check)Implementation
myst-toc— extendBookSectionwith'parts'; add toBOOK_SECTION_CHOICESfor validation.myst-cli/fromTOC.ts:formatPartTitle()builds"Part {Roman} — {title}"usingformatCounterfrommyst-transforms.pagesFromEntriesthreads a mutablePartCounterthrough recursion; sectionpartsincrements and emits a structural folder; sectionpartschildren inheritsection: 'chapters'by default.hasPartsSubtree()auto-detects parts in the TOC and startsprojectFromTOCatlevel=-1so chapters land at heading_1 (not heading_2).Verified output (from the local demo)
Figures auto-prefix correctly:
fig-intro=1.1,fig-theory=2.1,fig-applications=3.1.Tests
packages/myst-cli/src/project/fromTOC.parts.spec.tscovering folder emission, counter-across-parts, format/label overrides, book-mode gating, child-section default, parts+appendices coexistence, and the no-parts regression.'parts'.resolveTemplate/resolveArticleswere already failing onmainbefore this PR.Scope intentionally deferred
reset_on_part: true(Quarto-style chapter reset on part entry) — schema accepts it; not consumed.[](#part-1)) — would needid:on ParentEntry; follow-up if needed.Test plan
cd quantecon/demo-book-parts && myst build --siteproduces the table aboveqe-v3, bumpquantecon/VERSION.yml🤖 Generated with Claude Code