Expand description
check-text: counts the player-facing text still written as string
literals in the screens’ source (CheckText::dir), instead of asked
for by key with ctx.text("screen.thing") from the game’s language
file. It fails when the count is above CheckText::max_literals.
Like check-keys it is a line-based scanner, not a parser, built on
the same lexer. A string literal counts when it holds a word (letters
outside {…} placeholders) and is
- an argument of a call that puts text on the screen (
print…,draw…,MenuItem::new,MenuItem::disabled,with_suffix,help_line), directly or inside aformat!there; or - prose, wherever it stands: it has a capital letter or a space
(
format!("Turn {n}")kept in a variable,"out of range".to_owned(), a&strconstant). Cue names, storage keys and screen names ("menu_tick") don’t; or - one lowercase word (
"acted","info") that is the value of alet, amatcharm or anif, or stands in a tuple or an array: a label. As a constant, a call’s own argument (Some("heal")), a pattern ("foot" =>) or a value’s name (("count", &n)) it is an id.
The arguments of text(…), text_with(…), MenuItem::keyed(…) and
Label::key(…) are keys and value names, never text; those of an assertion, a panic or expect are never shown,
and neither is an attribute’s (#[error("…")]). Tests, the test
harness, the snapshots’ text form and the debug screens are skipped.
A literal the rules get wrong is let through with a
// check-text: not player text comment, with the reason, on its line
or the line above its item.
It also fails on a screen that reads a name field itself: the data’s
names are English, and a screen shows one through the game’s helpers
(CheckText::words_file), which give it in the player’s language. Reading .name (not calling .name()) on anything
but self counts; a view’s own field is let through with a
// check-text: not a data name comment.
Structs§
- Hit
- One literal found.
Constants§
- MARKER
- The comment that lets the next item (or its own line) through.
- NAME_
MARKER - The comment that lets a
.nameread on its line (or the item below it) through.
Functions§
- report
- The report: the count in the folder
diragainstmax, then the literals by file. - run
- Scans the project at
rootand returns every literal found, by file then line, and every file that couldn’t be read. - run_
names - Scans the project at
rootand returns what is wrong, one line each: every.namefield read found (scan_names), by file then line, and every file that couldn’t be read. Empty when the screens read none. - scan
- Scans one Rust file (
relis its repo-relative path, for the report). - scan_
names - The
.namefield reads of one Rust file (relis its repo-relative path, for the report):.namenot followed by(, on anything butself, outside tests and lines let through byNAME_MARKER. A hit’s text is what was read (unit.name). - verdict
- What the count means against
max: an error when above it, a note when below it (the number in the project file should come down too).hintsays what to do about a literal.