@forsakringskassan/docs-generator 2.29.2 → 2.30.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/dist/{create-markdown-renderer-B7-jbpT6.mjs → create-markdown-renderer-D5LtM0yF.mjs} +52 -41
- package/dist/create-markdown-renderer-D5LtM0yF.mjs.map +1 -0
- package/dist/index.d.mts +4 -3
- package/dist/index.mjs +67 -46
- package/dist/index.mjs.map +1 -1
- package/dist/markdown.d.mts +8 -8
- package/dist/markdown.mjs +2 -2
- package/dist/processors/selectable-version.mjs +3 -2
- package/dist/runtime.mjs +87106 -86492
- package/dist/style/core.css +1 -1
- package/dist/style/index.css +66 -2
- package/dist/style/site.css +65 -1
- package/dist/tsdoc-metadata.json +1 -1
- package/dist/{vendor-xg15tfEs.mjs → vendor-B6t9njJr.mjs} +83 -22
- package/dist/vendor-B6t9njJr.mjs.map +1 -0
- package/package.json +2 -1
- package/dist/create-markdown-renderer-B7-jbpT6.mjs.map +0 -1
- package/dist/vendor-xg15tfEs.mjs.map +0 -1
package/dist/index.mjs
CHANGED
|
@@ -4,8 +4,8 @@ const require = $createRequire(import.meta.url);
|
|
|
4
4
|
|
|
5
5
|
import fs from 'node:fs/promises';
|
|
6
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-
|
|
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-
|
|
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, o as inter } from './vendor-B6t9njJr.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-D5LtM0yF.mjs';
|
|
9
9
|
import path$1 from 'node:path';
|
|
10
10
|
import require$$1 from 'crypto';
|
|
11
11
|
import 'node:crypto';
|
|
@@ -125,16 +125,16 @@ function fileMatcher(patterns) {
|
|
|
125
125
|
function formatSize(value) {
|
|
126
126
|
const suffices = ["kB", "MB"];
|
|
127
127
|
if (value < 1e3) {
|
|
128
|
-
return
|
|
128
|
+
return String(value);
|
|
129
129
|
}
|
|
130
130
|
for (const suffix of suffices) {
|
|
131
131
|
value = Math.round(value / 1e3 * 100) / 100;
|
|
132
132
|
if (value < 1e3) {
|
|
133
|
-
return `${value} ${suffix}`;
|
|
133
|
+
return `${String(value)} ${suffix}`;
|
|
134
134
|
}
|
|
135
135
|
}
|
|
136
136
|
value = Math.round(value / 1e3 * 100) / 100;
|
|
137
|
-
return `${value} GB`;
|
|
137
|
+
return `${String(value)} GB`;
|
|
138
138
|
}
|
|
139
139
|
|
|
140
140
|
const matchHeading = /^(#+)(.*)$/gm;
|
|
@@ -183,12 +183,12 @@ function getIntegrity(source) {
|
|
|
183
183
|
function getPullRequestID(env) {
|
|
184
184
|
if (env.JOB_BASE_NAME) {
|
|
185
185
|
const name = env.JOB_BASE_NAME;
|
|
186
|
-
const match =
|
|
186
|
+
const match = /^PR-(\d+)$/.exec(name);
|
|
187
187
|
return match ? match[1] : void 0;
|
|
188
188
|
}
|
|
189
189
|
if (env.GITHUB_REF) {
|
|
190
190
|
const name = env.GITHUB_REF;
|
|
191
|
-
const match =
|
|
191
|
+
const match = /^refs\/pull\/([^/]+)\/merge$/.exec(name);
|
|
192
192
|
return match ? match[1] : void 0;
|
|
193
193
|
}
|
|
194
194
|
return void 0;
|
|
@@ -204,7 +204,7 @@ function getRepositoryUrl(value) {
|
|
|
204
204
|
value = url;
|
|
205
205
|
}
|
|
206
206
|
value = value.replace(/^git[+]/, "");
|
|
207
|
-
const ssh =
|
|
207
|
+
const ssh = RE_MATCH_SSH.exec(value);
|
|
208
208
|
if (ssh) {
|
|
209
209
|
const { host, path } = ssh.groups;
|
|
210
210
|
value = `https://${host}/${path}`;
|
|
@@ -242,7 +242,8 @@ function haveOutput(doc) {
|
|
|
242
242
|
function interpolate(value, data) {
|
|
243
243
|
return value.replace(/{{([^{}]+)}}/g, (match, raw) => {
|
|
244
244
|
const key = raw.trim();
|
|
245
|
-
|
|
245
|
+
const value2 = data[key];
|
|
246
|
+
return value2 ?? match;
|
|
246
247
|
});
|
|
247
248
|
}
|
|
248
249
|
|
|
@@ -376,7 +377,7 @@ const md$5 = MarkdownIt();
|
|
|
376
377
|
md$5.renderer.rules.fence = (tokens, idx, _options, collected) => {
|
|
377
378
|
const { content, info, map } = tokens[idx];
|
|
378
379
|
const { language: rawLanguage, tags } = parseInfostring(info);
|
|
379
|
-
const hashContent = `${map?.[0]}:${map?.[1]}:${info}:${content}`;
|
|
380
|
+
const hashContent = `${String(map?.[0])}:${String(map?.[1])}:${info}:${content}`;
|
|
380
381
|
const fingerprint = getFingerprint(hashContent);
|
|
381
382
|
let extension = void 0;
|
|
382
383
|
let language = rawLanguage;
|
|
@@ -418,7 +419,7 @@ function manifestPageFromDocument(doc) {
|
|
|
418
419
|
const { body, fileInfo, format } = doc;
|
|
419
420
|
return {
|
|
420
421
|
path: getOutputFilePath("", fileInfo),
|
|
421
|
-
title: doc.attributes.title ?? doc.name
|
|
422
|
+
title: doc.attributes.title ?? doc.name,
|
|
422
423
|
redirect: format === "redirect" ? body : null,
|
|
423
424
|
outline: flattenOutline(doc.outline),
|
|
424
425
|
examples: findExamples(doc)
|
|
@@ -691,7 +692,7 @@ function redirectProcessor() {
|
|
|
691
692
|
return {
|
|
692
693
|
name: "redirect-processor",
|
|
693
694
|
after: "generate-docs",
|
|
694
|
-
|
|
695
|
+
handler(context) {
|
|
695
696
|
const redirects = getRedirects(context.docs);
|
|
696
697
|
for (const redirect of redirects) {
|
|
697
698
|
const { dir, base, name } = path.parse(redirect.from);
|
|
@@ -908,7 +909,7 @@ function cookieProcessor(options = {}) {
|
|
|
908
909
|
return {
|
|
909
910
|
after: "generate-docs",
|
|
910
911
|
name: "cookie-processor",
|
|
911
|
-
|
|
912
|
+
handler(context) {
|
|
912
913
|
if (!enabled) {
|
|
913
914
|
return;
|
|
914
915
|
}
|
|
@@ -940,7 +941,7 @@ const suggestions = {
|
|
|
940
941
|
hidden: "visible"
|
|
941
942
|
};
|
|
942
943
|
function findLocation(content, attr) {
|
|
943
|
-
const match =
|
|
944
|
+
const match = /^---\n(.*?)^---/ms.exec(content);
|
|
944
945
|
if (!match || match.index !== 0) {
|
|
945
946
|
return null;
|
|
946
947
|
}
|
|
@@ -1073,7 +1074,7 @@ function parseFile$1(filePath, basePath, content) {
|
|
|
1073
1074
|
const attributes = blocks.attributes;
|
|
1074
1075
|
const isIndex = isIndexPage(parsed);
|
|
1075
1076
|
const filename = isIndex ? "index" : parsed.name.toLowerCase();
|
|
1076
|
-
const name = attributes.name
|
|
1077
|
+
const name = attributes.name ?? parsed.name;
|
|
1077
1078
|
const urlpath = parsed.dir;
|
|
1078
1079
|
const outline = getDocumentOutline(blocks.body);
|
|
1079
1080
|
const include = attributes.include ?? true;
|
|
@@ -1118,10 +1119,10 @@ async function frontMatterFileReader(filePath, basePath) {
|
|
|
1118
1119
|
|
|
1119
1120
|
function getPropSlotDeprecated(prop) {
|
|
1120
1121
|
const tags = prop.tags;
|
|
1121
|
-
if (!tags) {
|
|
1122
|
+
if (!tags?.deprecated) {
|
|
1122
1123
|
return null;
|
|
1123
1124
|
}
|
|
1124
|
-
const tag = tags
|
|
1125
|
+
const tag = tags.deprecated[0];
|
|
1125
1126
|
if (!tag?.description) {
|
|
1126
1127
|
return null;
|
|
1127
1128
|
}
|
|
@@ -1148,7 +1149,7 @@ function getEventDeprecated(event) {
|
|
|
1148
1149
|
}
|
|
1149
1150
|
function translateProps(props) {
|
|
1150
1151
|
const isRelevant = (prop) => {
|
|
1151
|
-
return prop.tags?.
|
|
1152
|
+
return prop.tags?.ignore === void 0;
|
|
1152
1153
|
};
|
|
1153
1154
|
return props.filter(isRelevant).map((prop) => {
|
|
1154
1155
|
const defaultValue = prop.defaultValue ? { value: prop.defaultValue.value } : null;
|
|
@@ -1194,8 +1195,8 @@ function translateEventProperties(event) {
|
|
|
1194
1195
|
const property = properties[i];
|
|
1195
1196
|
const name = property.name ?? "<anonymous>";
|
|
1196
1197
|
const eventType = types[i];
|
|
1197
|
-
const hasEventType =
|
|
1198
|
-
const type = hasEventType ? eventType :
|
|
1198
|
+
const hasEventType = Boolean(eventType) && eventType !== "undefined";
|
|
1199
|
+
const type = hasEventType ? eventType : property.type.names.join(" ");
|
|
1199
1200
|
const description = typeof property.description === "string" ? property.description : null;
|
|
1200
1201
|
translatedProperties.push({
|
|
1201
1202
|
name,
|
|
@@ -1262,19 +1263,26 @@ function filterModels(rawProps, rawEvents) {
|
|
|
1262
1263
|
return { models, props, events };
|
|
1263
1264
|
}
|
|
1264
1265
|
async function translateAPI(filePath) {
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1266
|
+
try {
|
|
1267
|
+
const api = await parse(filePath);
|
|
1268
|
+
const rawProps = api.props ? translateProps(api.props) : [];
|
|
1269
|
+
const rawEvents = api.events ? translateEvents(api.events) : [];
|
|
1270
|
+
const { models, props, events } = filterModels(rawProps, rawEvents);
|
|
1271
|
+
const slots = api.slots ? translateSlots(api.slots) : [];
|
|
1272
|
+
return {
|
|
1273
|
+
name: api.displayName,
|
|
1274
|
+
slug: slugify(api.displayName),
|
|
1275
|
+
models,
|
|
1276
|
+
props,
|
|
1277
|
+
events,
|
|
1278
|
+
slots
|
|
1279
|
+
};
|
|
1280
|
+
} catch (err) {
|
|
1281
|
+
throw new Error(
|
|
1282
|
+
`Failed to generate API description from "${filePath}"`,
|
|
1283
|
+
{ cause: err }
|
|
1284
|
+
);
|
|
1285
|
+
}
|
|
1278
1286
|
}
|
|
1279
1287
|
|
|
1280
1288
|
const md$4 = MarkdownIt();
|
|
@@ -1408,9 +1416,9 @@ function generateEventTable(slug, events) {
|
|
|
1408
1416
|
${haveProperties ? `<p class="docs-api__list-title">Arguments:</p><ul class="docs-api__list">` : ""}
|
|
1409
1417
|
${event.properties.map((it) => {
|
|
1410
1418
|
if (it.description) {
|
|
1411
|
-
return `<li><code>${htmlencode(it.name)}: ${htmlencode(it.type
|
|
1419
|
+
return `<li><code>${htmlencode(it.name)}: ${htmlencode(it.type)}</code> ${EM_DASH$2} ${renderInline$2(it.description)}</li>`;
|
|
1412
1420
|
} else {
|
|
1413
|
-
return `<li><code>${htmlencode(it.name)}: ${htmlencode(it.type
|
|
1421
|
+
return `<li><code>${htmlencode(it.name)}: ${htmlencode(it.type)}</code></li>`;
|
|
1414
1422
|
}
|
|
1415
1423
|
}).join("")}
|
|
1416
1424
|
${haveProperties ? `</ul>` : ""}
|
|
@@ -1463,9 +1471,9 @@ function generateSlotTable(slug, slots) {
|
|
|
1463
1471
|
${haveBindings ? `<p class="docs-api__list-title">Bindings:</p><ul class="docs-api__list">` : ""}
|
|
1464
1472
|
${slot.bindings.map((it) => {
|
|
1465
1473
|
if (it.description) {
|
|
1466
|
-
return `<li><code>${htmlencode(it.name)}: ${htmlencode(it.type
|
|
1474
|
+
return `<li><code>${htmlencode(it.name)}: ${htmlencode(it.type)}</code> ${EM_DASH$1} ${renderInline$1(it.description)}</li>`;
|
|
1467
1475
|
} else {
|
|
1468
|
-
return `<li><code>${htmlencode(it.name)}: ${htmlencode(it.type
|
|
1476
|
+
return `<li><code>${htmlencode(it.name)}: ${htmlencode(it.type)}</code></li>`;
|
|
1469
1477
|
}
|
|
1470
1478
|
}).join("")}
|
|
1471
1479
|
${haveBindings ? `</ul>` : ""}
|
|
@@ -1572,7 +1580,7 @@ function findDocComment(path, node) {
|
|
|
1572
1580
|
}
|
|
1573
1581
|
}
|
|
1574
1582
|
const grandparent = path.parentPath?.parent;
|
|
1575
|
-
if (parent.type === "VariableDeclarator" && grandparent
|
|
1583
|
+
if (parent.type === "VariableDeclarator" && grandparent?.leadingComments) {
|
|
1576
1584
|
const doc = grandparent.leadingComments.find(isDocComment);
|
|
1577
1585
|
if (doc) {
|
|
1578
1586
|
return doc;
|
|
@@ -1971,7 +1979,7 @@ async function compileScript(options) {
|
|
|
1971
1979
|
...buildOptions,
|
|
1972
1980
|
define: {
|
|
1973
1981
|
"process.env.DOCS_ICON_LIB": JSON.stringify(iconLib),
|
|
1974
|
-
...buildOptions
|
|
1982
|
+
...buildOptions.define
|
|
1975
1983
|
}
|
|
1976
1984
|
});
|
|
1977
1985
|
const content = await fs$1.readFile(outfile, "utf-8");
|
|
@@ -2312,6 +2320,7 @@ class TemplateLoader {
|
|
|
2312
2320
|
this.folders = [...folders, templateDirectory];
|
|
2313
2321
|
this.templateCache = /* @__PURE__ */ new Map();
|
|
2314
2322
|
}
|
|
2323
|
+
/* eslint-disable-next-line @typescript-eslint/no-misused-promises -- technical debt */
|
|
2315
2324
|
async getSource(name, callback) {
|
|
2316
2325
|
try {
|
|
2317
2326
|
const { content, filePath } = await this.resolveTemplate(name);
|
|
@@ -2415,7 +2424,7 @@ function findTemplate(folders, from, src, format) {
|
|
|
2415
2424
|
|
|
2416
2425
|
const messageRegex = /^[(][^)]+[)] \[Line \d+, Column \d+\]\n\s+Error: (.*)$/;
|
|
2417
2426
|
function getActualMessage(message) {
|
|
2418
|
-
const match =
|
|
2427
|
+
const match = messageRegex.exec(message);
|
|
2419
2428
|
if (match) {
|
|
2420
2429
|
return match[1].trim();
|
|
2421
2430
|
} else {
|
|
@@ -2691,7 +2700,7 @@ async function render(doc, docs, nav, vendors, options) {
|
|
|
2691
2700
|
});
|
|
2692
2701
|
const content2 = await Promise.all(promises);
|
|
2693
2702
|
const markup = content2.join("");
|
|
2694
|
-
|
|
2703
|
+
callback(null, new nunjucks.runtime.SafeString(markup));
|
|
2695
2704
|
}
|
|
2696
2705
|
});
|
|
2697
2706
|
await mkdir;
|
|
@@ -2716,7 +2725,7 @@ async function render(doc, docs, nav, vendors, options) {
|
|
|
2716
2725
|
return match;
|
|
2717
2726
|
}
|
|
2718
2727
|
});
|
|
2719
|
-
const writeFile = fs.writeFile(expandedDst, content
|
|
2728
|
+
const writeFile = fs.writeFile(expandedDst, content, "utf-8");
|
|
2720
2729
|
try {
|
|
2721
2730
|
const assets = Object.values(templateData.assets).filter(
|
|
2722
2731
|
(it) => it.importmap
|
|
@@ -2873,7 +2882,7 @@ async function compileVendor(assetFolder, vendor, options) {
|
|
|
2873
2882
|
__VUE_PROD_DEVTOOLS__: "true",
|
|
2874
2883
|
__VUE_PROD_HYDRATION_MISMATCH_DETAILS__: "false"
|
|
2875
2884
|
},
|
|
2876
|
-
alias: vendor.alias ? { [
|
|
2885
|
+
alias: vendor.alias ? { [vendor.package]: vendor.alias } : void 0,
|
|
2877
2886
|
...options
|
|
2878
2887
|
});
|
|
2879
2888
|
const content = await fs.readFile(outfile, "utf-8");
|
|
@@ -2964,7 +2973,7 @@ async function keypress() {
|
|
|
2964
2973
|
function printMenu(addr) {
|
|
2965
2974
|
console.log();
|
|
2966
2975
|
console.group(
|
|
2967
|
-
`Starting development server at http://localhost:${addr.port}`
|
|
2976
|
+
`Starting development server at http://localhost:${String(addr.port)}`
|
|
2968
2977
|
);
|
|
2969
2978
|
console.log();
|
|
2970
2979
|
console.log("[q] quit");
|
|
@@ -3031,7 +3040,7 @@ async function serve(options) {
|
|
|
3031
3040
|
});
|
|
3032
3041
|
livereload.changed({ body: { files } });
|
|
3033
3042
|
});
|
|
3034
|
-
watcher.on("change",
|
|
3043
|
+
watcher.on("change", (filePath) => {
|
|
3035
3044
|
rebuild(filePath);
|
|
3036
3045
|
});
|
|
3037
3046
|
for (; ; ) {
|
|
@@ -3168,7 +3177,7 @@ function createContext(outputFolder, templateLoader) {
|
|
|
3168
3177
|
return templateBlocks;
|
|
3169
3178
|
},
|
|
3170
3179
|
hasTemplate(name) {
|
|
3171
|
-
return
|
|
3180
|
+
return templateLoader.hasTemplate(name);
|
|
3172
3181
|
},
|
|
3173
3182
|
setTopNavigation(root) {
|
|
3174
3183
|
topnav = root;
|
|
@@ -3340,6 +3349,7 @@ class Generator {
|
|
|
3340
3349
|
});
|
|
3341
3350
|
await i18n.init();
|
|
3342
3351
|
await this._prepareFolders();
|
|
3352
|
+
await this._copyFonts();
|
|
3343
3353
|
const processors = [
|
|
3344
3354
|
fileReaderProcessor(sourceFiles),
|
|
3345
3355
|
redirectProcessor(),
|
|
@@ -3401,6 +3411,17 @@ class Generator {
|
|
|
3401
3411
|
await fs.mkdir(assetFolder, { recursive: true });
|
|
3402
3412
|
await fs.mkdir("temp", { recursive: true });
|
|
3403
3413
|
}
|
|
3414
|
+
async _copyFonts() {
|
|
3415
|
+
const { assetFolder } = this;
|
|
3416
|
+
const files = inter.subsets.map((subset) => {
|
|
3417
|
+
const filename = `inter-${subset}-wght-normal.woff2`;
|
|
3418
|
+
const module = `@fontsource-variable/inter/files/${filename}`;
|
|
3419
|
+
const src = fileURLToPath(import.meta.resolve(module));
|
|
3420
|
+
const dst = path$1.join(assetFolder, filename);
|
|
3421
|
+
return fs.copyFile(src, dst);
|
|
3422
|
+
});
|
|
3423
|
+
await Promise.all(files);
|
|
3424
|
+
}
|
|
3404
3425
|
}
|
|
3405
3426
|
|
|
3406
3427
|
function generateIndex(entries) {
|