@protoboardai/ext-docs 0.0.0-stage → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +202 -0
- package/NOTICE +18 -0
- package/README.md +78 -2
- package/evals/build-datasheet/case.json +147 -0
- package/fonts/KodeMono-Bold.ttf +0 -0
- package/fonts/KodeMono-Medium.ttf +0 -0
- package/fonts/KodeMono-Regular.ttf +0 -0
- package/fonts/KodeMono-SemiBold.ttf +0 -0
- package/fonts/OFL.txt +93 -0
- package/lib/blocks.ts +268 -0
- package/lib/bom.ts +126 -0
- package/lib/build.ts +202 -0
- package/lib/charts.ts +241 -0
- package/lib/context.ts +122 -0
- package/lib/derived.ts +181 -0
- package/lib/docs/assembly.ts +674 -0
- package/lib/docs/common.ts +81 -0
- package/lib/docs/datasheet.ts +875 -0
- package/lib/docs/product.ts +45 -0
- package/lib/figures.ts +195 -0
- package/lib/format.ts +221 -0
- package/lib/html.ts +135 -0
- package/lib/model.ts +312 -0
- package/lib/package/assembly.ts +268 -0
- package/lib/package/common.ts +109 -0
- package/lib/package/plan.ts +432 -0
- package/lib/package/spec.ts +203 -0
- package/lib/png.ts +91 -0
- package/lib/render/cdp.ts +5 -0
- package/lib/render/page/render.html +17 -0
- package/lib/render/page/render.js +390 -0
- package/lib/render/renderer.ts +161 -0
- package/lib/render/server.ts +105 -0
- package/lib/standin.ts +36 -0
- package/lib/standins/multirotor.ts +283 -0
- package/lib/templates/doc.css +247 -0
- package/lib/templates/flow.js +131 -0
- package/lib/testdata.ts +85 -0
- package/lib/types.ts +120 -0
- package/lib/values.ts +309 -0
- package/lib/verify.ts +276 -0
- package/ops/docs.ts +52 -0
- package/ops/package.ts +9 -0
- package/package.json +51 -4
- package/protoboard-extension.json +83 -0
- package/skills/uhd-tech-docs/SKILL.md +234 -0
- package/skills/uhd-tech-docs/references/docspec.md +56 -0
- package/skills/uhd-tech-docs/references/house-style.md +50 -0
- package/skills/uhd-tech-docs/references/style-study.md +270 -0
- package/skills/uhd-tech-docs/references/test-data.md +49 -0
- package/skills/uhd-tech-docs/references/value-queries.md +67 -0
- package/skills/uhd-tech-docs/templates/test-data.example.json +33 -0
- package/skills/uhd-tech-docs/templates/test-data.schema.json +213 -0
- package/skills/uhd-tech-docs-verify/SKILL.md +104 -0
- package/skills/uhd-tech-docs-verify/references/visual-review.md +43 -0
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared pieces of the document builders: build environment, cover page,
|
|
3
|
+
* thumbnails, test-data helpers.
|
|
4
|
+
*/
|
|
5
|
+
import { existsSync } from "fs";
|
|
6
|
+
import { join } from "path";
|
|
7
|
+
import type { ModuleDef } from "@deltarobotics/uhd";
|
|
8
|
+
import { esc, type Doc } from "../html.ts";
|
|
9
|
+
import type { FigureRenderer, RenderResult } from "../render/renderer.ts";
|
|
10
|
+
import type { BuiltContext } from "../context.ts";
|
|
11
|
+
import { category, featureNames, glbFor } from "../model.ts";
|
|
12
|
+
import { isolated, ISO } from "../figures.ts";
|
|
13
|
+
import type { TestData } from "../testdata.ts";
|
|
14
|
+
|
|
15
|
+
export interface BuildEnv {
|
|
16
|
+
ctx: BuiltContext;
|
|
17
|
+
doc: Doc;
|
|
18
|
+
r: FigureRenderer;
|
|
19
|
+
/** Absolute docs directory (the HTML's directory). */
|
|
20
|
+
docDir: string;
|
|
21
|
+
/** Project-relative docs directory. */
|
|
22
|
+
docRel: string;
|
|
23
|
+
/** Image path prefix relative to the HTML. */
|
|
24
|
+
img: (name: string) => string;
|
|
25
|
+
counters: { fig: number };
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export const figNum = (env: BuildEnv) => String(++env.counters.fig);
|
|
29
|
+
|
|
30
|
+
/** A module's body GLB is declared but its file is not in this checkout (vendor CAD whose redistribution is not cleared). */
|
|
31
|
+
export function bodyFileMissing(env: BuildEnv, def: ModuleDef): boolean {
|
|
32
|
+
const glb = glbFor(def);
|
|
33
|
+
const file = glb?.filePath ? env.ctx.sys.file(def, glb.filePath) : undefined;
|
|
34
|
+
return !!glb?.filePath && !(file && existsSync(file));
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/** Thumbnail of a module on its own; undefined when it has no body GLB, or its file is not available. */
|
|
38
|
+
export async function thumbnail(env: BuildEnv, def: ModuleDef, size = 360): Promise<RenderResult | undefined> {
|
|
39
|
+
const glb = glbFor(def);
|
|
40
|
+
const served = glb?.filePath ? env.ctx.sys.served(def, glb.filePath) : undefined;
|
|
41
|
+
if (!glb || !served || bodyFileMissing(env, def)) return undefined;
|
|
42
|
+
return env.r.render(`part-${def.id}`, {
|
|
43
|
+
width: size,
|
|
44
|
+
height: size,
|
|
45
|
+
mode: "lineart",
|
|
46
|
+
lineScale: 1.25,
|
|
47
|
+
bodies: isolated(def, served, featureNames(env.ctx.sys, def, glb), category(def), Boolean(glb.id.startsWith("cad_vendor"))),
|
|
48
|
+
camera: { dir: category(def) === "prop" || category(def) === "frame" || category(def) === "top_plate" ? [0.8, -1, 1.4] : ISO, margin: 0.08 },
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export function coverPage(env: BuildEnv, o: { kicker: string; hero: RenderResult; heroCaption: string; bottom: string }): string {
|
|
53
|
+
const m = env.doc.meta;
|
|
54
|
+
const words = m.title.split(" ");
|
|
55
|
+
const last = words.pop();
|
|
56
|
+
return `<div class="coverpage" data-page="cover">
|
|
57
|
+
<div class="cover-top"><div class="grid-bg"></div>
|
|
58
|
+
<div class="cover-brand">PR<b>0</b>TOBOARD <span class="muted">·</span> UHD</div>
|
|
59
|
+
<div class="cover-rev"><span>Rev ${esc(m.revision)}</span><span>${esc(m.date)}</span><span>${esc(m.docId)}</span></div>
|
|
60
|
+
<div class="cover-kicker">${esc(o.kicker)}</div>
|
|
61
|
+
<div class="cover-title">${esc(words.join(" "))} <span class="accent">${esc(last)}</span></div>
|
|
62
|
+
<div class="cover-sub">${env.doc.v("sys:system.description", undefined, { cls: "wrap" })}</div>
|
|
63
|
+
<div class="cover-hero"><img src="${esc(env.img(o.hero.file))}" width="${o.hero.width}" height="${o.hero.height}" alt="${esc(o.heroCaption)}"></div>
|
|
64
|
+
<div class="cover-herocap">${esc(o.heroCaption)}</div>
|
|
65
|
+
</div>
|
|
66
|
+
<div class="cover-bottom">${o.bottom}</div>
|
|
67
|
+
<div class="cover-foot"><span class="pg-brand">PR<b>0</b>TOBOARD · UHD</span><span>Generated from the UHD model of <code>${esc(env.ctx.sys.name)}</code> by @protoboardai/ext-docs</span><span class="right">${esc(m.docId)} · Rev ${esc(m.revision)} · ${esc(m.date)}</span></div>
|
|
68
|
+
</div>`;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
export function testOf(env: BuildEnv, id: string): TestData | undefined {
|
|
72
|
+
return env.ctx.tests.get(id);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/** "STAND-IN" / "MEASURED" tag for a test-data block. */
|
|
76
|
+
export function testTag(t: TestData | undefined): string {
|
|
77
|
+
if (!t) return `<span class="tag err">no data</span>`;
|
|
78
|
+
return t.status === "measured" ? `<span class="tag ok">measured</span>` : `<span class="tag warn standin-tag">stand-in · not measured</span>`;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
export const imgPath = (docDir: string) => (file: string) => file.startsWith(docDir) ? file.slice(docDir.length + 1) : join("images", file);
|