Files
curriculum-project-hub/crates/cph-typst/tests/fixtures/render-stub/lib.typ
T
sjfhsjfh bd1699a4c0 feat(checker): align cph-typst + cph-check to export-as-build model (WU-D)
Integrate the WU-B (structured targets) and WU-C (numbly, config) changes.

cph-typst:
- World resolves any @preview/* package from the in-repo vendored dir
  (<render_dir>/vendor/typst-packages/preview/<name>/<version>/), fully offline —
  no typst-kit download. Proven: build_pdf_with_real_render compiles the real
  render package (which imports @preview/numbly:0.1.0) through the embedded
  engine, PDF out.
- Driver threads each target's presentation config: looks up the TargetConfig by
  name, emits `config: (numbering: (heading: (...)))` (escaped) when an override
  is present, else `config: (:)` (render default).
- target_precheck guards artifact/target: FileTree → blocking diagnostic (MVP is
  single-file, deferred per ADR-0009); --target not declared → blocking
  diagnostic; no-targets lesson still defaults through.

cph-check:
- Migrated to Lesson.targets: Vec<TargetConfig> (target_names() / target.name at
  the 6 sites). Pipeline unchanged (already matches ADR-0010 phases). Documented
  that !has_errors() implements Spec.Courseware.Legal (no error-level diagnostic).

Workspace: fmt + clippy -D warnings + all tests green.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-22 08:47:13 +08:00

33 lines
1.1 KiB
Typst

// Minimal stand-in for the real `cph-render` package, used so cph-typst's
// World / compile / PDF path can be proven independently of WU-2.
//
// It exercises the same call shape as the real entry: it reads `info`, walks
// `parts` IN ORDER, and renders each part's content fields by `kind`. Content
// values are already-evaluated content (the driver produced them via include).
//
// `config` mirrors the real entry's ADR-0009 presentation-config parameter; the
// stub accepts it (the driver always passes `config:`) but ignores it.
#let display(info: (:), target: "student", parts: (), config: (:)) = {
set document(title: info.at("title", default: ""))
[= #info.at("title", default: "")]
[target: #target]
for p in parts {
let kind = p.at("kind", default: none)
[== #kind]
if kind == "segment" {
p.textbook
} else if kind == "lemma" {
p.stmt
let proof = p.at("proof", default: none)
if proof != none { proof }
} else if kind == "example" {
p.problem
p.solution
let src = p.at("source", default: none)
if src != none [来源:#src]
} else if kind == "sop" {
p.sop
}
}
}