Skip to content

Commit 1e55fd0

Browse files
committed
feat(catalog): the reference shows syntax, parameters and an example for the ten most used commands
1 parent 7f01e58 commit 1e55fd0

44 files changed

Lines changed: 562 additions & 20 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎README.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ The **ZPL** panel at the bottom shows the generated ZPL, **Copy** puts it on the
9595

9696
The **ZPL** panel highlights syntax and collapses long blocks of image data. Selecting a canvas object marks its ZPL lines. A notice above the code lists commands that change saved printer settings or control the printer.
9797

98-
The **command list** left of the code filters as you search. The **ZPL reference** on the right follows the cursor. Click a command to pin its details. A double-click or the right-click menu inserts the command at the cursor. A chevron folds each pane to a rail. Click the rail to bring it back.
98+
The **command list** left of the code filters as you search. The **ZPL reference** on the right follows the cursor. Click a command to pin its details. The details also show the syntax, a parameter table and an example where the reference has them. A double-click or the right-click menu inserts the command at the cursor. A chevron folds each pane to a rail. Click the rail to bring it back.
9999

100100
While you edit, the canvas shows a live preview. Canvas editing and the **Properties** tab are disabled. Page switching stays enabled. The editor refuses source that is too large or has mismatched `^XA`/`^XZ` commands, and marks the mismatches. Click a mark to insert the missing command.
101101

‎packages/core/src/catalog/catalog.test.ts‎

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ describe("zpl command catalog", () => {
2626
});
2727

2828
it("keeps every title a short plain phrase without parentheses", () => {
29-
// A name, not a sentence: the panel shows it beside the command, and the en text is what translations hash against.
29+
// A name, not a sentence: the panel shows it beside the command.
3030
const TITLE_WORD_CAP = 8;
3131
for (const c of ZPL_COMMANDS) {
3232
expect(c.title.split(/\s+/).length, c.cmd).toBeLessThanOrEqual(TITLE_WORD_CAP);
@@ -51,6 +51,33 @@ describe("zpl command catalog", () => {
5151
}
5252
});
5353

54+
it("ties each reference block to its command and keeps the parameter prose plain", () => {
55+
const PARAM_WORD_CAP = 12;
56+
for (const c of ZPL_COMMANDS) {
57+
if (!c.reference) continue;
58+
const { syntax, params, example } = c.reference;
59+
expect(syntax.startsWith(commandId(c)), c.cmd).toBe(true);
60+
expect(example, c.cmd).toContain(commandId(c));
61+
expect(syntax.slice(commandId(c).length).match(/[a-z]/g) ?? [], c.cmd).toEqual(params.map((p) => p.name));
62+
for (const p of params) {
63+
for (const text of [p.meaning, p.values, p.default ?? "x"]) {
64+
expect(text.split(/\s+/).length, `${c.cmd} ${p.name}`).toBeLessThanOrEqual(PARAM_WORD_CAP);
65+
expect(text, `${c.cmd} ${p.name}`).not.toMatch(/[();:]|[^\x20-\x7E]/);
66+
}
67+
// An enum cell lists its tokens, so a single-token default must be one of them.
68+
if (p.default && !/ to /.test(p.values) && /^[A-Z0-9]$/.test(p.default)) {
69+
expect(p.values.split(", ").map((v) => v.split(" ")[0]), `${c.cmd} ${p.name}`).toContain(p.default);
70+
}
71+
}
72+
}
73+
});
74+
75+
it("pins the commands that ship a parameter table", () => {
76+
for (const id of ["^FO", "^FD", "^A", "^A0", "^CF", "^FB", "^GB", "^BY", "^BC", "^PW", "^LL"]) {
77+
expect(catalogEntry(id)?.reference?.params.length, id).toBeGreaterThan(0);
78+
}
79+
});
80+
5481
it("never claims less on desktop than on the web, and names why a row is out of scope", () => {
5582
const rank = { no: 0, planned: 1, yes: 2 } as const;
5683
for (const c of ZPL_COMMANDS) {

0 commit comments

Comments
 (0)