@forsakringskassan/docs-generator 2.22.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 +14 -5
- package/dist/compile-example.js.map +1 -1
- package/dist/{create-markdown-renderer-CgqU8rql.js → create-markdown-renderer-wbIE-KQj.js} +11 -3
- package/dist/create-markdown-renderer-wbIE-KQj.js.map +1 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.js +344 -111
- package/dist/index.js.map +1 -1
- package/dist/markdown.d.ts +5 -0
- package/dist/markdown.js +4 -3
- package/dist/markdown.js.map +1 -1
- package/dist/runtime.js +2541 -1991
- package/dist/style/core.css +75 -5
- package/dist/style/index.css +81 -10
- package/dist/style/site.css +6 -5
- package/dist/tsdoc-metadata.json +1 -1
- package/dist/{vendor-BUiT5f0C.js → vendor-DQQ31U4v.js} +1178 -46
- package/dist/vendor-DQQ31U4v.js.map +1 -0
- package/dist/{vue3-CLY8kH6A.js → vue3-BQVQQ2Vn.js} +15 -8
- package/dist/vue3-BQVQQ2Vn.js.map +1 -0
- package/package.json +5 -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/templates/macro/menu.html +3 -0
- package/templates/partials/footer.html +9 -3
- package/dist/create-markdown-renderer-CgqU8rql.js.map +0 -1
- package/dist/vendor-BUiT5f0C.js.map +0 -1
- package/dist/vue3-CLY8kH6A.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,10 +11,12 @@ 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');
|
|
17
|
-
var Module = require('node:module');
|
|
18
20
|
var esbuild$1 = require('esbuild');
|
|
19
21
|
var nunjucks = require('nunjucks');
|
|
20
22
|
var express = require('express');
|
|
@@ -22,13 +24,13 @@ require('fs');
|
|
|
22
24
|
require('node:events');
|
|
23
25
|
require('node:stream');
|
|
24
26
|
require('node:string_decoder');
|
|
25
|
-
require('@vue/compiler-sfc');
|
|
26
27
|
require('typescript');
|
|
27
28
|
require('constants');
|
|
28
29
|
require('stream');
|
|
29
30
|
require('util');
|
|
30
31
|
require('assert');
|
|
31
32
|
require('path');
|
|
33
|
+
require('node:module');
|
|
32
34
|
require('readline');
|
|
33
35
|
require('events');
|
|
34
36
|
require('node:process');
|
|
@@ -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: [],
|
|
@@ -1526,63 +1785,20 @@ async function navigationFileReader(filePath, basePath) {
|
|
|
1526
1785
|
return [doc];
|
|
1527
1786
|
}
|
|
1528
1787
|
|
|
1529
|
-
function
|
|
1530
|
-
const fromFile = path$1.join(fs$1.realpathSync(fromDirectory), "noop.js");
|
|
1531
|
-
return Module._resolveFilename(moduleId, {
|
|
1532
|
-
id: fromFile,
|
|
1533
|
-
filename: fromFile,
|
|
1534
|
-
paths: Module._nodeModulePaths(fromDirectory)
|
|
1535
|
-
});
|
|
1536
|
-
}
|
|
1537
|
-
const WEBPACK_NODE_MODULE_PREFIX = "~";
|
|
1538
|
-
function moduleImporter(options) {
|
|
1539
|
-
const { cwd } = options;
|
|
1540
|
-
return {
|
|
1541
|
-
findFileUrl(url) {
|
|
1542
|
-
let findUrl = url;
|
|
1543
|
-
if (url.startsWith(WEBPACK_NODE_MODULE_PREFIX)) {
|
|
1544
|
-
findUrl = url.substring(1);
|
|
1545
|
-
}
|
|
1546
|
-
const directory = path$1.dirname(findUrl);
|
|
1547
|
-
const fileName = path$1.basename(findUrl);
|
|
1548
|
-
const search = [
|
|
1549
|
-
`${fileName}.css`,
|
|
1550
|
-
`${fileName}.scss`,
|
|
1551
|
-
`_${fileName}.scss`,
|
|
1552
|
-
`${fileName}`
|
|
1553
|
-
];
|
|
1554
|
-
for (const variant of search) {
|
|
1555
|
-
try {
|
|
1556
|
-
const moduleName = path$1.posix.join(directory, variant);
|
|
1557
|
-
const resolved = resolveFrom(cwd, moduleName);
|
|
1558
|
-
return new URL(node_url.pathToFileURL(resolved));
|
|
1559
|
-
} catch (err) {
|
|
1560
|
-
if (err.code !== "MODULE_NOT_FOUND") {
|
|
1561
|
-
throw err;
|
|
1562
|
-
}
|
|
1563
|
-
}
|
|
1564
|
-
}
|
|
1565
|
-
return null;
|
|
1566
|
-
}
|
|
1567
|
-
};
|
|
1568
|
-
}
|
|
1569
|
-
|
|
1570
|
-
async function compileSassString(dst, style, options = {}) {
|
|
1571
|
-
const { cwd = process.cwd() } = options;
|
|
1788
|
+
async function compileSassString(dst, style) {
|
|
1572
1789
|
const result = await sass.compileStringAsync(style, {
|
|
1573
1790
|
style: "expanded",
|
|
1574
|
-
importers: [new sass.NodePackageImporter(), moduleImporter
|
|
1791
|
+
importers: [new sass.NodePackageImporter(), vendor.moduleImporter]
|
|
1575
1792
|
});
|
|
1576
1793
|
await fs.mkdir(path$1.dirname(dst), { recursive: true });
|
|
1577
1794
|
await fs.writeFile(dst, result.css, "utf-8");
|
|
1578
1795
|
}
|
|
1579
1796
|
|
|
1580
|
-
async function compileStyle(assetFolder, name, src
|
|
1581
|
-
const { cwd } = options;
|
|
1797
|
+
async function compileStyle(assetFolder, name, src) {
|
|
1582
1798
|
try {
|
|
1583
1799
|
const outfile = path.join("temp", `asset-${name}.css`);
|
|
1584
1800
|
const source = await fs.readFile(src, "utf-8");
|
|
1585
|
-
await compileSassString(outfile, source
|
|
1801
|
+
await compileSassString(outfile, source);
|
|
1586
1802
|
const content = await fs.readFile(outfile, "utf-8");
|
|
1587
1803
|
const fingerprint = createMarkdownRenderer.getFingerprint(content);
|
|
1588
1804
|
const integrity = getIntegrity(content);
|
|
@@ -1611,8 +1827,7 @@ function byPriority$1({ options: a }, { options: b }) {
|
|
|
1611
1827
|
function toSorted$1(values, comparator) {
|
|
1612
1828
|
return [...values].sort(comparator);
|
|
1613
1829
|
}
|
|
1614
|
-
function cssAssetProcessor(assetFolder, assets
|
|
1615
|
-
const { cwd } = options;
|
|
1830
|
+
function cssAssetProcessor(assetFolder, assets) {
|
|
1616
1831
|
return {
|
|
1617
1832
|
name: "css-asset-processor",
|
|
1618
1833
|
after: "assets",
|
|
@@ -1624,8 +1839,7 @@ function cssAssetProcessor(assetFolder, assets, options) {
|
|
|
1624
1839
|
const info = await compileStyle(
|
|
1625
1840
|
assetFolder,
|
|
1626
1841
|
asset.name,
|
|
1627
|
-
asset.src
|
|
1628
|
-
{ cwd }
|
|
1842
|
+
asset.src
|
|
1629
1843
|
);
|
|
1630
1844
|
const attrs = serializeAttrs(asset.options.attributes);
|
|
1631
1845
|
const inject = { ...info, attrs: Array.from(attrs).join(" ") };
|
|
@@ -2252,6 +2466,9 @@ function createTemplateLoader(folders) {
|
|
|
2252
2466
|
loader = new TemplateLoader(folders);
|
|
2253
2467
|
return loader;
|
|
2254
2468
|
}
|
|
2469
|
+
function stripPrettierComments(content) {
|
|
2470
|
+
return content.replace(/\s*<!-- prettier-ignore -->\s*/gm, "");
|
|
2471
|
+
}
|
|
2255
2472
|
async function render(doc, docs, nav, vendors, options) {
|
|
2256
2473
|
const { fileInfo } = doc;
|
|
2257
2474
|
const { outputFolder, cacheFolder, templateFolders } = options;
|
|
@@ -2273,6 +2490,9 @@ async function render(doc, docs, nav, vendors, options) {
|
|
|
2273
2490
|
...options.templateData,
|
|
2274
2491
|
site: options.site,
|
|
2275
2492
|
doc,
|
|
2493
|
+
get layoutClass() {
|
|
2494
|
+
return `layout--${doc.template.replace(/[.]/g, "--")}`;
|
|
2495
|
+
},
|
|
2276
2496
|
topnav,
|
|
2277
2497
|
rootUrl(doc2) {
|
|
2278
2498
|
const { fileInfo: fileInfo2 } = doc2;
|
|
@@ -2380,7 +2600,9 @@ async function render(doc, docs, nav, vendors, options) {
|
|
|
2380
2600
|
await mkdir;
|
|
2381
2601
|
let content;
|
|
2382
2602
|
try {
|
|
2383
|
-
content =
|
|
2603
|
+
content = stripPrettierComments(
|
|
2604
|
+
await renderTemplate(template, templateData)
|
|
2605
|
+
);
|
|
2384
2606
|
} catch (err) {
|
|
2385
2607
|
const filename = fileInfo.fullPath;
|
|
2386
2608
|
if (err instanceof Error && err.name === "Template render error") {
|
|
@@ -2925,7 +3147,6 @@ class Generator {
|
|
|
2925
3147
|
return { pages };
|
|
2926
3148
|
}
|
|
2927
3149
|
async build(sourceFiles) {
|
|
2928
|
-
const cwd = process.cwd();
|
|
2929
3150
|
this.sourceFiles = sourceFiles;
|
|
2930
3151
|
const {
|
|
2931
3152
|
site,
|
|
@@ -2942,7 +3163,7 @@ class Generator {
|
|
|
2942
3163
|
fileReaderProcessor(sourceFiles),
|
|
2943
3164
|
redirectProcessor(),
|
|
2944
3165
|
vendorProcessor(assetFolder, this.vendor),
|
|
2945
|
-
cssAssetProcessor(assetFolder, this.styles
|
|
3166
|
+
cssAssetProcessor(assetFolder, this.styles),
|
|
2946
3167
|
jsAssetProcessor(assetFolder, this.scripts, this.vendor),
|
|
2947
3168
|
staticResourcesProcessor(assetFolder, this.resources),
|
|
2948
3169
|
navigationProcessor(),
|
|
@@ -3008,7 +3229,8 @@ function generateIndex(entries) {
|
|
|
3008
3229
|
for (const entry of entries) {
|
|
3009
3230
|
index.results.push({
|
|
3010
3231
|
url: entry.url,
|
|
3011
|
-
title: entry.title
|
|
3232
|
+
title: entry.title,
|
|
3233
|
+
terms: entry.terms
|
|
3012
3234
|
});
|
|
3013
3235
|
const resultIndex = index.results.length - 1;
|
|
3014
3236
|
for (const word of entry.words) {
|
|
@@ -3020,16 +3242,20 @@ function generateIndex(entries) {
|
|
|
3020
3242
|
return index;
|
|
3021
3243
|
}
|
|
3022
3244
|
|
|
3023
|
-
function extractTerms(doc) {
|
|
3245
|
+
function* extractTerms(doc) {
|
|
3024
3246
|
const { title, component } = doc.attributes;
|
|
3025
|
-
if (title
|
|
3026
|
-
|
|
3027
|
-
} else if (component) {
|
|
3028
|
-
return component.map((it) => it.name);
|
|
3029
|
-
} else if (title) {
|
|
3030
|
-
return [title];
|
|
3247
|
+
if (title) {
|
|
3248
|
+
yield title;
|
|
3031
3249
|
} else {
|
|
3032
|
-
|
|
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;
|
|
3033
3259
|
}
|
|
3034
3260
|
}
|
|
3035
3261
|
function isIndexable(doc) {
|
|
@@ -3039,8 +3265,12 @@ function isIndexable(doc) {
|
|
|
3039
3265
|
function getTerms(doc) {
|
|
3040
3266
|
return {
|
|
3041
3267
|
url: createMarkdownRenderer.getOutputFilePath(".", doc.fileInfo) ?? "",
|
|
3042
|
-
title: doc.name,
|
|
3043
|
-
|
|
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))
|
|
3044
3274
|
};
|
|
3045
3275
|
}
|
|
3046
3276
|
function searchProcessor() {
|
|
@@ -3050,7 +3280,7 @@ function searchProcessor() {
|
|
|
3050
3280
|
handler(context) {
|
|
3051
3281
|
const entries = context.docs.filter(createMarkdownRenderer.isDocumentPage).filter(isIndexable).map(getTerms);
|
|
3052
3282
|
const index = generateIndex(entries);
|
|
3053
|
-
const body = JSON.stringify(index);
|
|
3283
|
+
const body = JSON.stringify(index, null, 2);
|
|
3054
3284
|
const fingerprint = createMarkdownRenderer.getFingerprint(body);
|
|
3055
3285
|
const integrity = getIntegrity(body);
|
|
3056
3286
|
const outputName = `search-data-[hash].json`;
|
|
@@ -3065,7 +3295,10 @@ function searchProcessor() {
|
|
|
3065
3295
|
visible: false,
|
|
3066
3296
|
attributes: {
|
|
3067
3297
|
sortorder: Infinity,
|
|
3068
|
-
redirectFrom: []
|
|
3298
|
+
redirectFrom: [],
|
|
3299
|
+
search: {
|
|
3300
|
+
terms: []
|
|
3301
|
+
}
|
|
3069
3302
|
},
|
|
3070
3303
|
body,
|
|
3071
3304
|
outline: [],
|