@forsakringskassan/docs-generator 3.0.4 → 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.
- package/dist/{create-markdown-renderer-cnbxjnoS.mjs → create-markdown-renderer-castrIfY.mjs} +6 -6
- package/dist/{create-markdown-renderer-cnbxjnoS.mjs.map → create-markdown-renderer-castrIfY.mjs.map} +1 -1
- package/dist/{format-code.worker-Xf0JB1yl.mjs → format-code.worker-Cs0VeEOX.mjs} +2 -2
- package/dist/{format-code.worker-Xf0JB1yl.mjs.map → format-code.worker-Cs0VeEOX.mjs.map} +1 -1
- package/dist/index.d.mts +30 -1
- package/dist/index.mjs +124 -45
- package/dist/index.mjs.map +1 -1
- package/dist/markdown.mjs +3 -3
- package/dist/processors/selectable-version.mjs +15 -2
- package/dist/runtime.mjs +442 -392
- package/dist/{vendor-s-84ehgc.mjs → vendor-DO1GigtJ.mjs} +77 -30
- package/dist/{vendor-s-84ehgc.mjs.map → vendor-DO1GigtJ.mjs.map} +1 -1
- package/dist/{vue3-RC792pPN.mjs → vue3-CnvFixWY.mjs} +15 -3
- package/dist/{vue3-RC792pPN.mjs.map → vue3-CnvFixWY.mjs.map} +1 -1
- package/dist/{worker-CVWE4d_P.mjs → worker-DO8E5WXF.mjs} +2 -2
- package/dist/{worker-CVWE4d_P.mjs.map → worker-DO8E5WXF.mjs.map} +1 -1
- package/package.json +1 -1
- package/templates/base.template.html +0 -9
- package/templates/partials/search-preload.html +8 -0
|
@@ -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 { r as runAsWorker, f as format2, a as resolveConfig } from './vendor-
|
|
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-
|
|
57
|
+
//# sourceMappingURL=format-code.worker-Cs0VeEOX.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"format-code.worker-
|
|
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 { 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-
|
|
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 { g as generateId, f as formatCode, p as parseInfostring, i as isDocumentPage, n as normalizePath, a as getFingerprint, h as hasTag, b as
|
|
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-
|
|
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,
|
|
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
|
-
|
|
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,
|
|
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(
|
|
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(
|
|
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
|
}
|
|
@@ -2668,19 +2704,6 @@ var langSv = {
|
|
|
2668
2704
|
translation: translation
|
|
2669
2705
|
};
|
|
2670
2706
|
|
|
2671
|
-
function navigationProcessor() {
|
|
2672
|
-
return {
|
|
2673
|
-
stage: "generate-nav",
|
|
2674
|
-
name: "navigation-processor",
|
|
2675
|
-
handler(context) {
|
|
2676
|
-
const pages = context.docs.filter(isDocumentPage);
|
|
2677
|
-
const navtree = generateNavtree(pages);
|
|
2678
|
-
context.setTopNavigation(navtree);
|
|
2679
|
-
context.setSideNavigation(navtree);
|
|
2680
|
-
}
|
|
2681
|
-
};
|
|
2682
|
-
}
|
|
2683
|
-
|
|
2684
2707
|
function sortNavigationTree(tree) {
|
|
2685
2708
|
tree.children.sort((a, b) => {
|
|
2686
2709
|
if (a.sortorder < b.sortorder) {
|
|
@@ -2705,6 +2728,20 @@ function sortNavigationTree(tree) {
|
|
|
2705
2728
|
}
|
|
2706
2729
|
}
|
|
2707
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
|
+
|
|
2708
2745
|
const templateUrl = new URL("../templates", import.meta.url);
|
|
2709
2746
|
const templateDirectory = fileURLToPath(templateUrl);
|
|
2710
2747
|
|
|
@@ -2964,9 +3001,17 @@ function createTemplateLoader(folders) {
|
|
|
2964
3001
|
function stripPrettierComments(content) {
|
|
2965
3002
|
return content.replaceAll(/\s*<!-- prettier-ignore -->\s*/gm, "");
|
|
2966
3003
|
}
|
|
2967
|
-
async function render(doc, docs,
|
|
3004
|
+
async function render(doc, docs, options) {
|
|
2968
3005
|
const { fileInfo } = doc;
|
|
2969
|
-
const {
|
|
3006
|
+
const {
|
|
3007
|
+
i18n,
|
|
3008
|
+
outputFolder,
|
|
3009
|
+
cacheFolder,
|
|
3010
|
+
exampleFileMatcher,
|
|
3011
|
+
nav,
|
|
3012
|
+
templateFolders,
|
|
3013
|
+
vendors
|
|
3014
|
+
} = options;
|
|
2970
3015
|
if (!haveOutputFile(fileInfo)) {
|
|
2971
3016
|
return null;
|
|
2972
3017
|
}
|
|
@@ -3034,7 +3079,7 @@ async function render(doc, docs, nav, vendors, options) {
|
|
|
3034
3079
|
setupPath: options.setupPath,
|
|
3035
3080
|
exampleFolders: options.exampleFolders,
|
|
3036
3081
|
tags,
|
|
3037
|
-
fileMatcher
|
|
3082
|
+
fileMatcher: exampleFileMatcher
|
|
3038
3083
|
});
|
|
3039
3084
|
if (example.output) {
|
|
3040
3085
|
const { dir, name } = path__default.parse(example.output);
|
|
@@ -3050,7 +3095,7 @@ async function render(doc, docs, nav, vendors, options) {
|
|
|
3050
3095
|
},
|
|
3051
3096
|
getImportedSource(filename) {
|
|
3052
3097
|
const context = `when importing example from "${fileInfo.fullPath}"`;
|
|
3053
|
-
const match =
|
|
3098
|
+
const match = exampleFileMatcher(filename, context);
|
|
3054
3099
|
return readFileSync(match, "utf8");
|
|
3055
3100
|
},
|
|
3056
3101
|
addResource(dst2, src) {
|
|
@@ -3171,14 +3216,16 @@ function nunjucksProcessor(options) {
|
|
|
3171
3216
|
name: "nunjucks-renderer",
|
|
3172
3217
|
async handler(context) {
|
|
3173
3218
|
function renderDocument(doc) {
|
|
3174
|
-
|
|
3175
|
-
topnav: context.topnav,
|
|
3176
|
-
sidenav: context.sidenav
|
|
3177
|
-
};
|
|
3178
|
-
return render(doc, context.docs, nav, context.vendors, {
|
|
3219
|
+
return render(doc, context.docs, {
|
|
3179
3220
|
...options,
|
|
3221
|
+
exampleFileMatcher: context.exampleFileMatcher,
|
|
3222
|
+
nav: {
|
|
3223
|
+
topnav: context.topnav,
|
|
3224
|
+
sidenav: context.sidenav
|
|
3225
|
+
},
|
|
3180
3226
|
templateBlocks: context.getAllTemplateBlocks(),
|
|
3181
3227
|
templateData: context.getAllTemplateData(),
|
|
3228
|
+
vendors: context.vendors,
|
|
3182
3229
|
addResource(dst, src) {
|
|
3183
3230
|
context.addResource(dst, src);
|
|
3184
3231
|
}
|
|
@@ -3454,12 +3501,28 @@ async function stage(stage2, context, processors, options) {
|
|
|
3454
3501
|
console.log(isLast ? " \u2514\u2500" : " \u251C\u2500", processor.name);
|
|
3455
3502
|
}
|
|
3456
3503
|
try {
|
|
3504
|
+
const prefix = (() => {
|
|
3505
|
+
if (verbose) {
|
|
3506
|
+
return isLast ? " " : " \u2502 ";
|
|
3507
|
+
} else {
|
|
3508
|
+
return "";
|
|
3509
|
+
}
|
|
3510
|
+
})();
|
|
3457
3511
|
const result = await processor.handler({
|
|
3458
3512
|
...context,
|
|
3459
3513
|
log(...args) {
|
|
3460
3514
|
if (verbose) {
|
|
3461
|
-
console.log(
|
|
3515
|
+
console.log(prefix, ...args);
|
|
3462
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
|
+
);
|
|
3463
3526
|
}
|
|
3464
3527
|
});
|
|
3465
3528
|
if (result) {
|
|
@@ -3472,7 +3535,8 @@ async function stage(stage2, context, processors, options) {
|
|
|
3472
3535
|
}
|
|
3473
3536
|
return generatedFiles;
|
|
3474
3537
|
}
|
|
3475
|
-
function createContext(
|
|
3538
|
+
function createContext(options) {
|
|
3539
|
+
const { outputFolder, exampleFileMatcher, templateLoader } = options;
|
|
3476
3540
|
let docs = [];
|
|
3477
3541
|
let vendors = [];
|
|
3478
3542
|
const resources = [];
|
|
@@ -3511,6 +3575,7 @@ function createContext(outputFolder, templateLoader) {
|
|
|
3511
3575
|
return sidenav;
|
|
3512
3576
|
},
|
|
3513
3577
|
outputFolder,
|
|
3578
|
+
exampleFileMatcher,
|
|
3514
3579
|
addDocument(document) {
|
|
3515
3580
|
docs = [...docs, ...toArray(document)];
|
|
3516
3581
|
},
|
|
@@ -3609,7 +3674,7 @@ class Generator {
|
|
|
3609
3674
|
this.templateFolders = options.templateFolders ?? [];
|
|
3610
3675
|
this.processors = options.processors ?? [];
|
|
3611
3676
|
this.vendor = options.vendor ?? [];
|
|
3612
|
-
this.setupPath = options.setupPath
|
|
3677
|
+
this.setupPath = options.setupPath?.replaceAll("\\", "/") ?? null;
|
|
3613
3678
|
this.scripts = [];
|
|
3614
3679
|
this.styles = [];
|
|
3615
3680
|
this.resources = [];
|
|
@@ -3680,11 +3745,19 @@ class Generator {
|
|
|
3680
3745
|
redirectProcessor(),
|
|
3681
3746
|
...this.processors
|
|
3682
3747
|
];
|
|
3748
|
+
const examplePatterns = this.exampleFolders.map((it) => `${it}/**/*`);
|
|
3749
|
+
const exampleFileMatcher = fileMatcher(examplePatterns);
|
|
3683
3750
|
const templateLoader = createTemplateLoader([]);
|
|
3684
|
-
const context = createContext(
|
|
3751
|
+
const context = createContext({
|
|
3752
|
+
outputFolder: "",
|
|
3753
|
+
exampleFileMatcher,
|
|
3754
|
+
templateLoader
|
|
3755
|
+
});
|
|
3685
3756
|
await stage("generate-docs", context, processors, { verbose: false });
|
|
3686
3757
|
const docs = context.docs.filter(isDocumentPage).filter(haveOutput);
|
|
3687
|
-
const pages = docs.map(
|
|
3758
|
+
const pages = docs.map((doc) => {
|
|
3759
|
+
return manifestPageFromDocument({ exampleFileMatcher }, doc);
|
|
3760
|
+
});
|
|
3688
3761
|
return { pages };
|
|
3689
3762
|
}
|
|
3690
3763
|
async build(sourceFiles) {
|
|
@@ -3730,14 +3803,17 @@ class Generator {
|
|
|
3730
3803
|
exampleFolders,
|
|
3731
3804
|
templateFolders,
|
|
3732
3805
|
setupPath,
|
|
3733
|
-
markdown: markdownOptions ?? {}
|
|
3734
|
-
fileMatcher: fileMatcher(examplePatterns)
|
|
3806
|
+
markdown: markdownOptions ?? {}
|
|
3735
3807
|
}),
|
|
3736
3808
|
...this.processors
|
|
3737
3809
|
];
|
|
3738
3810
|
compileProcessorRuntime(this, import.meta.url, processors);
|
|
3739
3811
|
const templateLoader = createTemplateLoader(templateFolders);
|
|
3740
|
-
const context = createContext(
|
|
3812
|
+
const context = createContext({
|
|
3813
|
+
outputFolder,
|
|
3814
|
+
exampleFileMatcher: fileMatcher(examplePatterns),
|
|
3815
|
+
templateLoader
|
|
3816
|
+
});
|
|
3741
3817
|
const generatedFiles = [
|
|
3742
3818
|
await stage("generate-docs", context, processors),
|
|
3743
3819
|
await stage("generate-nav", context, processors),
|
|
@@ -3883,6 +3959,9 @@ function searchProcessor() {
|
|
|
3883
3959
|
context.addTemplateBlock("toolbar", "search-toolbar", {
|
|
3884
3960
|
filename: "partials/search-toolbar.html"
|
|
3885
3961
|
});
|
|
3962
|
+
context.addTemplateBlock("head", "search-preload", {
|
|
3963
|
+
filename: "partials/search-preload.html"
|
|
3964
|
+
});
|
|
3886
3965
|
context.addTemplateBlock("body:end", "search-dialog", {
|
|
3887
3966
|
filename: "partials/search-dialog.html"
|
|
3888
3967
|
});
|