@forsakringskassan/docs-generator 3.0.4 → 3.1.1
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 +126 -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,13 +782,16 @@ 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
|
});
|
|
779
791
|
const manifest = { pages };
|
|
780
792
|
if (markdown) {
|
|
781
793
|
const content = normalize(renderMarkdown(manifest));
|
|
794
|
+
await fs.mkdir(path__default.dirname(markdown), { recursive: true });
|
|
782
795
|
if (verify) {
|
|
783
796
|
const actual = normalize(
|
|
784
797
|
await fs.readFile(markdown, "utf8")
|
|
@@ -792,6 +805,7 @@ function manifestProcessor(options = {}) {
|
|
|
792
805
|
}
|
|
793
806
|
if (json) {
|
|
794
807
|
const content = renderJSON(manifest);
|
|
808
|
+
await fs.mkdir(path__default.dirname(json), { recursive: true });
|
|
795
809
|
await fs.writeFile(json, content, "utf8");
|
|
796
810
|
}
|
|
797
811
|
}
|
|
@@ -2289,12 +2303,32 @@ async function globAll(pattern) {
|
|
|
2289
2303
|
);
|
|
2290
2304
|
return new Set(results.flat());
|
|
2291
2305
|
}
|
|
2292
|
-
async function getDocumentsForSource(src) {
|
|
2306
|
+
async function getDocumentsForSource(context, src, index) {
|
|
2293
2307
|
const { transform } = src;
|
|
2294
2308
|
const include = await globAll(src.include);
|
|
2295
2309
|
const exclude = await globAll(src.exclude);
|
|
2296
2310
|
const files = Array.from(difference(include, exclude));
|
|
2311
|
+
let showWarning = true;
|
|
2297
2312
|
const promises = files.map(async (it) => {
|
|
2313
|
+
if (!src.fileReader) {
|
|
2314
|
+
if (showWarning) {
|
|
2315
|
+
const lines = JSON.stringify(src, null, 2).split("\n");
|
|
2316
|
+
context.error(
|
|
2317
|
+
`"${it}" ignored: \`fileReader\` property was not specified in configuration.`
|
|
2318
|
+
);
|
|
2319
|
+
context.error();
|
|
2320
|
+
context.error(
|
|
2321
|
+
`The file was matched from sourceFiles[${index}]:`
|
|
2322
|
+
);
|
|
2323
|
+
for (const line of lines) {
|
|
2324
|
+
context.error(" ", line);
|
|
2325
|
+
}
|
|
2326
|
+
context.error();
|
|
2327
|
+
context.error("This warning is only shown once.");
|
|
2328
|
+
showWarning = false;
|
|
2329
|
+
}
|
|
2330
|
+
return [];
|
|
2331
|
+
}
|
|
2298
2332
|
const docs2 = await src.fileReader(it, src.basePath);
|
|
2299
2333
|
if (transform) {
|
|
2300
2334
|
return docs2.map((it2) => transform(it2));
|
|
@@ -2305,8 +2339,12 @@ async function getDocumentsForSource(src) {
|
|
|
2305
2339
|
const docs = await Promise.all(promises);
|
|
2306
2340
|
return docs.flat();
|
|
2307
2341
|
}
|
|
2308
|
-
async function getAllDocuments(sourceFiles) {
|
|
2309
|
-
const result = await Promise.all(
|
|
2342
|
+
async function getAllDocuments(context, sourceFiles) {
|
|
2343
|
+
const result = await Promise.all(
|
|
2344
|
+
sourceFiles.map((entry, index) => {
|
|
2345
|
+
return getDocumentsForSource(context, entry, index);
|
|
2346
|
+
})
|
|
2347
|
+
);
|
|
2310
2348
|
return result.flat();
|
|
2311
2349
|
}
|
|
2312
2350
|
function fileReaderProcessor(sourceFiles) {
|
|
@@ -2314,7 +2352,7 @@ function fileReaderProcessor(sourceFiles) {
|
|
|
2314
2352
|
stage: "generate-docs",
|
|
2315
2353
|
name: "file-reader-processor",
|
|
2316
2354
|
async handler(context) {
|
|
2317
|
-
const result = await getAllDocuments(sourceFiles);
|
|
2355
|
+
const result = await getAllDocuments(context, sourceFiles);
|
|
2318
2356
|
context.addDocument(result);
|
|
2319
2357
|
context.log(result.length, "documents found");
|
|
2320
2358
|
}
|
|
@@ -2668,19 +2706,6 @@ var langSv = {
|
|
|
2668
2706
|
translation: translation
|
|
2669
2707
|
};
|
|
2670
2708
|
|
|
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
2709
|
function sortNavigationTree(tree) {
|
|
2685
2710
|
tree.children.sort((a, b) => {
|
|
2686
2711
|
if (a.sortorder < b.sortorder) {
|
|
@@ -2705,6 +2730,20 @@ function sortNavigationTree(tree) {
|
|
|
2705
2730
|
}
|
|
2706
2731
|
}
|
|
2707
2732
|
|
|
2733
|
+
function navigationProcessor() {
|
|
2734
|
+
return {
|
|
2735
|
+
stage: "generate-nav",
|
|
2736
|
+
name: "navigation-processor",
|
|
2737
|
+
handler(context) {
|
|
2738
|
+
const pages = context.docs.filter(isDocumentPage);
|
|
2739
|
+
const navtree = generateNavtree(pages);
|
|
2740
|
+
sortNavigationTree(navtree);
|
|
2741
|
+
context.setTopNavigation(navtree);
|
|
2742
|
+
context.setSideNavigation(navtree);
|
|
2743
|
+
}
|
|
2744
|
+
};
|
|
2745
|
+
}
|
|
2746
|
+
|
|
2708
2747
|
const templateUrl = new URL("../templates", import.meta.url);
|
|
2709
2748
|
const templateDirectory = fileURLToPath(templateUrl);
|
|
2710
2749
|
|
|
@@ -2964,9 +3003,17 @@ function createTemplateLoader(folders) {
|
|
|
2964
3003
|
function stripPrettierComments(content) {
|
|
2965
3004
|
return content.replaceAll(/\s*<!-- prettier-ignore -->\s*/gm, "");
|
|
2966
3005
|
}
|
|
2967
|
-
async function render(doc, docs,
|
|
3006
|
+
async function render(doc, docs, options) {
|
|
2968
3007
|
const { fileInfo } = doc;
|
|
2969
|
-
const {
|
|
3008
|
+
const {
|
|
3009
|
+
i18n,
|
|
3010
|
+
outputFolder,
|
|
3011
|
+
cacheFolder,
|
|
3012
|
+
exampleFileMatcher,
|
|
3013
|
+
nav,
|
|
3014
|
+
templateFolders,
|
|
3015
|
+
vendors
|
|
3016
|
+
} = options;
|
|
2970
3017
|
if (!haveOutputFile(fileInfo)) {
|
|
2971
3018
|
return null;
|
|
2972
3019
|
}
|
|
@@ -3034,7 +3081,7 @@ async function render(doc, docs, nav, vendors, options) {
|
|
|
3034
3081
|
setupPath: options.setupPath,
|
|
3035
3082
|
exampleFolders: options.exampleFolders,
|
|
3036
3083
|
tags,
|
|
3037
|
-
fileMatcher
|
|
3084
|
+
fileMatcher: exampleFileMatcher
|
|
3038
3085
|
});
|
|
3039
3086
|
if (example.output) {
|
|
3040
3087
|
const { dir, name } = path__default.parse(example.output);
|
|
@@ -3050,7 +3097,7 @@ async function render(doc, docs, nav, vendors, options) {
|
|
|
3050
3097
|
},
|
|
3051
3098
|
getImportedSource(filename) {
|
|
3052
3099
|
const context = `when importing example from "${fileInfo.fullPath}"`;
|
|
3053
|
-
const match =
|
|
3100
|
+
const match = exampleFileMatcher(filename, context);
|
|
3054
3101
|
return readFileSync(match, "utf8");
|
|
3055
3102
|
},
|
|
3056
3103
|
addResource(dst2, src) {
|
|
@@ -3171,14 +3218,16 @@ function nunjucksProcessor(options) {
|
|
|
3171
3218
|
name: "nunjucks-renderer",
|
|
3172
3219
|
async handler(context) {
|
|
3173
3220
|
function renderDocument(doc) {
|
|
3174
|
-
|
|
3175
|
-
topnav: context.topnav,
|
|
3176
|
-
sidenav: context.sidenav
|
|
3177
|
-
};
|
|
3178
|
-
return render(doc, context.docs, nav, context.vendors, {
|
|
3221
|
+
return render(doc, context.docs, {
|
|
3179
3222
|
...options,
|
|
3223
|
+
exampleFileMatcher: context.exampleFileMatcher,
|
|
3224
|
+
nav: {
|
|
3225
|
+
topnav: context.topnav,
|
|
3226
|
+
sidenav: context.sidenav
|
|
3227
|
+
},
|
|
3180
3228
|
templateBlocks: context.getAllTemplateBlocks(),
|
|
3181
3229
|
templateData: context.getAllTemplateData(),
|
|
3230
|
+
vendors: context.vendors,
|
|
3182
3231
|
addResource(dst, src) {
|
|
3183
3232
|
context.addResource(dst, src);
|
|
3184
3233
|
}
|
|
@@ -3454,12 +3503,28 @@ async function stage(stage2, context, processors, options) {
|
|
|
3454
3503
|
console.log(isLast ? " \u2514\u2500" : " \u251C\u2500", processor.name);
|
|
3455
3504
|
}
|
|
3456
3505
|
try {
|
|
3506
|
+
const prefix = (() => {
|
|
3507
|
+
if (verbose) {
|
|
3508
|
+
return isLast ? " " : " \u2502 ";
|
|
3509
|
+
} else {
|
|
3510
|
+
return "";
|
|
3511
|
+
}
|
|
3512
|
+
})();
|
|
3457
3513
|
const result = await processor.handler({
|
|
3458
3514
|
...context,
|
|
3459
3515
|
log(...args) {
|
|
3460
3516
|
if (verbose) {
|
|
3461
|
-
console.log(
|
|
3517
|
+
console.log(prefix, ...args);
|
|
3462
3518
|
}
|
|
3519
|
+
},
|
|
3520
|
+
error(...args) {
|
|
3521
|
+
process.exitCode = 1;
|
|
3522
|
+
console.error(
|
|
3523
|
+
prefix,
|
|
3524
|
+
...args.map(
|
|
3525
|
+
(it) => typeof it === "string" ? styleText("red", it) : it
|
|
3526
|
+
)
|
|
3527
|
+
);
|
|
3463
3528
|
}
|
|
3464
3529
|
});
|
|
3465
3530
|
if (result) {
|
|
@@ -3472,7 +3537,8 @@ async function stage(stage2, context, processors, options) {
|
|
|
3472
3537
|
}
|
|
3473
3538
|
return generatedFiles;
|
|
3474
3539
|
}
|
|
3475
|
-
function createContext(
|
|
3540
|
+
function createContext(options) {
|
|
3541
|
+
const { outputFolder, exampleFileMatcher, templateLoader } = options;
|
|
3476
3542
|
let docs = [];
|
|
3477
3543
|
let vendors = [];
|
|
3478
3544
|
const resources = [];
|
|
@@ -3511,6 +3577,7 @@ function createContext(outputFolder, templateLoader) {
|
|
|
3511
3577
|
return sidenav;
|
|
3512
3578
|
},
|
|
3513
3579
|
outputFolder,
|
|
3580
|
+
exampleFileMatcher,
|
|
3514
3581
|
addDocument(document) {
|
|
3515
3582
|
docs = [...docs, ...toArray(document)];
|
|
3516
3583
|
},
|
|
@@ -3609,7 +3676,7 @@ class Generator {
|
|
|
3609
3676
|
this.templateFolders = options.templateFolders ?? [];
|
|
3610
3677
|
this.processors = options.processors ?? [];
|
|
3611
3678
|
this.vendor = options.vendor ?? [];
|
|
3612
|
-
this.setupPath = options.setupPath
|
|
3679
|
+
this.setupPath = options.setupPath?.replaceAll("\\", "/") ?? null;
|
|
3613
3680
|
this.scripts = [];
|
|
3614
3681
|
this.styles = [];
|
|
3615
3682
|
this.resources = [];
|
|
@@ -3680,11 +3747,19 @@ class Generator {
|
|
|
3680
3747
|
redirectProcessor(),
|
|
3681
3748
|
...this.processors
|
|
3682
3749
|
];
|
|
3750
|
+
const examplePatterns = this.exampleFolders.map((it) => `${it}/**/*`);
|
|
3751
|
+
const exampleFileMatcher = fileMatcher(examplePatterns);
|
|
3683
3752
|
const templateLoader = createTemplateLoader([]);
|
|
3684
|
-
const context = createContext(
|
|
3753
|
+
const context = createContext({
|
|
3754
|
+
outputFolder: "",
|
|
3755
|
+
exampleFileMatcher,
|
|
3756
|
+
templateLoader
|
|
3757
|
+
});
|
|
3685
3758
|
await stage("generate-docs", context, processors, { verbose: false });
|
|
3686
3759
|
const docs = context.docs.filter(isDocumentPage).filter(haveOutput);
|
|
3687
|
-
const pages = docs.map(
|
|
3760
|
+
const pages = docs.map((doc) => {
|
|
3761
|
+
return manifestPageFromDocument({ exampleFileMatcher }, doc);
|
|
3762
|
+
});
|
|
3688
3763
|
return { pages };
|
|
3689
3764
|
}
|
|
3690
3765
|
async build(sourceFiles) {
|
|
@@ -3730,14 +3805,17 @@ class Generator {
|
|
|
3730
3805
|
exampleFolders,
|
|
3731
3806
|
templateFolders,
|
|
3732
3807
|
setupPath,
|
|
3733
|
-
markdown: markdownOptions ?? {}
|
|
3734
|
-
fileMatcher: fileMatcher(examplePatterns)
|
|
3808
|
+
markdown: markdownOptions ?? {}
|
|
3735
3809
|
}),
|
|
3736
3810
|
...this.processors
|
|
3737
3811
|
];
|
|
3738
3812
|
compileProcessorRuntime(this, import.meta.url, processors);
|
|
3739
3813
|
const templateLoader = createTemplateLoader(templateFolders);
|
|
3740
|
-
const context = createContext(
|
|
3814
|
+
const context = createContext({
|
|
3815
|
+
outputFolder,
|
|
3816
|
+
exampleFileMatcher: fileMatcher(examplePatterns),
|
|
3817
|
+
templateLoader
|
|
3818
|
+
});
|
|
3741
3819
|
const generatedFiles = [
|
|
3742
3820
|
await stage("generate-docs", context, processors),
|
|
3743
3821
|
await stage("generate-nav", context, processors),
|
|
@@ -3883,6 +3961,9 @@ function searchProcessor() {
|
|
|
3883
3961
|
context.addTemplateBlock("toolbar", "search-toolbar", {
|
|
3884
3962
|
filename: "partials/search-toolbar.html"
|
|
3885
3963
|
});
|
|
3964
|
+
context.addTemplateBlock("head", "search-preload", {
|
|
3965
|
+
filename: "partials/search-preload.html"
|
|
3966
|
+
});
|
|
3886
3967
|
context.addTemplateBlock("body:end", "search-dialog", {
|
|
3887
3968
|
filename: "partials/search-dialog.html"
|
|
3888
3969
|
});
|