@forsakringskassan/docs-generator 2.17.1 → 2.19.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/compile-example.js +4 -3
- package/dist/compile-example.js.map +1 -0
- package/dist/{create-markdown-renderer-2ejm6Tub.js → create-markdown-renderer-CbE5KJoX.js} +173 -125
- package/dist/create-markdown-renderer-CbE5KJoX.js.map +1 -0
- package/dist/index.d.ts +67 -26
- package/dist/index.js +88 -57
- 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/{vendor-BeoVq2Sv.js → vendor-BHA4LIog.js} +23 -17
- package/dist/vendor-BHA4LIog.js.map +1 -0
- package/dist/{vue3-B1yNeGmz.js → vue3-BhdC7RZQ.js} +69 -68
- package/dist/vue3-BhdC7RZQ.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-BHA4LIog.js');
|
|
6
|
+
var createMarkdownRenderer = require('./create-markdown-renderer-CbE5KJoX.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-2ejm6Tub.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-BhdC7RZQ.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}`,
|
|
@@ -424,21 +440,48 @@ function renderMarkdown(manifest) {
|
|
|
424
440
|
function renderJSON(manifest) {
|
|
425
441
|
return JSON.stringify(manifest, null, 2);
|
|
426
442
|
}
|
|
443
|
+
function normalize(text) {
|
|
444
|
+
return text.replace(/\r\n/g, "\n");
|
|
445
|
+
}
|
|
446
|
+
class ManifestError extends Error {
|
|
447
|
+
filename;
|
|
448
|
+
constructor(filename) {
|
|
449
|
+
super(`Documentation manifest "${filename}" is not up-to-date!`);
|
|
450
|
+
this.filename = filename;
|
|
451
|
+
}
|
|
452
|
+
prettyError() {
|
|
453
|
+
const { filename, message } = this;
|
|
454
|
+
return [
|
|
455
|
+
message,
|
|
456
|
+
"",
|
|
457
|
+
`Run the build locally and commit the content of "${filename}".`
|
|
458
|
+
].join("\n");
|
|
459
|
+
}
|
|
460
|
+
}
|
|
427
461
|
function manifestProcessor(options = {}) {
|
|
428
|
-
const { markdown, json } = options;
|
|
462
|
+
const { markdown, json, verify } = options;
|
|
429
463
|
return {
|
|
430
464
|
name: "manifestProcessor",
|
|
431
465
|
before: "render",
|
|
432
466
|
async handler(context) {
|
|
433
|
-
const docs = context.docs.filter(haveOutput);
|
|
467
|
+
const docs = context.docs.filter(createMarkdownRenderer.isDocumentPage).filter(haveOutput);
|
|
434
468
|
const pages = docs.map(manifestPageFromDocument);
|
|
435
469
|
pages.sort((a, b) => {
|
|
436
470
|
return a.path.localeCompare(b.path);
|
|
437
471
|
});
|
|
438
472
|
const manifest = { pages };
|
|
439
473
|
if (markdown) {
|
|
440
|
-
const content = renderMarkdown(manifest);
|
|
441
|
-
|
|
474
|
+
const content = normalize(renderMarkdown(manifest));
|
|
475
|
+
if (verify) {
|
|
476
|
+
const actual = normalize(
|
|
477
|
+
await fs.readFile(markdown, "utf-8")
|
|
478
|
+
);
|
|
479
|
+
if (actual !== content) {
|
|
480
|
+
throw new ManifestError(markdown);
|
|
481
|
+
}
|
|
482
|
+
} else {
|
|
483
|
+
await fs.writeFile(markdown, content, "utf-8");
|
|
484
|
+
}
|
|
442
485
|
}
|
|
443
486
|
if (json) {
|
|
444
487
|
const content = renderJSON(manifest);
|
|
@@ -452,7 +495,7 @@ function normalizeOptions(options) {
|
|
|
452
495
|
const defaults = {
|
|
453
496
|
enabled: true,
|
|
454
497
|
container: "body:begin",
|
|
455
|
-
message:
|
|
498
|
+
message: void 0
|
|
456
499
|
};
|
|
457
500
|
return { ...defaults, ...options };
|
|
458
501
|
}
|
|
@@ -474,7 +517,7 @@ function motdProcessor(options = {}) {
|
|
|
474
517
|
};
|
|
475
518
|
context.addTemplateBlock(container, "motd-container", {
|
|
476
519
|
filename: "partials/motd-container.njk.html",
|
|
477
|
-
data: useLegacyTemplate ?
|
|
520
|
+
data: useLegacyTemplate ? void 0 : data
|
|
478
521
|
});
|
|
479
522
|
if (useLegacyTemplate) {
|
|
480
523
|
console.warn(
|
|
@@ -582,7 +625,7 @@ function htmlRedirectProcessor() {
|
|
|
582
625
|
after: "render",
|
|
583
626
|
async handler(context) {
|
|
584
627
|
const { docs, outputFolder } = context;
|
|
585
|
-
for (const doc of docs.filter(haveOutput)) {
|
|
628
|
+
for (const doc of docs.filter(createMarkdownRenderer.isDocumentPage).filter(haveOutput)) {
|
|
586
629
|
if (doc.format !== "redirect") {
|
|
587
630
|
continue;
|
|
588
631
|
}
|
|
@@ -605,7 +648,7 @@ function redirectFileProcessor(prefix = "/", filename = "_redirects") {
|
|
|
605
648
|
after: "render",
|
|
606
649
|
async handler(context) {
|
|
607
650
|
const { docs } = context;
|
|
608
|
-
const lines = docs.filter(haveOutput).filter(isRedirect).map((doc) => {
|
|
651
|
+
const lines = docs.filter(createMarkdownRenderer.isDocumentPage).filter(haveOutput).filter(isRedirect).map((doc) => {
|
|
609
652
|
const src = createMarkdownRenderer.normalizePath(
|
|
610
653
|
doc.fileInfo.path,
|
|
611
654
|
doc.fileInfo.outputName
|
|
@@ -623,7 +666,7 @@ function redirectFileProcessor(prefix = "/", filename = "_redirects") {
|
|
|
623
666
|
}
|
|
624
667
|
|
|
625
668
|
function getRedirects(docs) {
|
|
626
|
-
return docs.map((it) => {
|
|
669
|
+
return docs.filter(createMarkdownRenderer.isDocumentPage).map((it) => {
|
|
627
670
|
const { fileInfo } = it;
|
|
628
671
|
const { path, outputName } = fileInfo;
|
|
629
672
|
if (outputName === false) {
|
|
@@ -647,6 +690,7 @@ function redirectProcessor() {
|
|
|
647
690
|
for (const redirect of redirects) {
|
|
648
691
|
const { dir, base, name } = path.parse(redirect.from);
|
|
649
692
|
context.addDocument({
|
|
693
|
+
kind: "page",
|
|
650
694
|
id: `redirect:${redirect.from}-${redirect.to}`,
|
|
651
695
|
name: `${redirect.from}-${redirect.to}`,
|
|
652
696
|
alias: [],
|
|
@@ -767,7 +811,7 @@ async function getSCMData(pkg, options) {
|
|
|
767
811
|
const { homepage } = pkg;
|
|
768
812
|
const repository = getRepositoryUrl(pkg) ?? "";
|
|
769
813
|
const pr = getPullRequestID(process.env);
|
|
770
|
-
const prUrl = pr ? interpolate(options.prUrlFormat, { homepage, pr, repository }) :
|
|
814
|
+
const prUrl = pr ? interpolate(options.prUrlFormat, { homepage, pr, repository }) : void 0;
|
|
771
815
|
return {
|
|
772
816
|
branch: await getGitBranch(),
|
|
773
817
|
commitShort,
|
|
@@ -884,21 +928,6 @@ function defineSources(sources) {
|
|
|
884
928
|
return sources;
|
|
885
929
|
}
|
|
886
930
|
|
|
887
|
-
const documentAttributeKeys = [
|
|
888
|
-
"title",
|
|
889
|
-
"short-title",
|
|
890
|
-
"layout",
|
|
891
|
-
"name",
|
|
892
|
-
"alias",
|
|
893
|
-
"status",
|
|
894
|
-
"visible",
|
|
895
|
-
"include",
|
|
896
|
-
"component",
|
|
897
|
-
"href",
|
|
898
|
-
"sortorder",
|
|
899
|
-
"redirect_from"
|
|
900
|
-
];
|
|
901
|
-
|
|
902
931
|
const threshold = 3;
|
|
903
932
|
const suggestions = {
|
|
904
933
|
hidden: "visible"
|
|
@@ -975,7 +1004,7 @@ function isIndexPage(parsed) {
|
|
|
975
1004
|
}
|
|
976
1005
|
function getBadge(attrs) {
|
|
977
1006
|
if (!attrs.status) {
|
|
978
|
-
return
|
|
1007
|
+
return void 0;
|
|
979
1008
|
}
|
|
980
1009
|
switch (attrs.status) {
|
|
981
1010
|
case "Produktionsklar":
|
|
@@ -1026,7 +1055,7 @@ function* getDocumentAlias(attrs) {
|
|
|
1026
1055
|
}
|
|
1027
1056
|
function getComponent(attrs) {
|
|
1028
1057
|
if (!attrs.component) {
|
|
1029
|
-
return
|
|
1058
|
+
return void 0;
|
|
1030
1059
|
}
|
|
1031
1060
|
return toArray$1(attrs.component).map(normalizeComponent);
|
|
1032
1061
|
}
|
|
@@ -1043,6 +1072,7 @@ function parseFile$1(filePath, basePath, content) {
|
|
|
1043
1072
|
const include = attributes.include ?? true;
|
|
1044
1073
|
validateAttributes(attributes, filePath, content);
|
|
1045
1074
|
return {
|
|
1075
|
+
kind: "page",
|
|
1046
1076
|
id: `fs:${filePath.replace(/\\/g, "/")}`,
|
|
1047
1077
|
name,
|
|
1048
1078
|
alias: Array.from(getDocumentAlias(attributes)),
|
|
@@ -1384,21 +1414,14 @@ function parseAPI(filePath, api) {
|
|
|
1384
1414
|
html += generateSlotTable(api.slug, api.slots);
|
|
1385
1415
|
}
|
|
1386
1416
|
return {
|
|
1417
|
+
kind: "partial",
|
|
1387
1418
|
id: `fs:${filePath.replace(/\\/g, "/")}`,
|
|
1388
1419
|
name: `vue:${componentName}`,
|
|
1389
1420
|
alias: [],
|
|
1390
|
-
visible: false,
|
|
1391
|
-
attributes: { sortorder: Infinity, redirectFrom: [] },
|
|
1392
1421
|
body: html,
|
|
1393
|
-
outline: [],
|
|
1394
1422
|
format: "html",
|
|
1395
|
-
tags: [],
|
|
1396
|
-
template: "",
|
|
1397
1423
|
fileInfo: {
|
|
1398
|
-
|
|
1399
|
-
name: "",
|
|
1400
|
-
fullPath: "",
|
|
1401
|
-
outputName: false
|
|
1424
|
+
fullPath: filePath
|
|
1402
1425
|
}
|
|
1403
1426
|
};
|
|
1404
1427
|
}
|
|
@@ -1464,6 +1487,7 @@ function parseFile(filePath, basePath, content) {
|
|
|
1464
1487
|
const name = parsed.name;
|
|
1465
1488
|
const urlpath = parsed.dir;
|
|
1466
1489
|
return {
|
|
1490
|
+
kind: "page",
|
|
1467
1491
|
id: `nav:${filePath.replace(/\\/g, "/")}`,
|
|
1468
1492
|
name,
|
|
1469
1493
|
alias: [],
|
|
@@ -1932,7 +1956,8 @@ function navigationProcessor() {
|
|
|
1932
1956
|
stage: "generate-nav",
|
|
1933
1957
|
name: "navigation-processor",
|
|
1934
1958
|
handler(context) {
|
|
1935
|
-
const
|
|
1959
|
+
const pages = context.docs.filter(createMarkdownRenderer.isDocumentPage);
|
|
1960
|
+
const navtree = generateNavtree(pages);
|
|
1936
1961
|
context.setTopNavigation(navtree);
|
|
1937
1962
|
context.setSideNavigation(navtree);
|
|
1938
1963
|
}
|
|
@@ -2091,9 +2116,14 @@ class TemplateRenderError extends Error {
|
|
|
2091
2116
|
}
|
|
2092
2117
|
prettyError() {
|
|
2093
2118
|
return [
|
|
2119
|
+
"",
|
|
2094
2120
|
`An error occured when rendering a document.`,
|
|
2095
2121
|
` Document: "${this.filename}".`,
|
|
2096
|
-
` Message: ${this.message}
|
|
2122
|
+
` Message: ${this.message}`,
|
|
2123
|
+
"",
|
|
2124
|
+
"---",
|
|
2125
|
+
"",
|
|
2126
|
+
this.stack
|
|
2097
2127
|
].join("\n");
|
|
2098
2128
|
}
|
|
2099
2129
|
}
|
|
@@ -2375,7 +2405,7 @@ function nunjucksProcessor(options) {
|
|
|
2375
2405
|
});
|
|
2376
2406
|
}
|
|
2377
2407
|
const formats = ["markdown", "json"];
|
|
2378
|
-
const docs = context.docs.filter((it) => {
|
|
2408
|
+
const docs = context.docs.filter(createMarkdownRenderer.isDocumentPage).filter((it) => {
|
|
2379
2409
|
if (!formats.includes(it.format)) {
|
|
2380
2410
|
return false;
|
|
2381
2411
|
}
|
|
@@ -2467,7 +2497,7 @@ async function compileVendor(assetFolder, vendor, options) {
|
|
|
2467
2497
|
__VUE_PROD_DEVTOOLS__: "true",
|
|
2468
2498
|
__VUE_PROD_HYDRATION_MISMATCH_DETAILS__: "false"
|
|
2469
2499
|
},
|
|
2470
|
-
alias: vendor.alias ? { [`${vendor.package}`]: vendor.alias } :
|
|
2500
|
+
alias: vendor.alias ? { [`${vendor.package}`]: vendor.alias } : void 0,
|
|
2471
2501
|
...options
|
|
2472
2502
|
});
|
|
2473
2503
|
const content = await fs.readFile(outfile, "utf-8");
|
|
@@ -2490,7 +2520,7 @@ function normalizeVendorDefinition(vendor) {
|
|
|
2490
2520
|
if (typeof vendor === "string") {
|
|
2491
2521
|
return {
|
|
2492
2522
|
package: vendor,
|
|
2493
|
-
global:
|
|
2523
|
+
global: void 0,
|
|
2494
2524
|
expose: "named",
|
|
2495
2525
|
subpaths: []
|
|
2496
2526
|
};
|
|
@@ -2500,7 +2530,7 @@ function normalizeVendorDefinition(vendor) {
|
|
|
2500
2530
|
global: vendor.global,
|
|
2501
2531
|
expose: vendor.expose ?? "named",
|
|
2502
2532
|
subpaths: vendor.subpaths ?? [],
|
|
2503
|
-
alias: vendor.alias ??
|
|
2533
|
+
alias: vendor.alias ?? void 0
|
|
2504
2534
|
};
|
|
2505
2535
|
}
|
|
2506
2536
|
}
|
|
@@ -2861,7 +2891,7 @@ class Generator {
|
|
|
2861
2891
|
const templateLoader = createTemplateLoader([]);
|
|
2862
2892
|
const context = createContext("", templateLoader);
|
|
2863
2893
|
await stage("generate-docs", context, processors, { verbose: false });
|
|
2864
|
-
const docs = context.docs.filter(haveOutput);
|
|
2894
|
+
const docs = context.docs.filter(createMarkdownRenderer.isDocumentPage).filter(haveOutput);
|
|
2865
2895
|
const pages = docs.map(manifestPageFromDocument);
|
|
2866
2896
|
return { pages };
|
|
2867
2897
|
}
|
|
@@ -2974,9 +3004,8 @@ function extractTerms(doc) {
|
|
|
2974
3004
|
}
|
|
2975
3005
|
}
|
|
2976
3006
|
function isIndexable(doc) {
|
|
2977
|
-
|
|
2978
|
-
|
|
2979
|
-
);
|
|
3007
|
+
const { visible, fileInfo, format } = doc;
|
|
3008
|
+
return Boolean(visible && fileInfo.outputName && format !== "redirect");
|
|
2980
3009
|
}
|
|
2981
3010
|
function getTerms(doc) {
|
|
2982
3011
|
return {
|
|
@@ -2990,7 +3019,7 @@ function searchProcessor() {
|
|
|
2990
3019
|
after: "generate-docs",
|
|
2991
3020
|
name: "search-processor",
|
|
2992
3021
|
handler(context) {
|
|
2993
|
-
const entries = context.docs.filter(isIndexable).map(getTerms);
|
|
3022
|
+
const entries = context.docs.filter(createMarkdownRenderer.isDocumentPage).filter(isIndexable).map(getTerms);
|
|
2994
3023
|
const index = generateIndex(entries);
|
|
2995
3024
|
const body = JSON.stringify(index);
|
|
2996
3025
|
const fingerprint = createMarkdownRenderer.getFingerprint(body);
|
|
@@ -3000,6 +3029,7 @@ function searchProcessor() {
|
|
|
3000
3029
|
context.setTemplateData("searchDataUrl", expandedName);
|
|
3001
3030
|
context.setTemplateData("searchDataIntegrity", integrity);
|
|
3002
3031
|
context.addDocument({
|
|
3032
|
+
kind: "page",
|
|
3003
3033
|
id: "search:data",
|
|
3004
3034
|
name: "search-data",
|
|
3005
3035
|
alias: [],
|
|
@@ -3053,3 +3083,4 @@ exports.topnavProcessor = topnavProcessor;
|
|
|
3053
3083
|
exports.versionBannerProcessor = versionBannerProcessor;
|
|
3054
3084
|
exports.versionProcessor = versionProcessor;
|
|
3055
3085
|
exports.vueFileReader = vueFileReader;
|
|
3086
|
+
//# sourceMappingURL=index.js.map
|