forked from EduCraft/curriculum-project-hub
docs(adr): cph 的 nested-manifest / batch-export 改号 0036/0037
上游 0029/0030 与本地 filelib 侧同号 ADR 相撞,cph 两份改到本地空闲号段, 代码锚点引用一并跟随。
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
// DEFAULT STUDENT TEMPLATE (framework default; ADR-0011, outline shape ADR-0029).
|
||||
// DEFAULT STUDENT TEMPLATE (framework default; ADR-0011, outline shape ADR-0036).
|
||||
//
|
||||
// This is a *real, editable* file that lives in an engineering file at
|
||||
// `exports/student.typ`. The framework compiles it AS THE MAIN FILE with the
|
||||
@@ -16,7 +16,7 @@
|
||||
// PACKAGE, not the engineering root. A `/<part.path>/<field>.typ` written HERE
|
||||
// (this template lives under `--root`) resolves against `--root`. So the
|
||||
// template loads content and hands cph-render an already-assembled `outline`
|
||||
// array (elements interleaved with section headings, ADR-0029).
|
||||
// array (elements interleaved with section headings, ADR-0036).
|
||||
//
|
||||
// OPEN CONTRACT POINT — optional-content presence. typst has no "does this file
|
||||
// exist" primitive (a missing `include` is a hard compile error). So the
|
||||
@@ -43,7 +43,7 @@
|
||||
// resolved against --root) and read scalar fields from <path>/element.toml.
|
||||
// `part-fields` (from cph-render) is the single source of truth for
|
||||
// kind->fields.
|
||||
// - a "section" entry (ADR-0029): pass its title/depth straight through — no
|
||||
// - a "section" entry (ADR-0036): pass its title/depth straight through — no
|
||||
// content to load, it is a heading.
|
||||
#let outline = raw-outline.map(raw => {
|
||||
if raw.at("type", default: "element") == "section" {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// DEFAULT TEACHER TEMPLATE (framework default; ADR-0011, outline shape ADR-0029).
|
||||
// DEFAULT TEACHER TEMPLATE (framework default; ADR-0011, outline shape ADR-0036).
|
||||
//
|
||||
// Lives in an engineering file at `exports/teacher.typ`. Compiled AS MAIN with
|
||||
// the manifest injected:
|
||||
@@ -21,7 +21,7 @@
|
||||
#let raw-outline = manifest.at("outline", default: ())
|
||||
|
||||
// Assemble each outline entry: an "element" entry includes its content fields
|
||||
// and reads scalars from element.toml; a "section" entry (ADR-0029) passes
|
||||
// and reads scalars from element.toml; a "section" entry (ADR-0036) passes
|
||||
// title/depth straight through as a heading, no content to load.
|
||||
#let outline = raw-outline.map(raw => {
|
||||
if raw.at("type", default: "element") == "section" {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
# Throwaway smoke engineering file for the cph-render template round
|
||||
# (ADR-0011, outline shape ADR-0029). Exercises all 4 kinds + a section heading
|
||||
# (ADR-0011, outline shape ADR-0036). Exercises all 4 kinds + a section heading
|
||||
# + nested headings (per-level numbering) + an example with a `source` scalar
|
||||
# and one without + a lemma with proof and one without.
|
||||
#
|
||||
@@ -27,7 +27,7 @@ kind = "segment"
|
||||
path = "segments/向量数量积"
|
||||
fields = ["textbook"]
|
||||
|
||||
# A section heading (ADR-0029): opens depth-1, groups the two examples that
|
||||
# A section heading (ADR-0036): opens depth-1, groups the two examples that
|
||||
# follow. Contributes no element to the sequence.
|
||||
[[outline]]
|
||||
type = "section"
|
||||
|
||||
+8
-8
@@ -2,7 +2,7 @@
|
||||
//
|
||||
// PUBLIC ENTRY: `render-lesson(info, target, outline, heading-numbering)`.
|
||||
//
|
||||
// MODEL (ADR-0011, outline shape per ADR-0029). A build compiles a *template
|
||||
// MODEL (ADR-0011, outline shape per ADR-0036). A build compiles a *template
|
||||
// file* (e.g. `exports/student.typ`) as the typst main, with the manifest
|
||||
// injected via `--input manifest=<path>`. The template reads the manifest,
|
||||
// loads each **element** entry's content, and calls `render-lesson` here.
|
||||
@@ -25,7 +25,7 @@
|
||||
// - an ELEMENT: `entry-type: "element"`, `kind` plus that kind's
|
||||
// content/scalar fields. Content field VALUES are already-evaluated typst
|
||||
// content (the template produced them via `include`).
|
||||
// - a SECTION (ADR-0029): `entry-type: "section"`, `title` (heading text),
|
||||
// - a SECTION (ADR-0036): `entry-type: "section"`, `title` (heading text),
|
||||
// `depth` (1-based heading level). Contributes no element; it is a
|
||||
// heading at its depth-first-open position in the outline.
|
||||
//
|
||||
@@ -109,14 +109,14 @@
|
||||
}
|
||||
}
|
||||
|
||||
/// Render one section-heading outline entry (ADR-0029): `entry.title` at
|
||||
/// Render one section-heading outline entry (ADR-0036): `entry.title` at
|
||||
/// `entry.depth` (1-based heading level).
|
||||
#let _render-section(entry) = {
|
||||
heading(level: entry.at("depth", default: 1))[#entry.at("title", default: "")]
|
||||
}
|
||||
|
||||
/// Render one outline entry: an element dispatches on `kind` via
|
||||
/// [`_render-part`]; a section (ADR-0029) renders its heading and contributes
|
||||
/// [`_render-part`]; a section (ADR-0036) renders its heading and contributes
|
||||
/// no element.
|
||||
#let _render-entry(entry, flags) = {
|
||||
if entry.at("entry-type", default: "element") == "section" {
|
||||
@@ -132,7 +132,7 @@
|
||||
/// Templates typically pass `manifest.at("info", default: (:))`.
|
||||
/// - `target`: string. MVP: "student" | "teacher". Unknown => conservative.
|
||||
/// Each template hardcodes its own target (student.typ => "student").
|
||||
/// - `outline`: ordered array of outline-entry dicts (ADR-0029), ALREADY
|
||||
/// - `outline`: ordered array of outline-entry dicts (ADR-0036), ALREADY
|
||||
/// ASSEMBLED by the template (element content fields included,
|
||||
/// scalars read; section entries carry `title`/`depth`). See file
|
||||
/// header for the entry shapes.
|
||||
@@ -183,7 +183,7 @@
|
||||
entry
|
||||
}
|
||||
|
||||
/// THE BUNDLE ENTRY POINT (ADR-0030) — called by a bundle target's template
|
||||
/// THE BUNDLE ENTRY POINT (ADR-0037) — called by a bundle target's template
|
||||
/// (`exports/<target>.typ` under a `bundle.toml` root) to assemble several
|
||||
/// already-loaded lessons into one combined document.
|
||||
///
|
||||
@@ -195,14 +195,14 @@
|
||||
/// bundle (ADR-0011 presentation-in-template stance; same knob as
|
||||
/// `render-lesson`).
|
||||
/// - `reset-counters`: whether `example`/`lemma` auto-counters reset at each
|
||||
/// lesson boundary. **Default `true`** (ADR-0030's recommended default: a
|
||||
/// lesson boundary. **Default `true`** (ADR-0037's recommended default: a
|
||||
/// lesson's internal "例题3" means that lesson's 例题3, so cross-lesson
|
||||
/// continuation would silently break author references). Pass `false` for
|
||||
/// a genuine "全书连续编号" 合集.
|
||||
///
|
||||
/// Each lesson's own outline is rendered under a depth-1 heading naming that
|
||||
/// lesson (`lesson.info.title`); the lesson's own section headings shift one
|
||||
/// level deeper (ADR-0029's per-lesson depths are relative to that lesson, so
|
||||
/// level deeper (ADR-0036's per-lesson depths are relative to that lesson, so
|
||||
/// nesting under the lesson-title heading keeps the outline↔structure
|
||||
/// correspondence meaningful in the combined document). `@label`/`@ref`
|
||||
/// cross-references stay global across the whole compiled document (typst's
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# Default export templates (ADR-0011, outline shape ADR-0029)
|
||||
# Default export templates (ADR-0011, outline shape ADR-0036)
|
||||
|
||||
`student.typ` / `teacher.typ` are the **framework default templates**. In a real
|
||||
engineering file they live at `exports/student.typ` / `exports/teacher.typ`; the
|
||||
@@ -9,7 +9,7 @@ offline smoke test below.
|
||||
Each template:
|
||||
|
||||
1. reads the injected manifest: `toml(sys.inputs.manifest)`;
|
||||
2. loops `manifest.outline` (ADR-0029's depth-first rendering order — elements
|
||||
2. loops `manifest.outline` (ADR-0036's depth-first rendering order — elements
|
||||
interleaved with section headings at their DFS-open position). For an
|
||||
`type = "element"` entry: `include`-ing each content field via a computed
|
||||
**root-relative absolute** path `/<part.path>/<field>.typ`, and reading
|
||||
@@ -46,7 +46,7 @@ content and hands `render-lesson` an already-assembled `outline` array;
|
||||
disk. *(OPEN: the exact manifest shape for this is for the Rust/manifest
|
||||
contract to pin.)*
|
||||
- **Sections carry no content fields.** A `type = "section"` outline entry
|
||||
(ADR-0029) has only `kind`/`title`/`depth`/`path`; the template passes it
|
||||
(ADR-0036) has only `kind`/`title`/`depth`/`path`; the template passes it
|
||||
through untouched — no `include`, no `element.toml` read.
|
||||
|
||||
## Offline smoke test
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// DEFAULT BUNDLE TEMPLATE (ADR-0030, outline shape ADR-0029).
|
||||
// DEFAULT BUNDLE TEMPLATE (ADR-0037, outline shape ADR-0036).
|
||||
//
|
||||
// Lives in a bundle at `<bundle-root>/exports/<target>.typ`, e.g.
|
||||
// `exports/merged.typ`. Compiled AS MAIN with the augmented BUNDLE manifest
|
||||
@@ -66,7 +66,7 @@
|
||||
))
|
||||
|
||||
// Presentation: shared per-level heading numbering across the whole bundle,
|
||||
// and the ADR-0030 recommended default of resetting auto-counters at each
|
||||
// and the ADR-0037 recommended default of resetting auto-counters at each
|
||||
// lesson boundary (override `reset-counters: false` for continuous numbering).
|
||||
#render-bundle(
|
||||
info: info,
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// DEFAULT STUDENT TEMPLATE (framework default; ADR-0011, outline shape ADR-0029).
|
||||
// DEFAULT STUDENT TEMPLATE (framework default; ADR-0011, outline shape ADR-0036).
|
||||
//
|
||||
// This is a *real, editable* file that lives in an engineering file at
|
||||
// `exports/student.typ`. The framework compiles it AS THE MAIN FILE with the
|
||||
@@ -16,7 +16,7 @@
|
||||
// PACKAGE, not the engineering root. A `/<part.path>/<field>.typ` written HERE
|
||||
// (this template lives under `--root`) resolves against `--root`. So the
|
||||
// template loads content and hands cph-render an already-assembled `outline`
|
||||
// array (elements interleaved with section headings, ADR-0029).
|
||||
// array (elements interleaved with section headings, ADR-0036).
|
||||
//
|
||||
// OPEN CONTRACT POINT — optional-content presence. typst has no "does this file
|
||||
// exist" primitive (a missing `include` is a hard compile error). So the
|
||||
@@ -43,7 +43,7 @@
|
||||
// resolved against --root) and read scalar fields from <path>/element.toml.
|
||||
// `part-fields` (from cph-render) is the single source of truth for
|
||||
// kind->fields.
|
||||
// - a "section" entry (ADR-0029): pass its title/depth straight through — no
|
||||
// - a "section" entry (ADR-0036): pass its title/depth straight through — no
|
||||
// content to load, it is a heading.
|
||||
#let outline = raw-outline.map(raw => {
|
||||
if raw.at("type", default: "element") == "section" {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// DEFAULT TEACHER TEMPLATE (framework default; ADR-0011, outline shape ADR-0029).
|
||||
// DEFAULT TEACHER TEMPLATE (framework default; ADR-0011, outline shape ADR-0036).
|
||||
//
|
||||
// Lives in an engineering file at `exports/teacher.typ`. Compiled AS MAIN with
|
||||
// the manifest injected:
|
||||
@@ -21,7 +21,7 @@
|
||||
#let raw-outline = manifest.at("outline", default: ())
|
||||
|
||||
// Assemble each outline entry: an "element" entry includes its content fields
|
||||
// and reads scalars from element.toml; a "section" entry (ADR-0029) passes
|
||||
// and reads scalars from element.toml; a "section" entry (ADR-0036) passes
|
||||
// title/depth straight through as a heading, no content to load.
|
||||
#let outline = raw-outline.map(raw => {
|
||||
if raw.at("type", default: "element") == "section" {
|
||||
|
||||
Reference in New Issue
Block a user