From fc7a57a9119f567699b6a6d031d2c30639be8293 Mon Sep 17 00:00:00 2001 From: SirEdvin Date: Wed, 22 Jul 2026 19:11:43 +0000 Subject: [PATCH] docs: render isometric peripheral blocks --- .../documentation/generate-docs.mjs | 24 +++++++++++++------ .../documentation/generate-docs.test.mjs | 5 +++- .../documentation/guides/advanced-items.md | 2 +- .../documentation/guides/basic-digitizer.md | 2 +- .../documentation/index.md | 4 ++-- 5 files changed, 25 insertions(+), 12 deletions(-) diff --git a/projects/typed-peripheral-digitalitems/documentation/generate-docs.mjs b/projects/typed-peripheral-digitalitems/documentation/generate-docs.mjs index 8cbcc97..455963a 100644 --- a/projects/typed-peripheral-digitalitems/documentation/generate-docs.mjs +++ b/projects/typed-peripheral-digitalitems/documentation/generate-docs.mjs @@ -96,6 +96,17 @@ function escapeCell(value) { return value.replaceAll("|", "\\|").replaceAll("\n", " "); } +async function renderBlock(textureRoot, block) { + const texture = async (face) => (await readFile(resolve(textureRoot, `${block}_${face}.png`))).toString("base64"); + const [side, front, top] = await Promise.all([texture("side"), texture("front_on"), texture("top")]); + return ` + + + + +\n`; +} + export function renderPeripheral(peripheral, revision = "") { const lines = [ "## Peripheral methods", @@ -104,11 +115,9 @@ export function renderPeripheral(peripheral, revision = "") { "", ]; for (const method of peripheral.methods) { - lines.push(`### \`${method.name}\``, ""); - if (method.inheritedFrom) lines.push(`*Inherited from \`${method.inheritedFrom}\`.*`, ""); - for (const [index, signature] of method.signatures.entries()) { - if (method.signatures.length > 1) lines.push(`#### Overload ${index + 1}`, ""); - lines.push("```typescript", signature.signature, "```", ""); + for (const signature of method.signatures) { + lines.push(`### \`${signature.signature}\``, ""); + if (method.inheritedFrom) lines.push(`*Inherited from \`${method.inheritedFrom}\`.*`, ""); if (signature.summary) lines.push(signature.summary, ""); if (signature.parameters.length) { lines.push("| Parameter | Type | Description |", "| --- | --- | --- |"); @@ -149,8 +158,9 @@ export async function buildDocs(args = []) { }); await mkdir(resolve(buildRoot, "assets/peripherals"), { recursive: true }); const textureRoot = resolve(projectRoot, "../core/src/main/resources/assets/digitalitems/textures/block"); - await cp(resolve(textureRoot, "digitizer_front_on.png"), resolve(buildRoot, "assets/peripherals/digitizer.png")); - await cp(resolve(textureRoot, "advanced_digitizer_front_on.png"), resolve(buildRoot, "assets/peripherals/advanced_digitizer.png")); + for (const block of ["digitizer", "advanced_digitizer"]) { + await writeFile(resolve(buildRoot, "assets/peripherals", `${block}.svg`), await renderBlock(textureRoot, block)); + } await mkdir(resolve(buildRoot, "assets/stylesheets"), { recursive: true }); await mkdir(resolve(buildRoot, "assets/javascripts"), { recursive: true }); await cp(resolve(projectRoot, "documentation/theme/digitalitems.css"), resolve(buildRoot, "assets/stylesheets/digitalitems.css")); diff --git a/projects/typed-peripheral-digitalitems/documentation/generate-docs.test.mjs b/projects/typed-peripheral-digitalitems/documentation/generate-docs.test.mjs index 6c111e6..17c66db 100644 --- a/projects/typed-peripheral-digitalitems/documentation/generate-docs.test.mjs +++ b/projects/typed-peripheral-digitalitems/documentation/generate-docs.test.mjs @@ -19,7 +19,10 @@ test("extracts direct, inherited, and generic digitizer methods", () => { assert.equal(peripheral.methods.length, 15); assert.match(peripheral.methods.find(({ name }) => name === "getConfiguration").signatures[0].signature, /DigitizerConfiguration/); assert.equal(peripheral.methods.find(({ name }) => name === "size").inheritedFrom, "InventoryViewAPI"); - assert.match(renderPeripheral(peripheral), /\*\*Throws:\*\* A Lua error if the slot is empty/); + const markdown = renderPeripheral(peripheral); + assert.match(markdown, /\*\*Throws:\*\* A Lua error if the slot is empty/); + assert.match(markdown, /### `getConfiguration\(\): DigitizerConfiguration`/); + assert.doesNotMatch(markdown, /```typescript/); }); test("preserves advanced digitizer overloads and nullable tuple unions", () => { diff --git a/projects/typed-peripheral-digitalitems/documentation/guides/advanced-items.md b/projects/typed-peripheral-digitalitems/documentation/guides/advanced-items.md index 00d5cd1..58cecc4 100644 --- a/projects/typed-peripheral-digitalitems/documentation/guides/advanced-items.md +++ b/projects/typed-peripheral-digitalitems/documentation/guides/advanced-items.md @@ -5,7 +5,7 @@ peripheralInterface: AdvancedDigitizer # Advanced Digitizer
-
Advanced digitizer block
+
Advanced digitizer block
MULTI-STORAGE PERIPHERAL

The advanced digitizer moves items, fluids, and energy between attached storage and durable digital identifiers.

Peripheral type
{{ peripheralType }}
Storage
Items, fluids, energy
Failure style
Recoverable result pairs
diff --git a/projects/typed-peripheral-digitalitems/documentation/guides/basic-digitizer.md b/projects/typed-peripheral-digitalitems/documentation/guides/basic-digitizer.md index ad1a08a..4aa1636 100644 --- a/projects/typed-peripheral-digitalitems/documentation/guides/basic-digitizer.md +++ b/projects/typed-peripheral-digitalitems/documentation/guides/basic-digitizer.md @@ -5,7 +5,7 @@ peripheralInterface: Digitizer # Basic Digitizer
-
Digitizer block
+
Digitizer block
ITEM PERIPHERAL

The basic digitizer turns physical item stacks into portable digital identifiers and restores them through its internal inventory.

Peripheral type
{{ peripheralType }}
Storage
Items
Failure style
Lua errors
diff --git a/projects/typed-peripheral-digitalitems/documentation/index.md b/projects/typed-peripheral-digitalitems/documentation/index.md index a216b0d..13ce6da 100644 --- a/projects/typed-peripheral-digitalitems/documentation/index.md +++ b/projects/typed-peripheral-digitalitems/documentation/index.md @@ -8,11 +8,11 @@ TypeScript with TypeScriptToLua.
- Digitizer block + Digitizer block DigitizerPeripheral type: digitizerDigitize and restore items through a simple internal inventory.Open peripheral guide → - Advanced digitizer block + Advanced digitizer block Advanced DigitizerPeripheral type: advanced_digitizerMove items, fluids, and energy between remote storage and digital IDs.Open peripheral guide →