@forsakringskassan/docs-generator 2.17.0 → 2.18.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 +2 -2
- package/dist/{create-markdown-renderer-Bj0NKzgi.js → create-markdown-renderer-CaJTFjAd.js} +24 -17
- package/dist/index.d.ts +3 -0
- package/dist/index.js +46 -18
- package/dist/markdown.js +3 -3
- package/dist/{vendor-BeoVq2Sv.js → vendor-Bagon7WF.js} +5 -0
- package/dist/{vue3-B1yNeGmz.js → vue3-CEAR7ggN.js} +1 -1
- package/package.json +1 -1
package/dist/compile-example.js
CHANGED
|
@@ -3,10 +3,10 @@
|
|
|
3
3
|
var path$1 = require('node:path');
|
|
4
4
|
var esbuild = require('esbuild');
|
|
5
5
|
var vue = require('vue');
|
|
6
|
-
var vue3 = require('./vue3-
|
|
6
|
+
var vue3 = require('./vue3-CEAR7ggN.js');
|
|
7
7
|
var path = require('node:path/posix');
|
|
8
8
|
require('@vue/compiler-sfc');
|
|
9
|
-
require('./vendor-
|
|
9
|
+
require('./vendor-Bagon7WF.js');
|
|
10
10
|
require('node:url');
|
|
11
11
|
require('fs');
|
|
12
12
|
require('node:fs');
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var vendor = require('./vendor-
|
|
3
|
+
var vendor = require('./vendor-Bagon7WF.js');
|
|
4
4
|
var path = require('node:path/posix');
|
|
5
5
|
var path$1 = require('node:path');
|
|
6
6
|
require('crypto');
|
|
@@ -8,7 +8,7 @@ var crypto = require('node:crypto');
|
|
|
8
8
|
require('node:child_process');
|
|
9
9
|
var fs = require('node:fs');
|
|
10
10
|
var vue = require('vue');
|
|
11
|
-
var vue3 = require('./vue3-
|
|
11
|
+
var vue3 = require('./vue3-CEAR7ggN.js');
|
|
12
12
|
|
|
13
13
|
function findDocument(haystack, needle) {
|
|
14
14
|
const match = haystack.find((it) => {
|
|
@@ -85,6 +85,19 @@ function hasTag(tags, tag) {
|
|
|
85
85
|
return Boolean(match);
|
|
86
86
|
}
|
|
87
87
|
|
|
88
|
+
const replacement = {
|
|
89
|
+
"<": `<`,
|
|
90
|
+
">": `>`,
|
|
91
|
+
"&": `&`,
|
|
92
|
+
'"': `"`,
|
|
93
|
+
"'": `'`
|
|
94
|
+
};
|
|
95
|
+
function htmlencode(text) {
|
|
96
|
+
return text.replace(/[<>&"']/g, (m) => {
|
|
97
|
+
return replacement[m];
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
|
|
88
101
|
function parseImport(raw) {
|
|
89
102
|
const comments = [];
|
|
90
103
|
const stripped = raw.replace(/<!--.*?-->/gms, (match) => {
|
|
@@ -502,19 +515,6 @@ function highlight({
|
|
|
502
515
|
}
|
|
503
516
|
}
|
|
504
517
|
|
|
505
|
-
const replacement = {
|
|
506
|
-
"<": `<`,
|
|
507
|
-
">": `>`,
|
|
508
|
-
"&": `&`,
|
|
509
|
-
'"': `"`,
|
|
510
|
-
"'": `'`
|
|
511
|
-
};
|
|
512
|
-
function htmlencode(text) {
|
|
513
|
-
return text.replace(/[<>&"']/g, (m) => {
|
|
514
|
-
return replacement[m];
|
|
515
|
-
});
|
|
516
|
-
}
|
|
517
|
-
|
|
518
518
|
function replaceAtLink(text) {
|
|
519
519
|
return text.replace(
|
|
520
520
|
/{@link [^}]+[$}]/g,
|
|
@@ -538,13 +538,18 @@ function getStandalonePath(output) {
|
|
|
538
538
|
function getSource(content, language, tags, { namedExamples }) {
|
|
539
539
|
const compare = findTag(tags, "compare");
|
|
540
540
|
if (compare && compare.value !== null) {
|
|
541
|
+
const { value: context } = findTag(tags, "context") ?? {};
|
|
541
542
|
const reference = namedExamples.get(compare.value);
|
|
542
543
|
if (!reference) {
|
|
543
544
|
throw new Error(
|
|
544
545
|
`Failed to find referenced example "${compare.value}"`
|
|
545
546
|
);
|
|
546
547
|
}
|
|
547
|
-
const
|
|
548
|
+
const a = transformCode(reference.content, reference.language);
|
|
549
|
+
const b = transformCode(content, language);
|
|
550
|
+
const diff = vendor.createTwoFilesPatch("a", "b", a, b, "", "", {
|
|
551
|
+
context: context ? parseInt(context, 10) : 3
|
|
552
|
+
}).split("\n").slice(4).join("\n");
|
|
548
553
|
return {
|
|
549
554
|
source: diff,
|
|
550
555
|
language: "diff"
|
|
@@ -566,7 +571,8 @@ function codePreview(options) {
|
|
|
566
571
|
env.namedExamples.set(name, {
|
|
567
572
|
name,
|
|
568
573
|
tags: rawTags,
|
|
569
|
-
content: rawContent
|
|
574
|
+
content: rawContent,
|
|
575
|
+
language: rawLanguage
|
|
570
576
|
});
|
|
571
577
|
}
|
|
572
578
|
if (hasTag(rawTags, "hidden")) {
|
|
@@ -1092,5 +1098,6 @@ exports.generateId = generateId;
|
|
|
1092
1098
|
exports.getFingerprint = getFingerprint;
|
|
1093
1099
|
exports.getOutputFilePath = getOutputFilePath;
|
|
1094
1100
|
exports.hasTag = hasTag;
|
|
1101
|
+
exports.htmlencode = htmlencode;
|
|
1095
1102
|
exports.normalizePath = normalizePath;
|
|
1096
1103
|
exports.parseInfostring = parseInfostring;
|
package/dist/index.d.ts
CHANGED
|
@@ -325,6 +325,9 @@ export declare interface ManifestProcessorOptions {
|
|
|
325
325
|
markdown?: string;
|
|
326
326
|
/** If set, the manifest will be written as JSON to this destination */
|
|
327
327
|
json?: string;
|
|
328
|
+
/** If set to `true` the markdown manifest will be verified instead of
|
|
329
|
+
* written (typically enabled during CI) */
|
|
330
|
+
verify?: boolean;
|
|
328
331
|
}
|
|
329
332
|
|
|
330
333
|
/**
|
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-Bagon7WF.js');
|
|
6
6
|
var path$1 = require('node:path');
|
|
7
7
|
var require$$1 = require('crypto');
|
|
8
8
|
require('node:crypto');
|
|
9
|
-
var createMarkdownRenderer = require('./create-markdown-renderer-
|
|
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-CEAR7ggN.js');
|
|
48
48
|
|
|
49
49
|
var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null;
|
|
50
50
|
function toArray$2(value) {
|
|
@@ -424,8 +424,26 @@ function renderMarkdown(manifest) {
|
|
|
424
424
|
function renderJSON(manifest) {
|
|
425
425
|
return JSON.stringify(manifest, null, 2);
|
|
426
426
|
}
|
|
427
|
+
function normalize(text) {
|
|
428
|
+
return text.replace(/\r\n/g, "\n");
|
|
429
|
+
}
|
|
430
|
+
class ManifestError extends Error {
|
|
431
|
+
filename;
|
|
432
|
+
constructor(filename) {
|
|
433
|
+
super(`Documentation manifest "${filename}" is not up-to-date!`);
|
|
434
|
+
this.filename = filename;
|
|
435
|
+
}
|
|
436
|
+
prettyError() {
|
|
437
|
+
const { filename, message } = this;
|
|
438
|
+
return [
|
|
439
|
+
message,
|
|
440
|
+
"",
|
|
441
|
+
`Run the build locally and commit the content of "${filename}".`
|
|
442
|
+
].join("\n");
|
|
443
|
+
}
|
|
444
|
+
}
|
|
427
445
|
function manifestProcessor(options = {}) {
|
|
428
|
-
const { markdown, json } = options;
|
|
446
|
+
const { markdown, json, verify } = options;
|
|
429
447
|
return {
|
|
430
448
|
name: "manifestProcessor",
|
|
431
449
|
before: "render",
|
|
@@ -437,8 +455,17 @@ function manifestProcessor(options = {}) {
|
|
|
437
455
|
});
|
|
438
456
|
const manifest = { pages };
|
|
439
457
|
if (markdown) {
|
|
440
|
-
const content = renderMarkdown(manifest);
|
|
441
|
-
|
|
458
|
+
const content = normalize(renderMarkdown(manifest));
|
|
459
|
+
if (verify) {
|
|
460
|
+
const actual = normalize(
|
|
461
|
+
await fs.readFile(markdown, "utf-8")
|
|
462
|
+
);
|
|
463
|
+
if (actual !== content) {
|
|
464
|
+
throw new ManifestError(markdown);
|
|
465
|
+
}
|
|
466
|
+
} else {
|
|
467
|
+
await fs.writeFile(markdown, content, "utf-8");
|
|
468
|
+
}
|
|
442
469
|
}
|
|
443
470
|
if (json) {
|
|
444
471
|
const content = renderJSON(manifest);
|
|
@@ -1231,15 +1258,16 @@ function generatePropTable(slug, props) {
|
|
|
1231
1258
|
<dl class="docs-api docs-api--slots">
|
|
1232
1259
|
${props.map((prop) => {
|
|
1233
1260
|
const { name } = prop;
|
|
1234
|
-
const id = `${slug}-
|
|
1261
|
+
const id = `${slug}-prop-${slugify(name)}`;
|
|
1235
1262
|
return (
|
|
1236
1263
|
/* HTML */
|
|
1237
1264
|
`
|
|
1238
1265
|
<dt>
|
|
1239
1266
|
<code id="${id}"
|
|
1240
1267
|
><a class="docs-api__anchor" href="#${id}"
|
|
1241
|
-
><span class="docs-api__name"
|
|
1242
|
-
|
|
1268
|
+
><span class="docs-api__name"
|
|
1269
|
+
>${createMarkdownRenderer.htmlencode(name)}</span
|
|
1270
|
+
>: ${createMarkdownRenderer.htmlencode(prop.type ?? "unknown")}</a
|
|
1243
1271
|
></code
|
|
1244
1272
|
>
|
|
1245
1273
|
${prop.required ? "" : `<span class="docs-tag docs-tag--default">Optional</span>`}
|
|
@@ -1247,7 +1275,7 @@ function generatePropTable(slug, props) {
|
|
|
1247
1275
|
</dt>
|
|
1248
1276
|
<dd>
|
|
1249
1277
|
${render$3(prop.description)}
|
|
1250
|
-
${prop.default ? `<p class="doc-api__item">Default: <code>${prop.default.value}</code></p>` : ""}
|
|
1278
|
+
${prop.default ? `<p class="doc-api__item">Default: <code>${createMarkdownRenderer.htmlencode(prop.default.value)}</code></p>` : ""}
|
|
1251
1279
|
${prop.deprecated ? `<p class="doc-api__item docs-deprecated">Deprecated: ${renderInline$2(prop.deprecated)}</p>` : ""}
|
|
1252
1280
|
</dd>
|
|
1253
1281
|
`
|
|
@@ -1277,7 +1305,7 @@ function generateEventTable(slug, events) {
|
|
|
1277
1305
|
<dl class="docs-api docs-api--events">
|
|
1278
1306
|
${events.map((event) => {
|
|
1279
1307
|
const { name } = event;
|
|
1280
|
-
const id = `${slug}-event-${name}`;
|
|
1308
|
+
const id = `${slug}-event-${slugify(name)}`;
|
|
1281
1309
|
const haveProperties = event.properties.length > 0;
|
|
1282
1310
|
return (
|
|
1283
1311
|
/* HTML */
|
|
@@ -1286,7 +1314,7 @@ function generateEventTable(slug, events) {
|
|
|
1286
1314
|
<code id="${id}"
|
|
1287
1315
|
><a class="docs-api__anchor" href="#${id}"
|
|
1288
1316
|
><span class="docs-api__name"
|
|
1289
|
-
>${name}</span
|
|
1317
|
+
>${createMarkdownRenderer.htmlencode(name)}</span
|
|
1290
1318
|
></a
|
|
1291
1319
|
></code
|
|
1292
1320
|
>
|
|
@@ -1297,9 +1325,9 @@ function generateEventTable(slug, events) {
|
|
|
1297
1325
|
${haveProperties ? `<p class="docs-api__list-title">Arguments:</p><ul class="docs-api__list">` : ""}
|
|
1298
1326
|
${event.properties.map((it) => {
|
|
1299
1327
|
if (it.description) {
|
|
1300
|
-
return `<li><code>${it.name}: ${it.type}</code> ${EM_DASH$1} ${it.description}</li>`;
|
|
1328
|
+
return `<li><code>${createMarkdownRenderer.htmlencode(it.name)}: ${createMarkdownRenderer.htmlencode(it.type ?? "unknown")}</code> ${EM_DASH$1} ${renderInline$1(it.description)}</li>`;
|
|
1301
1329
|
} else {
|
|
1302
|
-
return `<li><code>${it.name}: ${it.type}</code></li>`;
|
|
1330
|
+
return `<li><code>${createMarkdownRenderer.htmlencode(it.name)}: ${createMarkdownRenderer.htmlencode(it.type ?? "unknown")}</code></li>`;
|
|
1303
1331
|
}
|
|
1304
1332
|
}).join("")}
|
|
1305
1333
|
${haveProperties ? `</ul>` : ""}
|
|
@@ -1332,7 +1360,7 @@ function generateSlotTable(slug, slots) {
|
|
|
1332
1360
|
<dl class="docs-api docs-api--slots">
|
|
1333
1361
|
${slots.map((slot) => {
|
|
1334
1362
|
const { name } = slot;
|
|
1335
|
-
const id = `${slug}-slot-${name}`;
|
|
1363
|
+
const id = `${slug}-slot-${slugify(name)}`;
|
|
1336
1364
|
const haveBindings = slot.bindings.length > 0;
|
|
1337
1365
|
return (
|
|
1338
1366
|
/* HTML */
|
|
@@ -1341,7 +1369,7 @@ function generateSlotTable(slug, slots) {
|
|
|
1341
1369
|
<code id="${id}"
|
|
1342
1370
|
><a class="docs-api__anchor" href="#${id}"
|
|
1343
1371
|
><span class="docs-api__name"
|
|
1344
|
-
>${name}</span
|
|
1372
|
+
>${createMarkdownRenderer.htmlencode(name)}</span
|
|
1345
1373
|
></a
|
|
1346
1374
|
></code
|
|
1347
1375
|
>
|
|
@@ -1352,9 +1380,9 @@ function generateSlotTable(slug, slots) {
|
|
|
1352
1380
|
${haveBindings ? `<p class="docs-api__list-title">Bindings:</p><ul class="docs-api__list">` : ""}
|
|
1353
1381
|
${slot.bindings.map((it) => {
|
|
1354
1382
|
if (it.description) {
|
|
1355
|
-
return `<li><code>${it.name}: ${it.type}</code> ${EM_DASH} ${it.description}</li>`;
|
|
1383
|
+
return `<li><code>${createMarkdownRenderer.htmlencode(it.name)}: ${createMarkdownRenderer.htmlencode(it.type ?? "unknown")}</code> ${EM_DASH} ${renderInline(it.description)}</li>`;
|
|
1356
1384
|
} else {
|
|
1357
|
-
return `<li><code>${it.name}: ${it.type}</code></li>`;
|
|
1385
|
+
return `<li><code>${createMarkdownRenderer.htmlencode(it.name)}: ${createMarkdownRenderer.htmlencode(it.type ?? "unknown")}</code></li>`;
|
|
1358
1386
|
}
|
|
1359
1387
|
}).join("")}
|
|
1360
1388
|
${haveBindings ? `</ul>` : ""}
|
package/dist/markdown.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var createMarkdownRenderer = require('./create-markdown-renderer-
|
|
4
|
-
require('./vendor-
|
|
3
|
+
var createMarkdownRenderer = require('./create-markdown-renderer-CaJTFjAd.js');
|
|
4
|
+
require('./vendor-Bagon7WF.js');
|
|
5
5
|
require('node:url');
|
|
6
6
|
require('node:path');
|
|
7
7
|
require('fs');
|
|
@@ -37,7 +37,7 @@ require('querystring');
|
|
|
37
37
|
require('node:path/posix');
|
|
38
38
|
require('node:crypto');
|
|
39
39
|
require('vue');
|
|
40
|
-
require('./vue3-
|
|
40
|
+
require('./vue3-CEAR7ggN.js');
|
|
41
41
|
|
|
42
42
|
|
|
43
43
|
|
|
@@ -26515,6 +26515,11 @@ function formatPatch(diff) {
|
|
|
26515
26515
|
}
|
|
26516
26516
|
function createTwoFilesPatch(oldFileName, newFileName, oldStr, newStr, oldHeader, newHeader, options) {
|
|
26517
26517
|
var _options2;
|
|
26518
|
+
if (typeof options === 'function') {
|
|
26519
|
+
options = {
|
|
26520
|
+
callback: options
|
|
26521
|
+
};
|
|
26522
|
+
}
|
|
26518
26523
|
if (!((_options2 = options) !== null && _options2 !== undefined && _options2.callback)) {
|
|
26519
26524
|
var patchObj = structuredPatch(oldFileName, newFileName, oldStr, newStr, oldHeader, newHeader, options);
|
|
26520
26525
|
if (!patchObj) {
|