From 9310caf37b70dc4a658907d94f719ff28701b055 Mon Sep 17 00:00:00 2001 From: Dandaedre Date: Fri, 21 Aug 2026 04:25:59 +0200 Subject: [PATCH] Modular compilation and build.yaml --- Readme.md | 27 +++++++++++++++ chapters/origines.typ | 22 ++++++++++-- chapters/schools/schools.typ | 58 +++++++++++++++----------------- data/config/balance_report.yaml | 5 +-- data/config/build.yaml | 39 +++++++++++++++++++++ data/src/db | 2 +- data/src/glossaries/classes.yml | 2 +- main.typ | 34 +++++++++---------- setup/analysis/report_config.typ | 1 - setup/build_config.typ | 31 ++++++++++++++--- setup/setup.typ | 3 ++ setup/theme/variables.typ | 11 +++--- 12 files changed, 170 insertions(+), 65 deletions(-) create mode 100644 data/config/build.yaml diff --git a/Readme.md b/Readme.md index 361147b..8246701 100644 --- a/Readme.md +++ b/Readme.md @@ -13,6 +13,33 @@ typst compile main.typ main.pdf typst compile balance_report.typ balance_report.pdf ``` +All shared build settings live in `data/config/build.yaml`. To build the +player-facing edition with the predefined chapter exclusions, use one override: + +```sh +typst compile --input preset=player-handbook main.typ player-handbook.pdf +``` + +The preset can be combined with independent origin and school selectors: + +```sh +typst compile \ + --input preset=player-handbook \ + --input origin=dragon_1 \ + --input school=artilleur \ + main.typ dragon-1-artilleur-handbook.pdf +``` + +`origin` and `school` default to an empty string, which includes every entry. +Origins identify individual YAML variants such as `dragon_1`, `dragon_2`, or +`guivre_1`, rather than an entire origin family. +They can also be set persistently under `build` in the YAML. Invalid identifiers +fail compilation with an explicit error instead of producing an incomplete book. + +Edit `build.disabled_chapters` for permanent project-specific exclusions, or +add another entry under `presets` for a reusable edition. Chapter IDs are the +names passed to `chapter-enabled` in `main.typ`. + For live rebuilding while editing, use: ```sh diff --git a/chapters/origines.typ b/chapters/origines.typ index 489f5e0..5c496ca 100644 --- a/chapters/origines.typ +++ b/chapters/origines.typ @@ -1,5 +1,5 @@ #import "/setup/models/origin.typ": creature-title, render-creature -#import "/setup/setup.typ": theme +#import "/setup/setup.typ": theme, build-config, origin-enabled //----- DOCUMENT ----- #let origins = ( @@ -18,7 +18,25 @@ ("Yénuï", "yenui", 2), ) +#let origin-ids = origins.fold((), (ids, origin) => { + let slug = origin.at(1) + let count = origin.at(2) + ids + range(1, count + 1).map(i => slug + "_" + str(i)) +}) +#assert( + build-config.origin == "" or build-config.origin in origin-ids, + message: "Unknown origin selector: " + build-config.origin, +) + #for (name, slug, count) in origins { + let selected-variants = range(1, count + 1).filter(i => ( + origin-enabled(slug + "_" + str(i)) + )) + + if selected-variants.len() == 0 { + continue + } + show heading: it => { align(center)[#text( size: creature-title.size, @@ -35,7 +53,7 @@ } heading(level: 3)[#name] - for i in range(1, count + 1) { + for i in selected-variants { render-creature( yaml("/data/src/origines/" + slug + "_" + str(i) + ".yaml"), ) diff --git a/chapters/schools/schools.typ b/chapters/schools/schools.typ index 6a6c6c6..822583a 100644 --- a/chapters/schools/schools.typ +++ b/chapters/schools/schools.typ @@ -1,4 +1,21 @@ -#import "/setup/setup.typ": ddlvl, ravhelp +#import "/setup/setup.typ": ddlvl, ravhelp, build-config, school-enabled + +#let school-ids = ( + "heavy-weapon-specialist", + "einerjar", + "franc-tireur", + "protecteur", + "lancier", + "maitre-lames", + "artilleur", + "mage-bestial", + "guerrier-mage", + "sangremage", +) +#assert( + build-config.school == "" or build-config.school in school-ids, + message: "Unknown school selector: " + build-config.school, +) = Écoles de combat Les écoles de combat représentent un savoir ancestral, concentré en une seule discipline et affiné à travers les âges. Bien que toutes les techniques aient étés conçues pour être utilisées conjointement, de nombreux chasseurs décident de mixer les diverses écoles pour former un style qui leur est propre. @@ -82,32 +99,13 @@ Il est à noter que si une technique donne un effet sans préciser une limite de #pagebreak() -#include "heavy_weapon_specialist.typ" -#pagebreak() - -#include "einerjar.typ" -#pagebreak() - -#include "franc_tireur.typ" -#pagebreak() - -#include "protecteur.typ" -#pagebreak() - -#include "lancier.typ" -#pagebreak() - -#include "maitre_lames.typ" -#pagebreak() - -#include "artilleur.typ" -#pagebreak() - -#include "mage_bestial.typ" -#pagebreak() - -#include "guerrier_mage.typ" -#pagebreak() - -#include "sangremage.typ" -#pagebreak() +#if school-enabled("heavy-weapon-specialist") { include "heavy_weapon_specialist.typ"; pagebreak() } +#if school-enabled("einerjar") { include "einerjar.typ"; pagebreak() } +#if school-enabled("franc-tireur") { include "franc_tireur.typ"; pagebreak() } +#if school-enabled("protecteur") { include "protecteur.typ"; pagebreak() } +#if school-enabled("lancier") { include "lancier.typ"; pagebreak() } +#if school-enabled("maitre-lames") { include "maitre_lames.typ"; pagebreak() } +#if school-enabled("artilleur") { include "artilleur.typ"; pagebreak() } +#if school-enabled("mage-bestial") { include "mage_bestial.typ"; pagebreak() } +#if school-enabled("guerrier-mage") { include "guerrier_mage.typ"; pagebreak() } +#if school-enabled("sangremage") { include "sangremage.typ"; pagebreak() } diff --git a/data/config/balance_report.yaml b/data/config/balance_report.yaml index 52de15f..5c6c8c5 100644 --- a/data/config/balance_report.yaml +++ b/data/config/balance_report.yaml @@ -1,9 +1,6 @@ -# Central configuration for the standalone balancing report. +# Configuration specific to the standalone balancing report. # Ranges use inclusive `min` and `max` values. -build: - max_tier_exclusive: 5 - weapons: natural_precision: 7 die_sides: 10 diff --git a/data/config/build.yaml b/data/config/build.yaml new file mode 100644 index 0000000..8b326d8 --- /dev/null +++ b/data/config/build.yaml @@ -0,0 +1,39 @@ +# Central configuration shared by every Ravenous build target. + +document: + name: Ravenous + title: Ravenous + copyright: Dandaedre + date: "2021" + color_scheme: warm + +build: + # Data tiers are included while tier < max_tier_exclusive. + max_tier_exclusive: 5 + warnings: true + + # The default can be overridden without editing this file: + # typst compile --input preset=player-handbook main.typ player-handbook.pdf + preset: full + + # Optional content selectors. Prefer command-line inputs for one-off books: + # --input origin=dragon_1 --input school=artilleur + # An empty value includes every origin or school. + origin: "" + school: "" + + # Always excluded, in addition to the exclusions from the selected preset. + disabled_chapters: [] + +# Chapter IDs are defined in main.typ. Presets only list what they hide, so new +# chapters remain visible by default and a custom exclusion stays easy to audit. +presets: + full: + disabled_chapters: [] + + player-handbook: + disabled_chapters: + - acknowledgements + - geography + - game-master-help + - bestiary diff --git a/data/src/db b/data/src/db index 4553fb3..de4fbf7 160000 --- a/data/src/db +++ b/data/src/db @@ -1 +1 @@ -Subproject commit 4553fb36cb63e70965ff398817031f8646d63bae +Subproject commit de4fbf7832d468ada99c7739005de49fa591cb26 diff --git a/data/src/glossaries/classes.yml b/data/src/glossaries/classes.yml index d660974..0c5827b 100644 --- a/data/src/glossaries/classes.yml +++ b/data/src/glossaries/classes.yml @@ -38,7 +38,7 @@ icon: true short: typst: 'box(height: 0.7em, baseline: 0.5pt, inset: 0pt, image("/images/icons/spider.svg"))' - description: '_Coût alternatif_ : Sang Bestial . Reprensente le sang d''un ennemi ; obtenu avec violence.' + description: '_Coût alternatif_ : Sang Bestial. Reprensente le sang d''un ennemi ; obtenu avec violence.' group: "Écoles : Sangremage" - key: cl_sgS diff --git a/main.typ b/main.typ index 6505070..c7d1228 100644 --- a/main.typ +++ b/main.typ @@ -1,31 +1,31 @@ //----- Load the main document configuration ----- -#import "/setup/setup.typ": config_main, disable-warnings +#import "/setup/setup.typ": config_main, disable-warnings, build-config, chapter-enabled #show: config_main -//----- Enable this to suppress project warnings ----- -// #disable-warnings() +//----- Apply the warning policy from data/config/build.yaml ----- +#if not build-config.warnings { disable-warnings() } //----- Front matter ----- -#include "chapters/title.typ" -#include "chapters/acknowledgements.typ" +#if chapter-enabled("title") { include "chapters/title.typ" } +#if chapter-enabled("acknowledgements") { include "chapters/acknowledgements.typ" } //----- Core rulebook chapters ----- -#include "chapters/introduction/presentation.typ" -#include "chapters/introduction/geography.typ" -#include "chapters/hunters_and_calamities.typ" +#if chapter-enabled("presentation") { include "chapters/introduction/presentation.typ" } +#if chapter-enabled("geography") { include "chapters/introduction/geography.typ" } +#if chapter-enabled("hunters-and-calamities") { include "chapters/hunters_and_calamities.typ" } //----- Additional chapters planned for later integration ----- -#include "chapters/races.typ" -#include "chapters/rules/rules.typ" +#if chapter-enabled("races") { include "chapters/races.typ" } +#if chapter-enabled("rules") { include "chapters/rules/rules.typ" } // #include "chapters/character_sheet.typ" -#include "chapters/creation.typ" -#include "chapters/experience_gains.typ" -#include "chapters/game_master_help.typ" -#include "chapters/bestiaire.typ" +#if chapter-enabled("creation") { include "chapters/creation.typ" } +#if chapter-enabled("experience-gains") { include "chapters/experience_gains.typ" } +#if chapter-enabled("game-master-help") { include "chapters/game_master_help.typ" } +#if chapter-enabled("bestiary") { include "chapters/bestiaire.typ" } -#include "chapters/origines.typ" -#include "chapters/schools/schools.typ" -#include "chapters/artisanat.typ" +#if chapter-enabled("origins") { include "chapters/origines.typ" } +#if chapter-enabled("schools") { include "chapters/schools/schools.typ" } +#if chapter-enabled("crafting") { include "chapters/artisanat.typ" } // Tests // #include "symbol_test.typ" diff --git a/setup/analysis/report_config.typ b/setup/analysis/report_config.typ index 9719c56..cbbf321 100644 --- a/setup/analysis/report_config.typ +++ b/setup/analysis/report_config.typ @@ -1,6 +1,5 @@ // Typed accessors and validation for the balance-report YAML configuration. #let report-config = yaml("/data/config/balance_report.yaml") -#let build-settings = report-config.build #let weapon-settings = report-config.weapons #let sensitivity-settings = weapon-settings.sensitivity #let armor-settings = weapon-settings.armor diff --git a/setup/build_config.typ b/setup/build_config.typ index f4cd547..e3e0193 100644 --- a/setup/build_config.typ +++ b/setup/build_config.typ @@ -1,12 +1,35 @@ -// Shared build-time data limits, sourced from the report configuration. -// Tiers are included when `tier < max-tier-exclusive`. -#import "analysis/report_config.typ": build-settings +// Typed accessors and validation for the whole-project build configuration. +#let config = yaml("/data/config/build.yaml") +#let document-config = config.document +#let raw-build-config = config.build +#let presets = config.presets + +// `--input preset=...` is the lightweight entry point for alternate editions. +#let selected-preset = sys.inputs.at("preset", default: raw-build-config.preset) +#assert(selected-preset in presets, message: "Unknown build preset: " + selected-preset) +#let selected-origin = sys.inputs.at("origin", default: raw-build-config.origin) +#let selected-school = sys.inputs.at("school", default: raw-build-config.school) + +#let preset-disabled-chapters = presets.at(selected-preset).disabled_chapters +#let disabled-chapters = ( + raw-build-config.disabled_chapters + preset-disabled-chapters +).dedup() #let build-config = ( - max-tier-exclusive: build-settings.max_tier_exclusive, + max-tier-exclusive: raw-build-config.max_tier_exclusive, + warnings: raw-build-config.warnings, + preset: selected-preset, + origin: selected-origin, + school: selected-school, + disabled-chapters: disabled-chapters, ) #let max-tier-exclusive = build-config.max-tier-exclusive #let tier-is-enabled(tier) = tier == none or tier < max-tier-exclusive #let craft-tiers = range(0, max-tier-exclusive) #let school-tiers = range(1, max-tier-exclusive) +#let chapter-enabled(id) = id not in disabled-chapters +#let origin-enabled(id) = selected-origin == "" or selected-origin == id +#let school-enabled(id) = selected-school == "" or selected-school == id + +#assert(max-tier-exclusive > 1, message: "build.max_tier_exclusive must be greater than 1") diff --git a/setup/setup.typ b/setup/setup.typ index d4207f2..712e3c4 100644 --- a/setup/setup.typ +++ b/setup/setup.typ @@ -18,6 +18,9 @@ #let build_info = build_info #let build-config = build_config.build-config #let max-tier-exclusive = build_config.max-tier-exclusive +#let chapter-enabled = build_config.chapter-enabled +#let origin-enabled = build_config.origin-enabled +#let school-enabled = build_config.school-enabled #let gls = model.gls #let gls-description = model.gls-description #let macros = macros diff --git a/setup/theme/variables.typ b/setup/theme/variables.typ index 28f1b28..41ac7e7 100644 --- a/setup/theme/variables.typ +++ b/setup/theme/variables.typ @@ -1,17 +1,18 @@ //----- Theme constructors ----- #import "themes.typ" as th +#import "../build_config.typ": document-config // make-theme, make-theme-variable, fantasy-label,fantasy-rule,fantasy-section //----- Project metadata ----- #let ravenous = ( - name: "Ravenous", - title: "Ravenous", - copyright: "Dandaedre", - date: "2021", + name: document-config.name, + title: document-config.title, + copyright: document-config.copyright, + date: document-config.date, ) //----- Select the active color scheme ----- -#let color_scheme = "warm" +#let color_scheme = document-config.color_scheme //----- Build the active theme and its variable form ----- #let theme = th.make-theme(theme-name: color_scheme)