@forsakringskassan/docs-generator 3.1.2 → 3.3.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-fg4eQJx_.mjs → create-markdown-renderer-DLvvsGCZ.mjs} +93 -66
- package/dist/create-markdown-renderer-DLvvsGCZ.mjs.map +1 -0
- package/dist/{format-code.worker-DnB63s6w.mjs → format-code.worker-BRTVVuKa.mjs} +2 -2
- package/dist/{format-code.worker-DnB63s6w.mjs.map → format-code.worker-BRTVVuKa.mjs.map} +1 -1
- package/dist/index.d.mts +52 -0
- package/dist/index.mjs +21 -16
- package/dist/index.mjs.map +1 -1
- package/dist/markdown.d.mts +50 -0
- package/dist/markdown.mjs +2 -2
- package/dist/processors/selectable-version.mjs +3 -2
- package/dist/runtime.mjs +31 -13
- package/dist/{vendor-DWCXj2K2.mjs → vendor-DR1Vkbzf.mjs} +6 -3
- package/dist/{vendor-DWCXj2K2.mjs.map → vendor-DR1Vkbzf.mjs.map} +1 -1
- package/package.json +14 -6
- package/dist/create-markdown-renderer-fg4eQJx_.mjs.map +0 -1
package/dist/{create-markdown-renderer-fg4eQJx_.mjs → create-markdown-renderer-DLvvsGCZ.mjs}
RENAMED
|
@@ -2,7 +2,7 @@ import { createRequire as $createRequire } from "node:module";
|
|
|
2
2
|
|
|
3
3
|
const require = $createRequire(import.meta.url);
|
|
4
4
|
|
|
5
|
-
import { c as createSyncFn, d as dedent, H as HighlightJS, b as createTwoFilesPatch, M as MarkdownIt, e as deflist_plugin } from './vendor-
|
|
5
|
+
import { c as createSyncFn, d as dedent, H as HighlightJS, b as createTwoFilesPatch, M as MarkdownIt, e as deflist_plugin } from './vendor-DR1Vkbzf.mjs';
|
|
6
6
|
import path from 'node:path/posix';
|
|
7
7
|
import path__default from 'node:path';
|
|
8
8
|
import crypto from 'node:crypto';
|
|
@@ -73,7 +73,7 @@ function getFingerprint(source) {
|
|
|
73
73
|
|
|
74
74
|
function normalizePath(...pathSegments) {
|
|
75
75
|
const filePath = path.join(...pathSegments);
|
|
76
|
-
return path.normalize(filePath).replace(/^
|
|
76
|
+
return path.normalize(filePath).replace(/^[A-Z]:\\/, "/").replaceAll("\\", "/");
|
|
77
77
|
}
|
|
78
78
|
|
|
79
79
|
function getOutputFilePath(outputFolder, fileInfo) {
|
|
@@ -84,7 +84,7 @@ function getOutputFilePath(outputFolder, fileInfo) {
|
|
|
84
84
|
return normalizePath(outputFolder, path, outputName);
|
|
85
85
|
}
|
|
86
86
|
|
|
87
|
-
const url$1 = new URL("./format-code.worker-
|
|
87
|
+
const url$1 = new URL("./format-code.worker-BRTVVuKa.mjs", import.meta.url);
|
|
88
88
|
const filePath$1 = fileURLToPath(url$1);
|
|
89
89
|
|
|
90
90
|
const formatCode = createSyncFn(filePath$1);
|
|
@@ -113,7 +113,7 @@ function parseImport(raw) {
|
|
|
113
113
|
let previous;
|
|
114
114
|
do {
|
|
115
115
|
previous = stripped;
|
|
116
|
-
stripped = stripped.replaceAll(/<!--.*?-->/
|
|
116
|
+
stripped = stripped.replaceAll(/<!--.*?-->/gs, (match) => {
|
|
117
117
|
comments.push(match);
|
|
118
118
|
return "";
|
|
119
119
|
});
|
|
@@ -328,16 +328,13 @@ function cutSnippets(code) {
|
|
|
328
328
|
return lines.join("");
|
|
329
329
|
}
|
|
330
330
|
function stripEslintComments(code) {
|
|
331
|
-
const matchLine = /^[\t ]*(
|
|
332
|
-
const matchEmbedded = (
|
|
333
|
-
/* eslint-disable-next-line sonarjs/slow-regex -- technical debt */
|
|
334
|
-
/[\t ]*(\/\* eslint-disable[^*]*\*\/|\/\/ eslint-disable.*)/g
|
|
335
|
-
);
|
|
331
|
+
const matchLine = /^[\t ]*(?:\/\* eslint-disable[^*]*\*\/|\/\/ eslint-disable.*)\n/gm;
|
|
332
|
+
const matchEmbedded = /[\t ]*(?:\/\* eslint-disable[^*]*\*\/|\/\/ eslint-disable.*)/g;
|
|
336
333
|
return code.replaceAll(matchLine, "").replaceAll(matchEmbedded, "");
|
|
337
334
|
}
|
|
338
335
|
function stripHtmlValidateComments(code) {
|
|
339
|
-
const matchLine = /^[\t ]
|
|
340
|
-
const matchEmbedded = /[\t ]
|
|
336
|
+
const matchLine = /^[\t ]*<!--\s*\[html-validate-[^\]]+\]\s*-->\n/gm;
|
|
337
|
+
const matchEmbedded = /[\t ]*<!--\s*\[html-validate-[^\]]+\]\s*-->/g;
|
|
341
338
|
return code.replaceAll(matchLine, "").replaceAll(matchEmbedded, "");
|
|
342
339
|
}
|
|
343
340
|
function maybeDedent(value) {
|
|
@@ -407,7 +404,7 @@ function getRelativeUrl(from, to) {
|
|
|
407
404
|
}
|
|
408
405
|
function getLinkTitle(doc, key, explicitTitle) {
|
|
409
406
|
if (explicitTitle) {
|
|
410
|
-
return explicitTitle
|
|
407
|
+
return explicitTitle;
|
|
411
408
|
}
|
|
412
409
|
const { title, component } = doc.attributes;
|
|
413
410
|
if (component?.some((it) => it.name === key)) {
|
|
@@ -416,51 +413,79 @@ function getLinkTitle(doc, key, explicitTitle) {
|
|
|
416
413
|
return title ?? doc.name;
|
|
417
414
|
}
|
|
418
415
|
}
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
if (!match) {
|
|
425
|
-
throw new SoftError(
|
|
426
|
-
"ELINKFORMAT",
|
|
427
|
-
`Failed to parse link "${content}"`
|
|
428
|
-
);
|
|
429
|
-
}
|
|
430
|
-
const key = match[1];
|
|
431
|
-
const hash = match[2];
|
|
432
|
-
const explicitTitle = match[3];
|
|
433
|
-
if (key.startsWith("http://") || key.startsWith("https://")) {
|
|
434
|
-
return `<a href="${key}${hash ?? ""}">${explicitTitle ?? key}</a>`;
|
|
435
|
-
}
|
|
436
|
-
const { document: linked } = findDocument(docs, key);
|
|
437
|
-
if (!linked) {
|
|
438
|
-
throw new SoftError(
|
|
439
|
-
"ELINKTARGET",
|
|
440
|
-
`Failed to find linked document "${key}"`,
|
|
441
|
-
{
|
|
442
|
-
key,
|
|
443
|
-
hash,
|
|
444
|
-
title: explicitTitle
|
|
445
|
-
}
|
|
446
|
-
);
|
|
447
|
-
}
|
|
448
|
-
if (!isDocumentPage(linked)) {
|
|
449
|
-
throw new SoftError(
|
|
450
|
-
"ELINKPARTIAL",
|
|
451
|
-
`Cannot link to partial document "${key}"`,
|
|
452
|
-
{
|
|
453
|
-
key,
|
|
454
|
-
hash,
|
|
455
|
-
title: explicitTitle
|
|
456
|
-
}
|
|
457
|
-
);
|
|
458
|
-
}
|
|
459
|
-
const url = getRelativeUrl(doc, linked);
|
|
460
|
-
const title = getLinkTitle(linked, key, explicitTitle);
|
|
461
|
-
return `<a href="${url}${hash ?? ""}">${title}</a>`;
|
|
416
|
+
function renderLink(link) {
|
|
417
|
+
const { href, title, rel } = link;
|
|
418
|
+
const attrs = /* @__PURE__ */ new Map();
|
|
419
|
+
if (rel) {
|
|
420
|
+
attrs.set("rel", rel);
|
|
462
421
|
}
|
|
463
|
-
};
|
|
422
|
+
const serialized = attrs.entries().map(([key, value]) => ` ${key}="${value}"`).toArray().join("");
|
|
423
|
+
return `<a href="${href}"${serialized}>${title}</a>`;
|
|
424
|
+
}
|
|
425
|
+
function linkTag(linkResolvers) {
|
|
426
|
+
return {
|
|
427
|
+
name: "link",
|
|
428
|
+
description: "Create a link to another document",
|
|
429
|
+
handler(doc, docs, content) {
|
|
430
|
+
const match = /^([^\s#]+)(#\S+)?\s*(.+)?$/.exec(content);
|
|
431
|
+
if (!match) {
|
|
432
|
+
throw new SoftError(
|
|
433
|
+
"ELINKFORMAT",
|
|
434
|
+
`Failed to parse link "${content}"`
|
|
435
|
+
);
|
|
436
|
+
}
|
|
437
|
+
const key = match[1];
|
|
438
|
+
const hash = match[2];
|
|
439
|
+
const explicitTitle = match[3];
|
|
440
|
+
const normalizedTitle = explicitTitle?.replace(/^[\\|]\s*/, "");
|
|
441
|
+
if (key.startsWith("http://") || key.startsWith("https://")) {
|
|
442
|
+
return renderLink({
|
|
443
|
+
href: `${key}${hash ?? ""}`,
|
|
444
|
+
title: normalizedTitle ?? key
|
|
445
|
+
});
|
|
446
|
+
}
|
|
447
|
+
const { document: linked } = findDocument(docs, key);
|
|
448
|
+
const linkData = {
|
|
449
|
+
key,
|
|
450
|
+
hash: hash ?? null,
|
|
451
|
+
title: normalizedTitle ?? null,
|
|
452
|
+
doc: linked
|
|
453
|
+
};
|
|
454
|
+
const resolved = linkResolvers.values().map((it) => it(linkData)).find(Boolean);
|
|
455
|
+
if (resolved) {
|
|
456
|
+
return renderLink(resolved);
|
|
457
|
+
}
|
|
458
|
+
if (!linked) {
|
|
459
|
+
throw new SoftError(
|
|
460
|
+
"ELINKTARGET",
|
|
461
|
+
`Failed to find linked document "${key}"`,
|
|
462
|
+
{
|
|
463
|
+
key,
|
|
464
|
+
hash,
|
|
465
|
+
title: normalizedTitle
|
|
466
|
+
}
|
|
467
|
+
);
|
|
468
|
+
}
|
|
469
|
+
if (!isDocumentPage(linked)) {
|
|
470
|
+
throw new SoftError(
|
|
471
|
+
"ELINKPARTIAL",
|
|
472
|
+
`Cannot link to partial document "${key}"`,
|
|
473
|
+
{
|
|
474
|
+
key,
|
|
475
|
+
hash,
|
|
476
|
+
title: normalizedTitle
|
|
477
|
+
}
|
|
478
|
+
);
|
|
479
|
+
}
|
|
480
|
+
const url = getRelativeUrl(doc, linked);
|
|
481
|
+
const title = getLinkTitle(linked, key, normalizedTitle);
|
|
482
|
+
return renderLink({
|
|
483
|
+
href: `${url}${hash ?? ""}`,
|
|
484
|
+
title
|
|
485
|
+
});
|
|
486
|
+
}
|
|
487
|
+
};
|
|
488
|
+
}
|
|
464
489
|
|
|
465
490
|
const optionalTag = {
|
|
466
491
|
name: "optional",
|
|
@@ -470,7 +495,9 @@ const optionalTag = {
|
|
|
470
495
|
}
|
|
471
496
|
};
|
|
472
497
|
|
|
473
|
-
|
|
498
|
+
function inlineTags(linkResolvers) {
|
|
499
|
+
return [linkTag(linkResolvers), optionalTag];
|
|
500
|
+
}
|
|
474
501
|
var inline_tags_default = inlineTags;
|
|
475
502
|
|
|
476
503
|
function findTestId(tags) {
|
|
@@ -529,10 +556,9 @@ function highlight({
|
|
|
529
556
|
}
|
|
530
557
|
|
|
531
558
|
function replaceAtLink(text) {
|
|
532
|
-
return text.replaceAll(
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
);
|
|
559
|
+
return text.replaceAll(/\{@link [^}]+[$}]/g, (match) => {
|
|
560
|
+
return match.replace(/^\{/, "{").replace(/\}$/, "}");
|
|
561
|
+
});
|
|
536
562
|
}
|
|
537
563
|
|
|
538
564
|
function getClassModifier(tags) {
|
|
@@ -1118,12 +1144,13 @@ function codeInline() {
|
|
|
1118
1144
|
|
|
1119
1145
|
function processInlineTags(tags, doc, docs, text, handleSoftError) {
|
|
1120
1146
|
return text.replaceAll(
|
|
1121
|
-
/
|
|
1147
|
+
/* eslint-disable-next-line regexp/no-misleading-capturing-group -- technical debt */
|
|
1148
|
+
/\{@(@?)([^{}]+)\}/g,
|
|
1122
1149
|
(_, escape, content) => {
|
|
1123
1150
|
if (escape) {
|
|
1124
1151
|
return `{@${content}}`;
|
|
1125
1152
|
}
|
|
1126
|
-
const match = /^(\S+)($|\s[
|
|
1153
|
+
const match = /^(\S+)($|\s[\s\S]+)$/.exec(content);
|
|
1127
1154
|
if (!match) {
|
|
1128
1155
|
return `{@${content}}`;
|
|
1129
1156
|
}
|
|
@@ -1151,7 +1178,7 @@ function processInlineTags(tags, doc, docs, text, handleSoftError) {
|
|
|
1151
1178
|
}
|
|
1152
1179
|
|
|
1153
1180
|
function createMarkdownRenderer(options) {
|
|
1154
|
-
const { docs } = options;
|
|
1181
|
+
const { docs, linkResolvers } = options;
|
|
1155
1182
|
const env = {
|
|
1156
1183
|
fileInfo: {
|
|
1157
1184
|
fullPath: "",
|
|
@@ -1213,7 +1240,7 @@ function createMarkdownRenderer(options) {
|
|
|
1213
1240
|
env.ids = /* @__PURE__ */ new Set();
|
|
1214
1241
|
const html = md.render(content, env);
|
|
1215
1242
|
return processInlineTags(
|
|
1216
|
-
inline_tags_default,
|
|
1243
|
+
inline_tags_default(linkResolvers ?? []),
|
|
1217
1244
|
doc,
|
|
1218
1245
|
docs,
|
|
1219
1246
|
html,
|
|
@@ -1224,4 +1251,4 @@ function createMarkdownRenderer(options) {
|
|
|
1224
1251
|
}
|
|
1225
1252
|
|
|
1226
1253
|
export { SoftError as S, getFingerprint as a, parseImport as b, createMarkdownRenderer as c, findTag as d, getOutputFilePath as e, formatCode as f, generateId as g, hasTag as h, isDocumentPage as i, htmlencode as j, filePath as k, generateExample as l, normalizePath as n, parseInfostring as p };
|
|
1227
|
-
//# sourceMappingURL=create-markdown-renderer-
|
|
1254
|
+
//# sourceMappingURL=create-markdown-renderer-DLvvsGCZ.mjs.map
|