@forsakringskassan/docs-generator 3.19.0 → 3.19.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-DrDHT9bZ.mjs → create-markdown-renderer-DSov_Gkx.mjs} +4 -4
- package/dist/{create-markdown-renderer-DrDHT9bZ.mjs.map → create-markdown-renderer-DSov_Gkx.mjs.map} +1 -1
- package/dist/{format-code.worker-CFQ372Nb.mjs → format-code.worker-DR9lHLhH.mjs} +2 -2
- package/dist/{format-code.worker-CFQ372Nb.mjs.map → format-code.worker-DR9lHLhH.mjs.map} +1 -1
- package/dist/index.mjs +149 -135
- package/dist/index.mjs.map +1 -1
- package/dist/markdown.mjs +2 -2
- package/dist/tsdoc-metadata.json +1 -1
- package/dist/{vendor-i-8GIz5x.mjs → vendor-CLyw83WG.mjs} +51 -6
- package/dist/{vendor-i-8GIz5x.mjs.map → vendor-CLyw83WG.mjs.map} +1 -1
- package/dist/{worker--TrTGmqL.mjs → worker-DfUDllYf.mjs} +3 -3
- package/dist/worker-DfUDllYf.mjs.map +1 -0
- package/package.json +2 -2
- package/dist/worker--TrTGmqL.mjs.map +0 -1
|
@@ -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-CLyw83WG.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-DR9lHLhH.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"format-code.worker-
|
|
1
|
+
{"version":3,"file":"format-code.worker-DR9lHLhH.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\n/* eslint-disable-next-line unicorn/no-top-level-side-effects -- required for worker to function */\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;AAGA,WAAA,CAAY,UAAU,CAAA;;"}
|
package/dist/index.mjs
CHANGED
|
@@ -3,13 +3,13 @@ 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 { Z as Ze, M as MarkdownItCallable, g as fm, s as strToU8, z as zlibSync, h as strFromU8, d as dedent, i as closest, j as distance, k as isCI, m as moduleImporter, l as cliProgress, t as tinylr, w as watch, n as createInstance, o as fse, p as inter } from './vendor-
|
|
6
|
+
import { Z as Ze, M as MarkdownItCallable, g as fm, s as strToU8, z as zlibSync, h as strFromU8, d as dedent, i as closest, j as distance, k as isCI, m as moduleImporter, l as cliProgress, t as tinylr, w as watch, n as createInstance, o as fse, p as inter } from './vendor-CLyw83WG.mjs';
|
|
7
7
|
import path__default from 'node:path';
|
|
8
8
|
import fs from 'node:fs/promises';
|
|
9
9
|
import crypto from 'node:crypto';
|
|
10
10
|
import path from 'node:path/posix';
|
|
11
11
|
import { exec, execSync } from 'node:child_process';
|
|
12
|
-
import { g as generateId, f as formatCode, p as
|
|
12
|
+
import { g as generateId, f as formatCode, p as parseInfostring, a as getFingerprint, h as hasTag, b as parseImport, d as findTag, e as getOutputFilePath, i as isDocumentPage, j as findDocument, k as getDocumentBody, n as normalizePath, l as htmlencode, c as createMarkdownRenderer } from './create-markdown-renderer-DSov_Gkx.mjs';
|
|
13
13
|
import { DocExcerpt } from '@microsoft/tsdoc';
|
|
14
14
|
import pkg from '../package.json' with { type: "json" };
|
|
15
15
|
import fs__default, { existsSync, readFileSync, copyFileSync } from 'node:fs';
|
|
@@ -640,108 +640,6 @@ function isDocumentPartial(doc) {
|
|
|
640
640
|
return doc.kind === "partial";
|
|
641
641
|
}
|
|
642
642
|
|
|
643
|
-
function getExampleName(filename) {
|
|
644
|
-
return path__default.parse(filename).name;
|
|
645
|
-
}
|
|
646
|
-
|
|
647
|
-
const vueMajor = Number(version.split(".", 2)[0]);
|
|
648
|
-
function vueGenerator() {
|
|
649
|
-
switch (vueMajor) {
|
|
650
|
-
case 2:
|
|
651
|
-
throw new Error(
|
|
652
|
-
"Vue 2 is no longer supported, upgrade to Vue 3 or downgrade docs-generator"
|
|
653
|
-
);
|
|
654
|
-
case 3:
|
|
655
|
-
return generateCode;
|
|
656
|
-
}
|
|
657
|
-
}
|
|
658
|
-
function generateExample(options) {
|
|
659
|
-
const { language, fileMatcher } = options;
|
|
660
|
-
if (language === "import") {
|
|
661
|
-
const parsed = parseImport(options.source);
|
|
662
|
-
const filename = fileMatcher(parsed.filename, "when importing example");
|
|
663
|
-
const language2 = parsed.extension;
|
|
664
|
-
const comments = parsed.comments;
|
|
665
|
-
const content = fs__default.readFileSync(filename, "utf8");
|
|
666
|
-
const example = generateExample({
|
|
667
|
-
...options,
|
|
668
|
-
source: content,
|
|
669
|
-
language: language2,
|
|
670
|
-
filename
|
|
671
|
-
});
|
|
672
|
-
return { ...example, comments };
|
|
673
|
-
}
|
|
674
|
-
switch (language) {
|
|
675
|
-
case "vue":
|
|
676
|
-
return generateVueExample(options);
|
|
677
|
-
case "html":
|
|
678
|
-
return generateStaticExample(options);
|
|
679
|
-
default:
|
|
680
|
-
return generateStaticExample(options);
|
|
681
|
-
}
|
|
682
|
-
}
|
|
683
|
-
function generateVueExample(options) {
|
|
684
|
-
const { filename, source, parent, setupPath, tags } = options;
|
|
685
|
-
const fn = vueGenerator();
|
|
686
|
-
const slug = getExampleName(filename);
|
|
687
|
-
const fingerprint = getFingerprint(source);
|
|
688
|
-
const { markup, sourcecode, output } = fn({
|
|
689
|
-
filename,
|
|
690
|
-
slug,
|
|
691
|
-
fingerprint,
|
|
692
|
-
code: source,
|
|
693
|
-
setupPath
|
|
694
|
-
});
|
|
695
|
-
if (output) {
|
|
696
|
-
return {
|
|
697
|
-
source,
|
|
698
|
-
language: options.language,
|
|
699
|
-
comments: [],
|
|
700
|
-
tags,
|
|
701
|
-
markup,
|
|
702
|
-
output,
|
|
703
|
-
runtime: true,
|
|
704
|
-
task: {
|
|
705
|
-
outputFile: output,
|
|
706
|
-
sourcecode,
|
|
707
|
-
sourceFile: filename,
|
|
708
|
-
parent
|
|
709
|
-
}
|
|
710
|
-
};
|
|
711
|
-
}
|
|
712
|
-
return {
|
|
713
|
-
source: sourcecode,
|
|
714
|
-
language: "plaintext",
|
|
715
|
-
comments: [],
|
|
716
|
-
tags,
|
|
717
|
-
markup,
|
|
718
|
-
output: null,
|
|
719
|
-
runtime: true,
|
|
720
|
-
task: null
|
|
721
|
-
};
|
|
722
|
-
}
|
|
723
|
-
function generateStaticExample(options) {
|
|
724
|
-
const { filename, source, language, tags } = options;
|
|
725
|
-
const slug = getExampleName(filename);
|
|
726
|
-
const fingerprint = getFingerprint(source);
|
|
727
|
-
const asset = `${slug}-${fingerprint}.${language}`;
|
|
728
|
-
const runtimeLanguages = ["html"];
|
|
729
|
-
const runtime = runtimeLanguages.includes(language);
|
|
730
|
-
return {
|
|
731
|
-
source,
|
|
732
|
-
language: options.language,
|
|
733
|
-
comments: [],
|
|
734
|
-
tags,
|
|
735
|
-
markup: source,
|
|
736
|
-
output: runtime ? asset : null,
|
|
737
|
-
runtime,
|
|
738
|
-
task: null
|
|
739
|
-
};
|
|
740
|
-
}
|
|
741
|
-
|
|
742
|
-
const url = new URL("./worker--TrTGmqL.mjs", import.meta.url);
|
|
743
|
-
const filePath = fileURLToPath(url);
|
|
744
|
-
|
|
745
643
|
const md$6 = MarkdownItCallable();
|
|
746
644
|
md$6.renderer.rules.fence = (tokens, idx, _options, env) => {
|
|
747
645
|
const { collected, exampleFileMatcher } = env;
|
|
@@ -929,39 +827,46 @@ ${JSON.stringify(attributes)}
|
|
|
929
827
|
function cmp(a, b) {
|
|
930
828
|
return a[0].localeCompare(b[0]);
|
|
931
829
|
}
|
|
932
|
-
|
|
933
|
-
const
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
830
|
+
function findApiContainer(text, cb) {
|
|
831
|
+
const regex = /^:::\s*api(.*)\n([\s\S]+?):::\n/gm;
|
|
832
|
+
return text.replaceAll(regex, (match, info, rawContent) => {
|
|
833
|
+
const content = rawContent.trim();
|
|
834
|
+
const trimmedInfo = info.trim();
|
|
835
|
+
const tags = trimmedInfo ? trimmedInfo.split(/\s+/) : [];
|
|
836
|
+
return cb({ match, tags, content });
|
|
837
|
+
});
|
|
838
|
+
}
|
|
839
|
+
function onApiContainer(docs, partials, container) {
|
|
840
|
+
const { match, tags, content } = container;
|
|
841
|
+
const result = findDocument(docs, content);
|
|
842
|
+
if (!result.document) {
|
|
843
|
+
return match;
|
|
844
|
+
}
|
|
845
|
+
const { document, kind, reference } = result;
|
|
846
|
+
if (!isDocumentPartial(document)) {
|
|
847
|
+
return match;
|
|
848
|
+
}
|
|
849
|
+
const body = getDocumentBody(document, tags, {
|
|
850
|
+
kind,
|
|
851
|
+
reference
|
|
852
|
+
});
|
|
853
|
+
const fingerprint = getFingerprint(body);
|
|
854
|
+
const id = `partial:${document.format}:${fingerprint}`;
|
|
855
|
+
partials.set(id, {
|
|
856
|
+
id,
|
|
857
|
+
format: document.format,
|
|
858
|
+
body
|
|
859
|
+
});
|
|
860
|
+
return `:::api
|
|
960
861
|
${id}
|
|
961
862
|
:::
|
|
962
863
|
`;
|
|
963
|
-
|
|
964
|
-
|
|
864
|
+
}
|
|
865
|
+
async function extractDocument(doc, docs, partials, options) {
|
|
866
|
+
const { outputFolder } = options;
|
|
867
|
+
const markdown = findApiContainer(doc.body, (container) => {
|
|
868
|
+
return onApiContainer(docs, partials, container);
|
|
869
|
+
});
|
|
965
870
|
const src = doc.fileInfo.fullPath;
|
|
966
871
|
const dst = path__default.join(outputFolder, "files", doc.fileInfo.fullPath);
|
|
967
872
|
const fm2 = await getFrontMatter(src);
|
|
@@ -1089,6 +994,108 @@ function extractMarkdownProcessor(options) {
|
|
|
1089
994
|
};
|
|
1090
995
|
}
|
|
1091
996
|
|
|
997
|
+
function getExampleName(filename) {
|
|
998
|
+
return path__default.parse(filename).name;
|
|
999
|
+
}
|
|
1000
|
+
|
|
1001
|
+
const vueMajor = Number(version.split(".", 2)[0]);
|
|
1002
|
+
function vueGenerator() {
|
|
1003
|
+
switch (vueMajor) {
|
|
1004
|
+
case 2:
|
|
1005
|
+
throw new Error(
|
|
1006
|
+
"Vue 2 is no longer supported, upgrade to Vue 3 or downgrade docs-generator"
|
|
1007
|
+
);
|
|
1008
|
+
case 3:
|
|
1009
|
+
return generateCode;
|
|
1010
|
+
}
|
|
1011
|
+
}
|
|
1012
|
+
function generateExample(options) {
|
|
1013
|
+
const { language, fileMatcher } = options;
|
|
1014
|
+
if (language === "import") {
|
|
1015
|
+
const parsed = parseImport(options.source);
|
|
1016
|
+
const filename = fileMatcher(parsed.filename, "when importing example");
|
|
1017
|
+
const language2 = parsed.extension;
|
|
1018
|
+
const comments = parsed.comments;
|
|
1019
|
+
const content = fs__default.readFileSync(filename, "utf8");
|
|
1020
|
+
const example = generateExample({
|
|
1021
|
+
...options,
|
|
1022
|
+
source: content,
|
|
1023
|
+
language: language2,
|
|
1024
|
+
filename
|
|
1025
|
+
});
|
|
1026
|
+
return { ...example, comments };
|
|
1027
|
+
}
|
|
1028
|
+
switch (language) {
|
|
1029
|
+
case "vue":
|
|
1030
|
+
return generateVueExample(options);
|
|
1031
|
+
case "html":
|
|
1032
|
+
return generateStaticExample(options);
|
|
1033
|
+
default:
|
|
1034
|
+
return generateStaticExample(options);
|
|
1035
|
+
}
|
|
1036
|
+
}
|
|
1037
|
+
function generateVueExample(options) {
|
|
1038
|
+
const { filename, source, parent, setupPath, tags } = options;
|
|
1039
|
+
const fn = vueGenerator();
|
|
1040
|
+
const slug = getExampleName(filename);
|
|
1041
|
+
const fingerprint = getFingerprint(source);
|
|
1042
|
+
const { markup, sourcecode, output } = fn({
|
|
1043
|
+
filename,
|
|
1044
|
+
slug,
|
|
1045
|
+
fingerprint,
|
|
1046
|
+
code: source,
|
|
1047
|
+
setupPath
|
|
1048
|
+
});
|
|
1049
|
+
if (output) {
|
|
1050
|
+
return {
|
|
1051
|
+
source,
|
|
1052
|
+
language: options.language,
|
|
1053
|
+
comments: [],
|
|
1054
|
+
tags,
|
|
1055
|
+
markup,
|
|
1056
|
+
output,
|
|
1057
|
+
runtime: true,
|
|
1058
|
+
task: {
|
|
1059
|
+
outputFile: output,
|
|
1060
|
+
sourcecode,
|
|
1061
|
+
sourceFile: filename,
|
|
1062
|
+
parent
|
|
1063
|
+
}
|
|
1064
|
+
};
|
|
1065
|
+
}
|
|
1066
|
+
return {
|
|
1067
|
+
source: sourcecode,
|
|
1068
|
+
language: "plaintext",
|
|
1069
|
+
comments: [],
|
|
1070
|
+
tags,
|
|
1071
|
+
markup,
|
|
1072
|
+
output: null,
|
|
1073
|
+
runtime: true,
|
|
1074
|
+
task: null
|
|
1075
|
+
};
|
|
1076
|
+
}
|
|
1077
|
+
function generateStaticExample(options) {
|
|
1078
|
+
const { filename, source, language, tags } = options;
|
|
1079
|
+
const slug = getExampleName(filename);
|
|
1080
|
+
const fingerprint = getFingerprint(source);
|
|
1081
|
+
const asset = `${slug}-${fingerprint}.${language}`;
|
|
1082
|
+
const runtimeLanguages = ["html"];
|
|
1083
|
+
const runtime = runtimeLanguages.includes(language);
|
|
1084
|
+
return {
|
|
1085
|
+
source,
|
|
1086
|
+
language: options.language,
|
|
1087
|
+
comments: [],
|
|
1088
|
+
tags,
|
|
1089
|
+
markup: source,
|
|
1090
|
+
output: runtime ? asset : null,
|
|
1091
|
+
runtime,
|
|
1092
|
+
task: null
|
|
1093
|
+
};
|
|
1094
|
+
}
|
|
1095
|
+
|
|
1096
|
+
const url = new URL("./worker-DfUDllYf.mjs", import.meta.url);
|
|
1097
|
+
const filePath = fileURLToPath(url);
|
|
1098
|
+
|
|
1092
1099
|
const md$5 = MarkdownItCallable();
|
|
1093
1100
|
md$5.renderer.rules.fence = (tokens, idx, _options, rawEnv) => {
|
|
1094
1101
|
const { collected } = rawEnv;
|
|
@@ -2138,6 +2145,13 @@ function getComponent(attrs) {
|
|
|
2138
2145
|
}
|
|
2139
2146
|
return toArray$1(attrs.component).map(normalizeComponent);
|
|
2140
2147
|
}
|
|
2148
|
+
function normalizeBody(text) {
|
|
2149
|
+
text = text.replaceAll("\r\n", "\n");
|
|
2150
|
+
if (!text.endsWith("\n")) {
|
|
2151
|
+
text += "\n";
|
|
2152
|
+
}
|
|
2153
|
+
return text;
|
|
2154
|
+
}
|
|
2141
2155
|
function parseFile$2(filePath, basePath, content) {
|
|
2142
2156
|
const relative = basePath ? path__default.relative(basePath, normalizePath(filePath)) : normalizePath(filePath);
|
|
2143
2157
|
const parsed = path__default.parse(relative);
|
|
@@ -2169,7 +2183,7 @@ function parseFile$2(filePath, basePath, content) {
|
|
|
2169
2183
|
},
|
|
2170
2184
|
sortorder: attributes.sortorder ?? Infinity
|
|
2171
2185
|
},
|
|
2172
|
-
body: blocks.body,
|
|
2186
|
+
body: normalizeBody(blocks.body),
|
|
2173
2187
|
outline,
|
|
2174
2188
|
format: "markdown",
|
|
2175
2189
|
tags: [],
|