@forsakringskassan/docs-generator 2.12.0 → 2.14.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/index.js CHANGED
@@ -1,13 +1,13 @@
1
1
  'use strict';
2
2
 
3
3
  var fs = require('node:fs/promises');
4
- var vendor = require('./vendor-CJBsNZrh.js');
5
- var path = require('node:path');
4
+ var path = require('node:path/posix');
5
+ var vendor = require('./vendor-Bb38Rlio.js');
6
+ var path$1 = require('node:path');
6
7
  var require$$1 = require('crypto');
7
- var createMarkdownRenderer = require('./create-markdown-renderer-D5z4jt-T.js');
8
- var node_child_process = require('node:child_process');
9
- var path$1 = require('node:path/posix');
10
8
  require('node:crypto');
9
+ var createMarkdownRenderer = require('./create-markdown-renderer-DVss8WXD.js');
10
+ var node_child_process = require('node:child_process');
11
11
  var util = require('node:util');
12
12
  var vueDocgenApi = require('vue-docgen-api');
13
13
  var fs$1 = require('node:fs');
@@ -16,13 +16,13 @@ var node_url = require('node:url');
16
16
  var Module = require('node:module');
17
17
  var esbuild$1 = require('esbuild');
18
18
  var nunjucks = require('nunjucks');
19
- var vue = require('vue');
20
- var vue3 = require('./vue3-rkJOanAd.js');
21
19
  var express = require('express');
22
20
  require('fs');
23
21
  require('node:events');
24
22
  require('node:stream');
25
23
  require('node:string_decoder');
24
+ require('@vue/compiler-sfc');
25
+ require('typescript');
26
26
  require('constants');
27
27
  require('stream');
28
28
  require('util');
@@ -32,8 +32,6 @@ require('readline');
32
32
  require('events');
33
33
  require('node:process');
34
34
  require('node:stream/promises');
35
- require('@vue/compiler-sfc');
36
- require('typescript');
37
35
  require('fs/promises');
38
36
  require('os');
39
37
  require('http');
@@ -44,6 +42,8 @@ require('net');
44
42
  require('tls');
45
43
  require('tty');
46
44
  require('querystring');
45
+ require('vue');
46
+ require('./vue3-BqgRpcI0.js');
47
47
 
48
48
  var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null;
49
49
  function toArray$2(value) {
@@ -225,21 +225,6 @@ function interpolate(value, data) {
225
225
  });
226
226
  }
227
227
 
