@forsakringskassan/docs-generator 2.23.0 → 2.25.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.
Files changed (32) hide show
  1. package/dist/compile-example.js +2 -2
  2. package/dist/{create-markdown-renderer-BSbHc8U0.js → create-markdown-renderer-CoJjMIzN.js} +3 -3
  3. package/dist/{create-markdown-renderer-BSbHc8U0.js.map → create-markdown-renderer-CoJjMIzN.js.map} +1 -1
  4. package/dist/index.d.ts +5 -0
  5. package/dist/index.js +386 -58
  6. package/dist/index.js.map +1 -1
  7. package/dist/markdown.d.ts +5 -0
  8. package/dist/markdown.js +3 -3
  9. package/dist/runtime.js +57 -16
  10. package/dist/style/core.css +89 -0
  11. package/dist/style/index.css +91 -0
  12. package/dist/style/site.css +2 -0
  13. package/dist/tsdoc-metadata.json +1 -1
  14. package/dist/{vendor-BxO3IPg6.js → vendor-y4sQkzVC.js} +2777 -63
  15. package/dist/vendor-y4sQkzVC.js.map +1 -0
  16. package/dist/{vue3-CZnjnYGV.js → vue3-DXIVBodU.js} +2 -2
  17. package/dist/{vue3-CZnjnYGV.js.map → vue3-DXIVBodU.js.map} +1 -1
  18. package/package.json +3 -1
  19. package/templates/api.class.template.html +1 -0
  20. package/templates/api.composable.template.html +1 -0
  21. package/templates/api.constant.template.html +1 -0
  22. package/templates/api.enum.template.html +1 -0
  23. package/templates/api.function.template.html +1 -0
  24. package/templates/api.interface.template.html +1 -0
  25. package/templates/api.method.template.html +1 -0
  26. package/templates/api.template.html +1 -0
  27. package/templates/api.type.template.html +1 -0
  28. package/templates/base.template.html +2 -2
  29. package/templates/component.template.html +16 -13
  30. package/templates/partials/search-dialog.html +3 -3
  31. package/templates/partials/search-toolbar.html +1 -1
  32. 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-BxO3IPg6.js');
