@forsakringskassan/docs-generator 2.18.0 → 2.19.1
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/compile-example.js +4 -3
- package/dist/compile-example.js.map +1 -0
- package/dist/{create-markdown-renderer-CaJTFjAd.js → create-markdown-renderer-BVgcQwRq.js} +165 -123
- package/dist/create-markdown-renderer-BVgcQwRq.js.map +1 -0
- package/dist/index.d.ts +64 -26
- package/dist/index.js +68 -55
- package/dist/index.js.map +1 -0
- package/dist/markdown.d.ts +65 -22
- package/dist/markdown.js +4 -3
- package/dist/markdown.js.map +1 -0
- package/dist/processors/selectable-version.js +5 -2
- package/dist/runtime.js +18 -16
- package/dist/tsdoc-metadata.json +1 -1
- package/dist/{vendor-Bagon7WF.js → vendor-BO0JjPoU.js} +47 -17
- package/dist/vendor-BO0JjPoU.js.map +1 -0
- package/dist/{vue3-CEAR7ggN.js → vue3-BitM0YmN.js} +69 -68
- package/dist/vue3-BitM0YmN.js.map +1 -0
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
|
|
3
3
|
var fs = require('node:fs/promises');
|
|
4
4
|
var path = require('node:path/posix');
|
|
5
|
-
var vendor = require('./vendor-
|
|
5
|
+
var vendor = require('./vendor-BO0JjPoU.js');
|
|
6
|
+
var createMarkdownRenderer = require('./create-markdown-renderer-BVgcQwRq.js');
|
|
6
7
|
var path$1 = require('node:path');
|
|
7
8
|
var require$$1 = require('crypto');
|
|
8
9
|
require('node:crypto');
|
|
9
|
-
var createMarkdownRenderer = require('./create-markdown-renderer-CaJTFjAd.js');
|
|
10
10
|
var node_child_process = require('node:child_process');
|
|
11
11
|
var util = require('node:util');
|
|
12
12
|
var codeFrame = require('@babel/code-frame');
|
|
@@ -44,7 +44,7 @@ require('tls');
|
|
|
44
44
|
require('tty');
|
|
45
45
|
require('querystring');
|
|
46
46
|
require('vue');
|
|
47
|
-
require('./vue3-
|
|
47
|
+
require('./vue3-BitM0YmN.js');
|
|
48
48
|
|
|
49
49
|
var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null;
|
|
50
50
|
function toArray$2(value) {
|
|
@@ -70,6 +70,21 @@ function matomoProcessor(options) {
|
|
|
70
70
|
};
|
|
71
71
|
}
|
|
72
72
|
|
|
73
|
+
const documentAttributeKeys = [
|
|
74
|
+
"title",
|
|
75
|
+
"short-title",
|
|
76
|
+
"layout",
|
|
77
|
+
"name",
|
|
78
|
+
"alias",
|
|
79
|
+
"status",
|
|
80
|
+
"visible",
|
|
81
|
+
"include",
|
|
82
|
+
"component",
|
|
83
|
+
"href",
|
|
84
|
+
"sortorder",
|
|
85
|
+
"redirect_from"
|
|
86
|
+
];
|
|
87
|
+
|
|
73
88
|
function cacheKey$1(...args) {
|
|
74
89
|
return JSON.stringify(args);
|
|
75
90
|
}
|
|
@@ -167,14 +182,14 @@ function getPullRequestID(env) {
|
|
|
167
182
|
if (env.JOB_BASE_NAME) {
|
|
168
183
|
const name = env.JOB_BASE_NAME;
|
|
169
184
|
const match = name.match(/^PR-(\d+)$/);
|
|
170
|
-
return match ? match[1] :
|
|
185
|
+
return match ? match[1] : void 0;
|
|
171
186
|
}
|
|
172
187
|
if (env.GITHUB_REF) {
|
|
173
188
|
const name = env.GITHUB_REF;
|
|
174
189
|
const match = name.match(/^refs\/pull\/([^/]+)\/merge$/);
|
|
175
|
-
return match ? match[1] :
|
|
190
|
+
return match ? match[1] : void 0;
|
|
176
191
|
}
|
|
177
|
-
return
|
|
192
|
+
return void 0;
|
|
178
193
|
}
|
|
179
194
|
|
|
180
195
|
const RE_MATCH_SSH = /^(ssh:\/\/)?(?<user>[^@]+)@(?<host>[^:]+):(?<path>.*)$/;
|
|
@@ -274,7 +289,7 @@ md$4.renderer.rules.fence = (tokens, idx, _options, collected) => {
|
|
|
274
289
|
return "";
|
|
275
290
|
}
|
|
276
291
|
const nameTag = tags.find((it) => it.startsWith("name="));
|
|
277
|
-
const name = nameTag ? slugify(nameTag.slice("name=".length)) :
|
|
292
|
+
const name = nameTag ? slugify(nameTag.slice("name=".length)) : void 0;
|
|
278
293
|
collected.push({
|
|
279
294
|
name,
|
|
280
295
|
content,
|
|
@@ -331,8 +346,9 @@ function extractExamplesProcessor(options) {
|
|
|
331
346
|
);
|
|
332
347
|
}
|
|
333
348
|
await fs.rm(outputFolder, { recursive: true, force: true });
|
|
349
|
+
const docs = context.docs.filter(createMarkdownRenderer.isDocumentPage).filter(haveOutput);
|
|
334
350
|
let total = 0;
|
|
335
|
-
for (const doc of
|
|
351
|
+
for (const doc of docs) {
|
|
336
352
|
const examples = findExamples$1(doc).filter(isRelevant);
|
|
337
353
|
if (examples.length === 0) {
|
|
338
354
|
continue;
|
|
@@ -360,14 +376,14 @@ md$3.renderer.rules.fence = (tokens, idx, _options, collected) => {
|
|
|
360
376
|
const { language, tags } = createMarkdownRenderer.parseInfostring(info);
|
|
361
377
|
const hashContent = `${map?.[0]}:${map?.[1]}:${info}:${content}`;
|
|
362
378
|
const fingerprint = createMarkdownRenderer.getFingerprint(hashContent);
|
|
363
|
-
let extension =
|
|
379
|
+
let extension = void 0;
|
|
364
380
|
if (language === "import") {
|
|
365
381
|
extension = content.split(".").at(-1)?.trim();
|
|
366
382
|
}
|
|
367
383
|
if (createMarkdownRenderer.hasTag(tags, "hidden")) {
|
|
368
384
|
return "";
|
|
369
385
|
}
|
|
370
|
-
const name = createMarkdownRenderer.findTag(tags, "name")?.value ??
|
|
386
|
+
const name = createMarkdownRenderer.findTag(tags, "name")?.value ?? void 0;
|
|
371
387
|
collected.push({
|
|
372
388
|
name,
|
|
373
389
|
selector: `#example-${fingerprint}`,
|
|
@@ -448,7 +464,7 @@ function manifestProcessor(options = {}) {
|
|
|
448
464
|
name: "manifestProcessor",
|
|
449
465
|
before: "render",
|
|
450
466
|
async handler(context) {
|
|
451
|
-
const docs = context.docs.filter(haveOutput);
|
|
467
|
+
const docs = context.docs.filter(createMarkdownRenderer.isDocumentPage).filter(haveOutput);
|
|
452
468
|
const pages = docs.map(manifestPageFromDocument);
|
|
453
469
|
pages.sort((a, b) => {
|
|
454
470
|
return a.path.localeCompare(b.path);
|
|
@@ -479,7 +495,7 @@ function normalizeOptions(options) {
|
|
|
479
495
|
const defaults = {
|
|
480
496
|
enabled: true,
|
|
481
497
|
container: "body:begin",
|
|
482
|
-
message:
|
|
498
|
+
message: void 0
|
|
483
499
|
};
|
|
484
500
|
return { ...defaults, ...options };
|
|
485
501
|
}
|
|
@@ -501,7 +517,7 @@ function motdProcessor(options = {}) {
|
|
|
501
517
|
};
|
|
502
518
|
context.addTemplateBlock(container, "motd-container", {
|
|
503
519
|
filename: "partials/motd-container.njk.html",
|
|
504
|
-
data: useLegacyTemplate ?
|
|
520
|
+
data: useLegacyTemplate ? void 0 : data
|
|
505
521
|
});
|
|
506
522
|
if (useLegacyTemplate) {
|
|
507
523
|
console.warn(
|
|
@@ -609,7 +625,7 @@ function htmlRedirectProcessor() {
|
|
|
609
625
|
after: "render",
|
|
610
626
|
async handler(context) {
|
|
611
627
|
const { docs, outputFolder } = context;
|
|
612
|
-
for (const doc of docs.filter(haveOutput)) {
|
|
628
|
+
for (const doc of docs.filter(createMarkdownRenderer.isDocumentPage).filter(haveOutput)) {
|
|
613
629
|
if (doc.format !== "redirect") {
|
|
614
630
|
continue;
|
|
615
631
|
}
|
|
@@ -632,7 +648,7 @@ function redirectFileProcessor(prefix = "/", filename = "_redirects") {
|
|
|
632
648
|
after: "render",
|
|
633
649
|
async handler(context) {
|
|
634
650
|
const { docs } = context;
|
|
635
|
-
const lines = docs.filter(haveOutput).filter(isRedirect).map((doc) => {
|
|
651
|
+
const lines = docs.filter(createMarkdownRenderer.isDocumentPage).filter(haveOutput).filter(isRedirect).map((doc) => {
|
|
636
652
|
const src = createMarkdownRenderer.normalizePath(
|
|
637
653
|
doc.fileInfo.path,
|
|
638
654
|
doc.fileInfo.outputName
|
|
@@ -650,7 +666,7 @@ function redirectFileProcessor(prefix = "/", filename = "_redirects") {
|
|
|
650
666
|
}
|
|
651
667
|
|
|
652
668
|
function getRedirects(docs) {
|
|
653
|
-
return docs.map((it) => {
|
|
669
|
+
return docs.filter(createMarkdownRenderer.isDocumentPage).map((it) => {
|
|
654
670
|
const { fileInfo } = it;
|
|
655
671
|
const { path, outputName } = fileInfo;
|
|
656
672
|
if (outputName === false) {
|
|
@@ -674,6 +690,7 @@ function redirectProcessor() {
|
|
|
674
690
|
for (const redirect of redirects) {
|
|
675
691
|
const { dir, base, name } = path.parse(redirect.from);
|
|
676
692
|
context.addDocument({
|
|
693
|
+
kind: "page",
|
|
677
694
|
id: `redirect:${redirect.from}-${redirect.to}`,
|
|
678
695
|
name: `${redirect.from}-${redirect.to}`,
|
|
679
696
|
alias: [],
|
|
@@ -794,7 +811,7 @@ async function getSCMData(pkg, options) {
|
|
|
794
811
|
const { homepage } = pkg;
|
|
795
812
|
const repository = getRepositoryUrl(pkg) ?? "";
|
|
796
813
|
const pr = getPullRequestID(process.env);
|
|
797
|
-
const prUrl = pr ? interpolate(options.prUrlFormat, { homepage, pr, repository }) :
|
|
814
|
+
const prUrl = pr ? interpolate(options.prUrlFormat, { homepage, pr, repository }) : void 0;
|
|
798
815
|
return {
|
|
799
816
|
branch: await getGitBranch(),
|
|
800
817
|
commitShort,
|
|
@@ -911,21 +928,6 @@ function defineSources(sources) {
|
|
|
911
928
|
return sources;
|
|
912
929
|
}
|
|
913
930
|
|
|
914
|
-
const documentAttributeKeys = [
|
|
915
|
-
"title",
|
|
916
|
-
"short-title",
|
|
917
|
-
"layout",
|
|
918
|
-
"name",
|
|
919
|
-
"alias",
|
|
920
|
-
"status",
|
|
921
|
-
"visible",
|
|
922
|
-
"include",
|
|
923
|
-
"component",
|
|
924
|
-
"href",
|
|
925
|
-
"sortorder",
|
|
926
|
-
"redirect_from"
|
|
927
|
-
];
|
|
928
|
-
|
|
929
931
|
const threshold = 3;
|
|
930
932
|
const suggestions = {
|
|
931
933
|
hidden: "visible"
|
|
@@ -1002,7 +1004,7 @@ function isIndexPage(parsed) {
|
|
|
1002
1004
|
}
|
|
1003
1005
|
function getBadge(attrs) {
|
|
1004
1006
|
if (!attrs.status) {
|
|
1005
|
-
return
|
|
1007
|
+
return void 0;
|
|
1006
1008
|
}
|
|
1007
1009
|
switch (attrs.status) {
|
|
1008
1010
|
case "Produktionsklar":
|
|
@@ -1053,7 +1055,7 @@ function* getDocumentAlias(attrs) {
|
|
|
1053
1055
|
}
|
|
1054
1056
|
function getComponent(attrs) {
|
|
1055
1057
|
if (!attrs.component) {
|
|
1056
|
-
return
|
|
1058
|
+
return void 0;
|
|
1057
1059
|
}
|
|
1058
1060
|
return toArray$1(attrs.component).map(normalizeComponent);
|
|
1059
1061
|
}
|
|
@@ -1070,6 +1072,7 @@ function parseFile$1(filePath, basePath, content) {
|
|
|
1070
1072
|
const include = attributes.include ?? true;
|
|
1071
1073
|
validateAttributes(attributes, filePath, content);
|
|
1072
1074
|
return {
|
|
1075
|
+
kind: "page",
|
|
1073
1076
|
id: `fs:${filePath.replace(/\\/g, "/")}`,
|
|
1074
1077
|
name,
|
|
1075
1078
|
alias: Array.from(getDocumentAlias(attributes)),
|
|
@@ -1134,7 +1137,10 @@ function getEventDeprecated(event) {
|
|
|
1134
1137
|
}
|
|
1135
1138
|
}
|
|
1136
1139
|
function translateProps(props) {
|
|
1137
|
-
|
|
1140
|
+
const isRelevant = (prop) => {
|
|
1141
|
+
return prop.tags?.["ignore"] === void 0;
|
|
1142
|
+
};
|
|
1143
|
+
return props.filter(isRelevant).map((prop) => {
|
|
1138
1144
|
const defaultValue = prop.defaultValue ? { value: prop.defaultValue.value } : null;
|
|
1139
1145
|
return {
|
|
1140
1146
|
name: prop.name,
|
|
@@ -1149,6 +1155,9 @@ function translateProps(props) {
|
|
|
1149
1155
|
function translateEvents(events) {
|
|
1150
1156
|
const translatedEvents = [];
|
|
1151
1157
|
for (const event of events) {
|
|
1158
|
+
if (event.tags?.find((it) => it.title === "ignore")) {
|
|
1159
|
+
continue;
|
|
1160
|
+
}
|
|
1152
1161
|
const translatedEvent = {
|
|
1153
1162
|
name: event.name,
|
|
1154
1163
|
description: event.description ?? null,
|
|
@@ -1189,6 +1198,9 @@ function translateEventProperties(event) {
|
|
|
1189
1198
|
function translateSlots(slots) {
|
|
1190
1199
|
const translatedSlots = [];
|
|
1191
1200
|
for (const slot of slots) {
|
|
1201
|
+
if (slot.tags?.ignore) {
|
|
1202
|
+
continue;
|
|
1203
|
+
}
|
|
1192
1204
|
const translatedSlot = {
|
|
1193
1205
|
name: slot.name,
|
|
1194
1206
|
description: slot.description ?? null,
|
|
@@ -1411,21 +1423,14 @@ function parseAPI(filePath, api) {
|
|
|
1411
1423
|
html += generateSlotTable(api.slug, api.slots);
|
|
1412
1424
|
}
|
|
1413
1425
|
return {
|
|
1426
|
+
kind: "partial",
|
|
1414
1427
|
id: `fs:${filePath.replace(/\\/g, "/")}`,
|
|
1415
1428
|
name: `vue:${componentName}`,
|
|
1416
1429
|
alias: [],
|
|
1417
|
-
visible: false,
|
|
1418
|
-
attributes: { sortorder: Infinity, redirectFrom: [] },
|
|
1419
1430
|
body: html,
|
|
1420
|
-
outline: [],
|
|
1421
1431
|
format: "html",
|
|
1422
|
-
tags: [],
|
|
1423
|
-
template: "",
|
|
1424
1432
|
fileInfo: {
|
|
1425
|
-
|
|
1426
|
-
name: "",
|
|
1427
|
-
fullPath: "",
|
|
1428
|
-
outputName: false
|
|
1433
|
+
fullPath: filePath
|
|
1429
1434
|
}
|
|
1430
1435
|
};
|
|
1431
1436
|
}
|
|
@@ -1491,6 +1496,7 @@ function parseFile(filePath, basePath, content) {
|
|
|
1491
1496
|
const name = parsed.name;
|
|
1492
1497
|
const urlpath = parsed.dir;
|
|
1493
1498
|
return {
|
|
1499
|
+
kind: "page",
|
|
1494
1500
|
id: `nav:${filePath.replace(/\\/g, "/")}`,
|
|
1495
1501
|
name,
|
|
1496
1502
|
alias: [],
|
|
@@ -1959,7 +1965,8 @@ function navigationProcessor() {
|
|
|
1959
1965
|
stage: "generate-nav",
|
|
1960
1966
|
name: "navigation-processor",
|
|
1961
1967
|
handler(context) {
|
|
1962
|
-
const
|
|
1968
|
+
const pages = context.docs.filter(createMarkdownRenderer.isDocumentPage);
|
|
1969
|
+
const navtree = generateNavtree(pages);
|
|
1963
1970
|
context.setTopNavigation(navtree);
|
|
1964
1971
|
context.setSideNavigation(navtree);
|
|
1965
1972
|
}
|
|
@@ -2118,9 +2125,14 @@ class TemplateRenderError extends Error {
|
|
|
2118
2125
|
}
|
|
2119
2126
|
prettyError() {
|
|
2120
2127
|
return [
|
|
2128
|
+
"",
|
|
2121
2129
|
`An error occured when rendering a document.`,
|
|
2122
2130
|
` Document: "${this.filename}".`,
|
|
2123
|
-
` Message: ${this.message}
|
|
2131
|
+
` Message: ${this.message}`,
|
|
2132
|
+
"",
|
|
2133
|
+
"---",
|
|
2134
|
+
"",
|
|
2135
|
+
this.stack
|
|
2124
2136
|
].join("\n");
|
|
2125
2137
|
}
|
|
2126
2138
|
}
|
|
@@ -2402,7 +2414,7 @@ function nunjucksProcessor(options) {
|
|
|
2402
2414
|
});
|
|
2403
2415
|
}
|
|
2404
2416
|
const formats = ["markdown", "json"];
|
|
2405
|
-
const docs = context.docs.filter((it) => {
|
|
2417
|
+
const docs = context.docs.filter(createMarkdownRenderer.isDocumentPage).filter((it) => {
|
|
2406
2418
|
if (!formats.includes(it.format)) {
|
|
2407
2419
|
return false;
|
|
2408
2420
|
}
|
|
@@ -2494,7 +2506,7 @@ async function compileVendor(assetFolder, vendor, options) {
|
|
|
2494
2506
|
__VUE_PROD_DEVTOOLS__: "true",
|
|
2495
2507
|
__VUE_PROD_HYDRATION_MISMATCH_DETAILS__: "false"
|
|
2496
2508
|
},
|
|
2497
|
-
alias: vendor.alias ? { [`${vendor.package}`]: vendor.alias } :
|
|
2509
|
+
alias: vendor.alias ? { [`${vendor.package}`]: vendor.alias } : void 0,
|
|
2498
2510
|
...options
|
|
2499
2511
|
});
|
|
2500
2512
|
const content = await fs.readFile(outfile, "utf-8");
|
|
@@ -2517,7 +2529,7 @@ function normalizeVendorDefinition(vendor) {
|
|
|
2517
2529
|
if (typeof vendor === "string") {
|
|
2518
2530
|
return {
|
|
2519
2531
|
package: vendor,
|
|
2520
|
-
global:
|
|
2532
|
+
global: void 0,
|
|
2521
2533
|
expose: "named",
|
|
2522
2534
|
subpaths: []
|
|
2523
2535
|
};
|
|
@@ -2527,7 +2539,7 @@ function normalizeVendorDefinition(vendor) {
|
|
|
2527
2539
|
global: vendor.global,
|
|
2528
2540
|
expose: vendor.expose ?? "named",
|
|
2529
2541
|
subpaths: vendor.subpaths ?? [],
|
|
2530
|
-
alias: vendor.alias ??
|
|
2542
|
+
alias: vendor.alias ?? void 0
|
|
2531
2543
|
};
|
|
2532
2544
|
}
|
|
2533
2545
|
}
|
|
@@ -2888,7 +2900,7 @@ class Generator {
|
|
|
2888
2900
|
const templateLoader = createTemplateLoader([]);
|
|
2889
2901
|
const context = createContext("", templateLoader);
|
|
2890
2902
|
await stage("generate-docs", context, processors, { verbose: false });
|
|
2891
|
-
const docs = context.docs.filter(haveOutput);
|
|
2903
|
+
const docs = context.docs.filter(createMarkdownRenderer.isDocumentPage).filter(haveOutput);
|
|
2892
2904
|
const pages = docs.map(manifestPageFromDocument);
|
|
2893
2905
|
return { pages };
|
|
2894
2906
|
}
|
|
@@ -3001,9 +3013,8 @@ function extractTerms(doc) {
|
|
|
3001
3013
|
}
|
|
3002
3014
|
}
|
|
3003
3015
|
function isIndexable(doc) {
|
|
3004
|
-
|
|
3005
|
-
|
|
3006
|
-
);
|
|
3016
|
+
const { visible, fileInfo, format } = doc;
|
|
3017
|
+
return Boolean(visible && fileInfo.outputName && format !== "redirect");
|
|
3007
3018
|
}
|
|
3008
3019
|
function getTerms(doc) {
|
|
3009
3020
|
return {
|
|
@@ -3017,7 +3028,7 @@ function searchProcessor() {
|
|
|
3017
3028
|
after: "generate-docs",
|
|
3018
3029
|
name: "search-processor",
|
|
3019
3030
|
handler(context) {
|
|
3020
|
-
const entries = context.docs.filter(isIndexable).map(getTerms);
|
|
3031
|
+
const entries = context.docs.filter(createMarkdownRenderer.isDocumentPage).filter(isIndexable).map(getTerms);
|
|
3021
3032
|
const index = generateIndex(entries);
|
|
3022
3033
|
const body = JSON.stringify(index);
|
|
3023
3034
|
const fingerprint = createMarkdownRenderer.getFingerprint(body);
|
|
@@ -3027,6 +3038,7 @@ function searchProcessor() {
|
|
|
3027
3038
|
context.setTemplateData("searchDataUrl", expandedName);
|
|
3028
3039
|
context.setTemplateData("searchDataIntegrity", integrity);
|
|
3029
3040
|
context.addDocument({
|
|
3041
|
+
kind: "page",
|
|
3030
3042
|
id: "search:data",
|
|
3031
3043
|
name: "search-data",
|
|
3032
3044
|
alias: [],
|
|
@@ -3080,3 +3092,4 @@ exports.topnavProcessor = topnavProcessor;
|
|
|
3080
3092
|
exports.versionBannerProcessor = versionBannerProcessor;
|
|
3081
3093
|
exports.versionProcessor = versionProcessor;
|
|
3082
3094
|
exports.vueFileReader = vueFileReader;
|
|
3095
|
+
//# sourceMappingURL=index.js.map
|