228
- function parseImport(raw) {
229
- const comments = [];
230
- const stripped = raw.replace(/<!--.*?-->/gms, (match) => {
231
- comments.push(match);
232
- return "";
233
- });
234
- const filename = stripped.trim();
235
- const extension = path.parse(filename).ext.slice(1);
236
- return {
237
- filename,
238
- extension,
239
- comments
240
- };
241
- }
242
-
243
228
  function quote(text) {
244
229
  return String(text).replace(/"/g, "&quot;");
245
230
  }
@@ -277,6 +262,108 @@ function slugify(value) {
277
262
  return value.toLowerCase().replace(/\//g, "--").replace(/[^a-z]+/g, "-").replace(/(^-+|-+$)/, "");
278
263
  }
279
264
 
265
+ const md$2 = vendor.MarkdownIt();
266
+ md$2.renderer.rules.fence = (tokens, idx, _options, collected) => {
267
+ const { content, info } = tokens[idx];
268
+ const { language, tags } = createMarkdownRenderer.parseInfostring(info);
269
+ if (language === "import") {
270
+ return "";
271
+ }
272
+ collected.push({
273
+ content,
274
+ language,
275
+ tags
276
+ });
277
+ return "";
278
+ };
279
+ function findExamples$1(doc) {
280
+ if (doc.format !== "markdown") {
281
+ return [];
282
+ }
283
+ const collected = [];
284
+ md$2.render(doc.body, collected);
285
+ return collected;
286
+ }
287
+ function getSuffix(tags) {
288
+ const relevant = tags.filter((it) => ["nocompile", "nolint"].includes(it));
289
+ if (relevant.length > 0) {
290
+ return `-${relevant.join("-")}`;
291
+ } else {
292
+ return "";
293
+ }
294
+ }
295
+ function getExtension(lang) {
296
+ switch (lang) {
297
+ case "typescript":
298
+ return "ts";
299
+ case "javascript":
300
+ return "js";
301
+ default:
302
+ return lang;
303
+ }
304
+ }
305
+ function extractExamplesProcessor(options) {
306
+ const {
307
+ enabled = true,
308
+ outputFolder,
309
+ languages = ["javascript", "typescript", "css", "scss"]
310
+ } = options;
311
+ function isRelevant(example) {
312
+ return languages.includes(example.language);
313
+ }
314
+ return {
315
+ stage: "render",
316
+ name: "extract-examples-processor",
317
+ async handler(context) {
318
+ if (!enabled) {
319
+ return;
320
+ }
321
+ if (!outputFolder) {
322
+ throw new Error(
323
+ `"outputFolder" not set in "extractExamplesProcessor(..)"`
324
+ );
325
+ }
326
+ await fs.rm(outputFolder, { recursive: true, force: true });
327
+ let total = 0;
328
+ for (const doc of context.docs.filter(haveOutput)) {
329
+ const examples = findExamples$1(doc).filter(isRelevant);
330
+ if (examples.length === 0) {
331
+ continue;
332
+ }
333
+ const dir = createMarkdownRenderer.normalizePath(outputFolder, doc.fileInfo.fullPath);
334
+ await fs.mkdir(dir, { recursive: true });
335
+ let n = 1;
336
+ for (const example of examples) {
337
+ const suffix = getSuffix(example.tags);
338
+ const extension = getExtension(example.language);
339
+ const filename = `example-${String(n++)}${suffix}.${extension}`;
340
+ const filePath = path.join(dir, filename);
341
+ await fs.writeFile(filePath, example.content, "utf-8");
342
+ total++;
343
+ }
344
+ }
345
+ context.log(total, "examples extracted");
346
+ }
347
+ };
348
+ }
349
+
350
+ const md$1 = vendor.MarkdownIt();
351
+ md$1.renderer.rules.fence = (tokens, idx, _options, collected) => {
352
+ const { content, info, map } = tokens[idx];
353
+ const { language, tags } = createMarkdownRenderer.parseInfostring(info);
354
+ const hashContent = `${map?.[0]}:${map?.[1]}:${info}:${content}`;
355
+ const fingerprint = createMarkdownRenderer.getFingerprint(hashContent);
356
+ let extension = void 0;
357
+ if (language === "import") {
358
+ extension = content.split(".").at(-1)?.trim();
359
+ }
360
+ collected.push({
361
+ selector: `#example-${fingerprint}`,
362
+ language: extension ?? language,
363
+ tags
364
+ });
365
+ return "";
366
+ };
280
367
  function flattenOutline(outline) {
281
368
  return outline.flatMap((entry) => {
282
369
  return [
@@ -290,24 +377,7 @@ function findExamples(doc) {
290
377
  return [];
291
378
  }
292
379
  const collected = [];
293
- const md = vendor.MarkdownIt();
294
- md.renderer.rules.fence = (tokens, idx) => {
295
- const { content, info, map } = tokens[idx];
296
- const [language, ...tags] = info.split(/\s+/);
297
- const hashContent = `${map?.[0]}:${map?.[1]}:${info}:${content}`;
298
- const fingerprint = createMarkdownRenderer.getFingerprint(hashContent);
299
- let extension = void 0;
300
- if (language === "import") {
301
- extension = content.split(".").at(-1)?.trim();
302
- }
303
- collected.push({
304
- selector: `#example-${fingerprint}`,
305
- language: extension ?? language,
306
- tags
307
- });
308
- return "";
309
- };
310
- md.render(doc.body);
380
+ md$1.render(doc.body, collected);
311
381
  return collected;
312
382
  }
313
383
  function manifestPageFromDocument(doc) {
@@ -374,7 +444,7 @@ function normalizeOptions(options) {
374
444
  };
375
445
  return { ...defaults, ...options };
376
446
  }
377
- function motdProcessor(options) {
447
+ function motdProcessor(options = {}) {
378
448
  const { enabled, container, message } = normalizeOptions(options);
379
449
  return {
380
450
  name: "motd-processor",
@@ -466,7 +536,7 @@ function relative(url, { fileInfo }) {
466
536
  if (outputPath === url || `${outputPath}/` === url) {
467
537
  return "./";
468
538
  }
469
- const relative2 = path$1.relative(outputPath, url);
539
+ const relative2 = path.relative(outputPath, url);
470
540
  const prefix = relative2.startsWith(".") ? "" : "./";
471
541
  const suffix = url.endsWith("/") ? "/" : "";
472
542
  return [prefix, relative2, suffix].join("");
@@ -506,7 +576,7 @@ function htmlRedirectProcessor() {
506
576
  const filePath = createMarkdownRenderer.getOutputFilePath(outputFolder, doc.fileInfo);
507
577
  const dst = relative(doc.body, doc);
508
578
  const content = template(dst);
509
- await fs.mkdir(path$1.dirname(filePath), { recursive: true });
579
+ await fs.mkdir(path.dirname(filePath), { recursive: true });
510
580
  await fs.writeFile(filePath, vendor.dedent(content), "utf-8");
511
581
  }
512
582
  }
@@ -531,8 +601,8 @@ function redirectFileProcessor(prefix = "/", filename = "_redirects") {
531
601
  return `${prefix}${src} ${prefix}${dst} 301
532
602
  `;
533
603
  });
534
- const filePath = path$1.join(context.outputFolder, filename);
535
- await fs.mkdir(path$1.dirname(filePath), { recursive: true });
604
+ const filePath = path.join(context.outputFolder, filename);
605
+ await fs.mkdir(path.dirname(filePath), { recursive: true });
536
606
  await fs.writeFile(filePath, lines.join(""), "utf-8");
537
607
  context.log(filename, "generated");
538
608
  }
@@ -562,7 +632,7 @@ function redirectProcessor() {
562
632
  async handler(context) {
563
633
  const redirects = getRedirects(context.docs);
564
634
  for (const redirect of redirects) {
565
- const { dir, base, name } = path$1.parse(redirect.from);
635
+ const { dir, base, name } = path.parse(redirect.from);
566
636
  context.addDocument({
567
637
  id: `redirect:${redirect.from}-${redirect.to}`,
568
638
  name: `${redirect.from}-${redirect.to}`,
@@ -621,7 +691,7 @@ function selectableVersionProcessor(pkg, container, options) {
621
691
 
622
692
  function generateNavigation(entries) {
623
693
  const children = entries.map((it, index) => {
624
- const key = path$1.parse(it.path).name;
694
+ const key = path.parse(it.path).name;
625
695
  return {
626
696
  key,
627
697
  sortorder: index,
@@ -805,7 +875,7 @@ function toArray$1(value) {
805
875
  return Array.isArray(value) ? value : [value];
806
876
  }
807
877
  function isIndexPage(parsed) {
808
- const folder = path.basename(parsed.dir);
878
+ const folder = path$1.basename(parsed.dir);
809
879
  if (parsed.name === folder) {
810
880
  return true;
811
881
  }
@@ -857,8 +927,8 @@ function getComponent(attrs) {
857
927
  });
858
928
  }
859
929
  function parseFile$1(filePath, basePath, content) {
860
- const relative = basePath ? path.relative(basePath, createMarkdownRenderer.normalizePath(filePath)) : createMarkdownRenderer.normalizePath(filePath);
861
- const parsed = path.parse(relative);
930
+ const relative = basePath ? path$1.relative(basePath, createMarkdownRenderer.normalizePath(filePath)) : createMarkdownRenderer.normalizePath(filePath);
931
+ const parsed = path$1.parse(relative);
862
932
  const blocks = vendor.fm(content);
863
933
  const attributes = blocks.attributes;
864
934
  const isIndex = isIndexPage(parsed);
@@ -1038,7 +1108,7 @@ function parseAPIToArray(api) {
1038
1108
  }
1039
1109
  function parseAPI(filePath, api) {
1040
1110
  const relative = createMarkdownRenderer.normalizePath(filePath);
1041
- const parsedPath = path.parse(relative);
1111
+ const parsedPath = path$1.parse(relative);
1042
1112
  const componentName = parsedPath.name;
1043
1113
  let html = "";
1044
1114
  if (api.props.length) {
@@ -1085,7 +1155,9 @@ async function globAll(pattern) {
1085
1155
  if (!Array.isArray(pattern)) {
1086
1156
  return globAll([pattern]);
1087
1157
  }
1088
- const results = await Promise.all(pattern.map((it) => vendor.glob(it)));
1158
+ const results = await Promise.all(
1159
+ pattern.map((it) => vendor.glob(it, { nodir: true }))
1160
+ );
1089
1161
  return new Set(results.flat());
1090
1162
  }
1091
1163
  async function getDocumentsForSource(src) {
@@ -1126,8 +1198,8 @@ function parseFile(filePath, basePath, content) {
1126
1198
  if (!title) {
1127
1199
  throw new Error(`No title property set in "${filePath}"`);
1128
1200
  }
1129
- const relative = basePath ? path.relative(basePath, createMarkdownRenderer.normalizePath(filePath)) : createMarkdownRenderer.normalizePath(filePath);
1130
- const parsed = path.parse(relative);
1201
+ const relative = basePath ? path$1.relative(basePath, createMarkdownRenderer.normalizePath(filePath)) : createMarkdownRenderer.normalizePath(filePath);
1202
+ const parsed = path$1.parse(relative);
1131
1203
  const filename = parsed.name.toLowerCase();
1132
1204
  const name = parsed.name;
1133
1205
  const urlpath = parsed.dir;
@@ -1162,7 +1234,7 @@ async function navigationFileReader(filePath, basePath) {
1162
1234
  }
1163
1235
 
1164
1236
  function resolveFrom(fromDirectory, moduleId) {
1165
- const fromFile = path.join(fs$1.realpathSync(fromDirectory), "noop.js");
1237
+ const fromFile = path$1.join(fs$1.realpathSync(fromDirectory), "noop.js");
1166
1238
  return Module._resolveFilename(moduleId, {
1167
1239
  id: fromFile,
1168
1240
  filename: fromFile,
@@ -1178,8 +1250,8 @@ function moduleImporter(options) {
1178
1250
  if (url.startsWith(WEBPACK_NODE_MODULE_PREFIX)) {
1179
1251
  findUrl = url.substring(1);
1180
1252
  }
1181
- const directory = path.dirname(findUrl);
1182
- const fileName = path.basename(findUrl);
1253
+ const directory = path$1.dirname(findUrl);
1254
+ const fileName = path$1.basename(findUrl);
1183
1255
  const search = [
1184
1256
  `${fileName}.css`,
1185
1257
  `${fileName}.scss`,
@@ -1188,7 +1260,7 @@ function moduleImporter(options) {
1188
1260
  ];
1189
1261
  for (const variant of search) {
1190
1262
  try {
1191
- const moduleName = path.posix.join(directory, variant);
1263
+ const moduleName = path$1.posix.join(directory, variant);
1192
1264
  const resolved = resolveFrom(cwd, moduleName);
1193
1265
  return new URL(node_url.pathToFileURL(resolved));
1194
1266
  } catch (err) {
@@ -1208,21 +1280,21 @@ async function compileSassString(dst, style, options = {}) {
1208
1280
  style: "expanded",
1209
1281
  importers: [new sass.NodePackageImporter(), moduleImporter({ cwd })]
1210
1282
  });
1211
- await fs.mkdir(path.dirname(dst), { recursive: true });
1283
+ await fs.mkdir(path$1.dirname(dst), { recursive: true });
1212
1284
  await fs.writeFile(dst, result.css, "utf-8");
1213
1285
  }
1214
1286
 
1215
1287
  async function compileStyle(assetFolder, name, src, options) {
1216
1288
  const { cwd } = options;
1217
1289
  try {
1218
- const outfile = path$1.join("temp", `asset-${name}.css`);
1290
+ const outfile = path.join("temp", `asset-${name}.css`);
1219
1291
  const source = await fs.readFile(src, "utf-8");
1220
1292
  await compileSassString(outfile, source, { cwd });
1221
1293
  const content = await fs.readFile(outfile, "utf-8");
1222
1294
  const fingerprint = createMarkdownRenderer.getFingerprint(content);
1223
1295
  const integrity = getIntegrity(content);
1224
1296
  const filename = `${name}-${fingerprint}.css`;
1225
- const dst = path$1.join(assetFolder, filename);
1297
+ const dst = path.join(assetFolder, filename);
1226
1298
  await fs.rename(outfile, dst);
1227
1299
  const stat = await fs.stat(dst);
1228
1300
  return {
@@ -1298,7 +1370,7 @@ async function compileScript(options) {
1298
1370
  const iconLib = process.env.DOCS_ICON_LIB ?? "@fkui/icon-lib-default";
1299
1371
  try {
1300
1372
  const entryPoints = [src instanceof URL ? node_url.fileURLToPath(src) : src];
1301
- const outfile = path.join("temp", `asset-${name}.js`);
1373
+ const outfile = path$1.join("temp", `asset-${name}.js`);
1302
1374
  await esbuild({
1303
1375
  entryPoints,
1304
1376
  outfile,
@@ -1306,7 +1378,7 @@ async function compileScript(options) {
1306
1378
  format: "iife",
1307
1379
  platform: "browser",
1308
1380
  external: ["vue", "@fkui/vue"],
1309
- tsconfig: path.join(__dirname, "../tsconfig-examples.json"),
1381
+ tsconfig: path$1.join(__dirname, "../tsconfig-examples.json"),
1310
1382
  ...buildOptions,
1311
1383
  define: {
1312
1384
  "process.env.DOCS_ICON_LIB": JSON.stringify(iconLib),
@@ -1317,8 +1389,8 @@ async function compileScript(options) {
1317
1389
  const fingerprint = createMarkdownRenderer.getFingerprint(content);
1318
1390
  const integrity = getIntegrity(content);
1319
1391
  const filename = `${name}-${fingerprint}.js`;
1320
- const dst = path.join(assetFolder, filename);
1321
- await fs$1.mkdir(path.dirname(dst), { recursive: true });
1392
+ const dst = path$1.join(assetFolder, filename);
1393
+ await fs$1.mkdir(path$1.dirname(dst), { recursive: true });
1322
1394
  await fs$1.rename(outfile, dst);
1323
1395
  const stat = await fs$1.stat(dst);
1324
1396
  return {
@@ -1384,7 +1456,7 @@ function staticResourcesProcessor(assetFolder, resources) {
1384
1456
  async handler(context) {
1385
1457
  for (const resource of [...resources, ...context.resources]) {
1386
1458
  const src = resource.from;
1387
- const dst = path$1.join(assetFolder, resource.to);
1459
+ const dst = path.join(assetFolder, resource.to);
1388
1460
  await fs.cp(src, dst, {
1389
1461
  recursive: true
1390
1462
  });
@@ -1410,7 +1482,7 @@ function compileProcessorRuntime(generator, distDir, processors) {
1410
1482
  const assetName = [
1411
1483
  "processors",
1412
1484
  processor.name.replace(/-processor/, ""),
1413
- entry.name ?? path.parse(entry.src).name
1485
+ entry.name ?? path$1.parse(entry.src).name
1414
1486
  ].join("/");
1415
1487
  const name = processorRuntimeName(processor, entry);
1416
1488
  const bundled = new URL(`${name}.js`, distDir);
@@ -1430,110 +1502,6 @@ function compileProcessorRuntime(generator, distDir, processors) {
1430
1502
  }
1431
1503
  }
1432
1504
 
1433
- function getExampleImport(searchDirs, filename) {
1434
- const pattern = searchDirs.map((dir) => `${dir}/**/${filename}`);
1435
- const matches = vendor.globSync(pattern);
1436
- if (matches.length === 0) {
1437
- const message = `No files matched import "${filename}"`;
1438
- throw new Error(message);
1439
- } else if (matches.length > 1) {
1440
- const message = `Multiple files matched import "${filename}"`;
1441
- throw new Error(message);
1442
- } else {
1443
- return createMarkdownRenderer.normalizePath(matches[0]);
1444
- }
1445
- }
1446
-
1447
- function getExampleName(filename) {
1448
- return path.parse(filename).name;
1449
- }
1450
-
1451
- const vueMajor = parseInt(vue.version.split(".", 2)[0], 10);
1452
- function vueGenerator() {
1453
- switch (vueMajor) {
1454
- case 2:
1455
- throw new Error(
1456
- "Vue 2 is no longer supported, upgrade to Vue 3 or downgrade docs-generator"
1457
- );
1458
- case 3:
1459
- return vue3.generateCode;
1460
- }
1461
- }
1462
- function generateExample(options) {
1463
- const { language } = options;
1464
- if (language === "import") {
1465
- const parsed = parseImport(options.source);
1466
- const filename = getExampleImport(
1467
- options.exampleFolders,
1468
- parsed.filename
1469
- );
1470
- const source = fs$1.readFileSync(filename, "utf-8");
1471
- const language2 = parsed.extension;
1472
- const comments = parsed.comments;
1473
- const example = generateExample({
1474
- ...options,
1475
- source,
1476
- language: language2,
1477
- filename
1478
- });
1479
- return { ...example, comments };
1480
- }
1481
- switch (language) {
1482
- case "vue":
1483
- return generateVueExample(options);
1484
- case "html":
1485
- return generateStaticExample(options);
1486
- default:
1487
- return generateStaticExample(options);
1488
- }
1489
- }
1490
- function generateVueExample(options) {
1491
- const { filename, source, parent, setupPath, tags } = options;
1492
- const fn = vueGenerator();
1493
- const slug = getExampleName(filename);
1494
- const fingerprint = createMarkdownRenderer.getFingerprint(source);
1495
- const { markup, sourcecode, output } = fn({
1496
- filename,
1497
- slug,
1498
- fingerprint,
1499
- code: source,
1500
- setupPath
1501
- });
1502
- return {
1503
- source,
1504
- language: options.language,
1505
- comments: [],
1506
- tags,
1507
- markup,
1508
- output,
1509
- runtime: true,
1510
- task: {
1511
- outputFile: output,
1512
- sourcecode,
1513
- sourceFile: filename,
1514
- parent
1515
- }
1516
- };
1517
- }
1518
- function generateStaticExample(options) {
1519
- const { filename, source, language, tags } = options;
1520
- const slug = getExampleName(filename);
1521
- const fingerprint = createMarkdownRenderer.getFingerprint(source);
1522
- const asset = `${slug}-${fingerprint}.${language}`;
1523
- const runtimeLanguages = ["html"];
1524
- const runtime = runtimeLanguages.includes(language);
1525
- return {
1526
- source,
1527
- language: options.language,
1528
- comments: [],
1529
- tags,
1530
- markup: source,
1531
- output: runtime ? asset : null,
1532
- runtime,
1533
- task: null
1534
- };
1535
- }
1536
-
1537
1505
  function isNavigationSection(node) {
1538
1506
  return "key" in node;
1539
1507
  }
@@ -1542,7 +1510,7 @@ function pathFromDoc({ fileInfo }) {
1542
1510
  return [fileInfo.path.replace(/\\/g, "/"), true];
1543
1511
  } else {
1544
1512
  return [
1545
- `./${path.join(fileInfo.path, fileInfo.name).replace(/\\/g, "/")}`,
1513
+ `./${path$1.join(fileInfo.path, fileInfo.name).replace(/\\/g, "/")}`,
1546
1514
  false
1547
1515
  ];
1548
1516
  }
@@ -1740,7 +1708,7 @@ class TemplateLoader {
1740
1708
  folders;
1741
1709
  templateCache;
1742
1710
  constructor(folders = []) {
1743
- this.folders = [...folders, path.join(__dirname, "../templates")];
1711
+ this.folders = [...folders, path$1.join(__dirname, "../templates")];
1744
1712
  this.templateCache = /* @__PURE__ */ new Map();
1745
1713
  }
1746
1714
  async getSource(name, callback) {
@@ -1791,7 +1759,7 @@ Make sure the name is correct and the template file exists in one of the listed
1791
1759
  }
1792
1760
  findTemplateFile(name) {
1793
1761
  const { folders } = this;
1794
- const searchPaths = folders.map((it) => path.join(it, name));
1762
+ const searchPaths = folders.map((it) => path$1.join(it, name));
1795
1763
  return searchPaths.find((it) => fs$1.existsSync(it));
1796
1764
  }
1797
1765
  }
@@ -1813,7 +1781,7 @@ class MissingTemplateError extends Error {
1813
1781
  ].join("\n");
1814
1782
  }
1815
1783
  }
1816
- const templateDirectory = path.join(__dirname, "../templates");
1784
+ const templateDirectory = path$1.join(__dirname, "../templates");
1817
1785
  const cache$1 = /* @__PURE__ */ new Map();
1818
1786
  function cacheKey(layout, extension) {
1819
1787
  return [layout, extension].join("|");
@@ -1835,7 +1803,7 @@ function findTemplate(folders, from, src, format) {
1835
1803
  folders = [...folders, templateDirectory];
1836
1804
  const template = `${layout}.template.${format}`;
1837
1805
  const searchPaths = folders.map((it) => {
1838
- return path.join(it, template);
1806
+ return path$1.join(it, template);
1839
1807
  });
1840
1808
  const found = searchPaths.find((it) => fs$1.existsSync(it));
1841
1809
  if (!found) {
@@ -1845,7 +1813,7 @@ function findTemplate(folders, from, src, format) {
1845
1813
  return template;
1846
1814
  }
1847
1815
 
1848
- const scriptPath = path.join(__dirname, "compile-example.js");
1816
+ const scriptPath = path$1.join(__dirname, "compile-example.js");
1849
1817
  let loader = null;
1850
1818
  function haveOutputFile(fileInfo) {
1851
1819
  return fileInfo.outputName !== false;
@@ -1879,8 +1847,8 @@ function findSidenav(doc, tree) {
1879
1847
  }
1880
1848
  function cache(cacheFolder, outputFolder) {
1881
1849
  return (it) => {
1882
- const cacheFile = path.join(cacheFolder, it.outputFile);
1883
- const outputFile = path.join(outputFolder, it.outputFile);
1850
+ const cacheFile = path$1.join(cacheFolder, it.outputFile);
1851
+ const outputFile = path$1.join(outputFolder, it.outputFile);
1884
1852
  if (fs$1.existsSync(cacheFile)) {
1885
1853
  fs$1.copyFileSync(cacheFile, outputFile);
1886
1854
  return false;
@@ -1894,8 +1862,8 @@ async function compileExamples(options) {
1894
1862
  if (tasks.length === 0) {
1895
1863
  return;
1896
1864
  }
1897
- const cacheFolder = path.posix.join(options.cacheFolder, fileInfo.path);
1898
- const outputFolder = path.posix.join(options.outputFolder, fileInfo.path);
1865
+ const cacheFolder = path$1.posix.join(options.cacheFolder, fileInfo.path);
1866
+ const outputFolder = path$1.posix.join(options.outputFolder, fileInfo.path);
1899
1867
  const cacheMiss = cache(cacheFolder, outputFolder);
1900
1868
  const dirtyTasks = tasks.filter(cacheMiss);
1901
1869
  if (dirtyTasks.length === 0) {
@@ -1918,8 +1886,8 @@ async function compileStandalones(options) {
1918
1886
  if (tasks.length === 0) {
1919
1887
  return;
1920
1888
  }
1921
- const cacheFolder = path.posix.join(options.cacheFolder, fileInfo.path);
1922
- const outputFolder = path.posix.join(options.outputFolder, fileInfo.path);
1889
+ const cacheFolder = path$1.posix.join(options.cacheFolder, fileInfo.path);
1890
+ const outputFolder = path$1.posix.join(options.outputFolder, fileInfo.path);
1923
1891
  const cacheMiss = cache(cacheFolder, outputFolder);
1924
1892
  const dirtyTasks = tasks.filter(cacheMiss);
1925
1893
  const standaloneTemplate = findTemplate(
@@ -1928,7 +1896,7 @@ async function compileStandalones(options) {
1928
1896
  "example"
1929
1897
  );
1930
1898
  for (const task of dirtyTasks) {
1931
- const outputFile = path.join(outputFolder, task.outputFile);
1899
+ const outputFile = path$1.join(outputFolder, task.outputFile);
1932
1900
  const content = await renderTemplate(standaloneTemplate, {
1933
1901
  ...templateData,
1934
1902
  content: task.content
@@ -1947,7 +1915,7 @@ async function render(doc, docs, nav, vendors, options) {
1947
1915
  return null;
1948
1916
  }
1949
1917
  const dst = createMarkdownRenderer.getOutputFilePath(outputFolder, fileInfo);
1950
- const mkdir = fs.mkdir(path.dirname(dst), { recursive: true });
1918
+ const mkdir = fs.mkdir(path$1.dirname(dst), { recursive: true });
1951
1919
  const topnav = nav.topnav;
1952
1920
  const sidenav = findSidenav(doc, nav.sidenav);
1953
1921
  if (sidenav && isNavigationSection(sidenav)) {
@@ -1964,7 +1932,7 @@ async function render(doc, docs, nav, vendors, options) {
1964
1932
  topnav,
1965
1933
  rootUrl(doc2) {
1966
1934
  const { fileInfo: fileInfo2 } = doc2;
1967
- const relative = path$1.relative(fileInfo2.path, ".");
1935
+ const relative = path.relative(fileInfo2.path, ".");
1968
1936
  return relative !== "" ? relative : ".";
1969
1937
  },
1970
1938
  sidenav,
@@ -1975,7 +1943,7 @@ async function render(doc, docs, nav, vendors, options) {
1975
1943
  const markdownRenderer = createMarkdownRenderer.createMarkdownRenderer({
1976
1944
  docs,
1977
1945
  generateExample({ source, language, filename, tags }) {
1978
- const example = generateExample({
1946
+ const example = createMarkdownRenderer.generateExample({
1979
1947
  source,
1980
1948
  language,
1981
1949
  filename,
@@ -1985,12 +1953,12 @@ async function render(doc, docs, nav, vendors, options) {
1985
1953
  tags
1986
1954
  });
1987
1955
  if (example.output) {
1988
- const { dir, name } = path.parse(example.output);
1956
+ const { dir, name } = path$1.parse(example.output);
1989
1957
  if (example.task) {
1990
1958
  generatedExamples.push(example.task);
1991
1959
  }
1992
1960
  generatedStandalone.push({
1993
- outputFile: path.join(dir, `${name}.html`),
1961
+ outputFile: path$1.join(dir, `${name}.html`),
1994
1962
  content: example.markup
1995
1963
  });
1996
1964
  }
@@ -2190,12 +2158,12 @@ function getAssetSource(asset, require) {
2190
2158
  return lines.join("\n");
2191
2159
  }
2192
2160
  async function compileVendor(assetFolder, vendor, options) {
2193
- const name = path.isAbsolute(vendor.package) ? path.basename(vendor.package) : vendor.package;
2161
+ const name = path$1.isAbsolute(vendor.package) ? path$1.basename(vendor.package) : vendor.package;
2194
2162
  const slug = slugify(name);
2195
2163
  const outfile = `temp/vendor-${slug}.out.js`;
2196
2164
  const tmpfile = `temp/vendor-${slug}.in.js`;
2197
2165
  const source = getAssetSource(vendor, customRequire.toString());
2198
- const tsconfig = path.resolve(__dirname, "../tsconfig-examples.json");
2166
+ const tsconfig = path$1.resolve(__dirname, "../tsconfig-examples.json");
2199
2167
  await fs.writeFile(tmpfile, source, "utf-8");
2200
2168
  await esbuild$1.build({
2201
2169
  entryPoints: [tmpfile],
@@ -2217,7 +2185,7 @@ async function compileVendor(assetFolder, vendor, options) {
2217
2185
  const fingerprint = createMarkdownRenderer.getFingerprint(content);
2218
2186
  const integrity = getIntegrity(content);
2219
2187
  const filename = `vendor-${slug}-${fingerprint}.js`;
2220
- const dst = path.join(assetFolder, filename).replace(/\\/g, "/");
2188
+ const dst = path$1.join(assetFolder, filename).replace(/\\/g, "/");
2221
2189
  await fs.rename(outfile, dst);
2222
2190
  const stat = await fs.stat(dst);
2223
2191
  return {
@@ -2270,7 +2238,7 @@ function vendorProcessor(assetFolder, vendor) {
2270
2238
  const assets = await generateVendorAssets(assetFolder, vendor);
2271
2239
  context.addVendorAsset(assets);
2272
2240
  for (const asset of assets) {
2273
- const filename = path$1.basename(asset.publicPath);
2241
+ const filename = path.basename(asset.publicPath);
2274
2242
  context.log(filename, formatSize(asset.size));
2275
2243
  }
2276
2244
  }
@@ -2350,7 +2318,7 @@ async function serve(options) {
2350
2318
  const watcher = vendor.watch(options.watch);
2351
2319
  const rebuild = createRebuilder(options.rebuild, (filePath) => {
2352
2320
  const files = filePath.map((it) => {
2353
- return path$1.relative(options.outputFolder, it);
2321
+ return path.relative(options.outputFolder, it);
2354
2322
  });
2355
2323
  livereload.changed({ body: { files } });
2356
2324
  });
@@ -2529,10 +2497,10 @@ class Generator {
2529
2497
  throw new Error("site metadata not set in configuration");
2530
2498
  }
2531
2499
  this.site = options.site;
2532
- this.outputFolder = options.outputFolder;
2533
- this.cacheFolder = options.cacheFolder;
2534
- this.assetFolder = path.posix.join(options.outputFolder, "assets");
2535
- this.exampleFolders = options.exampleFolders;
2500
+ this.outputFolder = options.outputFolder ?? "./public";
2501
+ this.cacheFolder = options.cacheFolder ?? "./temp/docs";
2502
+ this.assetFolder = path$1.posix.join(this.outputFolder, "assets");
2503
+ this.exampleFolders = options.exampleFolders ?? [];
2536
2504
  this.templateFolders = options.templateFolders ?? [];
2537
2505
  this.processors = options.processors ?? [];
2538
2506
  this.vendor = options.vendor ?? [];
@@ -2670,7 +2638,7 @@ class Generator {
2670
2638
  const { outputFolder, cacheFolder, assetFolder } = this;
2671
2639
  await fs.rm(cacheFolder, { force: true, recursive: true });
2672
2640
  if (fs$1.existsSync(outputFolder)) {
2673
- await fs.mkdir(path.dirname(cacheFolder), { recursive: true });
2641
+ await fs.mkdir(path$1.dirname(cacheFolder), { recursive: true });
2674
2642
  await vendor.fse.copy(outputFolder, cacheFolder);
2675
2643
  await fs.rm(outputFolder, { recursive: true });
2676
2644
  }
@@ -2775,6 +2743,7 @@ exports.Generator = Generator;
2775
2743
  exports.availableProcessors = availableProcessors;
2776
2744
  exports.cookieProcessor = cookieProcessor;
2777
2745
  exports.defineSources = defineSources;
2746
+ exports.extractExamplesProcessor = extractExamplesProcessor;
2778
2747
  exports.frontMatterFileReader = frontMatterFileReader;
2779
2748
  exports.htmlRedirectProcessor = htmlRedirectProcessor;
2780
2749
  exports.livereloadProcessor = livereloadProcessor;