Expand description
Templates as data (ADR-0013 §3): a folder with a template.ron and
the files of its parts, which shuyi new turns into a new game.
Template: the manifest, read and checked byTemplate::load(a folder) orTemplate::read(its files, already in memory);Part: a folder of files, with the modules, targets and stage it adds, andWhenit applies;Question: a question of the template’s own, and its answers;Answers: the answers picked, by question, asanswers.ronholds them;compose: the template and the answers made into aPlan, the files and their bytes, with no I/O;applywrites a plan.
The engine’s own template, templates/shuyi-default, is embedded in
the shuyi binary (built_in). docs/templates.md describes the
format. No template runs code: a template is data, and new writes
files.
Structs§
- Answer
- One answer to a question.
- Answers
- The answers a game picked: by question id, the ids of its answers, as
answers.ronholds them ({ "perspective": ["top-down-grid"] }). - Applied
- What
applywrote. - Fill
- What fills a template’s placeholders, but the answers.
- Load
Error - Why a template can’t be read: the file, the field and what is wrong.
- Part
- A part of a template: a folder of files, what they turn on, and when they are written.
- Plan
- What a template makes for a set of answers: the new game’s files and what its parts turn on.
- Question
- A question of a template’s own.
- Template
- A template: what
template.ronsays, with the files of its folder.
Enums§
- Compose
Error - Why a template makes no game for a set of answers.
- Pick
- How many answers a question takes.
- When
- When a part applies.
Constants§
- BUILT_
IN_ ORIGIN - Where the engine’s own template is, in the engine’s repository.
- ENGINE_
VERSION - The engine’s version, which a template’s
enginemust match. - FORMAT_
VERSION - The version of the template format this
shuyireads. - GENERATED_
STAGES - The flow’s list of stages, which
shuyi newwrites from the parts’ stages. - MANIFEST
- The manifest of a template, in its folder.
Functions§
- apply
- Writes
plan’s files intodir, made if missing. A folder that isn’t empty is refused unlessforce, with the files it would write over; withforce,Applied::overwrittenlists them. - built_
in - The engine’s own template,
templates/shuyi-default, as theshuyibinary embeds it. - compose
- The game
templatemakes foranswers(each question they leave out at its default), with the engine’s modules incatalogand the placeholders filledwith: its files and their bytes, and what its parts turn on. The same input always gives the same plan. - engine_
version - The engine’s version, parsed.
- fill
text, the filefile, with its placeholders filled:{{name}},{{crate_name}},"{{engine.<crate>}}"(with its quotes),{{engine_ref}},{{engine.docs}}and{{answer.<question>}}(the question’s answers inanswers, joined by,). A GitHub Actions expression,${{ … }}, passes through as it is. Any other{{isComposeError::Placeholder.- stages_
rs - The flow’s list of stages (
GENERATED_STAGES) forstages, in order, each a modulestages/<id with _>.rsof the game crate that gives itsOwnpart of the game’s data and itsownreader, itsfirstscreen, itsscreens, itscrash_recordand itsTools. With none, the title is the game’s one screen and its tools areBasicTools.
Type Aliases§
- Files
- A template’s files, by their path from its folder (
/-separated), with their bytes.