@forsakringskassan/docs-generator 2.26.4 → 2.27.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/README.md +5 -5
- package/dist/{create-markdown-renderer-DRsx8BA_.js → create-markdown-renderer-B9Y9VYNq.mjs} +27 -33
- package/dist/create-markdown-renderer-B9Y9VYNq.mjs.map +1 -0
- package/dist/{index.d.ts → index.d.mts} +8 -0
- package/dist/{index.js → index.mjs} +195 -182
- package/dist/index.mjs.map +1 -0
- package/dist/markdown.mjs +41 -0
- package/dist/markdown.mjs.map +1 -0
- package/dist/processors/{motd.js → motd.mjs} +0 -2
- package/dist/processors/{selectable-version.js → selectable-version.mjs} +91 -92
- package/dist/{runtime-bootstrap.js → runtime-bootstrap.mjs} +0 -2
- package/dist/{runtime.js → runtime.mjs} +4 -10
- package/dist/tsconfig-path-bG7G_cK8.mjs +11 -0
- package/dist/tsconfig-path-bG7G_cK8.mjs.map +1 -0
- package/dist/tsdoc-metadata.json +1 -1
- package/dist/{vendor-DKOm4V-g.js → vendor-DiqWVUfS.mjs} +164 -551
- package/dist/vendor-DiqWVUfS.mjs.map +1 -0
- package/dist/{vue3-D18_q-Ol.js → vue3-BzNzaBbK.mjs} +12 -11
- package/dist/vue3-BzNzaBbK.mjs.map +1 -0
- package/dist/worker-BnI39lrZ.mjs +150 -0
- package/dist/worker-BnI39lrZ.mjs.map +1 -0
- package/package.json +18 -8
- package/dist/compile-example.js +0 -152
- package/dist/compile-example.js.map +0 -1
- package/dist/create-markdown-renderer-DRsx8BA_.js.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/markdown.js +0 -47
- package/dist/markdown.js.map +0 -1
- package/dist/vendor-DKOm4V-g.js.map +0 -1
- package/dist/vue3-D18_q-Ol.js.map +0 -1
- /package/dist/{markdown.d.ts → markdown.d.mts} +0 -0
- /package/dist/{runtime.d.ts → runtime.d.mts} +0 -0
|
@@ -1,54 +1,55 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
1
|
+
import { createRequire as $createRequire } from "node:module";
|
|
2
|
+
|
|
3
|
+
const require = $createRequire(import.meta.url);
|
|
4
|
+
|
|
5
|
+
import fs from 'node:fs/promises';
|
|
6
|
+
import path from 'node:path/posix';
|
|
7
|
+
import { g as globSync, m as minimatch, M as MarkdownIt, d as dedent, b as closest, e as distance, f as fm, i as isCI, h as glob, j as moduleImporter, k as cliProgress, t as tinylr, w as watch, l as createInstance, n as fse } from './vendor-DiqWVUfS.mjs';
|
|
8
|
+
import { g as generateId, p as parseInfostring, i as isDocumentPage, n as normalizePath, a as getFingerprint, h as hasTag, f as findTag, b as getOutputFilePath, d as htmlencode, e as exampleWorkerUrl, c as createMarkdownRenderer, j as generateExample } from './create-markdown-renderer-B9Y9VYNq.mjs';
|
|
9
|
+
import path$1 from 'node:path';
|
|
10
|
+
import require$$1 from 'crypto';
|
|
11
|
+
import 'node:crypto';
|
|
12
|
+
import { exec } from 'node:child_process';
|
|
13
|
+
import util, { promisify } from 'node:util';
|
|
14
|
+
import { codeFrameColumns } from '@babel/code-frame';
|
|
15
|
+
import { parse } from 'vue-docgen-api';
|
|
16
|
+
import { parse as parse$2 } from '@babel/parser';
|
|
17
|
+
import traverseModule from '@babel/traverse';
|
|
18
|
+
import { parse as parse$1, compileScript as compileScript$1, compileTemplate } from '@vue/compiler-sfc';
|
|
19
|
+
import fs__default, { existsSync, readFileSync, copyFileSync } from 'node:fs';
|
|
20
|
+
import { fileURLToPath } from 'node:url';
|
|
21
|
+
import { compileStringAsync, NodePackageImporter } from 'sass';
|
|
22
|
+
import { t as tsconfigPath } from './tsconfig-path-bG7G_cK8.mjs';
|
|
23
|
+
import esbuild$1, { build } from 'esbuild';
|
|
24
|
+
import { Worker } from 'node:worker_threads';
|
|
25
|
+
import nunjucks from 'nunjucks';
|
|
26
|
+
import express from 'express';
|
|
27
|
+
import 'fs';
|
|
28
|
+
import 'node:events';
|
|
29
|
+
import 'node:stream';
|
|
30
|
+
import 'node:string_decoder';
|
|
31
|
+
import 'typescript';
|
|
32
|
+
import 'constants';
|
|
33
|
+
import 'stream';
|
|
34
|
+
import 'util';
|
|
35
|
+
import 'assert';
|
|
36
|
+
import 'path';
|
|
37
|
+
import 'node:module';
|
|
38
|
+
import 'readline';
|
|
39
|
+
import 'events';
|
|
40
|
+
import 'fs/promises';
|
|
41
|
+
import 'os';
|
|
42
|
+
import 'http';
|
|
43
|
+
import 'https';
|
|
44
|
+
import 'url';
|
|
45
|
+
import 'buffer';
|
|
46
|
+
import 'net';
|
|
47
|
+
import 'tls';
|
|
48
|
+
import 'tty';
|
|
49
|
+
import 'querystring';
|
|
50
|
+
import 'vue';
|
|
51
|
+
import './vue3-BzNzaBbK.mjs';
|
|
52
|
+
|
|
52
53
|
function toArray$2(value) {
|
|
53
54
|
return Array.isArray(value) ? value : [value];
|
|
54
55
|
}
|
|
@@ -103,12 +104,12 @@ function memoize(callback) {
|
|
|
103
104
|
}
|
|
104
105
|
|
|
105
106
|
function fileMatcher(patterns) {
|
|
106
|
-
const fileList =
|
|
107
|
+
const fileList = globSync(patterns, {
|
|
107
108
|
posix: true,
|
|
108
109
|
ignore: "**/node_modules/**"
|
|
109
110
|
});
|
|
110
111
|
return memoize((filename, context) => {
|
|
111
|
-
const matches =
|
|
112
|
+
const matches = minimatch.match(fileList, `**/${filename}`);
|
|
112
113
|
if (matches.length === 0) {
|
|
113
114
|
const additionalInfo = context ? ` (${context})` : "";
|
|
114
115
|
const message = `No files matched pattern "${filename}"${additionalInfo}`;
|
|
@@ -148,7 +149,7 @@ function cleanTitle(text) {
|
|
|
148
149
|
function parseHeading(match) {
|
|
149
150
|
const [, prefix, text] = match;
|
|
150
151
|
const rank = prefix.length;
|
|
151
|
-
const id =
|
|
152
|
+
const id = generateId(text);
|
|
152
153
|
return {
|
|
153
154
|
rank,
|
|
154
155
|
title: cleanTitle(text),
|
|
@@ -216,7 +217,7 @@ function getRepositoryUrl(value) {
|
|
|
216
217
|
|
|
217
218
|
function runCommand(cmd, defaultValue) {
|
|
218
219
|
return new Promise((resolve) => {
|
|
219
|
-
|
|
220
|
+
exec(cmd, { encoding: "utf-8" }, (error, stdout) => {
|
|
220
221
|
if (error) {
|
|
221
222
|
console.error(error);
|
|
222
223
|
resolve(defaultValue);
|
|
@@ -284,10 +285,10 @@ function slugify(value) {
|
|
|
284
285
|
return value.toLowerCase().replace(/\//g, "--").replace(/[^a-z]+/g, "-").replace(/(^-+|-+$)/, "");
|
|
285
286
|
}
|
|
286
287
|
|
|
287
|
-
const md$5 =
|
|
288
|
+
const md$5 = MarkdownIt();
|
|
288
289
|
md$5.renderer.rules.fence = (tokens, idx, _options, collected) => {
|
|
289
290
|
const { content, info } = tokens[idx];
|
|
290
|
-
const { language, tags } =
|
|
291
|
+
const { language, tags } = parseInfostring(info);
|
|
291
292
|
if (language === "import") {
|
|
292
293
|
return "";
|
|
293
294
|
}
|
|
@@ -349,14 +350,14 @@ function extractExamplesProcessor(options) {
|
|
|
349
350
|
);
|
|
350
351
|
}
|
|
351
352
|
await fs.rm(outputFolder, { recursive: true, force: true });
|
|
352
|
-
const docs = context.docs.filter(
|
|
353
|
+
const docs = context.docs.filter(isDocumentPage).filter(haveOutput);
|
|
353
354
|
let total = 0;
|
|
354
355
|
for (const doc of docs) {
|
|
355
356
|
const examples = findExamples$1(doc).filter(isRelevant);
|
|
356
357
|
if (examples.length === 0) {
|
|
357
358
|
continue;
|
|
358
359
|
}
|
|
359
|
-
const dir =
|
|
360
|
+
const dir = normalizePath(outputFolder, doc.fileInfo.fullPath);
|
|
360
361
|
await fs.mkdir(dir, { recursive: true });
|
|
361
362
|
let n = 1;
|
|
362
363
|
for (const example of examples) {
|
|
@@ -373,24 +374,24 @@ function extractExamplesProcessor(options) {
|
|
|
373
374
|
};
|
|
374
375
|
}
|
|
375
376
|
|
|
376
|
-
const md$4 =
|
|
377
|
+
const md$4 = MarkdownIt();
|
|
377
378
|
md$4.renderer.rules.fence = (tokens, idx, _options, collected) => {
|
|
378
379
|
const { content, info, map } = tokens[idx];
|
|
379
|
-
const { language: rawLanguage, tags } =
|
|
380
|
+
const { language: rawLanguage, tags } = parseInfostring(info);
|
|
380
381
|
const hashContent = `${map?.[0]}:${map?.[1]}:${info}:${content}`;
|
|
381
|
-
const fingerprint =
|
|
382
|
+
const fingerprint = getFingerprint(hashContent);
|
|
382
383
|
let extension = void 0;
|
|
383
384
|
let language = rawLanguage;
|
|
384
|
-
if (
|
|
385
|
+
if (hasTag(tags, "compare")) {
|
|
385
386
|
language = "diff";
|
|
386
387
|
}
|
|
387
388
|
if (language === "import") {
|
|
388
389
|
extension = content.split(".").at(-1)?.trim();
|
|
389
390
|
}
|
|
390
|
-
if (
|
|
391
|
+
if (hasTag(tags, "hidden")) {
|
|
391
392
|
return "";
|
|
392
393
|
}
|
|
393
|
-
const name =
|
|
394
|
+
const name = findTag(tags, "name")?.value ?? void 0;
|
|
394
395
|
collected.push({
|
|
395
396
|
name,
|
|
396
397
|
selector: `#example-${fingerprint}`,
|
|
@@ -418,7 +419,7 @@ function findExamples(doc) {
|
|
|
418
419
|
function manifestPageFromDocument(doc) {
|
|
419
420
|
const { body, fileInfo, format } = doc;
|
|
420
421
|
return {
|
|
421
|
-
path:
|
|
422
|
+
path: getOutputFilePath("", fileInfo),
|
|
422
423
|
title: doc.attributes.title ?? doc.name ?? "",
|
|
423
424
|
redirect: format === "redirect" ? body : null,
|
|
424
425
|
outline: flattenOutline(doc.outline),
|
|
@@ -471,7 +472,7 @@ function manifestProcessor(options = {}) {
|
|
|
471
472
|
name: "manifestProcessor",
|
|
472
473
|
before: "render",
|
|
473
474
|
async handler(context) {
|
|
474
|
-
const docs = context.docs.filter(
|
|
475
|
+
const docs = context.docs.filter(isDocumentPage).filter(haveOutput);
|
|
475
476
|
const pages = docs.map(manifestPageFromDocument);
|
|
476
477
|
pages.sort((a, b) => {
|
|
477
478
|
return a.path.localeCompare(b.path);
|
|
@@ -593,8 +594,8 @@ function relative(url, { fileInfo }) {
|
|
|
593
594
|
if (isAbsoluteUrl(url)) {
|
|
594
595
|
url = `.${url}`;
|
|
595
596
|
}
|
|
596
|
-
url =
|
|
597
|
-
const outputPath =
|
|
597
|
+
url = normalizePath(url);
|
|
598
|
+
const outputPath = normalizePath(fileInfo.path);
|
|
598
599
|
if (outputPath === url || `${outputPath}/` === url) {
|
|
599
600
|
return "./";
|
|
600
601
|
}
|
|
@@ -632,15 +633,15 @@ function htmlRedirectProcessor() {
|
|
|
632
633
|
after: "render",
|
|
633
634
|
async handler(context) {
|
|
634
635
|
const { docs, outputFolder } = context;
|
|
635
|
-
for (const doc of docs.filter(
|
|
636
|
+
for (const doc of docs.filter(isDocumentPage).filter(haveOutput)) {
|
|
636
637
|
if (doc.format !== "redirect") {
|
|
637
638
|
continue;
|
|
638
639
|
}
|
|
639
|
-
const filePath =
|
|
640
|
+
const filePath = getOutputFilePath(outputFolder, doc.fileInfo);
|
|
640
641
|
const dst = relative(doc.body, doc);
|
|
641
642
|
const content = template(dst);
|
|
642
643
|
await fs.mkdir(path.dirname(filePath), { recursive: true });
|
|
643
|
-
await fs.writeFile(filePath,
|
|
644
|
+
await fs.writeFile(filePath, dedent(content), "utf-8");
|
|
644
645
|
}
|
|
645
646
|
}
|
|
646
647
|
};
|
|
@@ -655,8 +656,8 @@ function redirectFileProcessor(prefix = "/", filename = "_redirects") {
|
|
|
655
656
|
after: "render",
|
|
656
657
|
async handler(context) {
|
|
657
658
|
const { docs } = context;
|
|
658
|
-
const lines = docs.filter(
|
|
659
|
-
const src =
|
|
659
|
+
const lines = docs.filter(isDocumentPage).filter(haveOutput).filter(isRedirect).map((doc) => {
|
|
660
|
+
const src = normalizePath(
|
|
660
661
|
doc.fileInfo.path,
|
|
661
662
|
doc.fileInfo.outputName
|
|
662
663
|
);
|
|
@@ -673,7 +674,7 @@ function redirectFileProcessor(prefix = "/", filename = "_redirects") {
|
|
|
673
674
|
}
|
|
674
675
|
|
|
675
676
|
function getRedirects(docs) {
|
|
676
|
-
return docs.filter(
|
|
677
|
+
return docs.filter(isDocumentPage).map((it) => {
|
|
677
678
|
const { fileInfo } = it;
|
|
678
679
|
const { path, outputName } = fileInfo;
|
|
679
680
|
if (outputName === false) {
|
|
@@ -682,7 +683,7 @@ function getRedirects(docs) {
|
|
|
682
683
|
return it.attributes.redirectFrom.map((jt) => {
|
|
683
684
|
return {
|
|
684
685
|
from: jt.startsWith("/") ? jt.slice(1) : jt,
|
|
685
|
-
to:
|
|
686
|
+
to: normalizePath(path, outputName)
|
|
686
687
|
};
|
|
687
688
|
});
|
|
688
689
|
}).flat();
|
|
@@ -962,8 +963,8 @@ function getSuggestion(attribute) {
|
|
|
962
963
|
if (manual) {
|
|
963
964
|
return [manual, 0];
|
|
964
965
|
}
|
|
965
|
-
const closestKey =
|
|
966
|
-
const d =
|
|
966
|
+
const closestKey = closest(attribute, documentAttributeKeys);
|
|
967
|
+
const d = distance(attribute, closestKey);
|
|
967
968
|
return [closestKey, d];
|
|
968
969
|
}
|
|
969
970
|
class AttributeError extends Error {
|
|
@@ -982,7 +983,7 @@ class AttributeError extends Error {
|
|
|
982
983
|
const suggestion = d <= threshold ? `Did you mean to use "${closestMatch}"?` : `Unknown attribute "${attribute}"`;
|
|
983
984
|
const location = findLocation(content, attribute);
|
|
984
985
|
if (location) {
|
|
985
|
-
const codeframe =
|
|
986
|
+
const codeframe = codeFrameColumns(content, location, {
|
|
986
987
|
message: suggestion
|
|
987
988
|
});
|
|
988
989
|
return [message, "", codeframe].join("\n");
|
|
@@ -1068,9 +1069,9 @@ function getComponent(attrs) {
|
|
|
1068
1069
|
return toArray$1(attrs.component).map(normalizeComponent);
|
|
1069
1070
|
}
|
|
1070
1071
|
function parseFile$1(filePath, basePath, content) {
|
|
1071
|
-
const relative = basePath ? path$1.relative(basePath,
|
|
1072
|
+
const relative = basePath ? path$1.relative(basePath, normalizePath(filePath)) : normalizePath(filePath);
|
|
1072
1073
|
const parsed = path$1.parse(relative);
|
|
1073
|
-
const blocks =
|
|
1074
|
+
const blocks = fm(content);
|
|
1074
1075
|
const attributes = blocks.attributes;
|
|
1075
1076
|
const isIndex = isIndexPage(parsed);
|
|
1076
1077
|
const filename = isIndex ? "index" : parsed.name.toLowerCase();
|
|
@@ -1104,9 +1105,9 @@ function parseFile$1(filePath, basePath, content) {
|
|
|
1104
1105
|
tags: [],
|
|
1105
1106
|
template: blocks.attributes.layout ?? "default",
|
|
1106
1107
|
fileInfo: {
|
|
1107
|
-
path: ["", "."].includes(urlpath) ? "." : `./${
|
|
1108
|
+
path: ["", "."].includes(urlpath) ? "." : `./${normalizePath(urlpath)}`,
|
|
1108
1109
|
name: filename,
|
|
1109
|
-
fullPath:
|
|
1110
|
+
fullPath: normalizePath(filePath),
|
|
1110
1111
|
outputName: include ? `${filename}.html` : false
|
|
1111
1112
|
}
|
|
1112
1113
|
};
|
|
@@ -1240,7 +1241,7 @@ function translateSlotBindings(slot) {
|
|
|
1240
1241
|
return translatedBindings;
|
|
1241
1242
|
}
|
|
1242
1243
|
async function translateAPI(filePath) {
|
|
1243
|
-
const api = await
|
|
1244
|
+
const api = await parse(filePath);
|
|
1244
1245
|
const props = api.props ? translateProps(api.props) : [];
|
|
1245
1246
|
const events = api.events ? translateEvents(api.events) : [];
|
|
1246
1247
|
const slots = api.slots ? translateSlots(api.slots) : [];
|
|
@@ -1263,7 +1264,7 @@ async function translateAPI(filePath) {
|
|
|
1263
1264
|
};
|
|
1264
1265
|
}
|
|
1265
1266
|
|
|
1266
|
-
const md$3 =
|
|
1267
|
+
const md$3 = MarkdownIt();
|
|
1267
1268
|
const EMPTY_CHAR$3 = "‐";
|
|
1268
1269
|
function render$4(text) {
|
|
1269
1270
|
return text ? md$3.render(text) : EMPTY_CHAR$3;
|
|
@@ -1289,8 +1290,8 @@ function generatePropTable(slug, props) {
|
|
|
1289
1290
|
<code id="${id}"
|
|
1290
1291
|
><a class="docs-api__anchor" href="#${id}"
|
|
1291
1292
|
><span class="docs-api__name"
|
|
1292
|
-
>${
|
|
1293
|
-
>: ${
|
|
1293
|
+
>${htmlencode(name)}</span
|
|
1294
|
+
>: ${htmlencode(prop.type ?? "unknown")}</a
|
|
1294
1295
|
></code
|
|
1295
1296
|
>
|
|
1296
1297
|
${prop.required ? "" : `<span class="docs-tag docs-tag--default">Optional</span>`}
|
|
@@ -1298,7 +1299,7 @@ function generatePropTable(slug, props) {
|
|
|
1298
1299
|
</dt>
|
|
1299
1300
|
<dd>
|
|
1300
1301
|
${render$4(prop.description)}
|
|
1301
|
-
${prop.default ? `<p class="doc-api__item">Default: <code>${
|
|
1302
|
+
${prop.default ? `<p class="doc-api__item">Default: <code>${htmlencode(prop.default.value)}</code></p>` : ""}
|
|
1302
1303
|
${prop.deprecated ? `<p class="doc-api__item docs-deprecated">Deprecated: ${renderInline$3(prop.deprecated)}</p>` : ""}
|
|
1303
1304
|
</dd>
|
|
1304
1305
|
`
|
|
@@ -1309,7 +1310,7 @@ function generatePropTable(slug, props) {
|
|
|
1309
1310
|
);
|
|
1310
1311
|
}
|
|
1311
1312
|
|
|
1312
|
-
const md$2 =
|
|
1313
|
+
const md$2 = MarkdownIt();
|
|
1313
1314
|
const EMPTY_CHAR$2 = "‐";
|
|
1314
1315
|
const EM_DASH$2 = `<span role="presentation">—</span>`;
|
|
1315
1316
|
function render$3(text) {
|
|
@@ -1337,7 +1338,7 @@ function generateEventTable(slug, events) {
|
|
|
1337
1338
|
<code id="${id}"
|
|
1338
1339
|
><a class="docs-api__anchor" href="#${id}"
|
|
1339
1340
|
><span class="docs-api__name"
|
|
1340
|
-
>${
|
|
1341
|
+
>${htmlencode(name)}</span
|
|
1341
1342
|
></a
|
|
1342
1343
|
></code
|
|
1343
1344
|
>
|
|
@@ -1348,9 +1349,9 @@ function generateEventTable(slug, events) {
|
|
|
1348
1349
|
${haveProperties ? `<p class="docs-api__list-title">Arguments:</p><ul class="docs-api__list">` : ""}
|
|
1349
1350
|
${event.properties.map((it) => {
|
|
1350
1351
|
if (it.description) {
|
|
1351
|
-
return `<li><code>${
|
|
1352
|
+
return `<li><code>${htmlencode(it.name)}: ${htmlencode(it.type ?? "unknown")}</code> ${EM_DASH$2} ${renderInline$2(it.description)}</li>`;
|
|
1352
1353
|
} else {
|
|
1353
|
-
return `<li><code>${
|
|
1354
|
+
return `<li><code>${htmlencode(it.name)}: ${htmlencode(it.type ?? "unknown")}</code></li>`;
|
|
1354
1355
|
}
|
|
1355
1356
|
}).join("")}
|
|
1356
1357
|
${haveProperties ? `</ul>` : ""}
|
|
@@ -1364,7 +1365,7 @@ function generateEventTable(slug, events) {
|
|
|
1364
1365
|
);
|
|
1365
1366
|
}
|
|
1366
1367
|
|
|
1367
|
-
const md$1 =
|
|
1368
|
+
const md$1 = MarkdownIt();
|
|
1368
1369
|
const EMPTY_CHAR$1 = "‐";
|
|
1369
1370
|
const EM_DASH$1 = `<span role="presentation">—</span>`;
|
|
1370
1371
|
function render$2(text) {
|
|
@@ -1392,7 +1393,7 @@ function generateSlotTable(slug, slots) {
|
|
|
1392
1393
|
<code id="${id}"
|
|
1393
1394
|
><a class="docs-api__anchor" href="#${id}"
|
|
1394
1395
|
><span class="docs-api__name"
|
|
1395
|
-
>${
|
|
1396
|
+
>${htmlencode(name)}</span
|
|
1396
1397
|
></a
|
|
1397
1398
|
></code
|
|
1398
1399
|
>
|
|
@@ -1403,9 +1404,9 @@ function generateSlotTable(slug, slots) {
|
|
|
1403
1404
|
${haveBindings ? `<p class="docs-api__list-title">Bindings:</p><ul class="docs-api__list">` : ""}
|
|
1404
1405
|
${slot.bindings.map((it) => {
|
|
1405
1406
|
if (it.description) {
|
|
1406
|
-
return `<li><code>${
|
|
1407
|
+
return `<li><code>${htmlencode(it.name)}: ${htmlencode(it.type ?? "unknown")}</code> ${EM_DASH$1} ${renderInline$1(it.description)}</li>`;
|
|
1407
1408
|
} else {
|
|
1408
|
-
return `<li><code>${
|
|
1409
|
+
return `<li><code>${htmlencode(it.name)}: ${htmlencode(it.type ?? "unknown")}</code></li>`;
|
|
1409
1410
|
}
|
|
1410
1411
|
}).join("")}
|
|
1411
1412
|
${haveBindings ? `</ul>` : ""}
|
|
@@ -1521,9 +1522,9 @@ function findDocComment(path, node) {
|
|
|
1521
1522
|
return null;
|
|
1522
1523
|
}
|
|
1523
1524
|
function findTranslations(filename, content) {
|
|
1524
|
-
const { descriptor, errors } =
|
|
1525
|
+
const { descriptor, errors } = parse$1(content, { filename });
|
|
1525
1526
|
if (errors.length > 0) {
|
|
1526
|
-
if (
|
|
1527
|
+
if (isCI) {
|
|
1527
1528
|
const first = errors[0].message;
|
|
1528
1529
|
throw new Error(
|
|
1529
1530
|
`Errors occurred when trying to parse "${filename}": ${first}`
|
|
@@ -1535,7 +1536,7 @@ function findTranslations(filename, content) {
|
|
|
1535
1536
|
let sourcecode = "";
|
|
1536
1537
|
let bindings = void 0;
|
|
1537
1538
|
if (descriptor.script || descriptor.scriptSetup) {
|
|
1538
|
-
const script =
|
|
1539
|
+
const script = compileScript$1(descriptor, {
|
|
1539
1540
|
id,
|
|
1540
1541
|
isProd: false,
|
|
1541
1542
|
sourceMap: false,
|
|
@@ -1558,7 +1559,7 @@ function findTranslations(filename, content) {
|
|
|
1558
1559
|
`;
|
|
1559
1560
|
}
|
|
1560
1561
|
if (descriptor.template) {
|
|
1561
|
-
const template =
|
|
1562
|
+
const template = compileTemplate({
|
|
1562
1563
|
id,
|
|
1563
1564
|
filename,
|
|
1564
1565
|
source: descriptor.template.content,
|
|
@@ -1575,7 +1576,7 @@ function findTranslations(filename, content) {
|
|
|
1575
1576
|
|
|
1576
1577
|
`;
|
|
1577
1578
|
}
|
|
1578
|
-
const ast =
|
|
1579
|
+
const ast = parse$2(sourcecode, {
|
|
1579
1580
|
sourceType: "module",
|
|
1580
1581
|
plugins: ["typescript"]
|
|
1581
1582
|
});
|
|
@@ -1605,7 +1606,7 @@ function findTranslations(filename, content) {
|
|
|
1605
1606
|
return result;
|
|
1606
1607
|
}
|
|
1607
1608
|
|
|
1608
|
-
const md =
|
|
1609
|
+
const md = MarkdownIt();
|
|
1609
1610
|
const EMPTY_CHAR = "‐";
|
|
1610
1611
|
const EM_DASH = `<span role="presentation">—</span>`;
|
|
1611
1612
|
function render$1(text) {
|
|
@@ -1630,20 +1631,20 @@ function generateTranslationTable(slug, translations) {
|
|
|
1630
1631
|
<code id="${id}"
|
|
1631
1632
|
><a class="docs-api__anchor" href="#${id}"
|
|
1632
1633
|
><span class="docs-api__name"
|
|
1633
|
-
>${
|
|
1634
|
+
>${htmlencode(name)}</span
|
|
1634
1635
|
></a
|
|
1635
1636
|
></code
|
|
1636
1637
|
>
|
|
1637
1638
|
</dt>
|
|
1638
1639
|
<dd>
|
|
1639
1640
|
${render$1(translation.description)}
|
|
1640
|
-
${translation.defaultTranslation ? `<p class="doc-api__item">Default: "${
|
|
1641
|
+
${translation.defaultTranslation ? `<p class="doc-api__item">Default: "${htmlencode(translation.defaultTranslation)}"</p>` : ""}
|
|
1641
1642
|
${haveParameters ? `<p class="docs-api__list-title">Parameters:</p><ul class="docs-api__list">` : ""}
|
|
1642
1643
|
${translation.parameters.map((it) => {
|
|
1643
1644
|
if (it.description) {
|
|
1644
|
-
return `<li><code>${
|
|
1645
|
+
return `<li><code>${htmlencode(it.name)}</code> ${EM_DASH} ${renderInline(it.description)}</li>`;
|
|
1645
1646
|
} else {
|
|
1646
|
-
return `<li><code>${
|
|
1647
|
+
return `<li><code>${htmlencode(it.name)}</code></li>`;
|
|
1647
1648
|
}
|
|
1648
1649
|
}).join("")}
|
|
1649
1650
|
${haveParameters ? `</ul>` : ""}
|
|
@@ -1657,7 +1658,7 @@ function generateTranslationTable(slug, translations) {
|
|
|
1657
1658
|
}
|
|
1658
1659
|
|
|
1659
1660
|
function parseAPI(filePath, api) {
|
|
1660
|
-
const relative =
|
|
1661
|
+
const relative = normalizePath(filePath);
|
|
1661
1662
|
const parsedPath = path$1.parse(relative);
|
|
1662
1663
|
const componentName = parsedPath.name;
|
|
1663
1664
|
let html = "";
|
|
@@ -1683,7 +1684,7 @@ function parseAPI(filePath, api) {
|
|
|
1683
1684
|
};
|
|
1684
1685
|
}
|
|
1685
1686
|
async function parseTranslation(slug, filePath) {
|
|
1686
|
-
const relative =
|
|
1687
|
+
const relative = normalizePath(filePath);
|
|
1687
1688
|
const parsedPath = path$1.parse(relative);
|
|
1688
1689
|
const componentName = parsedPath.name;
|
|
1689
1690
|
const content = await fs.readFile(filePath, "utf-8");
|
|
@@ -1717,7 +1718,7 @@ async function globAll(pattern) {
|
|
|
1717
1718
|
return globAll([pattern]);
|
|
1718
1719
|
}
|
|
1719
1720
|
const results = await Promise.all(
|
|
1720
|
-
pattern.map((it) =>
|
|
1721
|
+
pattern.map((it) => glob(it, { nodir: true }))
|
|
1721
1722
|
);
|
|
1722
1723
|
return new Set(results.flat());
|
|
1723
1724
|
}
|
|
@@ -1759,7 +1760,7 @@ function parseFile(filePath, basePath, content) {
|
|
|
1759
1760
|
if (!title) {
|
|
1760
1761
|
throw new Error(`No title property set in "${filePath}"`);
|
|
1761
1762
|
}
|
|
1762
|
-
const relative = basePath ? path$1.relative(basePath,
|
|
1763
|
+
const relative = basePath ? path$1.relative(basePath, normalizePath(filePath)) : normalizePath(filePath);
|
|
1763
1764
|
const parsed = path$1.parse(relative);
|
|
1764
1765
|
const filename = parsed.name.toLowerCase();
|
|
1765
1766
|
const name = parsed.name;
|
|
@@ -1783,9 +1784,9 @@ function parseFile(filePath, basePath, content) {
|
|
|
1783
1784
|
tags: [],
|
|
1784
1785
|
template: "default",
|
|
1785
1786
|
fileInfo: {
|
|
1786
|
-
path: ["", "."].includes(urlpath) ? "." : `./${
|
|
1787
|
+
path: ["", "."].includes(urlpath) ? "." : `./${normalizePath(urlpath)}`,
|
|
1787
1788
|
name: filename,
|
|
1788
|
-
fullPath:
|
|
1789
|
+
fullPath: normalizePath(filePath),
|
|
1789
1790
|
outputName: false
|
|
1790
1791
|
}
|
|
1791
1792
|
};
|
|
@@ -1797,9 +1798,9 @@ async function navigationFileReader(filePath, basePath) {
|
|
|
1797
1798
|
}
|
|
1798
1799
|
|
|
1799
1800
|
async function compileSassString(dst, style) {
|
|
1800
|
-
const result = await
|
|
1801
|
+
const result = await compileStringAsync(style, {
|
|
1801
1802
|
style: "expanded",
|
|
1802
|
-
importers: [new
|
|
1803
|
+
importers: [new NodePackageImporter(), moduleImporter]
|
|
1803
1804
|
});
|
|
1804
1805
|
await fs.mkdir(path$1.dirname(dst), { recursive: true });
|
|
1805
1806
|
await fs.writeFile(dst, result.css, "utf-8");
|
|
@@ -1811,7 +1812,7 @@ async function compileStyle(assetFolder, name, src) {
|
|
|
1811
1812
|
const source = await fs.readFile(src, "utf-8");
|
|
1812
1813
|
await compileSassString(outfile, source);
|
|
1813
1814
|
const content = await fs.readFile(outfile, "utf-8");
|
|
1814
|
-
const fingerprint =
|
|
1815
|
+
const fingerprint = getFingerprint(content);
|
|
1815
1816
|
const integrity = getIntegrity(content);
|
|
1816
1817
|
const filename = `${name}-${fingerprint}.css`;
|
|
1817
1818
|
const dst = path.join(assetFolder, filename);
|
|
@@ -1875,7 +1876,7 @@ function cssAssetProcessor(assetFolder, assets) {
|
|
|
1875
1876
|
}
|
|
1876
1877
|
|
|
1877
1878
|
function esbuild(options) {
|
|
1878
|
-
return
|
|
1879
|
+
return build(options);
|
|
1879
1880
|
}
|
|
1880
1881
|
|
|
1881
1882
|
function toExternalVendor(vendor) {
|
|
@@ -1893,7 +1894,7 @@ async function compileScript(options) {
|
|
|
1893
1894
|
} = options;
|
|
1894
1895
|
const iconLib = process.env.DOCS_ICON_LIB ?? "@fkui/icon-lib-default";
|
|
1895
1896
|
try {
|
|
1896
|
-
const entryPoints = [src instanceof URL ?
|
|
1897
|
+
const entryPoints = [src instanceof URL ? fileURLToPath(src) : src];
|
|
1897
1898
|
const outfile = path$1.join("temp", `asset-${name}.js`);
|
|
1898
1899
|
const external = [...assets, ...vendor.map(toExternalVendor)];
|
|
1899
1900
|
const format = buildOptions.format ?? "esm";
|
|
@@ -1904,7 +1905,7 @@ async function compileScript(options) {
|
|
|
1904
1905
|
format,
|
|
1905
1906
|
platform: "browser",
|
|
1906
1907
|
external,
|
|
1907
|
-
tsconfig:
|
|
1908
|
+
tsconfig: tsconfigPath,
|
|
1908
1909
|
...buildOptions,
|
|
1909
1910
|
define: {
|
|
1910
1911
|
"process.env.DOCS_ICON_LIB": JSON.stringify(iconLib),
|
|
@@ -1912,7 +1913,7 @@ async function compileScript(options) {
|
|
|
1912
1913
|
}
|
|
1913
1914
|
});
|
|
1914
1915
|
const content = await fs$1.readFile(outfile, "utf-8");
|
|
1915
|
-
const fingerprint =
|
|
1916
|
+
const fingerprint = getFingerprint(content);
|
|
1916
1917
|
const integrity = getIntegrity(content);
|
|
1917
1918
|
const filename = `${name}-${fingerprint}.js`;
|
|
1918
1919
|
const dst = path$1.join(assetFolder, filename);
|
|
@@ -2019,8 +2020,8 @@ function compileProcessorRuntime(generator, distDir, processors) {
|
|
|
2019
2020
|
entry.name ?? path$1.parse(entry.src).name
|
|
2020
2021
|
].join("/");
|
|
2021
2022
|
const name = processorRuntimeName(processor, entry);
|
|
2022
|
-
const bundled = new URL(`${name}.
|
|
2023
|
-
const scriptPath =
|
|
2023
|
+
const bundled = new URL(`${name}.mjs`, distDir);
|
|
2024
|
+
const scriptPath = existsSync(bundled) ? bundled : entry.src;
|
|
2024
2025
|
generator.compileScript(
|
|
2025
2026
|
assetName,
|
|
2026
2027
|
scriptPath,
|
|
@@ -2206,7 +2207,7 @@ function navigationProcessor() {
|
|
|
2206
2207
|
stage: "generate-nav",
|
|
2207
2208
|
name: "navigation-processor",
|
|
2208
2209
|
handler(context) {
|
|
2209
|
-
const pages = context.docs.filter(
|
|
2210
|
+
const pages = context.docs.filter(isDocumentPage);
|
|
2210
2211
|
const navtree = generateNavtree(pages);
|
|
2211
2212
|
context.setTopNavigation(navtree);
|
|
2212
2213
|
context.setSideNavigation(navtree);
|
|
@@ -2238,12 +2239,15 @@ function sortNavigationTree(tree) {
|
|
|
2238
2239
|
}
|
|
2239
2240
|
}
|
|
2240
2241
|
|
|
2242
|
+
const templateUrl = new URL("../templates", import.meta.url);
|
|
2243
|
+
const templateDirectory = fileURLToPath(templateUrl);
|
|
2244
|
+
|
|
2241
2245
|
class TemplateLoader {
|
|
2242
2246
|
async = true;
|
|
2243
2247
|
folders;
|
|
2244
2248
|
templateCache;
|
|
2245
2249
|
constructor(folders = []) {
|
|
2246
|
-
this.folders = [...folders,
|
|
2250
|
+
this.folders = [...folders, templateDirectory];
|
|
2247
2251
|
this.templateCache = /* @__PURE__ */ new Map();
|
|
2248
2252
|
}
|
|
2249
2253
|
async getSource(name, callback) {
|
|
@@ -2295,7 +2299,7 @@ Make sure the name is correct and the template file exists in one of the listed
|
|
|
2295
2299
|
findTemplateFile(name) {
|
|
2296
2300
|
const { folders } = this;
|
|
2297
2301
|
const searchPaths = folders.map((it) => path$1.join(it, name));
|
|
2298
|
-
return searchPaths.find((it) =>
|
|
2302
|
+
return searchPaths.find((it) => existsSync(it));
|
|
2299
2303
|
}
|
|
2300
2304
|
}
|
|
2301
2305
|
|
|
@@ -2316,7 +2320,6 @@ class MissingTemplateError extends Error {
|
|
|
2316
2320
|
].join("\n");
|
|
2317
2321
|
}
|
|
2318
2322
|
}
|
|
2319
|
-
const templateDirectory = path$1.join(__dirname, "../templates");
|
|
2320
2323
|
const cache$1 = /* @__PURE__ */ new Map();
|
|
2321
2324
|
function cacheKey(layout, extension) {
|
|
2322
2325
|
return [layout, extension].join("|");
|
|
@@ -2340,7 +2343,7 @@ function findTemplate(folders, from, src, format) {
|
|
|
2340
2343
|
const searchPaths = folders.map((it) => {
|
|
2341
2344
|
return path$1.join(it, template);
|
|
2342
2345
|
});
|
|
2343
|
-
const found = searchPaths.find((it) =>
|
|
2346
|
+
const found = searchPaths.find((it) => fs__default.existsSync(it));
|
|
2344
2347
|
if (!found) {
|
|
2345
2348
|
throw new MissingTemplateError(from, template, format, folders);
|
|
2346
2349
|
}
|
|
@@ -2378,7 +2381,9 @@ class TemplateRenderError extends Error {
|
|
|
2378
2381
|
}
|
|
2379
2382
|
}
|
|
2380
2383
|
|
|
2381
|
-
const
|
|
2384
|
+
const exampleWorker = new Worker(exampleWorkerUrl);
|
|
2385
|
+
exampleWorker.unref();
|
|
2386
|
+
let taskRef = 1;
|
|
2382
2387
|
let loader = null;
|
|
2383
2388
|
function haveOutputFile(fileInfo) {
|
|
2384
2389
|
return fileInfo.outputName !== false;
|
|
@@ -2414,8 +2419,8 @@ function cache(cacheFolder, outputFolder) {
|
|
|
2414
2419
|
return (it) => {
|
|
2415
2420
|
const cacheFile = path$1.join(cacheFolder, it.outputFile);
|
|
2416
2421
|
const outputFile = path$1.join(outputFolder, it.outputFile);
|
|
2417
|
-
if (
|
|
2418
|
-
|
|
2422
|
+
if (existsSync(cacheFile)) {
|
|
2423
|
+
copyFileSync(cacheFile, outputFile);
|
|
2419
2424
|
return false;
|
|
2420
2425
|
} else {
|
|
2421
2426
|
return true;
|
|
@@ -2438,17 +2443,29 @@ async function compileExamples(options) {
|
|
|
2438
2443
|
if (dirtyTasks.length === 0) {
|
|
2439
2444
|
return;
|
|
2440
2445
|
}
|
|
2441
|
-
const
|
|
2446
|
+
const ref = taskRef++;
|
|
2447
|
+
const message = {
|
|
2448
|
+
message: "compile",
|
|
2449
|
+
ref,
|
|
2442
2450
|
outputFolder,
|
|
2443
2451
|
external,
|
|
2444
2452
|
tasks: dirtyTasks
|
|
2445
2453
|
};
|
|
2446
|
-
|
|
2447
|
-
|
|
2454
|
+
return new Promise((resolve, reject) => {
|
|
2455
|
+
function onmessage(message2) {
|
|
2456
|
+
if (message2.ref === ref) {
|
|
2457
|
+
exampleWorker.off("message", onmessage);
|
|
2458
|
+
exampleWorker.off("error", onerror);
|
|
2459
|
+
resolve();
|
|
2460
|
+
}
|
|
2461
|
+
}
|
|
2462
|
+
function onerror(err) {
|
|
2463
|
+
reject(err);
|
|
2464
|
+
}
|
|
2465
|
+
exampleWorker.on("message", onmessage);
|
|
2466
|
+
exampleWorker.on("error", onerror);
|
|
2467
|
+
exampleWorker.postMessage(message);
|
|
2448
2468
|
});
|
|
2449
|
-
if (result.output.length > 0) {
|
|
2450
|
-
console.log(result.output);
|
|
2451
|
-
}
|
|
2452
2469
|
}
|
|
2453
2470
|
async function compileStandalones(options) {
|
|
2454
2471
|
const { fileInfo, tasks, renderTemplate, templateData, templateFolders } = options;
|
|
@@ -2486,7 +2503,7 @@ async function render(doc, docs, nav, vendors, options) {
|
|
|
2486
2503
|
if (!haveOutputFile(fileInfo)) {
|
|
2487
2504
|
return null;
|
|
2488
2505
|
}
|
|
2489
|
-
const dst =
|
|
2506
|
+
const dst = getOutputFilePath(outputFolder, fileInfo);
|
|
2490
2507
|
const mkdir = fs.mkdir(path$1.dirname(dst), { recursive: true });
|
|
2491
2508
|
const topnav = nav.topnav;
|
|
2492
2509
|
const sidenav = findSidenav(doc, nav.sidenav);
|
|
@@ -2494,7 +2511,7 @@ async function render(doc, docs, nav, vendors, options) {
|
|
|
2494
2511
|
sortNavigationTree(sidenav);
|
|
2495
2512
|
}
|
|
2496
2513
|
const njk = new nunjucks.Environment(loader, { autoescape: false });
|
|
2497
|
-
const asyncRender =
|
|
2514
|
+
const asyncRender = promisify(njk.render);
|
|
2498
2515
|
const renderTemplate = asyncRender.bind(njk);
|
|
2499
2516
|
const template = findTemplate(templateFolders, doc.fileInfo, doc);
|
|
2500
2517
|
const templateData = {
|
|
@@ -2539,10 +2556,10 @@ async function render(doc, docs, nav, vendors, options) {
|
|
|
2539
2556
|
};
|
|
2540
2557
|
const generatedExamples = [];
|
|
2541
2558
|
const generatedStandalone = [];
|
|
2542
|
-
const markdownRenderer = createMarkdownRenderer
|
|
2559
|
+
const markdownRenderer = createMarkdownRenderer({
|
|
2543
2560
|
docs,
|
|
2544
2561
|
generateExample({ source, language, filename, tags }) {
|
|
2545
|
-
const example =
|
|
2562
|
+
const example = generateExample({
|
|
2546
2563
|
source,
|
|
2547
2564
|
language,
|
|
2548
2565
|
filename,
|
|
@@ -2567,10 +2584,10 @@ async function render(doc, docs, nav, vendors, options) {
|
|
|
2567
2584
|
getImportedSource(filename) {
|
|
2568
2585
|
const context = `when importing example from "${fileInfo.fullPath}"`;
|
|
2569
2586
|
const match = fileMatcher(filename, context);
|
|
2570
|
-
return
|
|
2587
|
+
return readFileSync(match, "utf-8");
|
|
2571
2588
|
},
|
|
2572
2589
|
addResource(dst2, src) {
|
|
2573
|
-
if (!
|
|
2590
|
+
if (!existsSync(src)) {
|
|
2574
2591
|
throw new Error(`Failed to find image "${src}"`);
|
|
2575
2592
|
}
|
|
2576
2593
|
options.addResource(dst2, src);
|
|
@@ -2632,7 +2649,7 @@ async function render(doc, docs, nav, vendors, options) {
|
|
|
2632
2649
|
}
|
|
2633
2650
|
const expandedDst = dst.replace(/\[([^]+)\]/g, (match, key) => {
|
|
2634
2651
|
if (key === "hash") {
|
|
2635
|
-
return
|
|
2652
|
+
return getFingerprint(doc.body);
|
|
2636
2653
|
} else {
|
|
2637
2654
|
return match;
|
|
2638
2655
|
}
|
|
@@ -2674,7 +2691,7 @@ async function render(doc, docs, nav, vendors, options) {
|
|
|
2674
2691
|
return dst;
|
|
2675
2692
|
}
|
|
2676
2693
|
|
|
2677
|
-
const progressbar = new
|
|
2694
|
+
const progressbar = new cliProgress.SingleBar({
|
|
2678
2695
|
format: " {bar} {percentage}% | {value}/{total} documents | {filename}",
|
|
2679
2696
|
barCompleteChar: "\u2588",
|
|
2680
2697
|
barIncompleteChar: "\u2591",
|
|
@@ -2701,7 +2718,7 @@ function nunjucksProcessor(options) {
|
|
|
2701
2718
|
});
|
|
2702
2719
|
}
|
|
2703
2720
|
const formats = ["markdown", "json"];
|
|
2704
|
-
const docs = context.docs.filter(
|
|
2721
|
+
const docs = context.docs.filter(isDocumentPage).filter((it) => {
|
|
2705
2722
|
if (!formats.includes(it.format)) {
|
|
2706
2723
|
return false;
|
|
2707
2724
|
}
|
|
@@ -2780,7 +2797,6 @@ async function compileVendor(assetFolder, vendor, options) {
|
|
|
2780
2797
|
const outfile = `temp/vendor-${slug}.out.js`;
|
|
2781
2798
|
const tmpfile = `temp/vendor-${slug}.in.js`;
|
|
2782
2799
|
const source = getAssetSource(vendor);
|
|
2783
|
-
const tsconfig = path$1.resolve(__dirname, "../tsconfig-examples.json");
|
|
2784
2800
|
await fs.writeFile(tmpfile, source, "utf-8");
|
|
2785
2801
|
await esbuild$1.build({
|
|
2786
2802
|
entryPoints: [tmpfile],
|
|
@@ -2788,7 +2804,7 @@ async function compileVendor(assetFolder, vendor, options) {
|
|
|
2788
2804
|
bundle: true,
|
|
2789
2805
|
format: "esm",
|
|
2790
2806
|
platform: "browser",
|
|
2791
|
-
tsconfig,
|
|
2807
|
+
tsconfig: tsconfigPath,
|
|
2792
2808
|
define: {
|
|
2793
2809
|
"process.env.NODE_ENV": JSON.stringify("development"),
|
|
2794
2810
|
__VUE_OPTIONS_API__: "true",
|
|
@@ -2799,7 +2815,7 @@ async function compileVendor(assetFolder, vendor, options) {
|
|
|
2799
2815
|
...options
|
|
2800
2816
|
});
|
|
2801
2817
|
const content = await fs.readFile(outfile, "utf-8");
|
|
2802
|
-
const fingerprint =
|
|
2818
|
+
const fingerprint = getFingerprint(content);
|
|
2803
2819
|
const integrity = getIntegrity(content);
|
|
2804
2820
|
const filename = `vendor-${slug}-${fingerprint}.js`;
|
|
2805
2821
|
const dst = path$1.join(assetFolder, filename).replace(/\\/g, "/");
|
|
@@ -2925,9 +2941,9 @@ async function serve(options) {
|
|
|
2925
2941
|
app.use(express.static(options.outputFolder));
|
|
2926
2942
|
const server = app.listen(8080);
|
|
2927
2943
|
printMenu(server.address());
|
|
2928
|
-
const livereload =
|
|
2944
|
+
const livereload = tinylr();
|
|
2929
2945
|
livereload.listen(35729);
|
|
2930
|
-
const watcher =
|
|
2946
|
+
const watcher = watch(options.watch);
|
|
2931
2947
|
const rebuild = createRebuilder(options.rebuild, (filePath) => {
|
|
2932
2948
|
const files = filePath.map((it) => {
|
|
2933
2949
|
return path.relative(options.outputFolder, it);
|
|
@@ -3097,7 +3113,17 @@ function createContext(outputFolder, templateLoader) {
|
|
|
3097
3113
|
}
|
|
3098
3114
|
};
|
|
3099
3115
|
}
|
|
3116
|
+
function getWorkingDir(value) {
|
|
3117
|
+
if (value) {
|
|
3118
|
+
const url = typeof value === "string" ? new URL(value) : value;
|
|
3119
|
+
const normalized = normalizePath(fileURLToPath(url));
|
|
3120
|
+
return path$1.posix.dirname(normalized);
|
|
3121
|
+
} else {
|
|
3122
|
+
return normalizePath(process.cwd());
|
|
3123
|
+
}
|
|
3124
|
+
}
|
|
3100
3125
|
class Generator {
|
|
3126
|
+
cwd;
|
|
3101
3127
|
site;
|
|
3102
3128
|
outputFolder;
|
|
3103
3129
|
cacheFolder;
|
|
@@ -3112,10 +3138,18 @@ class Generator {
|
|
|
3112
3138
|
resources;
|
|
3113
3139
|
sourceFiles;
|
|
3114
3140
|
markdownOptions;
|
|
3115
|
-
constructor(
|
|
3141
|
+
constructor(...args) {
|
|
3142
|
+
const cwd = getWorkingDir(args.length === 2 ? args[0] : null);
|
|
3143
|
+
const options = args.length === 2 ? args[1] : args[0];
|
|
3144
|
+
if (args.length === 1) {
|
|
3145
|
+
console.error(
|
|
3146
|
+
"[docs-generator] deprecated: not passing import.meta.url as the first argument is deprecated, assuming `process.cwd()`."
|
|
3147
|
+
);
|
|
3148
|
+
}
|
|
3116
3149
|
if (typeof options.site === "undefined") {
|
|
3117
3150
|
throw new Error("site metadata not set in configuration");
|
|
3118
3151
|
}
|
|
3152
|
+
this.cwd = cwd;
|
|
3119
3153
|
this.site = options.site;
|
|
3120
3154
|
this.outputFolder = options.outputFolder ?? "./public";
|
|
3121
3155
|
this.cacheFolder = options.cacheFolder ?? "./temp/docs";
|
|
@@ -3130,7 +3164,7 @@ class Generator {
|
|
|
3130
3164
|
this.resources = [];
|
|
3131
3165
|
this.sourceFiles = [];
|
|
3132
3166
|
this.markdownOptions = options.markdown;
|
|
3133
|
-
const bootstrapUrl = new URL("runtime-bootstrap.
|
|
3167
|
+
const bootstrapUrl = new URL("runtime-bootstrap.mjs", import.meta.url);
|
|
3134
3168
|
this.compileScript(
|
|
3135
3169
|
"bootstrap",
|
|
3136
3170
|
bootstrapUrl,
|
|
@@ -3198,7 +3232,7 @@ class Generator {
|
|
|
3198
3232
|
const templateLoader = createTemplateLoader([]);
|
|
3199
3233
|
const context = createContext("", templateLoader);
|
|
3200
3234
|
await stage("generate-docs", context, processors, { verbose: false });
|
|
3201
|
-
const docs = context.docs.filter(
|
|
3235
|
+
const docs = context.docs.filter(isDocumentPage).filter(haveOutput);
|
|
3202
3236
|
const pages = docs.map(manifestPageFromDocument);
|
|
3203
3237
|
return { pages };
|
|
3204
3238
|
}
|
|
@@ -3215,7 +3249,7 @@ class Generator {
|
|
|
3215
3249
|
markdownOptions
|
|
3216
3250
|
} = this;
|
|
3217
3251
|
const examplePatterns = this.exampleFolders.map((it) => `${it}/**/*`);
|
|
3218
|
-
const i18n =
|
|
3252
|
+
const i18n = createInstance({
|
|
3219
3253
|
lng: site.lang,
|
|
3220
3254
|
fallbackLng: "en",
|
|
3221
3255
|
resources: {
|
|
@@ -3249,7 +3283,7 @@ class Generator {
|
|
|
3249
3283
|
}),
|
|
3250
3284
|
...this.processors
|
|
3251
3285
|
];
|
|
3252
|
-
compileProcessorRuntime(this,
|
|
3286
|
+
compileProcessorRuntime(this, import.meta.url, processors);
|
|
3253
3287
|
const templateLoader = createTemplateLoader(templateFolders);
|
|
3254
3288
|
const context = createContext(outputFolder, templateLoader);
|
|
3255
3289
|
const generatedFiles = [
|
|
@@ -3277,9 +3311,9 @@ class Generator {
|
|
|
3277
3311
|
async _prepareFolders() {
|
|
3278
3312
|
const { outputFolder, cacheFolder, assetFolder } = this;
|
|
3279
3313
|
await fs.rm(cacheFolder, { force: true, recursive: true });
|
|
3280
|
-
if (
|
|
3314
|
+
if (existsSync(outputFolder)) {
|
|
3281
3315
|
await fs.mkdir(path$1.dirname(cacheFolder), { recursive: true });
|
|
3282
|
-
await
|
|
3316
|
+
await fse.copy(outputFolder, cacheFolder);
|
|
3283
3317
|
await fs.rm(outputFolder, { recursive: true });
|
|
3284
3318
|
}
|
|
3285
3319
|
await fs.mkdir(outputFolder, { recursive: true });
|
|
@@ -3332,7 +3366,7 @@ function isIndexable(doc) {
|
|
|
3332
3366
|
}
|
|
3333
3367
|
function getTerms(doc) {
|
|
3334
3368
|
return {
|
|
3335
|
-
url:
|
|
3369
|
+
url: getOutputFilePath(".", doc.fileInfo) ?? "",
|
|
3336
3370
|
title: doc.attributes.title ?? doc.name,
|
|
3337
3371
|
terms: [
|
|
3338
3372
|
...doc.attributes.search.terms,
|
|
@@ -3346,10 +3380,10 @@ function searchProcessor() {
|
|
|
3346
3380
|
after: "generate-docs",
|
|
3347
3381
|
name: "search-processor",
|
|
3348
3382
|
handler(context) {
|
|
3349
|
-
const entries = context.docs.filter(
|
|
3383
|
+
const entries = context.docs.filter(isDocumentPage).filter(isIndexable).map(getTerms);
|
|
3350
3384
|
const index = generateIndex(entries);
|
|
3351
3385
|
const body = JSON.stringify(index, null, 2);
|
|
3352
|
-
const fingerprint =
|
|
3386
|
+
const fingerprint = getFingerprint(body);
|
|
3353
3387
|
const integrity = getIntegrity(body);
|
|
3354
3388
|
const outputName = `search-data-[hash].json`;
|
|
3355
3389
|
const expandedName = `search-data-${fingerprint}.json`;
|
|
@@ -3391,26 +3425,5 @@ function searchProcessor() {
|
|
|
3391
3425
|
};
|
|
3392
3426
|
}
|
|
3393
3427
|
|
|
3394
|
-
|
|
3395
|
-
|
|
3396
|
-
exports.cookieProcessor = cookieProcessor;
|
|
3397
|
-
exports.defineSources = defineSources;
|
|
3398
|
-
exports.extractExamplesProcessor = extractExamplesProcessor;
|
|
3399
|
-
exports.frontMatterFileReader = frontMatterFileReader;
|
|
3400
|
-
exports.htmlRedirectProcessor = htmlRedirectProcessor;
|
|
3401
|
-
exports.livereloadProcessor = livereloadProcessor;
|
|
3402
|
-
exports.manifestProcessor = manifestProcessor;
|
|
3403
|
-
exports.matomoProcessor = matomoProcessor;
|
|
3404
|
-
exports.motdProcessor = motdProcessor;
|
|
3405
|
-
exports.navigationFileReader = navigationFileReader;
|
|
3406
|
-
exports.processorRuntimeName = processorRuntimeName;
|
|
3407
|
-
exports.redirectFileProcessor = redirectFileProcessor;
|
|
3408
|
-
exports.searchProcessor = searchProcessor;
|
|
3409
|
-
exports.selectableVersionProcessor = selectableVersionProcessor;
|
|
3410
|
-
exports.sourceUrlProcessor = sourceUrlProcessor;
|
|
3411
|
-
exports.themeSelectProcessor = themeSelectProcessor;
|
|
3412
|
-
exports.topnavProcessor = topnavProcessor;
|
|
3413
|
-
exports.versionBannerProcessor = versionBannerProcessor;
|
|
3414
|
-
exports.versionProcessor = versionProcessor;
|
|
3415
|
-
exports.vueFileReader = vueFileReader;
|
|
3416
|
-
//# sourceMappingURL=index.js.map
|
|
3428
|
+
export { Generator, availableProcessors, cookieProcessor, defineSources, extractExamplesProcessor, frontMatterFileReader, htmlRedirectProcessor, livereloadProcessor, manifestProcessor, matomoProcessor, motdProcessor, navigationFileReader, processorRuntimeName, redirectFileProcessor, searchProcessor, selectableVersionProcessor, sourceUrlProcessor, themeSelectProcessor, topnavProcessor, versionBannerProcessor, versionProcessor, vueFileReader };
|
|
3429
|
+
//# sourceMappingURL=index.mjs.map
|