@intellectual-frontiers/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 +75 -0
- package/README.md +8 -2
- package/dist/build.d.ts +63 -0
- package/dist/build.js +103 -0
- package/dist/check.d.ts +63 -0
- package/dist/check.js +54 -0
- package/dist/cli.d.ts +51 -0
- package/dist/cli.js +165 -0
- package/dist/config.d.ts +196 -0
- package/dist/config.js +229 -0
- package/dist/emit/html.d.ts +67 -0
- package/dist/emit/html.js +338 -0
- package/dist/emit/markdown.d.ts +19 -0
- package/dist/emit/markdown.js +124 -0
- package/dist/emit/search.d.ts +15 -0
- package/dist/emit/search.js +29 -0
- package/dist/extract/api.d.ts +74 -0
- package/dist/extract/api.js +261 -0
- package/dist/extract/specs.d.ts +141 -0
- package/dist/extract/specs.js +208 -0
- package/dist/highlight.d.ts +22 -0
- package/dist/highlight.js +77 -0
- package/dist/layered.d.ts +94 -0
- package/dist/layered.js +14 -0
- package/dist/lens/guides.d.ts +23 -0
- package/dist/lens/guides.js +49 -0
- package/dist/lens/layered.d.ts +16 -0
- package/dist/lens/layered.js +354 -0
- package/dist/lens/program.d.ts +23 -0
- package/dist/lens/program.js +124 -0
- package/dist/lens/releases.d.ts +10 -0
- package/dist/lens/releases.js +37 -0
- package/dist/lens.d.ts +30 -0
- package/dist/lens.js +1 -0
- package/dist/links.d.ts +96 -0
- package/dist/links.js +182 -0
- package/dist/main.d.ts +1 -0
- package/dist/main.js +12 -0
- package/dist/markdown.d.ts +43 -0
- package/dist/markdown.js +301 -0
- package/dist/mod.d.ts +32 -0
- package/dist/mod.js +9 -0
- package/dist/model.d.ts +159 -0
- package/dist/model.js +39 -0
- package/dist/pages/api.d.ts +41 -0
- package/dist/pages/api.js +162 -0
- package/dist/pages/areas.d.ts +39 -0
- package/dist/pages/areas.js +119 -0
- package/dist/pages/overview.d.ts +24 -0
- package/dist/pages/overview.js +283 -0
- package/dist/pages/specs.d.ts +31 -0
- package/dist/pages/specs.js +358 -0
- package/dist/site.d.ts +31 -0
- package/dist/site.js +288 -0
- package/dist/sources.d.ts +53 -0
- package/dist/sources.js +159 -0
- package/dist/theme/site.css +275 -0
- package/dist/theme/site.js +174 -0
- package/dist/tsdoc.d.ts +67 -0
- package/dist/tsdoc.js +94 -0
- package/ifc-docs.mjs +4 -0
- package/package.json +66 -4
- package/src/build.ts +117 -0
- package/src/check.ts +84 -0
- package/src/cli.ts +145 -0
- package/src/config.ts +370 -0
- package/src/emit/html.ts +398 -0
- package/src/emit/markdown.ts +129 -0
- package/src/emit/search.ts +38 -0
- package/src/extract/api.ts +297 -0
- package/src/extract/specs.ts +299 -0
- package/src/highlight.ts +98 -0
- package/src/layered.ts +102 -0
- package/src/lens/guides.ts +70 -0
- package/src/lens/layered.ts +341 -0
- package/src/lens/program.ts +137 -0
- package/src/lens/releases.ts +54 -0
- package/src/lens.ts +34 -0
- package/src/links.ts +234 -0
- package/src/main.ts +12 -0
- package/src/markdown.ts +320 -0
- package/src/mod.ts +53 -0
- package/src/model.ts +154 -0
- package/src/pages/api.ts +179 -0
- package/src/pages/areas.ts +133 -0
- package/src/pages/overview.ts +276 -0
- package/src/pages/specs.ts +366 -0
- package/src/site.ts +285 -0
- package/src/sources.ts +157 -0
- package/src/theme/site.css +275 -0
- package/src/theme/site.js +174 -0
- package/src/tsdoc.ts +131 -0
|
@@ -0,0 +1,358 @@
|
|
|
1
|
+
// Spec: 0001-docs FR-001
|
|
2
|
+
/**
|
|
3
|
+
* The Specifications section (commons 0011-documentation FR-015, FR-024): a page for each specification in force, its header as badges,
|
|
4
|
+
* an anchor for each requirement and success criterion with its row of `enforcement.tsv` (or of its `reviewed.tsv`) beside it, and, once
|
|
5
|
+
* every other page is made, the pages that cite each; the register; the matrix of every requirement with its mechanism and who enforces
|
|
6
|
+
* it; and the constitution of a plain spec kit.
|
|
7
|
+
*
|
|
8
|
+
* @module
|
|
9
|
+
*/
|
|
10
|
+
import { fs } from "@intellectual-frontiers/system";
|
|
11
|
+
import { under } from "../config.js";
|
|
12
|
+
import { specPage } from "../links.js";
|
|
13
|
+
import { plain, slugOf } from "../model.js";
|
|
14
|
+
const toneOf = (mechanism) => mechanism === "check" || mechanism === "gate" ? "good" : mechanism === "review" ? "info" : "warn";
|
|
15
|
+
const statusTone = (s) => (s === "Adopted" ? "good" : s === "Superseded" ? "warn" : "neutral");
|
|
16
|
+
/** The most rows a page of the matrix holds: a page ends at a specification once it has this many. */
|
|
17
|
+
export const ROW_BUDGET = 150;
|
|
18
|
+
const ITEM = /^((?:FR|SC)-\d{3}[a-z]?|OQ-\d+)$/;
|
|
19
|
+
/** The folder that holds a kit's specifications, from the root, of the kit a specification was read from: `commons/core/spec-kit` for `commons/core/spec-kit/specs/0001-core/spec.md`. */
|
|
20
|
+
export function kitDirOf(b, spec) {
|
|
21
|
+
return b.kit.sources.find((k) => spec.file.startsWith(`${k.dir}/`))?.dir ?? "";
|
|
22
|
+
}
|
|
23
|
+
/** The library a spec kit belongs to, by the name of the folder that holds `spec-kit`: `core` for `commons/core/spec-kit`, and `commons` for the repository's own kit. */
|
|
24
|
+
export function kitNameOf(dir) {
|
|
25
|
+
const parts = dir.split("/").filter((x) => x !== "");
|
|
26
|
+
const last = parts[parts.length - 1];
|
|
27
|
+
const owner = last === "spec-kit" || last === "specs" ? parts[parts.length - 2] : last;
|
|
28
|
+
return owner ?? "";
|
|
29
|
+
}
|
|
30
|
+
/** Reads the trace from the files of the repository: a requirement named in a quoted string of a test file is proved by it, and one named in the `// Spec:` header of any other file is written there. */
|
|
31
|
+
export function traceOf(b) {
|
|
32
|
+
const tests = new Map();
|
|
33
|
+
const code = new Map();
|
|
34
|
+
const roots = [...new Set(b.kit.sources.map((k) => k.dir.split("/").slice(0, -1).join("/")))].filter((d) => d !== "" || b.kit.sources.length > 0);
|
|
35
|
+
const walk = (rel, out) => {
|
|
36
|
+
if (!b.exists(rel))
|
|
37
|
+
return;
|
|
38
|
+
for (const e of [...fs.readDirSync(b.abs(rel))].sort((x, y) => (x.name < y.name ? -1 : 1))) {
|
|
39
|
+
const child = under(rel, e.name);
|
|
40
|
+
if (e.isDirectory) {
|
|
41
|
+
if (e.name !== "node_modules" && e.name !== "dist" && !e.name.startsWith("."))
|
|
42
|
+
walk(child, out);
|
|
43
|
+
}
|
|
44
|
+
else if (e.isFile && e.name.endsWith(".ts") && !e.name.includes(".auto."))
|
|
45
|
+
out.push(child);
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
const files = [];
|
|
49
|
+
for (const r of roots)
|
|
50
|
+
walk(r, files);
|
|
51
|
+
const top = roots.length === 0 ? "" : (roots.map((r) => r.split("/")[0] ?? "").find((x) => x !== "") ?? "");
|
|
52
|
+
if (top === "commons" || roots.includes("commons"))
|
|
53
|
+
walk("tests", files);
|
|
54
|
+
for (const f of [...new Set(files)]) {
|
|
55
|
+
const text = b.read(f);
|
|
56
|
+
if (f.includes(".test.") || /(^|\/)(suite|tests)\//.test(f)) {
|
|
57
|
+
for (const m of text.matchAll(/"(\d{3,4}-[a-z0-9-]+ FR-\d{3}[a-z]?)"/g)) {
|
|
58
|
+
const key = m[1] ?? "";
|
|
59
|
+
tests.set(key, (tests.get(key) ?? new Set()).add(f));
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
else {
|
|
63
|
+
const head = /^\/\/ Spec: (\d{3,4}-[a-z0-9-]+) ([^\n]*)/m.exec(text.slice(0, 400));
|
|
64
|
+
if (head !== null)
|
|
65
|
+
for (const r of (head[2] ?? "").matchAll(/FR-\d{3}[a-z]?/g)) {
|
|
66
|
+
const key = `${head[1]} ${r[0]}`;
|
|
67
|
+
code.set(key, (code.get(key) ?? new Set()).add(f));
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
const frozen = (m) => new Map([...m].map(([k, v]) => [k, [...v].sort()]));
|
|
72
|
+
return { tests: frozen(tests), code: frozen(code) };
|
|
73
|
+
}
|
|
74
|
+
/** The number of a specification's id: `0009` of `0009-example`. */
|
|
75
|
+
export const numberOf = (id) => id.split("-")[0] ?? id;
|
|
76
|
+
/** The page of the constitution of a plain spec kit. */
|
|
77
|
+
export const CONSTITUTION_PAGE = "specs/constitution.html";
|
|
78
|
+
/** The enforcement of a requirement, as a line under it; a plain kit says only what its `reviewed.tsv` says. */
|
|
79
|
+
function enforcedLine(spec, e) {
|
|
80
|
+
if (spec.layout === "spec-kit") {
|
|
81
|
+
return e === undefined ? [] : [{ kind: "meta", inlines: [{ kind: "strong", children: [{ kind: "text", text: "Reviewed: " }] }, { kind: "text", text: e.note }] }];
|
|
82
|
+
}
|
|
83
|
+
if (e === undefined)
|
|
84
|
+
return [{ kind: "meta", inlines: [{ kind: "text", text: "No row in enforcement.tsv." }] }];
|
|
85
|
+
const by = e.by === "-" ? [] : [{ kind: "code", text: e.by }, { kind: "text", text: " — " }];
|
|
86
|
+
return [{ kind: "meta", inlines: [{ kind: "strong", children: [{ kind: "text", text: `Enforced (${e.mechanism}): ` }] }, ...by, { kind: "text", text: e.note }] }];
|
|
87
|
+
}
|
|
88
|
+
/** The badges of a requirement: its mechanism, or, in a plain kit, `review` where it is reviewed and none where it is not. */
|
|
89
|
+
function requirementBadges(spec, e) {
|
|
90
|
+
if (spec.layout === "spec-kit")
|
|
91
|
+
return e === undefined ? [] : [{ text: "review", tone: "info" }];
|
|
92
|
+
return [{ text: e?.mechanism ?? "no row", tone: toneOf(e?.mechanism) }];
|
|
93
|
+
}
|
|
94
|
+
/** The lines under a requirement that say which files prove it and which are written to it. */
|
|
95
|
+
function traceLines(b, trace, key) {
|
|
96
|
+
const line = (label, files) => {
|
|
97
|
+
if (files === undefined || files.length === 0)
|
|
98
|
+
return [];
|
|
99
|
+
const shown = files.slice(0, 6);
|
|
100
|
+
return [{
|
|
101
|
+
kind: "meta",
|
|
102
|
+
inlines: [
|
|
103
|
+
{ kind: "strong", children: [{ kind: "text", text: `${label}: ` }] },
|
|
104
|
+
...shown.flatMap((f, i) => [...(i === 0 ? [] : [{ kind: "text", text: ", " }]), { kind: "link", href: { kind: "external", url: b.index.blob(f) }, children: [{ kind: "code", text: f.replace(/^commons\//, "") }] }]),
|
|
105
|
+
...(files.length > shown.length ? [{ kind: "text", text: ` and ${files.length - shown.length} more` }] : []),
|
|
106
|
+
],
|
|
107
|
+
}];
|
|
108
|
+
};
|
|
109
|
+
return [...line("Proved by", trace.tests.get(key)), ...line("Written in", trace.code.get(key))];
|
|
110
|
+
}
|
|
111
|
+
/** A list whose items are numbered items of the specification, made into entries with anchors. */
|
|
112
|
+
function itemEntries(b, spec, list, trace) {
|
|
113
|
+
const entries = [];
|
|
114
|
+
for (const item of list.items) {
|
|
115
|
+
const first = item[0];
|
|
116
|
+
if (first === undefined || first.kind !== "paragraph")
|
|
117
|
+
return undefined;
|
|
118
|
+
const lead = first.inlines[0];
|
|
119
|
+
if (lead === undefined || lead.kind !== "strong")
|
|
120
|
+
return undefined;
|
|
121
|
+
const id = plain(lead.children);
|
|
122
|
+
if (!ITEM.test(id))
|
|
123
|
+
return undefined;
|
|
124
|
+
const rest = first.inlines.slice(1);
|
|
125
|
+
const head = rest[0];
|
|
126
|
+
const trimmed = head !== undefined && head.kind === "text" ? [{ kind: "text", text: head.text.replace(spec.layout === "commons" ? /^:\s*/ : /^:?\s*/, "") }, ...rest.slice(1)] : rest;
|
|
127
|
+
const e = id.startsWith("FR-") ? b.kit.enforcement.get(`${spec.id} ${id}`) : undefined;
|
|
128
|
+
const badges = id.startsWith("FR-")
|
|
129
|
+
? requirementBadges(spec, e)
|
|
130
|
+
: [{ text: id.startsWith("SC-") ? "success criterion" : "open question", tone: "neutral" }];
|
|
131
|
+
entries.push({
|
|
132
|
+
kind: "entry",
|
|
133
|
+
id: id.toLowerCase(),
|
|
134
|
+
name: id,
|
|
135
|
+
badges,
|
|
136
|
+
blocks: [{ kind: "paragraph", inlines: trimmed }, ...item.slice(1), ...(id.startsWith("FR-") ? enforcedLine(spec, e) : []), ...(id.startsWith("FR-") ? traceLines(b, trace, `${spec.id} ${id}`) : [])],
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
return entries;
|
|
140
|
+
}
|
|
141
|
+
/** The title of the library whose spec kit holds a specification: the title of its package where the site has one, else its folder's name. */
|
|
142
|
+
function libraryTitle(b, spec) {
|
|
143
|
+
const name = kitNameOf(kitDirOf(b, spec));
|
|
144
|
+
if (name === "" || name === "commons")
|
|
145
|
+
return "Commons";
|
|
146
|
+
return b.packageTitles.get(name) ?? name;
|
|
147
|
+
}
|
|
148
|
+
/** A specification's page, without the pages that cite it, which `citedBy` adds once every page is made. */
|
|
149
|
+
function specPageOf(b, spec, order, trace) {
|
|
150
|
+
const page = specPage(spec.id);
|
|
151
|
+
const file = spec.file;
|
|
152
|
+
const scope = { page, file, spec: spec.id };
|
|
153
|
+
const blocks = [];
|
|
154
|
+
const parent = spec.partOf;
|
|
155
|
+
const said = [spec.id, ...(spec.owner === "" ? [] : [`owner ${spec.owner}`]), ...(spec.domain === "" ? [] : [`domain ${spec.domain}`])].join(" · ");
|
|
156
|
+
blocks.push({
|
|
157
|
+
kind: "paragraph",
|
|
158
|
+
inlines: [
|
|
159
|
+
{ kind: "text", text: said },
|
|
160
|
+
...(parent === undefined ? [] : [{ kind: "text", text: " · part of " }, ...b.line(parent, scope)]),
|
|
161
|
+
],
|
|
162
|
+
});
|
|
163
|
+
if (spec.input !== "")
|
|
164
|
+
blocks.push({ kind: "callout", tone: "note", title: "Input", blocks: b.md(spec.input, scope) });
|
|
165
|
+
for (const block of b.md(spec.body, scope)) {
|
|
166
|
+
if (block.kind === "list") {
|
|
167
|
+
const entries = itemEntries(b, spec, block, trace);
|
|
168
|
+
if (entries !== undefined) {
|
|
169
|
+
blocks.push(...entries);
|
|
170
|
+
continue;
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
blocks.push(block);
|
|
174
|
+
}
|
|
175
|
+
const lead = spec.input !== "" ? spec.input : /^(?![#>|`-])[^\n]+(?:\n(?![#>|`-])[^\n]+)*/m.exec(spec.body)?.[0] ?? spec.title;
|
|
176
|
+
return {
|
|
177
|
+
path: page,
|
|
178
|
+
title: spec.title,
|
|
179
|
+
description: plain(b.line(lead, scope)).slice(0, 240),
|
|
180
|
+
section: "specs",
|
|
181
|
+
group: libraryTitle(b, spec),
|
|
182
|
+
order,
|
|
183
|
+
badges: [{ text: numberOf(spec.id), tone: "neutral" }, ...(spec.status === "" ? [] : [{ text: spec.status, tone: statusTone(spec.status) }])],
|
|
184
|
+
blocks,
|
|
185
|
+
};
|
|
186
|
+
}
|
|
187
|
+
/** What a kit's matrix rows come from, as the matrix says it. */
|
|
188
|
+
function matrixSource(k) {
|
|
189
|
+
return k.layout === "commons" ? `with the row ${under(k.dir, "enforcement.tsv")} has for it` : `with the reason the reviewed.tsv beside its specification gives where it is proven by review`;
|
|
190
|
+
}
|
|
191
|
+
/** A list of phrases joined with commas and a last `and`. */
|
|
192
|
+
const joined = (xs) => (xs.length <= 1 ? xs.join("") : `${xs.slice(0, -1).join(", ")} and ${xs[xs.length - 1] ?? ""}`);
|
|
193
|
+
/**
|
|
194
|
+
* The register, the matrix and a page for each specification in force.
|
|
195
|
+
*
|
|
196
|
+
* @param b - the build
|
|
197
|
+
*/
|
|
198
|
+
export function specPages(b) {
|
|
199
|
+
if (b.kit.sources.length === 0)
|
|
200
|
+
return;
|
|
201
|
+
const subject = b.config.subject;
|
|
202
|
+
const libs = b.kit.sources.map((k) => ({ k, here: b.kit.specs.filter((s) => kitDirOf(b, s) === k.dir) })).filter((x) => x.here.length > 0);
|
|
203
|
+
const libTitle = (dir) => {
|
|
204
|
+
const name = kitNameOf(dir);
|
|
205
|
+
return name === "" || name === "commons" ? "Commons" : (b.packageTitles.get(name) ?? name);
|
|
206
|
+
};
|
|
207
|
+
const reqCount = (xs) => xs.reduce((n, s) => n + s.requirements.length, 0);
|
|
208
|
+
b.add({
|
|
209
|
+
path: "specs/index.html",
|
|
210
|
+
title: "Register",
|
|
211
|
+
description: `Every specification of ${subject} in force, by the library that keeps it.`,
|
|
212
|
+
section: "specs",
|
|
213
|
+
group: "Spec kit",
|
|
214
|
+
order: 0,
|
|
215
|
+
blocks: [
|
|
216
|
+
{ kind: "paragraph", inlines: [{ kind: "text", text: `${b.kit.specs.length} specifications of ${libs.length} libraries are in force, ${reqCount(b.kit.specs)} requirements in all. Each library keeps its own, numbered from 0001; commons keeps the ones that belong to it as a whole. Open a library to see its specifications, or filter the register by a word.` }] },
|
|
217
|
+
{
|
|
218
|
+
kind: "cards",
|
|
219
|
+
cards: libs.map(({ k, here }) => ({ title: libTitle(k.dir), href: { kind: "page", path: "specs/index.html", anchor: slugOf(kitNameOf(k.dir) === "" ? "specifications" : kitNameOf(k.dir)) }, text: [{ kind: "text", text: `${here.length} ${here.length === 1 ? "specification" : "specifications"}, ${reqCount(here)} requirements` }] })),
|
|
220
|
+
},
|
|
221
|
+
...libs.flatMap(({ k, here }) => {
|
|
222
|
+
const name = kitNameOf(k.dir);
|
|
223
|
+
return [
|
|
224
|
+
{ kind: "heading", level: 2, id: slugOf(name === "" ? "specifications" : name), text: [{ kind: "text", text: libTitle(k.dir) }] },
|
|
225
|
+
{
|
|
226
|
+
kind: "table",
|
|
227
|
+
filter: `Filter the specifications of ${libTitle(k.dir)}`,
|
|
228
|
+
head: ["Number", "Specification", "Status", "Requirements"].map((h) => [{ kind: "text", text: h }]),
|
|
229
|
+
rows: here.map((s) => [
|
|
230
|
+
[{ kind: "code", text: numberOf(s.id) }],
|
|
231
|
+
[{ kind: "link", href: { kind: "page", path: specPage(s.id) }, children: [{ kind: "text", text: s.title }] }, ...(s.partOf === undefined ? [] : [{ kind: "text", text: " · part of " }, { kind: "link", href: { kind: "page", path: specPage(s.partOf) }, children: [{ kind: "code", text: s.partOf }] }])],
|
|
232
|
+
[{ kind: "text", text: s.status }],
|
|
233
|
+
[{ kind: "text", text: String(s.requirements.length) }],
|
|
234
|
+
]),
|
|
235
|
+
},
|
|
236
|
+
];
|
|
237
|
+
}),
|
|
238
|
+
],
|
|
239
|
+
});
|
|
240
|
+
// the matrix is one page for each library, in chunks of at most ROW_BUDGET rows that end at a specification, with a summary page that counts how each requirement is enforced
|
|
241
|
+
const rowOf = (s, r) => {
|
|
242
|
+
const e = b.kit.enforcement.get(`${s.id} ${r.id}`);
|
|
243
|
+
return [
|
|
244
|
+
[{ kind: "link", href: { kind: "page", path: specPage(s.id), anchor: r.id.toLowerCase() }, children: [{ kind: "code", text: r.id }] }],
|
|
245
|
+
[{ kind: "text", text: e?.mechanism ?? (s.layout === "commons" ? "no row" : "") }],
|
|
246
|
+
e === undefined || e.by === "-" ? [] : [{ kind: "code", text: e.by.replace(/^\.github: cd commons\/[a-z-]+ && /, "").replace(/^\.github: /, "") }],
|
|
247
|
+
[{ kind: "text", text: e?.note ?? "" }],
|
|
248
|
+
];
|
|
249
|
+
};
|
|
250
|
+
const mechanismOf = (s, r) => b.kit.enforcement.get(`${s.id} ${r.id}`)?.mechanism ?? (s.layout === "commons" ? "no row" : "review");
|
|
251
|
+
const summary = [];
|
|
252
|
+
let matrixOrder = 100;
|
|
253
|
+
for (const { k, here } of libs) {
|
|
254
|
+
const name = kitNameOf(k.dir) === "" ? "specifications" : kitNameOf(k.dir);
|
|
255
|
+
const chunks = [];
|
|
256
|
+
let rowsSoFar = 0;
|
|
257
|
+
for (const s of here) {
|
|
258
|
+
if (chunks.length === 0 || (rowsSoFar > 0 && rowsSoFar + s.requirements.length > ROW_BUDGET)) {
|
|
259
|
+
chunks.push([]);
|
|
260
|
+
rowsSoFar = 0;
|
|
261
|
+
}
|
|
262
|
+
chunks[chunks.length - 1]?.push(s);
|
|
263
|
+
rowsSoFar += s.requirements.length;
|
|
264
|
+
}
|
|
265
|
+
const counts = new Map();
|
|
266
|
+
for (const s of here)
|
|
267
|
+
for (const r of s.requirements)
|
|
268
|
+
counts.set(mechanismOf(s, r), (counts.get(mechanismOf(s, r)) ?? 0) + 1);
|
|
269
|
+
const pageOf = (i) => `specs/matrix/${slugOf(name)}${i === 0 ? "" : `-${i + 1}`}.html`;
|
|
270
|
+
summary.push([
|
|
271
|
+
[{ kind: "link", href: { kind: "page", path: pageOf(0) }, children: [{ kind: "text", text: libTitle(k.dir) }] }],
|
|
272
|
+
[{ kind: "text", text: String(here.length) }],
|
|
273
|
+
[{ kind: "text", text: String(reqCount(here)) }],
|
|
274
|
+
...["check", "gate", "review", "none", "no row"].map((m) => [{ kind: "text", text: String(counts.get(m) ?? 0) }]),
|
|
275
|
+
]);
|
|
276
|
+
chunks.forEach((ss, i) => {
|
|
277
|
+
b.add({
|
|
278
|
+
path: pageOf(i),
|
|
279
|
+
title: chunks.length === 1 ? libTitle(k.dir) : `${libTitle(k.dir)} (${i + 1} of ${chunks.length})`,
|
|
280
|
+
description: `How each requirement of the specifications of ${libTitle(k.dir)} is enforced, and by what.`,
|
|
281
|
+
section: "specs",
|
|
282
|
+
group: "Spec kit",
|
|
283
|
+
order: matrixOrder++,
|
|
284
|
+
parent: "specs/matrix.html",
|
|
285
|
+
navKind: "Libraries",
|
|
286
|
+
navTitle: chunks.length === 1 ? libTitle(k.dir) : `${libTitle(k.dir)} ${i + 1}`,
|
|
287
|
+
blocks: [
|
|
288
|
+
{ kind: "paragraph", inlines: [{ kind: "text", text: `${ss.length} ${ss.length === 1 ? "specification" : "specifications"}, ${reqCount(ss)} requirements. ` }, { kind: "link", href: { kind: "page", path: "specs/matrix.html" }, children: [{ kind: "text", text: "All libraries" }] }] },
|
|
289
|
+
...ss.flatMap((s) => [
|
|
290
|
+
{ kind: "heading", level: 2, id: slugOf(s.id), text: [{ kind: "link", href: { kind: "page", path: specPage(s.id) }, children: [{ kind: "text", text: `${numberOf(s.id)} ${s.title}` }] }] },
|
|
291
|
+
{ kind: "table", compact: true, filter: `Filter the requirements of ${numberOf(s.id)}`, head: ["Requirement", "Mechanism", "Who", "Note"].map((h) => [{ kind: "text", text: h }]), rows: s.requirements.map((r) => rowOf(s, r)) },
|
|
292
|
+
]),
|
|
293
|
+
],
|
|
294
|
+
});
|
|
295
|
+
});
|
|
296
|
+
}
|
|
297
|
+
b.add({
|
|
298
|
+
path: "specs/matrix.html",
|
|
299
|
+
title: "Traceability matrix",
|
|
300
|
+
description: `How each requirement of ${subject} is enforced, by library.`,
|
|
301
|
+
section: "specs",
|
|
302
|
+
group: "Spec kit",
|
|
303
|
+
order: 1,
|
|
304
|
+
blocks: [
|
|
305
|
+
{ kind: "paragraph", inlines: [{ kind: "text", text: `Every requirement of ${subject}, ${joined(b.kit.sources.map(matrixSource))}. A requirement is checked by a test, gated by a command, reviewed by a person, or has no row yet. Open a library for its requirements, specification by specification.` }] },
|
|
306
|
+
{ kind: "table", filter: "Filter the libraries", head: ["Library", "Specifications", "Requirements", "Check", "Gate", "Review", "None", "No row"].map((h) => [{ kind: "text", text: h }]), rows: summary },
|
|
307
|
+
],
|
|
308
|
+
});
|
|
309
|
+
const c = b.kit.constitution;
|
|
310
|
+
if (c !== undefined) {
|
|
311
|
+
b.files.set(c.file, CONSTITUTION_PAGE);
|
|
312
|
+
const scope = { page: CONSTITUTION_PAGE, file: c.file };
|
|
313
|
+
b.add({
|
|
314
|
+
path: CONSTITUTION_PAGE,
|
|
315
|
+
title: c.title,
|
|
316
|
+
description: `The constitution of ${subject}, which governs every specification.`,
|
|
317
|
+
section: "specs",
|
|
318
|
+
group: "Spec kit",
|
|
319
|
+
order: 2,
|
|
320
|
+
navTitle: "Constitution",
|
|
321
|
+
blocks: b.md(c.body, scope),
|
|
322
|
+
});
|
|
323
|
+
}
|
|
324
|
+
const trace = traceOf(b);
|
|
325
|
+
b.kit.specs.forEach((s, i) => b.add(specPageOf(b, s, 10 + i, trace)));
|
|
326
|
+
}
|
|
327
|
+
/**
|
|
328
|
+
* The pages that cite each specification and requirement, added to the specifications' pages once every other page is made.
|
|
329
|
+
*
|
|
330
|
+
* @param b - the build
|
|
331
|
+
*/
|
|
332
|
+
export function citedBy(b) {
|
|
333
|
+
const titleOf = new Map(b.pages.map((p) => [p.path, p.title]));
|
|
334
|
+
const links = (key, self) => {
|
|
335
|
+
const pages = [...(b.citations.get(key) ?? [])].filter((p) => p !== self).sort();
|
|
336
|
+
return pages.flatMap((p, i) => [
|
|
337
|
+
...(i === 0 ? [] : [{ kind: "text", text: ", " }]),
|
|
338
|
+
{ kind: "link", href: { kind: "page", path: p }, children: [{ kind: "text", text: titleOf.get(p) ?? p }] },
|
|
339
|
+
]);
|
|
340
|
+
};
|
|
341
|
+
for (let i = 0; i < b.pages.length; i++) {
|
|
342
|
+
const p = b.pages[i];
|
|
343
|
+
if (p === undefined || p.section !== "specs" || !p.path.startsWith("specs/") || ["specs/index.html", "specs/matrix.html", CONSTITUTION_PAGE].includes(p.path) || p.path.startsWith("specs/matrix/"))
|
|
344
|
+
continue;
|
|
345
|
+
const id = p.path.slice("specs/".length, -".html".length);
|
|
346
|
+
const blocks = p.blocks.map((blk) => {
|
|
347
|
+
if (blk.kind !== "entry" || !blk.name.startsWith("FR-"))
|
|
348
|
+
return blk;
|
|
349
|
+
const cited = links(`${id} ${blk.name}`, p.path);
|
|
350
|
+
return cited.length === 0 ? blk : { ...blk, blocks: [...blk.blocks, { kind: "paragraph", inlines: [{ kind: "strong", children: [{ kind: "text", text: "Cited by: " }] }, ...cited] }] };
|
|
351
|
+
});
|
|
352
|
+
const all = links(id, p.path);
|
|
353
|
+
if (all.length > 0) {
|
|
354
|
+
blocks.push({ kind: "heading", level: 2, id: "cited-by", text: [{ kind: "text", text: "Cited by" }] }, { kind: "paragraph", inlines: all });
|
|
355
|
+
}
|
|
356
|
+
b.pages[i] = { ...p, blocks };
|
|
357
|
+
}
|
|
358
|
+
}
|
package/dist/site.d.ts
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { Finding } from "./check.js";
|
|
2
|
+
import { type Config } from "./config.js";
|
|
3
|
+
import type { SiteFile } from "./lens.js";
|
|
4
|
+
import { type Page } from "./model.js";
|
|
5
|
+
/** A built site: its pages, its search index and what was found while it was built. */
|
|
6
|
+
export interface Built {
|
|
7
|
+
/** The pages, in the order they were made. */
|
|
8
|
+
readonly pages: readonly Page[];
|
|
9
|
+
/** What was found. */
|
|
10
|
+
readonly found: readonly Finding[];
|
|
11
|
+
/** The files the lenses added beside the pages (the JSON of a model). */
|
|
12
|
+
readonly files: readonly SiteFile[];
|
|
13
|
+
}
|
|
14
|
+
/** The pages that name a retired name, and the pages people write that have a word they do not use. */
|
|
15
|
+
export declare function wordFindings(pages: readonly Page[], retired: readonly string[], forbidden: readonly string[]): Finding[];
|
|
16
|
+
/** The links of every page that lead to no page, or to no anchor of their page. */
|
|
17
|
+
export declare function brokenLinks(pages: readonly Page[]): Finding[];
|
|
18
|
+
/**
|
|
19
|
+
* The site of a repository, built in memory from its configuration.
|
|
20
|
+
*
|
|
21
|
+
* @param config - the configuration, checked
|
|
22
|
+
*/
|
|
23
|
+
export declare function buildSite(config: Config): Promise<Built>;
|
|
24
|
+
/**
|
|
25
|
+
* A built site written into a folder, which is emptied first.
|
|
26
|
+
*
|
|
27
|
+
* @param config - the configuration
|
|
28
|
+
* @param built - the site
|
|
29
|
+
* @param out - the folder
|
|
30
|
+
*/
|
|
31
|
+
export declare function writeSite(config: Config, built: Built, out: string): Promise<void>;
|
package/dist/site.js
ADDED
|
@@ -0,0 +1,288 @@
|
|
|
1
|
+
// Spec: 0001-docs FR-001
|
|
2
|
+
/**
|
|
3
|
+
* One build of the site (commons 0011-documentation FR-003, FR-009, FR-017, FR-018, FR-023, FR-026): the configuration's packages and
|
|
4
|
+
* spec kits read, every page made (the lenses the configuration passes make theirs), the pages that cite each specification added, every
|
|
5
|
+
* link and anchor held to the pages, and the site written as files: a page for each page, the stylesheet, the script, Mermaid and the
|
|
6
|
+
* search index. The same sources give the same bytes.
|
|
7
|
+
*
|
|
8
|
+
* @module
|
|
9
|
+
*/
|
|
10
|
+
import { absurd } from "@intellectual-frontiers/core";
|
|
11
|
+
import { fs, path } from "@intellectual-frontiers/system";
|
|
12
|
+
import { Build } from "./build.js";
|
|
13
|
+
import { under } from "./config.js";
|
|
14
|
+
import { diagramSources, document, drawable } from "./emit/html.js";
|
|
15
|
+
import { llmsIndex, markdownOf, twinOf } from "./emit/markdown.js";
|
|
16
|
+
import { searchIndex } from "./emit/search.js";
|
|
17
|
+
import { readApi } from "./extract/api.js";
|
|
18
|
+
import { readSpecKits } from "./extract/specs.js";
|
|
19
|
+
import { possessive } from "./model.js";
|
|
20
|
+
import { apiPages, registerApi } from "./pages/api.js";
|
|
21
|
+
import { areaPages } from "./pages/areas.js";
|
|
22
|
+
import { areaPage, overviewPages, packagePage } from "./pages/overview.js";
|
|
23
|
+
import { citedBy, specPages } from "./pages/specs.js";
|
|
24
|
+
import { areasOf, checkAbout, readPackage } from "./sources.js";
|
|
25
|
+
/** The section home pages for the API and the models, which list the areas and the models. */
|
|
26
|
+
function homes(b, packages) {
|
|
27
|
+
const areas = areasOf(packages);
|
|
28
|
+
b.add({
|
|
29
|
+
path: "api/index.html",
|
|
30
|
+
title: "API",
|
|
31
|
+
description: `The API of every area of ${b.config.subject}, read from its TypeScript.`,
|
|
32
|
+
section: "api",
|
|
33
|
+
group: "API",
|
|
34
|
+
order: 0,
|
|
35
|
+
blocks: packages
|
|
36
|
+
.filter((p) => (p.about.areas ?? []).length > 0)
|
|
37
|
+
.flatMap((p) => [
|
|
38
|
+
{ kind: "heading", level: 2, id: p.slug, text: [{ kind: "text", text: p.about.title }] },
|
|
39
|
+
{
|
|
40
|
+
kind: "cards",
|
|
41
|
+
cards: areas
|
|
42
|
+
.filter((a) => a.pkg.slug === p.slug)
|
|
43
|
+
.map((a) => ({
|
|
44
|
+
title: a.title,
|
|
45
|
+
href: { kind: "page", path: areaPage(a) },
|
|
46
|
+
text: [{ kind: "code", text: a.entryPoints.join(", ") }],
|
|
47
|
+
})),
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
kind: "paragraph",
|
|
51
|
+
inlines: [{ kind: "link", href: { kind: "page", path: packagePage(p) }, children: [{ kind: "text", text: `About ${p.about.title}` }] }],
|
|
52
|
+
},
|
|
53
|
+
]),
|
|
54
|
+
});
|
|
55
|
+
if (b.config.lenses.length > 0 && !b.pages.some((p) => p.section === "models")) {
|
|
56
|
+
b.add({
|
|
57
|
+
path: "models/index.html",
|
|
58
|
+
title: "Models",
|
|
59
|
+
description: `The schemas and layouts ${possessive(b.config.subject)} libraries define.`,
|
|
60
|
+
section: "models",
|
|
61
|
+
group: "Models",
|
|
62
|
+
order: 0,
|
|
63
|
+
blocks: [{ kind: "paragraph", inlines: [{ kind: "text", text: "No model has been read yet." }] }],
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
/** The pages that name a retired name, and the pages people write that have a word they do not use. */
|
|
68
|
+
export function wordFindings(pages, retired, forbidden) {
|
|
69
|
+
const found = [];
|
|
70
|
+
const escape = (w) => w.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
71
|
+
const has = (text, w) => new RegExp(`(^|[^A-Za-z0-9])${escape(w)}($|[^A-Za-z0-9])`, "i").test(text);
|
|
72
|
+
for (const p of pages) {
|
|
73
|
+
const text = markdownOf(p);
|
|
74
|
+
for (const name of retired)
|
|
75
|
+
if (has(text, name))
|
|
76
|
+
found.push({ where: p.path, problem: { kind: "retired-name", name } });
|
|
77
|
+
if (p.section === "start" || p.section === "concepts" || p.section === "howto") {
|
|
78
|
+
for (const word of forbidden)
|
|
79
|
+
if (has(text, word))
|
|
80
|
+
found.push({ where: p.path, problem: { kind: "forbidden-word", word } });
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
return found;
|
|
84
|
+
}
|
|
85
|
+
/** Every link of a page: the hrefs of its inlines and cards. */
|
|
86
|
+
function hrefsOf(bs) {
|
|
87
|
+
const out = [];
|
|
88
|
+
const inl = (xs) => {
|
|
89
|
+
for (const i of xs) {
|
|
90
|
+
switch (i.kind) {
|
|
91
|
+
case "link":
|
|
92
|
+
out.push(i.href);
|
|
93
|
+
inl(i.children);
|
|
94
|
+
break;
|
|
95
|
+
case "emphasis":
|
|
96
|
+
case "strong":
|
|
97
|
+
inl(i.children);
|
|
98
|
+
break;
|
|
99
|
+
case "text":
|
|
100
|
+
case "code":
|
|
101
|
+
break;
|
|
102
|
+
default:
|
|
103
|
+
absurd(i);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
};
|
|
107
|
+
const card = (c) => {
|
|
108
|
+
out.push(c.href);
|
|
109
|
+
inl(c.text);
|
|
110
|
+
for (const k of c.children ?? [])
|
|
111
|
+
card(k);
|
|
112
|
+
};
|
|
113
|
+
const walk = (xs) => {
|
|
114
|
+
for (const b of xs) {
|
|
115
|
+
switch (b.kind) {
|
|
116
|
+
case "heading":
|
|
117
|
+
inl(b.text);
|
|
118
|
+
break;
|
|
119
|
+
case "paragraph":
|
|
120
|
+
case "meta":
|
|
121
|
+
inl(b.inlines);
|
|
122
|
+
break;
|
|
123
|
+
case "list":
|
|
124
|
+
b.items.forEach(walk);
|
|
125
|
+
break;
|
|
126
|
+
case "table":
|
|
127
|
+
b.head.forEach(inl);
|
|
128
|
+
b.rows.forEach((r) => r.forEach(inl));
|
|
129
|
+
break;
|
|
130
|
+
case "callout":
|
|
131
|
+
case "entry":
|
|
132
|
+
walk(b.blocks);
|
|
133
|
+
break;
|
|
134
|
+
case "tabs":
|
|
135
|
+
b.tabs.forEach((t) => walk(t.blocks));
|
|
136
|
+
break;
|
|
137
|
+
case "cards":
|
|
138
|
+
b.cards.forEach(card);
|
|
139
|
+
break;
|
|
140
|
+
case "tree": {
|
|
141
|
+
const visit = (ns) => {
|
|
142
|
+
for (const n of ns) {
|
|
143
|
+
if (n.note !== undefined)
|
|
144
|
+
inl(n.note);
|
|
145
|
+
visit(n.children);
|
|
146
|
+
}
|
|
147
|
+
};
|
|
148
|
+
visit(b.nodes);
|
|
149
|
+
break;
|
|
150
|
+
}
|
|
151
|
+
case "code":
|
|
152
|
+
case "diagram":
|
|
153
|
+
case "badges":
|
|
154
|
+
break;
|
|
155
|
+
default:
|
|
156
|
+
absurd(b);
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
};
|
|
160
|
+
walk(bs);
|
|
161
|
+
return out;
|
|
162
|
+
}
|
|
163
|
+
/** The anchors of a page: its headings and entries, at any depth. */
|
|
164
|
+
function anchorsOf(bs, out = new Set()) {
|
|
165
|
+
for (const b of bs) {
|
|
166
|
+
if (b.kind === "heading")
|
|
167
|
+
out.add(b.id);
|
|
168
|
+
else if (b.kind === "entry") {
|
|
169
|
+
out.add(b.id);
|
|
170
|
+
anchorsOf(b.blocks, out);
|
|
171
|
+
}
|
|
172
|
+
else if (b.kind === "tabs")
|
|
173
|
+
for (const t of b.tabs)
|
|
174
|
+
anchorsOf(t.blocks, out);
|
|
175
|
+
else if (b.kind === "callout")
|
|
176
|
+
anchorsOf(b.blocks, out);
|
|
177
|
+
}
|
|
178
|
+
return out;
|
|
179
|
+
}
|
|
180
|
+
/** The links of every page that lead to no page, or to no anchor of their page. */
|
|
181
|
+
export function brokenLinks(pages) {
|
|
182
|
+
const anchors = new Map(pages.map((p) => [p.path, anchorsOf(p.blocks)]));
|
|
183
|
+
const found = [];
|
|
184
|
+
for (const p of pages) {
|
|
185
|
+
for (const h of hrefsOf(p.blocks)) {
|
|
186
|
+
if (h.kind !== "page")
|
|
187
|
+
continue;
|
|
188
|
+
const target = anchors.get(h.path);
|
|
189
|
+
const shown = `${h.path}${h.anchor === undefined ? "" : `#${h.anchor}`}`;
|
|
190
|
+
if (target === undefined || (h.anchor !== undefined && !target.has(h.anchor)))
|
|
191
|
+
found.push({ where: p.path, problem: { kind: "broken-link", href: shown } });
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
return found;
|
|
195
|
+
}
|
|
196
|
+
/**
|
|
197
|
+
* The site of a repository, built in memory from its configuration.
|
|
198
|
+
*
|
|
199
|
+
* @param config - the configuration, checked
|
|
200
|
+
*/
|
|
201
|
+
export async function buildSite(config) {
|
|
202
|
+
const root = config.root;
|
|
203
|
+
const found = [];
|
|
204
|
+
const b = new Build(config, readSpecKits(root, config.specKits, found));
|
|
205
|
+
b.found.push(...found);
|
|
206
|
+
const top = await readPackage(root, config.home, config.fileFromRoot, b.found);
|
|
207
|
+
const packages = [];
|
|
208
|
+
for (const src of config.packages) {
|
|
209
|
+
const p = await readPackage(root, src, config.fileFromRoot, b.found);
|
|
210
|
+
if (p === undefined)
|
|
211
|
+
continue;
|
|
212
|
+
packages.push(p);
|
|
213
|
+
b.packageTitles.set(p.slug, p.about.title);
|
|
214
|
+
b.found.push(...checkAbout(root, p, config.lintRules));
|
|
215
|
+
}
|
|
216
|
+
if (top !== undefined)
|
|
217
|
+
b.found.push(...checkAbout(root, top, config.lintRules));
|
|
218
|
+
const areas = areasOf(packages);
|
|
219
|
+
for (const a of areas)
|
|
220
|
+
for (const e of a.entryPoints)
|
|
221
|
+
b.files.set(under(a.pkg.dir, e), areaPage(a));
|
|
222
|
+
const apis = areas.length === 0
|
|
223
|
+
? []
|
|
224
|
+
: await readApi(root, areas.map((a) => ({ slug: a.slug, entryPoints: a.entryPoints.map((e) => under(a.pkg.dir, e)) })), packages.map((p) => p.dir));
|
|
225
|
+
const modules = registerApi(b, areas, apis);
|
|
226
|
+
const lenses = [];
|
|
227
|
+
for (const lens of config.lenses)
|
|
228
|
+
lenses.push(await lens.read(b, areas, apis));
|
|
229
|
+
specPages(b);
|
|
230
|
+
if (top !== undefined)
|
|
231
|
+
overviewPages(b, top, packages, areas);
|
|
232
|
+
apiPages(b, areas, apis, modules);
|
|
233
|
+
areaPages(b, areas, modules);
|
|
234
|
+
let after = 100;
|
|
235
|
+
for (const make of lenses)
|
|
236
|
+
after = make(b, after);
|
|
237
|
+
homes(b, packages);
|
|
238
|
+
citedBy(b);
|
|
239
|
+
b.found.push(...brokenLinks(b.pages));
|
|
240
|
+
for (const p of b.pages)
|
|
241
|
+
for (const src of diagramSources(p.blocks))
|
|
242
|
+
if (!drawable(src))
|
|
243
|
+
b.found.push({ where: p.path, problem: { kind: "diagram-undrawable", first: src.split("\n")[0] ?? "" } });
|
|
244
|
+
b.found.push(...wordFindings(b.pages, config.retired, config.forbiddenInGuides));
|
|
245
|
+
const files = config.lenses.flatMap((l) => l.files?.(b) ?? []);
|
|
246
|
+
return { pages: b.pages, found: b.found, files };
|
|
247
|
+
}
|
|
248
|
+
/** The files of the theme (beside this module, in the source and in the package alike), and where the site serves them. */
|
|
249
|
+
function assets() {
|
|
250
|
+
const theme = (f) => path.fromFileUrl(new URL(`./theme/${f}`, import.meta.url));
|
|
251
|
+
return [
|
|
252
|
+
[theme("site.css"), "assets/site.css"],
|
|
253
|
+
[theme("site.js"), "assets/site.js"],
|
|
254
|
+
];
|
|
255
|
+
}
|
|
256
|
+
/**
|
|
257
|
+
* A built site written into a folder, which is emptied first.
|
|
258
|
+
*
|
|
259
|
+
* @param config - the configuration
|
|
260
|
+
* @param built - the site
|
|
261
|
+
* @param out - the folder
|
|
262
|
+
*/
|
|
263
|
+
export async function writeSite(config, built, out) {
|
|
264
|
+
await fs.remove(out, { recursive: true }).catch(() => { });
|
|
265
|
+
await fs.ensureDir(out);
|
|
266
|
+
const sections = [...new Set(built.pages.map((p) => p.section))];
|
|
267
|
+
const site = { name: config.name, repository: config.repository, pages: built.pages, sections };
|
|
268
|
+
for (const p of [...built.pages].sort((a, b) => (a.path < b.path ? -1 : 1))) {
|
|
269
|
+
const file = path.join(out, p.path);
|
|
270
|
+
await fs.ensureDir(path.dirname(file));
|
|
271
|
+
await fs.writeTextFile(file, document(p, site));
|
|
272
|
+
// the Markdown twin of the page, beside it (FR-028)
|
|
273
|
+
await fs.writeTextFile(path.join(out, twinOf(p.path)), markdownOf(p));
|
|
274
|
+
}
|
|
275
|
+
for (const f of [...built.files].sort((a, b) => (a.path < b.path ? -1 : 1))) {
|
|
276
|
+
const file = path.join(out, f.path);
|
|
277
|
+
await fs.ensureDir(path.dirname(file));
|
|
278
|
+
await fs.writeTextFile(file, f.text);
|
|
279
|
+
}
|
|
280
|
+
await fs.writeTextFile(path.join(out, "llms.txt"), llmsIndex(config.name, built.pages, built.files.map((f) => [f.path, f.what])));
|
|
281
|
+
for (const [from, to] of assets()) {
|
|
282
|
+
const file = path.join(out, to);
|
|
283
|
+
await fs.ensureDir(path.dirname(file));
|
|
284
|
+
await fs.copyFile(from, file);
|
|
285
|
+
}
|
|
286
|
+
await fs.writeTextFile(path.join(out, "search.json"), `${JSON.stringify(searchIndex(built.pages))}\n`);
|
|
287
|
+
await fs.writeTextFile(path.join(out, ".nojekyll"), "");
|
|
288
|
+
}
|