@forsakringskassan/docs-generator 3.0.3 → 3.1.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.
@@ -2,7 +2,7 @@ import { createRequire as $createRequire } from "node:module";
2
2
 
3
3
  const require = $createRequire(import.meta.url);
4
4
 
5
- import { o as runAsWorker, j as format2, r as resolveConfig } from './vendor-DLyCCfC4.mjs';
5
+ import { r as runAsWorker, f as format2, a as resolveConfig } from './vendor-DO1GigtJ.mjs';
6
6
  import 'node:url';
7
7
  import 'node:path';
8
8
  import 'fs';
@@ -54,4 +54,4 @@ async function formatCode(source, filepath) {
54
54
  runAsWorker(formatCode);
55
55
 
56
56
  export { formatCode };
57
- //# sourceMappingURL=format-code.worker-DHkJESkS.mjs.map
57
+ //# sourceMappingURL=format-code.worker-Cs0VeEOX.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"format-code.worker-DHkJESkS.mjs","sources":["../src/utils/format-code.worker.ts"],"sourcesContent":["import { type Options, format as prettier, resolveConfig } from \"prettier\";\nimport { runAsWorker } from \"synckit\";\n\nconst configCache = new Map<string, Options | null>();\n\nasync function getConfig(filepath: string): Promise<Options | null> {\n const cached = configCache.get(filepath);\n if (cached !== undefined) {\n return cached;\n }\n const options = await resolveConfig(filepath);\n configCache.set(filepath, options);\n return options;\n}\n\n/**\n * @internal\n */\nexport async function formatCode(\n source: string,\n filepath: string,\n): Promise<string> {\n const options = await getConfig(filepath);\n const formatted = await prettier(source, { ...options, filepath });\n return formatted.trim();\n}\n\nrunAsWorker(formatCode);\n"],"names":["prettier"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGA,MAAM,WAAA,uBAAkB,GAAA,EAA4B;AAEpD,eAAe,UAAU,QAAA,EAA2C;AAChE,EAAA,MAAM,MAAA,GAAS,WAAA,CAAY,GAAA,CAAI,QAAQ,CAAA;AACvC,EAAA,IAAI,WAAW,MAAA,EAAW;AACtB,IAAA,OAAO,MAAA;AAAA,EACX;AACA,EAAA,MAAM,OAAA,GAAU,MAAM,aAAA,CAAc,QAAQ,CAAA;AAC5C,EAAA,WAAA,CAAY,GAAA,CAAI,UAAU,OAAO,CAAA;AACjC,EAAA,OAAO,OAAA;AACX;AAKA,eAAsB,UAAA,CAClB,QACA,QAAA,EACe;AACf,EAAA,MAAM,OAAA,GAAU,MAAM,SAAA,CAAU,QAAQ,CAAA;AACxC,EAAA,MAAM,SAAA,GAAY,MAAMA,OAAA,CAAS,MAAA,EAAQ,EAAE,GAAG,OAAA,EAAS,UAAU,CAAA;AACjE,EAAA,OAAO,UAAU,IAAA,EAAK;AAC1B;AAEA,WAAA,CAAY,UAAU,CAAA;;;;"}
1
+ {"version":3,"file":"format-code.worker-Cs0VeEOX.mjs","sources":["../src/utils/format-code.worker.ts"],"sourcesContent":["import { type Options, format as prettier, resolveConfig } from \"prettier\";\nimport { runAsWorker } from \"synckit\";\n\nconst configCache = new Map<string, Options | null>();\n\nasync function getConfig(filepath: string): Promise<Options | null> {\n const cached = configCache.get(filepath);\n if (cached !== undefined) {\n return cached;\n }\n const options = await resolveConfig(filepath);\n configCache.set(filepath, options);\n return options;\n}\n\n/**\n * @internal\n */\nexport async function formatCode(\n source: string,\n filepath: string,\n): Promise<string> {\n const options = await getConfig(filepath);\n const formatted = await prettier(source, { ...options, filepath });\n return formatted.trim();\n}\n\nrunAsWorker(formatCode);\n"],"names":["prettier"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGA,MAAM,WAAA,uBAAkB,GAAA,EAA4B;AAEpD,eAAe,UAAU,QAAA,EAA2C;AAChE,EAAA,MAAM,MAAA,GAAS,WAAA,CAAY,GAAA,CAAI,QAAQ,CAAA;AACvC,EAAA,IAAI,WAAW,MAAA,EAAW;AACtB,IAAA,OAAO,MAAA;AAAA,EACX;AACA,EAAA,MAAM,OAAA,GAAU,MAAM,aAAA,CAAc,QAAQ,CAAA;AAC5C,EAAA,WAAA,CAAY,GAAA,CAAI,UAAU,OAAO,CAAA;AACjC,EAAA,OAAO,OAAA;AACX;AAKA,eAAsB,UAAA,CAClB,QACA,QAAA,EACe;AACf,EAAA,MAAM,OAAA,GAAU,MAAM,SAAA,CAAU,QAAQ,CAAA;AACxC,EAAA,MAAM,SAAA,GAAY,MAAMA,OAAA,CAAS,MAAA,EAAQ,EAAE,GAAG,OAAA,EAAS,UAAU,CAAA;AACjE,EAAA,OAAO,UAAU,IAAA,EAAK;AAC1B;AAEA,WAAA,CAAY,UAAU,CAAA;;;;"}
package/dist/index.d.mts CHANGED
@@ -233,6 +233,18 @@ export declare interface FileInfo {
233
233
  outputName: string | false;
234
234
  }
235
235
 
236
+ /**
237
+ * A function to search for a filename.
238
+ *
239
+ * @public
240
+ * @since %version%
241
+ * @param filename - The filename to search for
242
+ * @param context - An optional context for usage in error messages
243
+ * @throws Throws an error if the filename could not be found
244
+ * @returns Filename relative to project root
245
+ */
246
+ export declare type FileMatcher = (filename: string, context?: string) => string;
247
+
236
248
  /**
237
249
  * Read and parse a file from disk to a doc-generator document.
238
250
  *
@@ -331,7 +343,7 @@ export declare interface GeneratorOptions {
331
343
  /** Path to file with exported `setup` function, responsible for mounting of component.
332
344
  * `function setup(options: { rootComponent: string, selector: string }): void`
333
345
  */
334
- setupPath: string;
346
+ setupPath: string | null;
335
347
  /**
336
348
  * Options for markdown renderer.
337
349
  */
@@ -398,6 +410,8 @@ export declare function livereloadProcessor(options: ProcessorOptions): Processo
398
410
  export declare interface Manifest {
399
411
  pages: Array<{
400
412
  path: string;
413
+ /** Path to the source document (relative to the project root) */
414
+ src: string;
401
415
  title: string;
402
416
  redirect: null | string;
403
417
  outline: Array<{
@@ -406,6 +420,8 @@ export declare interface Manifest {
406
420
  }>;
407
421
  examples: Array<{
408
422
  name?: string;
423
+ /** Path to imported example file (relative to project root) or `null` if example is inline */
424
+ src: string | null;
409
425
  selector: string;
410
426
  language: string;
411
427
  tags: string[];
@@ -579,6 +595,10 @@ export declare interface ProcessorContext {
579
595
  * @param renderer - Describes how to render the block content.
580
596
  */
581
597
  addTemplateBlock<T>(container: string, id: string, renderer: TemplateBlockRenderer<T>): void;
598
+ /**
599
+ * A `fileMatcher()` instance for finding imported examples.
600
+ */
601
+ readonly exampleFileMatcher: FileMatcher;
582
602
  /* Excluded from this release type: getAllTemplateBlocks */
583
603
  /* Excluded from this release type: hasTemplate */
584
604
  setTopNavigation(root: NavigationSection): void;
@@ -589,7 +609,16 @@ export declare interface ProcessorContext {
589
609
  getTemplateData(key: string): unknown;
590
610
  setTemplateData<K extends keyof TemplateData>(key: K, value: TemplateData[K]): void;
591
611
  setTemplateData(key: string, value: unknown): void;
612
+ /**
613
+ * Log information to the user.
614
+ */
592
615
  log(...args: unknown[]): void;
616
+ /**
617
+ * Log error to the user.
618
+ *
619
+ * The process will exit with a non-zero exit code after displaying one or more errors.
620
+ */
621
+ error(...args: unknown[]): void;
593
622
  }
594
623
 
595
624
  /**
package/dist/index.mjs CHANGED
@@ -3,15 +3,15 @@ import { createRequire as $createRequire } from "node:module";
3
3
  const require = $createRequire(import.meta.url);
4
4
 
5
5
  import { ApiItemKind, ApiModel } from '@microsoft/api-extractor-model';
6
- import { p as ts, Z as Ze, M as MarkdownIt, f as dedent, a as closest, h as distance, i as fm, m as isCI, n as moduleImporter, c as cliProgress, t as tinylr, w as watch, b as createInstance, k as fse, l as inter } from './vendor-DLyCCfC4.mjs';
6
+ import { t as ts, Z as Ze, M as MarkdownIt, d as dedent, g as closest, h as distance, i as fm, j as isCI, m as moduleImporter, k as cliProgress, l as tinylr, w as watch, n as createInstance, o as fse, p as inter } from './vendor-DO1GigtJ.mjs';
7
7
  import path__default from 'node:path';
8
8
  import crypto from 'node:crypto';
9
9
  import path from 'node:path/posix';
10
10
  import { exec, execSync } from 'node:child_process';
11
- import { d as generateId, b as formatCode, p as parseInfostring, k as isDocumentPage, n as normalizePath, e as getFingerprint, i as hasTag, a as findTag, h as getOutputFilePath, j as htmlencode, f as filePath, c as createMarkdownRenderer, g as generateExample } from './create-markdown-renderer-B2sP7UDF.mjs';
11
+ import { g as generateId, f as formatCode, p as parseInfostring, i as isDocumentPage, n as normalizePath, a as getFingerprint, h as hasTag, b as parseImport, d as findTag, e as getOutputFilePath, j as htmlencode, k as filePath, c as createMarkdownRenderer, l as generateExample } from './create-markdown-renderer-castrIfY.mjs';
12
12
  import { DocExcerpt } from '@microsoft/tsdoc';
13
13
  import fs from 'node:fs/promises';
14
- import util, { promisify } from 'node:util';
14
+ import util, { promisify, styleText } from 'node:util';
15
15
  import { codeFrameColumns } from '@babel/code-frame';
16
16
  import { parse as parse$1 } from '@babel/parser';
17
17
  import traverseModule from '@babel/traverse';
@@ -51,7 +51,7 @@ import 'fs/promises';
51
51
  import 'process';
52
52
  import 'v8';
53
53
  import 'vue';
54
- import './vue3-RC792pPN.mjs';
54
+ import './vue3-CnvFixWY.mjs';
55
55
 
56
56
  function toArray$2(value) {
57
57
  return Array.isArray(value) ? value : [value];
@@ -673,18 +673,22 @@ function extractExamplesProcessor(options) {
673
673
  }
674
674
 
675
675
  const md$5 = MarkdownIt();
676
- md$5.renderer.rules.fence = (tokens, idx, _options, collected) => {
676
+ md$5.renderer.rules.fence = (tokens, idx, _options, env) => {
677
+ const { collected, exampleFileMatcher } = env;
677
678
  const { content, info, map } = tokens[idx];
678
679
  const { language: rawLanguage, tags } = parseInfostring(info);
679
680
  const hashContent = `${String(map?.[0])}:${String(map?.[1])}:${info}:${content}`;
680
681
  const fingerprint = getFingerprint(hashContent);
681
682
  let extension = void 0;
683
+ let src = null;
682
684
  let language = rawLanguage;
683
685
  if (hasTag(tags, "compare")) {
684
686
  language = "diff";
685
687
  }
686
688
  if (language === "import") {
687
- extension = content.split(".").at(-1)?.trim();
689
+ const parsed = parseImport(content);
690
+ src = exampleFileMatcher(parsed.filename);
691
+ extension = parsed.extension;
688
692
  }
689
693
  if (hasTag(tags, "hidden")) {
690
694
  return "";
@@ -692,6 +696,7 @@ md$5.renderer.rules.fence = (tokens, idx, _options, collected) => {
692
696
  const name = findTag(tags, "name")?.value ?? void 0;
693
697
  collected.push({
694
698
  name,
699
+ src,
695
700
  selector: `#example-${fingerprint}`,
696
701
  language: extension ?? language,
697
702
  tags
@@ -706,22 +711,27 @@ function flattenOutline(outline) {
706
711
  ];
707
712
  });
708
713
  }
709
- function findExamples(doc) {
714
+ function findExamples(context, doc) {
715
+ const { exampleFileMatcher } = context;
710
716
  if (doc.format !== "markdown") {
711
717
  return [];
712
718
  }
713
719
  const collected = [];
714
- md$5.render(doc.body, collected);
720
+ md$5.render(doc.body, {
721
+ exampleFileMatcher,
722
+ collected
723
+ });
715
724
  return collected;
716
725
  }
717
- function manifestPageFromDocument(doc) {
726
+ function manifestPageFromDocument(context, doc) {
718
727
  const { body, fileInfo, format } = doc;
719
728
  return {
720
729
  path: getOutputFilePath("", fileInfo),
730
+ src: doc.fileInfo.fullPath,
721
731
  title: doc.attributes.title ?? doc.name,
722
732
  redirect: format === "redirect" ? body : null,
723
733
  outline: flattenOutline(doc.outline),
724
- examples: findExamples(doc)
734
+ examples: findExamples(context, doc)
725
735
  };
726
736
  }
727
737
 
@@ -772,7 +782,9 @@ function manifestProcessor(options = {}) {
772
782
  before: "render",
773
783
  async handler(context) {
774
784
  const docs = context.docs.filter(isDocumentPage).filter(haveOutput);
775
- const pages = docs.map(manifestPageFromDocument);
785
+ const pages = docs.map(
786
+ (doc) => manifestPageFromDocument(context, doc)
787
+ );
776
788
  pages.sort((a, b) => {
777
789
  return a.path.localeCompare(b.path);
778
790
  });
@@ -2289,12 +2301,32 @@ async function globAll(pattern) {
2289
2301
  );
2290
2302
  return new Set(results.flat());
2291
2303
  }
2292
- async function getDocumentsForSource(src) {
2304
+ async function getDocumentsForSource(context, src, index) {
2293
2305
  const { transform } = src;
2294
2306
  const include = await globAll(src.include);
2295
2307
  const exclude = await globAll(src.exclude);
2296
2308
  const files = Array.from(difference(include, exclude));
2309
+ let showWarning = true;
2297
2310
  const promises = files.map(async (it) => {
2311
+ if (!src.fileReader) {
2312
+ if (showWarning) {
2313
+ const lines = JSON.stringify(src, null, 2).split("\n");
2314
+ context.error(
2315
+ `"${it}" ignored: \`fileReader\` property was not specified in configuration.`
2316
+ );
2317
+ context.error();
2318
+ context.error(
2319
+ `The file was matched from sourceFiles[${index}]:`
2320
+ );
2321
+ for (const line of lines) {
2322
+ context.error(" ", line);
2323
+ }
2324
+ context.error();
2325
+ context.error("This warning is only shown once.");
2326
+ showWarning = false;
2327
+ }
2328
+ return [];
2329
+ }
2298
2330
  const docs2 = await src.fileReader(it, src.basePath);
2299
2331
  if (transform) {
2300
2332
  return docs2.map((it2) => transform(it2));
@@ -2305,8 +2337,12 @@ async function getDocumentsForSource(src) {
2305
2337
  const docs = await Promise.all(promises);
2306
2338
  return docs.flat();
2307
2339
  }
2308
- async function getAllDocuments(sourceFiles) {
2309
- const result = await Promise.all(sourceFiles.map(getDocumentsForSource));
2340
+ async function getAllDocuments(context, sourceFiles) {
2341
+ const result = await Promise.all(
2342
+ sourceFiles.map((entry, index) => {
2343
+ return getDocumentsForSource(context, entry, index);
2344
+ })
2345
+ );
2310
2346
  return result.flat();
2311
2347
  }
2312
2348
  function fileReaderProcessor(sourceFiles) {
@@ -2314,7 +2350,7 @@ function fileReaderProcessor(sourceFiles) {
2314
2350
  stage: "generate-docs",
2315
2351
  name: "file-reader-processor",
2316
2352
  async handler(context) {
2317
- const result = await getAllDocuments(sourceFiles);
2353
+ const result = await getAllDocuments(context, sourceFiles);
2318
2354
  context.addDocument(result);
2319
2355
  context.log(result.length, "documents found");
2320
2356
  }
@@ -2396,7 +2432,7 @@ async function compileStyle(assetFolder, name, src) {
2396
2432
  };
2397
2433
  } catch (err) {
2398
2434
  console.error(err);
2399
- throw new Error(`Failed to compile style "${name}"`);
2435
+ throw new Error(`Failed to compile style "${name}"`, { cause: err });
2400
2436
  }
2401
2437
  }
2402
2438
 
@@ -2495,7 +2531,9 @@ async function compileScript(options) {
2495
2531
  };
2496
2532
  } catch (err) {
2497
2533
  const reason = err instanceof Error ? err.message : String(err);
2498
- throw new Error(`Failed to compile script "${name}": ${reason}`);
2534
+ throw new Error(`Failed to compile script "${name}": ${reason}`, {
2535
+ cause: err
2536
+ });
2499
2537
  }
2500
2538
  }
2501
2539
 
@@ -2666,19 +2704,6 @@ var langSv = {
2666
2704
  translation: translation
2667
2705
  };
2668
2706
 
2669
- function navigationProcessor() {
2670
- return {
2671
- stage: "generate-nav",
2672
- name: "navigation-processor",
2673
- handler(context) {
2674
- const pages = context.docs.filter(isDocumentPage);
2675
- const navtree = generateNavtree(pages);
2676
- context.setTopNavigation(navtree);
2677
- context.setSideNavigation(navtree);
2678
- }
2679
- };
2680
- }
2681
-
2682
2707
  function sortNavigationTree(tree) {
2683
2708
  tree.children.sort((a, b) => {
2684
2709
  if (a.sortorder < b.sortorder) {
@@ -2703,6 +2728,20 @@ function sortNavigationTree(tree) {
2703
2728
  }
2704
2729
  }
2705
2730
 
2731
+ function navigationProcessor() {
2732
+ return {
2733
+ stage: "generate-nav",
2734
+ name: "navigation-processor",
2735
+ handler(context) {
2736
+ const pages = context.docs.filter(isDocumentPage);
2737
+ const navtree = generateNavtree(pages);
2738
+ sortNavigationTree(navtree);
2739
+ context.setTopNavigation(navtree);
2740
+ context.setSideNavigation(navtree);
2741
+ }
2742
+ };
2743
+ }
2744
+
2706
2745
  const templateUrl = new URL("../templates", import.meta.url);
2707
2746
  const templateDirectory = fileURLToPath(templateUrl);
2708
2747
 
@@ -2962,9 +3001,17 @@ function createTemplateLoader(folders) {
2962
3001
  function stripPrettierComments(content) {
2963
3002
  return content.replaceAll(/\s*<!-- prettier-ignore -->\s*/gm, "");
2964
3003
  }
2965
- async function render(doc, docs, nav, vendors, options) {
3004
+ async function render(doc, docs, options) {
2966
3005
  const { fileInfo } = doc;
2967
- const { i18n, outputFolder, cacheFolder, templateFolders, fileMatcher } = options;
3006
+ const {
3007
+ i18n,
3008
+ outputFolder,
3009
+ cacheFolder,
3010
+ exampleFileMatcher,
3011
+ nav,
3012
+ templateFolders,
3013
+ vendors
3014
+ } = options;
2968
3015
  if (!haveOutputFile(fileInfo)) {
2969
3016
  return null;
2970
3017
  }
@@ -3032,7 +3079,7 @@ async function render(doc, docs, nav, vendors, options) {
3032
3079
  setupPath: options.setupPath,
3033
3080
  exampleFolders: options.exampleFolders,
3034
3081
  tags,
3035
- fileMatcher
3082
+ fileMatcher: exampleFileMatcher
3036
3083
  });
3037
3084
  if (example.output) {
3038
3085
  const { dir, name } = path__default.parse(example.output);
@@ -3048,7 +3095,7 @@ async function render(doc, docs, nav, vendors, options) {
3048
3095
  },
3049
3096
  getImportedSource(filename) {
3050
3097
  const context = `when importing example from "${fileInfo.fullPath}"`;
3051
- const match = fileMatcher(filename, context);
3098
+ const match = exampleFileMatcher(filename, context);
3052
3099
  return readFileSync(match, "utf8");
3053
3100
  },
3054
3101
  addResource(dst2, src) {
@@ -3169,14 +3216,16 @@ function nunjucksProcessor(options) {
3169
3216
  name: "nunjucks-renderer",
3170
3217
  async handler(context) {
3171
3218
  function renderDocument(doc) {
3172
- const nav = {
3173
- topnav: context.topnav,
3174
- sidenav: context.sidenav
3175
- };
3176
- return render(doc, context.docs, nav, context.vendors, {
3219
+ return render(doc, context.docs, {
3177
3220
  ...options,
3221
+ exampleFileMatcher: context.exampleFileMatcher,
3222
+ nav: {
3223
+ topnav: context.topnav,
3224
+ sidenav: context.sidenav
3225
+ },
3178
3226
  templateBlocks: context.getAllTemplateBlocks(),
3179
3227
  templateData: context.getAllTemplateData(),
3228
+ vendors: context.vendors,
3180
3229
  addResource(dst, src) {
3181
3230
  context.addResource(dst, src);
3182
3231
  }
@@ -3452,12 +3501,28 @@ async function stage(stage2, context, processors, options) {
3452
3501
  console.log(isLast ? " \u2514\u2500" : " \u251C\u2500", processor.name);
3453
3502
  }
3454
3503
  try {
3504
+ const prefix = (() => {
3505
+ if (verbose) {
3506
+ return isLast ? " " : " \u2502 ";
3507
+ } else {
3508
+ return "";
3509
+ }
3510
+ })();
3455
3511
  const result = await processor.handler({
3456
3512
  ...context,
3457
3513
  log(...args) {
3458
3514
  if (verbose) {
3459
- console.log(isLast ? " " : " \u2502 ", ...args);
3515
+ console.log(prefix, ...args);
3460
3516
  }
3517
+ },
3518
+ error(...args) {
3519
+ process.exitCode = 1;
3520
+ console.error(
3521
+ prefix,
3522
+ ...args.map(
3523
+ (it) => typeof it === "string" ? styleText("red", it) : it
3524
+ )
3525
+ );
3461
3526
  }
3462
3527
  });
3463
3528
  if (result) {
@@ -3470,7 +3535,8 @@ async function stage(stage2, context, processors, options) {
3470
3535
  }
3471
3536
  return generatedFiles;
3472
3537
  }
3473
- function createContext(outputFolder, templateLoader) {
3538
+ function createContext(options) {
3539
+ const { outputFolder, exampleFileMatcher, templateLoader } = options;
3474
3540
  let docs = [];
3475
3541
  let vendors = [];
3476
3542
  const resources = [];
@@ -3509,6 +3575,7 @@ function createContext(outputFolder, templateLoader) {
3509
3575
  return sidenav;
3510
3576
  },
3511
3577
  outputFolder,
3578
+ exampleFileMatcher,
3512
3579
  addDocument(document) {
3513
3580
  docs = [...docs, ...toArray(document)];
3514
3581
  },
@@ -3607,7 +3674,7 @@ class Generator {
3607
3674
  this.templateFolders = options.templateFolders ?? [];
3608
3675
  this.processors = options.processors ?? [];
3609
3676
  this.vendor = options.vendor ?? [];
3610
- this.setupPath = options.setupPath.replaceAll("\\", "/");
3677
+ this.setupPath = options.setupPath?.replaceAll("\\", "/") ?? null;
3611
3678
  this.scripts = [];
3612
3679
  this.styles = [];
3613
3680
  this.resources = [];
@@ -3678,11 +3745,19 @@ class Generator {
3678
3745
  redirectProcessor(),
3679
3746
  ...this.processors
3680
3747
  ];
3748
+ const examplePatterns = this.exampleFolders.map((it) => `${it}/**/*`);
3749
+ const exampleFileMatcher = fileMatcher(examplePatterns);
3681
3750
  const templateLoader = createTemplateLoader([]);
3682
- const context = createContext("", templateLoader);
3751
+ const context = createContext({
3752
+ outputFolder: "",
3753
+ exampleFileMatcher,
3754
+ templateLoader
3755
+ });
3683
3756
  await stage("generate-docs", context, processors, { verbose: false });
3684
3757
  const docs = context.docs.filter(isDocumentPage).filter(haveOutput);
3685
- const pages = docs.map(manifestPageFromDocument);
3758
+ const pages = docs.map((doc) => {
3759
+ return manifestPageFromDocument({ exampleFileMatcher }, doc);
3760
+ });
3686
3761
  return { pages };
3687
3762
  }
3688
3763
  async build(sourceFiles) {
@@ -3728,14 +3803,17 @@ class Generator {
3728
3803
  exampleFolders,
3729
3804
  templateFolders,
3730
3805
  setupPath,
3731
- markdown: markdownOptions ?? {},
3732
- fileMatcher: fileMatcher(examplePatterns)
3806
+ markdown: markdownOptions ?? {}
3733
3807
  }),
3734
3808
  ...this.processors
3735
3809
  ];
3736
3810
  compileProcessorRuntime(this, import.meta.url, processors);
3737
3811
  const templateLoader = createTemplateLoader(templateFolders);
3738
- const context = createContext(outputFolder, templateLoader);
3812
+ const context = createContext({
3813
+ outputFolder,
3814
+ exampleFileMatcher: fileMatcher(examplePatterns),
3815
+ templateLoader
3816
+ });
3739
3817
  const generatedFiles = [
3740
3818
  await stage("generate-docs", context, processors),
3741
3819
  await stage("generate-nav", context, processors),
@@ -3881,6 +3959,9 @@ function searchProcessor() {
3881
3959
  context.addTemplateBlock("toolbar", "search-toolbar", {
3882
3960
  filename: "partials/search-toolbar.html"
3883
3961
  });
3962
+ context.addTemplateBlock("head", "search-preload", {
3963
+ filename: "partials/search-preload.html"
3964
+ });
3884
3965
  context.addTemplateBlock("body:end", "search-dialog", {
3885
3966
  filename: "partials/search-dialog.html"
3886
3967
  });