6
- var createMarkdownRenderer = require('./create-markdown-renderer-BSbHc8U0.js');
5
+ var vendor = require('./vendor-y4sQkzVC.js');
6
+ var createMarkdownRenderer = require('./create-markdown-renderer-CoJjMIzN.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-CZnjnYGV.js');
49
+ require('./vue3-DXIVBodU.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$4 = vendor.MarkdownIt();
285
- md$4.renderer.rules.fence = (tokens, idx, _options, collected) => {
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$4.render(doc.body, collected);
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$3 = vendor.MarkdownIt();
374
- md$3.renderer.rules.fence = (tokens, idx, _options, collected) => {
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$3.render(doc.body, collected);
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$2 = vendor.MarkdownIt();
1256
- const EMPTY_CHAR$2 = "‐";
1257
- function render$3(text) {
1258
- return text ? md$2.render(text) : EMPTY_CHAR$2;
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$2(text) {
1261
- return text ? md$2.renderInline(text) : EMPTY_CHAR$2;
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$3(prop.description)}
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$2(prop.deprecated)}</p>` : ""}
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$1 = vendor.MarkdownIt();
1302
- const EMPTY_CHAR$1 = "&#8208;";
1303
- const EM_DASH$1 = `<span role="presentation">&mdash;</span>`;
1304
- function render$2(text) {
1305
- return text ? md$1.render(text) : EMPTY_CHAR$1;
1308
+ const md$2 = vendor.MarkdownIt();
1309
+ const EMPTY_CHAR$2 = "&#8208;";
1310
+ const EM_DASH$2 = `<span role="presentation">&mdash;</span>`;
1311
+ function render$3(text) {
1312
+ return text ? md$2.render(text) : EMPTY_CHAR$2;
1306
1313
  }
1307
- function renderInline$1(text) {
1308
- return text ? md$1.renderInline(text) : EMPTY_CHAR$1;
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$2(event.description)}
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$1} ${renderInline$1(it.description)}</li>`;
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$1(event.deprecated)}</p>` : ""}
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 = "&#8208;";
1358
- const EM_DASH = `<span role="presentation">&mdash;</span>`;
1359
- function render$1(text) {
1360
- return text ? md.render(text) : EMPTY_CHAR;
1363
+ const md$1 = vendor.MarkdownIt();
1364
+ const EMPTY_CHAR$1 = "&#8208;";
1365
+ const EM_DASH$1 = `<span role="presentation">&mdash;</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$1(slot.description)}
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 = "&#8208;";
1599
+ const EM_DASH = `<span role="presentation">&mdash;</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 doc = parseAPI(filePath, translated);
1440
- return [doc];
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,9 +2466,12 @@ 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
- const { outputFolder, cacheFolder, templateFolders } = options;
2474
+ const { i18n, outputFolder, cacheFolder, templateFolders } = options;
2213
2475
  if (!haveOutputFile(fileInfo)) {
2214
2476
  return null;
2215
2477
  }
@@ -2226,8 +2488,12 @@ async function render(doc, docs, nav, vendors, options) {
2226
2488
  const template = findTemplate(templateFolders, doc.fileInfo, doc);
2227
2489
  const templateData = {
2228
2490
  ...options.templateData,
2491
+ $t: i18n.t,
2229
2492
  site: options.site,
2230
2493
  doc,
2494
+ get layoutClass() {
2495
+ return `layout--${doc.template.replace(/[.]/g, "--")}`;
2496
+ },
2231
2497
  topnav,
2232
2498
  rootUrl(doc2) {
2233
2499
  const { fileInfo: fileInfo2 } = doc2;
@@ -2335,7 +2601,9 @@ async function render(doc, docs, nav, vendors, options) {
2335
2601
  await mkdir;
2336
2602
  let content;
2337
2603
  try {
2338
- content = await renderTemplate(template, templateData);
2604
+ content = stripPrettierComments(
2605
+ await renderTemplate(template, templateData)
2606
+ );
2339
2607
  } catch (err) {
2340
2608
  const filename = fileInfo.fullPath;
2341
2609
  if (err instanceof Error && err.name === "Template render error") {
@@ -2445,6 +2713,44 @@ function nunjucksProcessor(options) {
2445
2713
  };
2446
2714
  }
2447
2715
 
2716
+ var translation$1 = {
2717
+ component: {
2718
+ component: "Component",
2719
+ status: "Status"
2720
+ },
2721
+ outline: {
2722
+ "in-this-article": "In this article"
2723
+ },
2724
+ search: {
2725
+ button: "Search",
2726
+ instructions: "<kbd>Esc</kbd> to close <kbd>Arrow up/down</kbd> to navigate <kbd>Enter</kbd> to select",
2727
+ title: "Search",
2728
+ placeholder: "Type to begin searching"
2729
+ }
2730
+ };
2731
+ var langEn = {
2732
+ translation: translation$1
2733
+ };
2734
+
2735
+ var translation = {
2736
+ component: {
2737
+ component: "Komponent",
2738
+ status: "Status"
2739
+ },
2740
+ outline: {
2741
+ "in-this-article": "Innehåll"
2742
+ },
2743
+ search: {
2744
+ button: "Sök",
2745
+ instructions: "<kbd>Esc</kbd> för att stänga <kbd>Pil upp/ner</kbd> för att navigera <kbd>Enter</kbd> för att välja",
2746
+ title: "Sök",
2747
+ placeholder: "Skriv för att börja söka"
2748
+ }
2749
+ };
2750
+ var langSv = {
2751
+ translation: translation
2752
+ };
2753
+
2448
2754
  function getAssetSource(asset) {
2449
2755
  const lines = [];
2450
2756
  const pkg = asset.package.replace(/\\/g, "/");
@@ -2891,6 +3197,15 @@ class Generator {
2891
3197
  setupPath,
2892
3198
  markdownOptions
2893
3199
  } = this;
3200
+ const i18n = vendor.createInstance({
3201
+ lng: site.lang,
3202
+ fallbackLng: "en",
3203
+ resources: {
3204
+ en: langEn,
3205
+ sv: langSv
3206
+ }
3207
+ });
3208
+ await i18n.init();
2894
3209
  await this._prepareFolders();
2895
3210
  const processors = [
2896
3211
  fileReaderProcessor(sourceFiles),
@@ -2907,6 +3222,7 @@ class Generator {
2907
3222
  },
2908
3223
  outputFolder,
2909
3224
  cacheFolder,
3225
+ i18n,
2910
3226
  exampleFolders,
2911
3227
  templateFolders,
2912
3228
  setupPath,
@@ -2962,7 +3278,8 @@ function generateIndex(entries) {
2962
3278
  for (const entry of entries) {
2963
3279
  index.results.push({
2964
3280
  url: entry.url,
2965
- title: entry.title
3281
+ title: entry.title,
3282
+ terms: entry.terms
2966
3283
  });
2967
3284
  const resultIndex = index.results.length - 1;
2968
3285
  for (const word of entry.words) {
@@ -2974,16 +3291,20 @@ function generateIndex(entries) {
2974
3291
  return index;
2975
3292
  }
2976
3293
 
2977
- function extractTerms(doc) {
3294
+ function* extractTerms(doc) {
2978
3295
  const { title, component } = doc.attributes;
2979
- if (title && component) {
2980
- return component.map((it) => `${title} (${it.name})`);
2981
- } else if (component) {
2982
- return component.map((it) => it.name);
2983
- } else if (title) {
2984
- return [title];
3296
+ if (title) {
3297
+ yield title;
2985
3298
  } else {
2986
- return [];
3299
+ yield doc.name;
3300
+ }
3301
+ if (component) {
3302
+ for (const name of component.map((it) => it.name)) {
3303
+ yield name;
3304
+ }
3305
+ }
3306
+ for (const term of doc.attributes.search.terms) {
3307
+ yield term;
2987
3308
  }
2988
3309
  }
2989
3310
  function isIndexable(doc) {
@@ -2993,8 +3314,12 @@ function isIndexable(doc) {
2993
3314
  function getTerms(doc) {
2994
3315
  return {
2995
3316
  url: createMarkdownRenderer.getOutputFilePath(".", doc.fileInfo) ?? "",
2996
- title: doc.name,
2997
- words: extractTerms(doc)
3317
+ title: doc.attributes.title ?? doc.name,
3318
+ terms: [
3319
+ ...doc.attributes.search.terms,
3320
+ ...doc.attributes.component?.map((it) => it.name) ?? []
3321
+ ],
3322
+ words: Array.from(extractTerms(doc))
2998
3323
  };
2999
3324
  }
3000
3325
  function searchProcessor() {
@@ -3004,7 +3329,7 @@ function searchProcessor() {
3004
3329
  handler(context) {
3005
3330
  const entries = context.docs.filter(createMarkdownRenderer.isDocumentPage).filter(isIndexable).map(getTerms);
3006
3331
  const index = generateIndex(entries);
3007
- const body = JSON.stringify(index);
3332
+ const body = JSON.stringify(index, null, 2);
3008
3333
  const fingerprint = createMarkdownRenderer.getFingerprint(body);
3009
3334
  const integrity = getIntegrity(body);
3010
3335
  const outputName = `search-data-[hash].json`;
@@ -3019,7 +3344,10 @@ function searchProcessor() {
3019
3344
  visible: false,
3020
3345
  attributes: {
3021
3346
  sortorder: Infinity,
3022
- redirectFrom: []
3347
+ redirectFrom: [],
3348
+ search: {
3349
+ terms: []
3350
+ }
3023
3351
  },
3024
3352
  body,
3025
3353
  outline: [],