Skip to main content

Module template

Module template 

Source
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 by Template::load (a folder) or Template::read (its files, already in memory);
  • Part: a folder of files, with the modules, targets and stage it adds, and When it applies;
  • Question: a question of the template’s own, and its answers;
  • Answers: the answers picked, by question, as answers.ron holds them;
  • compose: the template and the answers made into a Plan, the files and their bytes, with no I/O; apply writes 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.ron holds them ({ "perspective": ["top-down-grid"] }).
Applied
What apply wrote.
Fill
What fills a template’s placeholders, but the answers.
LoadError
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.ron says, with the files of its folder.

Enums§

ComposeError
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 engine must match.
FORMAT_VERSION
The version of the template format this shuyi reads.
GENERATED_STAGES
The flow’s list of stages, which shuyi new writes from the parts’ stages.
MANIFEST
The manifest of a template, in its folder.

Functions§

apply
Writes plan’s files into dir, made if missing. A folder that isn’t empty is refused unless force, with the files it would write over; with force, Applied::overwritten lists them.
built_in
The engine’s own template, templates/shuyi-default, as the shuyi binary embeds it.
compose
The game template makes for answers (each question they leave out at its default), with the engine’s modules in catalog and the placeholders filled with: 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 file file, with its placeholders filled: {{name}}, {{crate_name}}, "{{engine.<crate>}}" (with its quotes), {{engine_ref}}, {{engine.docs}} and {{answer.<question>}} (the question’s answers in answers, joined by ,). A GitHub Actions expression, ${{ … }}, passes through as it is. Any other {{ is ComposeError::Placeholder.
stages_rs
The flow’s list of stages (GENERATED_STAGES) for stages, in order, each a module stages/<id with _>.rs of the game crate that gives its Own part of the game’s data and its own reader, its first screen, its screens, its crash_record and its Tools. With none, the title is the game’s one screen and its tools are BasicTools.

Type Aliases§

Files
A template’s files, by their path from its folder (/-separated), with their bytes.