@forsakringskassan/docs-generator 2.23.0 → 2.24.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-BSbHc8U0.js → create-markdown-renderer-wbIE-KQj.js} +3 -3
- package/dist/{create-markdown-renderer-BSbHc8U0.js.map → create-markdown-renderer-wbIE-KQj.js.map} +1 -1
- package/dist/index.d.ts +5 -0
- package/dist/index.js +336 -57
- package/dist/index.js.map +1 -1
- package/dist/markdown.d.ts +5 -0
- package/dist/markdown.js +3 -3
- package/dist/runtime.js +57 -16
- package/dist/style/core.css +54 -0
- package/dist/style/index.css +54 -0
- package/dist/tsdoc-metadata.json +1 -1
- package/dist/{vendor-BxO3IPg6.js → vendor-DQQ31U4v.js} +520 -38
- package/dist/vendor-DQQ31U4v.js.map +1 -0
- package/dist/{vue3-CZnjnYGV.js → vue3-BQVQQ2Vn.js} +2 -2
- package/dist/{vue3-CZnjnYGV.js.map → vue3-BQVQQ2Vn.js.map} +1 -1
- package/package.json +3 -1
- package/templates/api.class.template.html +1 -0
- package/templates/api.composable.template.html +1 -0
- package/templates/api.constant.template.html +1 -0
- package/templates/api.enum.template.html +1 -0
- package/templates/api.function.template.html +1 -0
- package/templates/api.interface.template.html +1 -0
- package/templates/api.method.template.html +1 -0
- package/templates/api.template.html +1 -0
- package/templates/api.type.template.html +1 -0
- package/templates/base.template.html +1 -1
- package/dist/vendor-BxO3IPg6.js.map +0 -1
package/dist/index.js
CHANGED
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
var fs = require('node:fs/promises');
|
|
4
4
|
var path = require('node:path/posix');
|
|
5
|
-
var vendor = require('./vendor-
|
|
6
|
-
var createMarkdownRenderer = require('./create-markdown-renderer-
|
|
5
|
+
var vendor = require('./vendor-DQQ31U4v.js');
|
|
6
|
+
var createMarkdownRenderer = require('./create-markdown-renderer-wbIE-KQj.js');
|
|
7
7
|
var path$1 = require('node:path');
|
|
8
8
|
var require$$1 = require('crypto');
|
|
9
9
|
require('node:crypto');
|
|
@@ -11,6 +11,9 @@ var node_child_process = require('node:child_process');
|
|
|
11
11
|
var util = require('node:util');
|
|
12
12
|
var codeFrame = require('@babel/code-frame');
|
|
13
13
|
var vueDocgenApi = require('vue-docgen-api');
|
|
14
|
+
var parser = require('@babel/parser');
|
|
15
|
+
var traverseModule = require('@babel/traverse');
|
|
16
|
+
var require$$0 = require('@vue/compiler-sfc');
|
|
14
17
|
var fs$1 = require('node:fs');
|
|
15
18
|
var sass = require('sass');
|
|
16
19
|
var node_url = require('node:url');
|
|
@@ -21,7 +24,6 @@ require('fs');
|
|
|
21
24
|
require('node:events');
|
|
22
25
|
require('node:stream');
|
|
23
26
|
require('node:string_decoder');
|
|
24
|
-
require('@vue/compiler-sfc');
|
|
25
27
|
require('typescript');
|
|
26
28
|
require('constants');
|
|
27
29
|
require('stream');
|
|
@@ -44,7 +46,7 @@ require('tls');
|
|
|
44
46
|
require('tty');
|
|
45
47
|
require('querystring');
|
|
46
48
|
require('vue');
|
|
47
|
-
require('./vue3-
|
|
49
|
+
require('./vue3-BQVQQ2Vn.js');
|
|
48
50
|
|
|
49
51
|
var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null;
|
|
50
52
|
function toArray$2(value) {
|
|
@@ -81,6 +83,7 @@ const documentAttributeKeys = [
|
|
|
81
83
|
"include",
|
|
82
84
|
"component",
|
|
83
85
|
"href",
|
|
86
|
+
"search",
|
|
84
87
|
"sortorder",
|
|
85
88
|
"redirect_from"
|
|
86
89
|
];
|
|
@@ -281,8 +284,8 @@ function slugify(value) {
|
|
|
281
284
|
return value.toLowerCase().replace(/\//g, "--").replace(/[^a-z]+/g, "-").replace(/(^-+|-+$)/, "");
|
|
282
285
|
}
|
|
283
286
|
|
|
284
|
-
const md$
|
|
285
|
-
md$
|
|
287
|
+
const md$5 = vendor.MarkdownIt();
|
|
288
|
+
md$5.renderer.rules.fence = (tokens, idx, _options, collected) => {
|
|
286
289
|
const { content, info } = tokens[idx];
|
|
287
290
|
const { language, tags } = createMarkdownRenderer.parseInfostring(info);
|
|
288
291
|
if (language === "import") {
|
|
@@ -303,7 +306,7 @@ function findExamples$1(doc) {
|
|
|
303
306
|
return [];
|
|
304
307
|
}
|
|
305
308
|
const collected = [];
|
|
306
|
-
md$
|
|
309
|
+
md$5.render(doc.body, collected);
|
|
307
310
|
return collected;
|
|
308
311
|
}
|
|
309
312
|
function getSuffix(tags) {
|
|
@@ -370,8 +373,8 @@ function extractExamplesProcessor(options) {
|
|
|
370
373
|
};
|
|
371
374
|
}
|
|
372
375
|
|
|
373
|
-
const md$
|
|
374
|
-
md$
|
|
376
|
+
const md$4 = vendor.MarkdownIt();
|
|
377
|
+
md$4.renderer.rules.fence = (tokens, idx, _options, collected) => {
|
|
375
378
|
const { content, info, map } = tokens[idx];
|
|
376
379
|
const { language, tags } = createMarkdownRenderer.parseInfostring(info);
|
|
377
380
|
const hashContent = `${map?.[0]}:${map?.[1]}:${info}:${content}`;
|
|
@@ -405,7 +408,7 @@ function findExamples(doc) {
|
|
|
405
408
|
return [];
|
|
406
409
|
}
|
|
407
410
|
const collected = [];
|
|
408
|
-
md$
|
|
411
|
+
md$4.render(doc.body, collected);
|
|
409
412
|
return collected;
|
|
410
413
|
}
|
|
411
414
|
function manifestPageFromDocument(doc) {
|
|
@@ -697,7 +700,8 @@ function redirectProcessor() {
|
|
|
697
700
|
visible: false,
|
|
698
701
|
attributes: {
|
|
699
702
|
sortorder: Infinity,
|
|
700
|
-
redirectFrom: []
|
|
703
|
+
redirectFrom: [],
|
|
704
|
+
search: { terms: [] }
|
|
701
705
|
},
|
|
702
706
|
body: redirect.to,
|
|
703
707
|
outline: [],
|
|
@@ -1085,6 +1089,9 @@ function parseFile$1(filePath, basePath, content) {
|
|
|
1085
1089
|
badge: getBadge(attributes),
|
|
1086
1090
|
component: getComponent(attributes),
|
|
1087
1091
|
redirectFrom: toArray$1(attributes.redirect_from ?? []),
|
|
1092
|
+
search: {
|
|
1093
|
+
terms: toArray$1(attributes.search?.terms ?? [])
|
|
1094
|
+
},
|
|
1088
1095
|
sortorder: attributes.sortorder ?? Infinity
|
|
1089
1096
|
},
|
|
1090
1097
|
body: blocks.body,
|
|
@@ -1252,13 +1259,13 @@ async function translateAPI(filePath) {
|
|
|
1252
1259
|
};
|
|
1253
1260
|
}
|
|
1254
1261
|
|
|
1255
|
-
const md$
|
|
1256
|
-
const EMPTY_CHAR$
|
|
1257
|
-
function render$
|
|
1258
|
-
return text ? md$
|
|
1262
|
+
const md$3 = vendor.MarkdownIt();
|
|
1263
|
+
const EMPTY_CHAR$3 = "‐";
|
|
1264
|
+
function render$4(text) {
|
|
1265
|
+
return text ? md$3.render(text) : EMPTY_CHAR$3;
|
|
1259
1266
|
}
|
|
1260
|
-
function renderInline$
|
|
1261
|
-
return text ? md$
|
|
1267
|
+
function renderInline$3(text) {
|
|
1268
|
+
return text ? md$3.renderInline(text) : EMPTY_CHAR$3;
|
|
1262
1269
|
}
|
|
1263
1270
|
function generatePropTable(slug, props) {
|
|
1264
1271
|
return (
|
|
@@ -1286,9 +1293,9 @@ function generatePropTable(slug, props) {
|
|
|
1286
1293
|
${prop.deprecated === null ? "" : `<span class="docs-tag docs-tag--deprecated">Deprecated</span>`}
|
|
1287
1294
|
</dt>
|
|
1288
1295
|
<dd>
|
|
1289
|
-
${render$
|
|
1296
|
+
${render$4(prop.description)}
|
|
1290
1297
|
${prop.default ? `<p class="doc-api__item">Default: <code>${createMarkdownRenderer.htmlencode(prop.default.value)}</code></p>` : ""}
|
|
1291
|
-
${prop.deprecated ? `<p class="doc-api__item docs-deprecated">Deprecated: ${renderInline$
|
|
1298
|
+
${prop.deprecated ? `<p class="doc-api__item docs-deprecated">Deprecated: ${renderInline$3(prop.deprecated)}</p>` : ""}
|
|
1292
1299
|
</dd>
|
|
1293
1300
|
`
|
|
1294
1301
|
);
|
|
@@ -1298,14 +1305,14 @@ function generatePropTable(slug, props) {
|
|
|
1298
1305
|
);
|
|
1299
1306
|
}
|
|
1300
1307
|
|
|
1301
|
-
const md$
|
|
1302
|
-
const EMPTY_CHAR$
|
|
1303
|
-
const EM_DASH$
|
|
1304
|
-
function render$
|
|
1305
|
-
return text ? md$
|
|
1308
|
+
const md$2 = vendor.MarkdownIt();
|
|
1309
|
+
const EMPTY_CHAR$2 = "‐";
|
|
1310
|
+
const EM_DASH$2 = `<span role="presentation">—</span>`;
|
|
1311
|
+
function render$3(text) {
|
|
1312
|
+
return text ? md$2.render(text) : EMPTY_CHAR$2;
|
|
1306
1313
|
}
|
|
1307
|
-
function renderInline$
|
|
1308
|
-
return text ? md$
|
|
1314
|
+
function renderInline$2(text) {
|
|
1315
|
+
return text ? md$2.renderInline(text) : EMPTY_CHAR$2;
|
|
1309
1316
|
}
|
|
1310
1317
|
function generateEventTable(slug, events) {
|
|
1311
1318
|
return (
|
|
@@ -1333,17 +1340,17 @@ function generateEventTable(slug, events) {
|
|
|
1333
1340
|
${event.deprecated === null ? "" : `<span class="docs-tag docs-tag--deprecated">Deprecated</span>`}
|
|
1334
1341
|
</dt>
|
|
1335
1342
|
<dd>
|
|
1336
|
-
${render$
|
|
1343
|
+
${render$3(event.description)}
|
|
1337
1344
|
${haveProperties ? `<p class="docs-api__list-title">Arguments:</p><ul class="docs-api__list">` : ""}
|
|
1338
1345
|
${event.properties.map((it) => {
|
|
1339
1346
|
if (it.description) {
|
|
1340
|
-
return `<li><code>${createMarkdownRenderer.htmlencode(it.name)}: ${createMarkdownRenderer.htmlencode(it.type ?? "unknown")}</code> ${EM_DASH$
|
|
1347
|
+
return `<li><code>${createMarkdownRenderer.htmlencode(it.name)}: ${createMarkdownRenderer.htmlencode(it.type ?? "unknown")}</code> ${EM_DASH$2} ${renderInline$2(it.description)}</li>`;
|
|
1341
1348
|
} else {
|
|
1342
1349
|
return `<li><code>${createMarkdownRenderer.htmlencode(it.name)}: ${createMarkdownRenderer.htmlencode(it.type ?? "unknown")}</code></li>`;
|
|
1343
1350
|
}
|
|
1344
1351
|
}).join("")}
|
|
1345
1352
|
${haveProperties ? `</ul>` : ""}
|
|
1346
|
-
${event.deprecated ? `<p class="docs-api__deprecated docs-deprecated">Deprecated: ${renderInline$
|
|
1353
|
+
${event.deprecated ? `<p class="docs-api__deprecated docs-deprecated">Deprecated: ${renderInline$2(event.deprecated)}</p>` : ""}
|
|
1347
1354
|
</dd>
|
|
1348
1355
|
`
|
|
1349
1356
|
);
|
|
@@ -1353,14 +1360,14 @@ function generateEventTable(slug, events) {
|
|
|
1353
1360
|
);
|
|
1354
1361
|
}
|
|
1355
1362
|
|
|
1356
|
-
const md = vendor.MarkdownIt();
|
|
1357
|
-
const EMPTY_CHAR = "‐";
|
|
1358
|
-
const EM_DASH = `<span role="presentation">—</span>`;
|
|
1359
|
-
function render$
|
|
1360
|
-
return text ? md.render(text) : EMPTY_CHAR;
|
|
1363
|
+
const md$1 = vendor.MarkdownIt();
|
|
1364
|
+
const EMPTY_CHAR$1 = "‐";
|
|
1365
|
+
const EM_DASH$1 = `<span role="presentation">—</span>`;
|
|
1366
|
+
function render$2(text) {
|
|
1367
|
+
return text ? md$1.render(text) : EMPTY_CHAR$1;
|
|
1361
1368
|
}
|
|
1362
|
-
function renderInline(text) {
|
|
1363
|
-
return text ? md.renderInline(text) : EMPTY_CHAR;
|
|
1369
|
+
function renderInline$1(text) {
|
|
1370
|
+
return text ? md$1.renderInline(text) : EMPTY_CHAR$1;
|
|
1364
1371
|
}
|
|
1365
1372
|
function generateSlotTable(slug, slots) {
|
|
1366
1373
|
return (
|
|
@@ -1388,17 +1395,247 @@ function generateSlotTable(slug, slots) {
|
|
|
1388
1395
|
${slot.deprecated === null ? "" : `<span class="docs-tag docs-tag--deprecated">Deprecated</span>`}
|
|
1389
1396
|
</dt>
|
|
1390
1397
|
<dd>
|
|
1391
|
-
${render$
|
|
1398
|
+
${render$2(slot.description)}
|
|
1392
1399
|
${haveBindings ? `<p class="docs-api__list-title">Bindings:</p><ul class="docs-api__list">` : ""}
|
|
1393
1400
|
${slot.bindings.map((it) => {
|
|
1394
1401
|
if (it.description) {
|
|
1395
|
-
return `<li><code>${createMarkdownRenderer.htmlencode(it.name)}: ${createMarkdownRenderer.htmlencode(it.type ?? "unknown")}</code> ${EM_DASH} ${renderInline(it.description)}</li>`;
|
|
1402
|
+
return `<li><code>${createMarkdownRenderer.htmlencode(it.name)}: ${createMarkdownRenderer.htmlencode(it.type ?? "unknown")}</code> ${EM_DASH$1} ${renderInline$1(it.description)}</li>`;
|
|
1396
1403
|
} else {
|
|
1397
1404
|
return `<li><code>${createMarkdownRenderer.htmlencode(it.name)}: ${createMarkdownRenderer.htmlencode(it.type ?? "unknown")}</code></li>`;
|
|
1398
1405
|
}
|
|
1399
1406
|
}).join("")}
|
|
1400
1407
|
${haveBindings ? `</ul>` : ""}
|
|
1401
|
-
${slot.deprecated ? `<p class="docs-api__deprecated docs-deprecated">Deprecated: ${renderInline(slot.deprecated)}</p>` : ""}
|
|
1408
|
+
${slot.deprecated ? `<p class="docs-api__deprecated docs-deprecated">Deprecated: ${renderInline$1(slot.deprecated)}</p>` : ""}
|
|
1409
|
+
</dd>
|
|
1410
|
+
`
|
|
1411
|
+
);
|
|
1412
|
+
}).join("")}
|
|
1413
|
+
</dl>
|
|
1414
|
+
`
|
|
1415
|
+
);
|
|
1416
|
+
}
|
|
1417
|
+
|
|
1418
|
+
function isStringLiteral(node) {
|
|
1419
|
+
return node.type === "StringLiteral";
|
|
1420
|
+
}
|
|
1421
|
+
function isObjectExpression(node) {
|
|
1422
|
+
return node.type === "ObjectExpression";
|
|
1423
|
+
}
|
|
1424
|
+
function isDocComment(node) {
|
|
1425
|
+
return node.type === "CommentBlock";
|
|
1426
|
+
}
|
|
1427
|
+
function getDescription(node) {
|
|
1428
|
+
if (!node) {
|
|
1429
|
+
return null;
|
|
1430
|
+
}
|
|
1431
|
+
const text = node.value;
|
|
1432
|
+
if (!text.startsWith("*")) {
|
|
1433
|
+
return null;
|
|
1434
|
+
}
|
|
1435
|
+
return node.value.replace(/^\s*[*]\s/gm, "").replace(/\s+$/gm, "");
|
|
1436
|
+
}
|
|
1437
|
+
function flattenMemberExpression(node) {
|
|
1438
|
+
const { object, property } = node;
|
|
1439
|
+
if (property.type !== "Identifier") {
|
|
1440
|
+
return null;
|
|
1441
|
+
}
|
|
1442
|
+
if (object.type === "Identifier") {
|
|
1443
|
+
return [object.name, property.name].join(".");
|
|
1444
|
+
}
|
|
1445
|
+
if (object.type === "ThisExpression") {
|
|
1446
|
+
return ["this", property.name].join(".");
|
|
1447
|
+
}
|
|
1448
|
+
if (object.type === "MemberExpression") {
|
|
1449
|
+
const nested = flattenMemberExpression(object);
|
|
1450
|
+
if (nested) {
|
|
1451
|
+
return [nested, property.name].join(".");
|
|
1452
|
+
}
|
|
1453
|
+
}
|
|
1454
|
+
return null;
|
|
1455
|
+
}
|
|
1456
|
+
function getParameters(node) {
|
|
1457
|
+
if (!node) {
|
|
1458
|
+
return [];
|
|
1459
|
+
}
|
|
1460
|
+
const parameters = [];
|
|
1461
|
+
for (const property of node.properties) {
|
|
1462
|
+
if (property.type !== "ObjectProperty") {
|
|
1463
|
+
continue;
|
|
1464
|
+
}
|
|
1465
|
+
if (property.key.type !== "Identifier") {
|
|
1466
|
+
continue;
|
|
1467
|
+
}
|
|
1468
|
+
const docComment = property.leadingComments?.find(isDocComment);
|
|
1469
|
+
parameters.push({
|
|
1470
|
+
name: property.key.name,
|
|
1471
|
+
description: getDescription(docComment)
|
|
1472
|
+
});
|
|
1473
|
+
}
|
|
1474
|
+
return parameters;
|
|
1475
|
+
}
|
|
1476
|
+
function isTranslateCall(node) {
|
|
1477
|
+
const allowedNames = [
|
|
1478
|
+
"this.$t",
|
|
1479
|
+
// options api (inside computed, methods, etc)
|
|
1480
|
+
"_ctx.$t",
|
|
1481
|
+
// options api (template)
|
|
1482
|
+
"$setup.$t",
|
|
1483
|
+
// script setup or setup in options api
|
|
1484
|
+
"TranslationService.provider.translate"
|
|
1485
|
+
// props call this directly
|
|
1486
|
+
];
|
|
1487
|
+
if (node.callee.type === "MemberExpression") {
|
|
1488
|
+
const fullName = flattenMemberExpression(node.callee);
|
|
1489
|
+
return Boolean(fullName && allowedNames.includes(fullName));
|
|
1490
|
+
}
|
|
1491
|
+
if (node.callee.type === "Identifier") {
|
|
1492
|
+
return node.callee.name === "$t";
|
|
1493
|
+
}
|
|
1494
|
+
return false;
|
|
1495
|
+
}
|
|
1496
|
+
function findDocComment(path, node) {
|
|
1497
|
+
if (node.leadingComments) {
|
|
1498
|
+
const doc = node.leadingComments.find(isDocComment);
|
|
1499
|
+
if (doc) {
|
|
1500
|
+
return doc;
|
|
1501
|
+
}
|
|
1502
|
+
}
|
|
1503
|
+
const parent = path.parent;
|
|
1504
|
+
if (parent.leadingComments && (parent.type === "ReturnStatement" || parent.type === "ObjectProperty")) {
|
|
1505
|
+
const doc = parent.leadingComments.find(isDocComment);
|
|
1506
|
+
if (doc) {
|
|
1507
|
+
return doc;
|
|
1508
|
+
}
|
|
1509
|
+
}
|
|
1510
|
+
return null;
|
|
1511
|
+
}
|
|
1512
|
+
function findTranslations(filename, content) {
|
|
1513
|
+
const { descriptor, errors } = require$$0.parse(content, { filename });
|
|
1514
|
+
if (errors.length > 0) {
|
|
1515
|
+
if (vendor.isCI) {
|
|
1516
|
+
const first = errors[0].message;
|
|
1517
|
+
throw new Error(
|
|
1518
|
+
`Errors occurred when trying to parse "${filename}": ${first}`
|
|
1519
|
+
);
|
|
1520
|
+
}
|
|
1521
|
+
return [];
|
|
1522
|
+
}
|
|
1523
|
+
const id = "faux-id";
|
|
1524
|
+
let sourcecode = "";
|
|
1525
|
+
let bindings = void 0;
|
|
1526
|
+
if (descriptor.script || descriptor.scriptSetup) {
|
|
1527
|
+
const script = require$$0.compileScript(descriptor, {
|
|
1528
|
+
id,
|
|
1529
|
+
isProd: false,
|
|
1530
|
+
sourceMap: false,
|
|
1531
|
+
inlineTemplate: false,
|
|
1532
|
+
genDefaultAs: "exampleComponent",
|
|
1533
|
+
templateOptions: {
|
|
1534
|
+
filename,
|
|
1535
|
+
source: descriptor.template?.content,
|
|
1536
|
+
slotted: descriptor.slotted,
|
|
1537
|
+
compilerOptions: {
|
|
1538
|
+
comments: true,
|
|
1539
|
+
whitespace: "condense",
|
|
1540
|
+
mode: "module"
|
|
1541
|
+
}
|
|
1542
|
+
}
|
|
1543
|
+
});
|
|
1544
|
+
bindings = script.bindings;
|
|
1545
|
+
sourcecode += `${script.content}
|
|
1546
|
+
|
|
1547
|
+
`;
|
|
1548
|
+
}
|
|
1549
|
+
if (descriptor.template) {
|
|
1550
|
+
const template = require$$0.compileTemplate({
|
|
1551
|
+
id,
|
|
1552
|
+
filename,
|
|
1553
|
+
source: descriptor.template.content,
|
|
1554
|
+
slotted: descriptor.slotted,
|
|
1555
|
+
preprocessLang: descriptor.template.lang,
|
|
1556
|
+
compilerOptions: {
|
|
1557
|
+
bindingMetadata: bindings,
|
|
1558
|
+
comments: true,
|
|
1559
|
+
whitespace: "condense",
|
|
1560
|
+
mode: "module"
|
|
1561
|
+
}
|
|
1562
|
+
});
|
|
1563
|
+
sourcecode += `${template.code}
|
|
1564
|
+
|
|
1565
|
+
`;
|
|
1566
|
+
}
|
|
1567
|
+
const ast = parser.parse(sourcecode, {
|
|
1568
|
+
sourceType: "module",
|
|
1569
|
+
plugins: ["typescript"]
|
|
1570
|
+
});
|
|
1571
|
+
const traverse = "default" in traverseModule ? traverseModule.default : traverseModule;
|
|
1572
|
+
const result = [];
|
|
1573
|
+
traverse(ast, {
|
|
1574
|
+
CallExpression(path) {
|
|
1575
|
+
const { node } = path;
|
|
1576
|
+
if (isTranslateCall(node)) {
|
|
1577
|
+
const [name, ...defaultOrParams] = node.arguments;
|
|
1578
|
+
const textArgument = defaultOrParams.find(isStringLiteral);
|
|
1579
|
+
const paramArgument = defaultOrParams.find(isObjectExpression);
|
|
1580
|
+
if (name.type !== "StringLiteral") {
|
|
1581
|
+
return;
|
|
1582
|
+
}
|
|
1583
|
+
const defaultTranslation = textArgument ? textArgument.value : null;
|
|
1584
|
+
const docComment = findDocComment(path, node);
|
|
1585
|
+
result.push({
|
|
1586
|
+
name: name.value,
|
|
1587
|
+
defaultTranslation,
|
|
1588
|
+
description: getDescription(docComment),
|
|
1589
|
+
parameters: getParameters(paramArgument)
|
|
1590
|
+
});
|
|
1591
|
+
}
|
|
1592
|
+
}
|
|
1593
|
+
});
|
|
1594
|
+
return result;
|
|
1595
|
+
}
|
|
1596
|
+
|
|
1597
|
+
const md = vendor.MarkdownIt();
|
|
1598
|
+
const EMPTY_CHAR = "‐";
|
|
1599
|
+
const EM_DASH = `<span role="presentation">—</span>`;
|
|
1600
|
+
function render$1(text) {
|
|
1601
|
+
return text ? md.render(text) : EMPTY_CHAR;
|
|
1602
|
+
}
|
|
1603
|
+
function renderInline(text) {
|
|
1604
|
+
return text ? md.renderInline(text) : EMPTY_CHAR;
|
|
1605
|
+
}
|
|
1606
|
+
function generateTranslationTable(slug, translations) {
|
|
1607
|
+
return (
|
|
1608
|
+
/* HTML */
|
|
1609
|
+
`
|
|
1610
|
+
<dl class="docs-api docs-api--translation">
|
|
1611
|
+
${translations.map((translation) => {
|
|
1612
|
+
const { name } = translation;
|
|
1613
|
+
const id = `${slug}-translation-${slugify(name)}`;
|
|
1614
|
+
const haveParameters = translation.parameters.length > 0;
|
|
1615
|
+
return (
|
|
1616
|
+
/* HTML */
|
|
1617
|
+
`
|
|
1618
|
+
<dt>
|
|
1619
|
+
<code id="${id}"
|
|
1620
|
+
><a class="docs-api__anchor" href="#${id}"
|
|
1621
|
+
><span class="docs-api__name"
|
|
1622
|
+
>${createMarkdownRenderer.htmlencode(name)}</span
|
|
1623
|
+
></a
|
|
1624
|
+
></code
|
|
1625
|
+
>
|
|
1626
|
+
</dt>
|
|
1627
|
+
<dd>
|
|
1628
|
+
${render$1(translation.description)}
|
|
1629
|
+
${translation.defaultTranslation ? `<p class="doc-api__item">Default: "${createMarkdownRenderer.htmlencode(translation.defaultTranslation)}"</p>` : ""}
|
|
1630
|
+
${haveParameters ? `<p class="docs-api__list-title">Parameters:</p><ul class="docs-api__list">` : ""}
|
|
1631
|
+
${translation.parameters.map((it) => {
|
|
1632
|
+
if (it.description) {
|
|
1633
|
+
return `<li><code>${createMarkdownRenderer.htmlencode(it.name)}</code> ${EM_DASH} ${renderInline(it.description)}</li>`;
|
|
1634
|
+
} else {
|
|
1635
|
+
return `<li><code>${createMarkdownRenderer.htmlencode(it.name)}</code></li>`;
|
|
1636
|
+
}
|
|
1637
|
+
}).join("")}
|
|
1638
|
+
${haveParameters ? `</ul>` : ""}
|
|
1402
1639
|
</dd>
|
|
1403
1640
|
`
|
|
1404
1641
|
);
|
|
@@ -1424,7 +1661,7 @@ function parseAPI(filePath, api) {
|
|
|
1424
1661
|
}
|
|
1425
1662
|
return {
|
|
1426
1663
|
kind: "partial",
|
|
1427
|
-
id: `fs:${filePath.replace(/\\/g, "/")}`,
|
|
1664
|
+
id: `fs:${filePath.replace(/\\/g, "/")}:api`,
|
|
1428
1665
|
name: `vue:${componentName}`,
|
|
1429
1666
|
alias: [],
|
|
1430
1667
|
body: html,
|
|
@@ -1434,10 +1671,31 @@ function parseAPI(filePath, api) {
|
|
|
1434
1671
|
}
|
|
1435
1672
|
};
|
|
1436
1673
|
}
|
|
1674
|
+
async function parseTranslation(slug, filePath) {
|
|
1675
|
+
const relative = createMarkdownRenderer.normalizePath(filePath);
|
|
1676
|
+
const parsedPath = path$1.parse(relative);
|
|
1677
|
+
const componentName = parsedPath.name;
|
|
1678
|
+
const content = await fs.readFile(filePath, "utf-8");
|
|
1679
|
+
return {
|
|
1680
|
+
kind: "partial",
|
|
1681
|
+
id: `fs:${filePath.replace(/\\/g, "/")}:translation`,
|
|
1682
|
+
name: `translation:${componentName}`,
|
|
1683
|
+
alias: [],
|
|
1684
|
+
get body() {
|
|
1685
|
+
const translations = findTranslations(filePath, content);
|
|
1686
|
+
return generateTranslationTable(slug, translations);
|
|
1687
|
+
},
|
|
1688
|
+
format: "html",
|
|
1689
|
+
fileInfo: {
|
|
1690
|
+
fullPath: filePath
|
|
1691
|
+
}
|
|
1692
|
+
};
|
|
1693
|
+
}
|
|
1437
1694
|
async function vueFileReader(filePath) {
|
|
1438
1695
|
const translated = await translateAPI(filePath);
|
|
1439
|
-
const
|
|
1440
|
-
|
|
1696
|
+
const vueApi = parseAPI(filePath, translated);
|
|
1697
|
+
const vueTranslation = await parseTranslation(translated.slug, filePath);
|
|
1698
|
+
return [vueApi, vueTranslation];
|
|
1441
1699
|
}
|
|
1442
1700
|
|
|
1443
1701
|
async function globAll(pattern) {
|
|
@@ -1505,7 +1763,8 @@ function parseFile(filePath, basePath, content) {
|
|
|
1505
1763
|
title,
|
|
1506
1764
|
href,
|
|
1507
1765
|
sortorder: attributes.sortorder ?? Infinity,
|
|
1508
|
-
redirectFrom: []
|
|
1766
|
+
redirectFrom: [],
|
|
1767
|
+
search: { terms: [] }
|
|
1509
1768
|
},
|
|
1510
1769
|
body: content,
|
|
1511
1770
|
outline: [],
|
|
@@ -2207,6 +2466,9 @@ function createTemplateLoader(folders) {
|
|
|
2207
2466
|
loader = new TemplateLoader(folders);
|
|
2208
2467
|
return loader;
|
|
2209
2468
|
}
|
|
2469
|
+
function stripPrettierComments(content) {
|
|
2470
|
+
return content.replace(/\s*<!-- prettier-ignore -->\s*/gm, "");
|
|
2471
|
+
}
|
|
2210
2472
|
async function render(doc, docs, nav, vendors, options) {
|
|
2211
2473
|
const { fileInfo } = doc;
|
|
2212
2474
|
const { outputFolder, cacheFolder, templateFolders } = options;
|
|
@@ -2228,6 +2490,9 @@ async function render(doc, docs, nav, vendors, options) {
|
|
|
2228
2490
|
...options.templateData,
|
|
2229
2491
|
site: options.site,
|
|
2230
2492
|
doc,
|
|
2493
|
+
get layoutClass() {
|
|
2494
|
+
return `layout--${doc.template.replace(/[.]/g, "--")}`;
|
|
2495
|
+
},
|
|
2231
2496
|
topnav,
|
|
2232
2497
|
rootUrl(doc2) {
|
|
2233
2498
|
const { fileInfo: fileInfo2 } = doc2;
|
|
@@ -2335,7 +2600,9 @@ async function render(doc, docs, nav, vendors, options) {
|
|
|
2335
2600
|
await mkdir;
|
|
2336
2601
|
let content;
|
|
2337
2602
|
try {
|
|
2338
|
-
content =
|
|
2603
|
+
content = stripPrettierComments(
|
|
2604
|
+
await renderTemplate(template, templateData)
|
|
2605
|
+
);
|
|
2339
2606
|
} catch (err) {
|
|
2340
2607
|
const filename = fileInfo.fullPath;
|
|
2341
2608
|
if (err instanceof Error && err.name === "Template render error") {
|
|
@@ -2962,7 +3229,8 @@ function generateIndex(entries) {
|
|
|
2962
3229
|
for (const entry of entries) {
|
|
2963
3230
|
index.results.push({
|
|
2964
3231
|
url: entry.url,
|
|
2965
|
-
title: entry.title
|
|
3232
|
+
title: entry.title,
|
|
3233
|
+
terms: entry.terms
|
|
2966
3234
|
});
|
|
2967
3235
|
const resultIndex = index.results.length - 1;
|
|
2968
3236
|
for (const word of entry.words) {
|
|
@@ -2974,16 +3242,20 @@ function generateIndex(entries) {
|
|
|
2974
3242
|
return index;
|
|
2975
3243
|
}
|
|
2976
3244
|
|
|
2977
|
-
function extractTerms(doc) {
|
|
3245
|
+
function* extractTerms(doc) {
|
|
2978
3246
|
const { title, component } = doc.attributes;
|
|
2979
|
-
if (title
|
|
2980
|
-
|
|
2981
|
-
} else if (component) {
|
|
2982
|
-
return component.map((it) => it.name);
|
|
2983
|
-
} else if (title) {
|
|
2984
|
-
return [title];
|
|
3247
|
+
if (title) {
|
|
3248
|
+
yield title;
|
|
2985
3249
|
} else {
|
|
2986
|
-
|
|
3250
|
+
yield doc.name;
|
|
3251
|
+
}
|
|
3252
|
+
if (component) {
|
|
3253
|
+
for (const name of component.map((it) => it.name)) {
|
|
3254
|
+
yield name;
|
|
3255
|
+
}
|
|
3256
|
+
}
|
|
3257
|
+
for (const term of doc.attributes.search.terms) {
|
|
3258
|
+
yield term;
|
|
2987
3259
|
}
|
|
2988
3260
|
}
|
|
2989
3261
|
function isIndexable(doc) {
|
|
@@ -2993,8 +3265,12 @@ function isIndexable(doc) {
|
|
|
2993
3265
|
function getTerms(doc) {
|
|
2994
3266
|
return {
|
|
2995
3267
|
url: createMarkdownRenderer.getOutputFilePath(".", doc.fileInfo) ?? "",
|
|
2996
|
-
title: doc.name,
|
|
2997
|
-
|
|
3268
|
+
title: doc.attributes.title ?? doc.name,
|
|
3269
|
+
terms: [
|
|
3270
|
+
...doc.attributes.search.terms,
|
|
3271
|
+
...doc.attributes.component?.map((it) => it.name) ?? []
|
|
3272
|
+
],
|
|
3273
|
+
words: Array.from(extractTerms(doc))
|
|
2998
3274
|
};
|
|
2999
3275
|
}
|
|
3000
3276
|
function searchProcessor() {
|
|
@@ -3004,7 +3280,7 @@ function searchProcessor() {
|
|
|
3004
3280
|
handler(context) {
|
|
3005
3281
|
const entries = context.docs.filter(createMarkdownRenderer.isDocumentPage).filter(isIndexable).map(getTerms);
|
|
3006
3282
|
const index = generateIndex(entries);
|
|
3007
|
-
const body = JSON.stringify(index);
|
|
3283
|
+
const body = JSON.stringify(index, null, 2);
|
|
3008
3284
|
const fingerprint = createMarkdownRenderer.getFingerprint(body);
|
|
3009
3285
|
const integrity = getIntegrity(body);
|
|
3010
3286
|
const outputName = `search-data-[hash].json`;
|
|
@@ -3019,7 +3295,10 @@ function searchProcessor() {
|
|
|
3019
3295
|
visible: false,
|
|
3020
3296
|
attributes: {
|
|
3021
3297
|
sortorder: Infinity,
|
|
3022
|
-
redirectFrom: []
|
|
3298
|
+
redirectFrom: [],
|
|
3299
|
+
search: {
|
|
3300
|
+
terms: []
|
|
3301
|
+
}
|
|
3023
3302
|
},
|
|
3024
3303
|
body,
|
|
3025
3304
|
outline: [],
|