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

The advanced digitizer moves items, fluids, and energy between attached storage and durable digital identifiers.
{{ peripheralType }}
The basic digitizer turns physical item stacks into portable digital identifiers and restores them through its internal inventory.
{{ peripheralType }}