@forsakringskassan/docs-generator 3.1.1 → 3.2.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-castrIfY.mjs → create-markdown-renderer-p3FAbLe1.mjs} +83 -53
- package/dist/create-markdown-renderer-p3FAbLe1.mjs.map +1 -0
- package/dist/{format-code.worker-Cs0VeEOX.mjs → format-code.worker-BRTVVuKa.mjs} +2 -2
- package/dist/{format-code.worker-Cs0VeEOX.mjs.map → format-code.worker-BRTVVuKa.mjs.map} +1 -1
- package/dist/index.d.mts +58 -0
- package/dist/index.mjs +12 -6
- package/dist/index.mjs.map +1 -1
- package/dist/markdown.d.mts +50 -0
- package/dist/markdown.mjs +3 -3
- package/dist/processors/selectable-version.mjs +11 -3
- package/dist/runtime.mjs +4619 -4388
- package/dist/tsdoc-metadata.json +1 -1
- package/dist/{vendor-DO1GigtJ.mjs → vendor-DR1Vkbzf.mjs} +8 -5
- package/dist/{vendor-DO1GigtJ.mjs.map → vendor-DR1Vkbzf.mjs.map} +1 -1
- package/dist/{vue3-CnvFixWY.mjs → vue3-B3-18vX3.mjs} +6 -2
- package/dist/vue3-B3-18vX3.mjs.map +1 -0
- package/dist/{worker-DO8E5WXF.mjs → worker-DX8mHsqQ.mjs} +2 -2
- package/dist/{worker-DO8E5WXF.mjs.map → worker-DX8mHsqQ.mjs.map} +1 -1
- package/package.json +9 -1
- package/dist/create-markdown-renderer-castrIfY.mjs.map +0 -1
- package/dist/vue3-CnvFixWY.mjs.map +0 -1
package/dist/{create-markdown-renderer-castrIfY.mjs → create-markdown-renderer-p3FAbLe1.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';
|
|
@@ -10,7 +10,7 @@ import 'node:child_process';
|
|
|
10
10
|
import { fileURLToPath } from 'node:url';
|
|
11
11
|
import fs__default from 'node:fs';
|
|
12
12
|
import { version } from 'vue';
|
|
13
|
-
import { g as generateCode } from './vue3-
|
|
13
|
+
import { g as generateCode } from './vue3-B3-18vX3.mjs';
|
|
14
14
|
|
|
15
15
|
function findDocument(haystack, needle) {
|
|
16
16
|
for (const document of haystack) {
|
|
@@ -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);
|
|
@@ -370,7 +370,7 @@ function transformCode(code, lang) {
|
|
|
370
370
|
return code;
|
|
371
371
|
}
|
|
372
372
|
|
|
373
|
-
const url = new URL("./worker-
|
|
373
|
+
const url = new URL("./worker-DX8mHsqQ.mjs", import.meta.url);
|
|
374
374
|
const filePath = fileURLToPath(url);
|
|
375
375
|
|
|
376
376
|
class SoftError extends Error {
|
|
@@ -407,7 +407,7 @@ function getRelativeUrl(from, to) {
|
|
|
407
407
|
}
|
|
408
408
|
function getLinkTitle(doc, key, explicitTitle) {
|
|
409
409
|
if (explicitTitle) {
|
|
410
|
-
return explicitTitle
|
|
410
|
+
return explicitTitle;
|
|
411
411
|
}
|
|
412
412
|
const { title, component } = doc.attributes;
|
|
413
413
|
if (component?.some((it) => it.name === key)) {
|
|
@@ -416,51 +416,79 @@ function getLinkTitle(doc, key, explicitTitle) {
|
|
|
416
416
|
return title ?? doc.name;
|
|
417
417
|
}
|
|
418
418
|
}
|
|
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>`;
|
|
419
|
+
function renderLink(link) {
|
|
420
|
+
const { href, title, rel } = link;
|
|
421
|
+
const attrs = /* @__PURE__ */ new Map();
|
|
422
|
+
if (rel) {
|
|
423
|
+
attrs.set("rel", rel);
|
|
462
424
|
}
|
|
463
|
-
};
|
|
425
|
+
const serialized = attrs.entries().map(([key, value]) => ` ${key}="${value}"`).toArray().join("");
|
|
426
|
+
return `<a href="${href}"${serialized}>${title}</a>`;
|
|
427
|
+
}
|
|
428
|
+
function linkTag(linkResolvers) {
|
|
429
|
+
return {
|
|
430
|
+
name: "link",
|
|
431
|
+
description: "Create a link to another document",
|
|
432
|
+
handler(doc, docs, content) {
|
|
433
|
+
const match = /^([^\s#]+)(#\S+)?\s*(.+)?$/.exec(content);
|
|
434
|
+
if (!match) {
|
|
435
|
+
throw new SoftError(
|
|
436
|
+
"ELINKFORMAT",
|
|
437
|
+
`Failed to parse link "${content}"`
|
|
438
|
+
);
|
|
439
|
+
}
|
|
440
|
+
const key = match[1];
|
|
441
|
+
const hash = match[2];
|
|
442
|
+
const explicitTitle = match[3];
|
|
443
|
+
const normalizedTitle = explicitTitle?.replace(/^[\\|]\s*/, "");
|
|
444
|
+
if (key.startsWith("http://") || key.startsWith("https://")) {
|
|
445
|
+
return renderLink({
|
|
446
|
+
href: `${key}${hash ?? ""}`,
|
|
447
|
+
title: normalizedTitle ?? key
|
|
448
|
+
});
|
|
449
|
+
}
|
|
450
|
+
const { document: linked } = findDocument(docs, key);
|
|
451
|
+
const linkData = {
|
|
452
|
+
key,
|
|
453
|
+
hash: hash ?? null,
|
|
454
|
+
title: normalizedTitle ?? null,
|
|
455
|
+
doc: linked
|
|
456
|
+
};
|
|
457
|
+
const resolved = linkResolvers.values().map((it) => it(linkData)).find(Boolean);
|
|
458
|
+
if (resolved) {
|
|
459
|
+
return renderLink(resolved);
|
|
460
|
+
}
|
|
461
|
+
if (!linked) {
|
|
462
|
+
throw new SoftError(
|
|
463
|
+
"ELINKTARGET",
|
|
464
|
+
`Failed to find linked document "${key}"`,
|
|
465
|
+
{
|
|
466
|
+
key,
|
|
467
|
+
hash,
|
|
468
|
+
title: normalizedTitle
|
|
469
|
+
}
|
|
470
|
+
);
|
|
471
|
+
}
|
|
472
|
+
if (!isDocumentPage(linked)) {
|
|
473
|
+
throw new SoftError(
|
|
474
|
+
"ELINKPARTIAL",
|
|
475
|
+
`Cannot link to partial document "${key}"`,
|
|
476
|
+
{
|
|
477
|
+
key,
|
|
478
|
+
hash,
|
|
479
|
+
title: normalizedTitle
|
|
480
|
+
}
|
|
481
|
+
);
|
|
482
|
+
}
|
|
483
|
+
const url = getRelativeUrl(doc, linked);
|
|
484
|
+
const title = getLinkTitle(linked, key, normalizedTitle);
|
|
485
|
+
return renderLink({
|
|
486
|
+
href: `${url}${hash ?? ""}`,
|
|
487
|
+
title
|
|
488
|
+
});
|
|
489
|
+
}
|
|
490
|
+
};
|
|
491
|
+
}
|
|
464
492
|
|
|
465
493
|
const optionalTag = {
|
|
466
494
|
name: "optional",
|
|
@@ -470,7 +498,9 @@ const optionalTag = {
|
|
|
470
498
|
}
|
|
471
499
|
};
|
|
472
500
|
|
|
473
|
-
|
|
501
|
+
function inlineTags(linkResolvers) {
|
|
502
|
+
return [linkTag(linkResolvers), optionalTag];
|
|
503
|
+
}
|
|
474
504
|
var inline_tags_default = inlineTags;
|
|
475
505
|
|
|
476
506
|
function findTestId(tags) {
|
|
@@ -1151,7 +1181,7 @@ function processInlineTags(tags, doc, docs, text, handleSoftError) {
|
|
|
1151
1181
|
}
|
|
1152
1182
|
|
|
1153
1183
|
function createMarkdownRenderer(options) {
|
|
1154
|
-
const { docs } = options;
|
|
1184
|
+
const { docs, linkResolvers } = options;
|
|
1155
1185
|
const env = {
|
|
1156
1186
|
fileInfo: {
|
|
1157
1187
|
fullPath: "",
|
|
@@ -1213,7 +1243,7 @@ function createMarkdownRenderer(options) {
|
|
|
1213
1243
|
env.ids = /* @__PURE__ */ new Set();
|
|
1214
1244
|
const html = md.render(content, env);
|
|
1215
1245
|
return processInlineTags(
|
|
1216
|
-
inline_tags_default,
|
|
1246
|
+
inline_tags_default(linkResolvers ?? []),
|
|
1217
1247
|
doc,
|
|
1218
1248
|
docs,
|
|
1219
1249
|
html,
|
|
@@ -1224,4 +1254,4 @@ function createMarkdownRenderer(options) {
|
|
|
1224
1254
|
}
|
|
1225
1255
|
|
|
1226
1256
|
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-
|
|
1257
|
+
//# sourceMappingURL=create-markdown-renderer-p3FAbLe1.mjs.map
|