@forsakringskassan/docs-generator 3.13.0 → 3.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/{create-markdown-renderer-DwLB6VT1.mjs → create-markdown-renderer-BlUpDhJP.mjs} +12 -111
- package/dist/create-markdown-renderer-BlUpDhJP.mjs.map +1 -0
- package/dist/index.d.mts +18 -0
- package/dist/index.mjs +118 -6
- package/dist/index.mjs.map +1 -1
- package/dist/markdown.mjs +1 -4
- package/dist/markdown.mjs.map +1 -1
- package/dist/style/core.css +10 -2
- package/dist/style/index.css +10 -2
- package/package.json +3 -3
- package/dist/create-markdown-renderer-DwLB6VT1.mjs.map +0 -1
package/dist/{create-markdown-renderer-DwLB6VT1.mjs → create-markdown-renderer-BlUpDhJP.mjs}
RENAMED
|
@@ -8,9 +8,6 @@ import path__default from 'node:path';
|
|
|
8
8
|
import crypto from 'node:crypto';
|
|
9
9
|
import 'node:child_process';
|
|
10
10
|
import { fileURLToPath } from 'node:url';
|
|
11
|
-
import fs__default from 'node:fs';
|
|
12
|
-
import { version } from 'vue';
|
|
13
|
-
import { g as generateCode } from './vue3-DbJPWpmQ.mjs';
|
|
14
11
|
|
|
15
12
|
function findDocument(haystack, needle) {
|
|
16
13
|
for (const document of haystack) {
|
|
@@ -78,10 +75,10 @@ function getOutputFilePath(outputFolder, fileInfo) {
|
|
|
78
75
|
return normalizePath(outputFolder, path, outputName);
|
|
79
76
|
}
|
|
80
77
|
|
|
81
|
-
const url
|
|
82
|
-
const filePath
|
|
78
|
+
const url = new URL("./format-code.worker-C_xPgPcX.mjs", import.meta.url);
|
|
79
|
+
const filePath = fileURLToPath(url);
|
|
83
80
|
|
|
84
|
-
const formatCode = createSyncFn(filePath
|
|
81
|
+
const formatCode = createSyncFn(filePath);
|
|
85
82
|
|
|
86
83
|
function hasTag(tags, tag) {
|
|
87
84
|
const match = tags.some((it) => it === tag || it.startsWith(`${tag}=`));
|
|
@@ -129,105 +126,6 @@ function isDocumentPage(doc) {
|
|
|
129
126
|
return doc.kind === "page";
|
|
130
127
|
}
|
|
131
128
|
|
|
132
|
-
function getExampleName(filename) {
|
|
133
|
-
return path__default.parse(filename).name;
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
const vueMajor = Number(version.split(".", 2)[0]);
|
|
137
|
-
function vueGenerator() {
|
|
138
|
-
switch (vueMajor) {
|
|
139
|
-
case 2:
|
|
140
|
-
throw new Error(
|
|
141
|
-
"Vue 2 is no longer supported, upgrade to Vue 3 or downgrade docs-generator"
|
|
142
|
-
);
|
|
143
|
-
case 3:
|
|
144
|
-
return generateCode;
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
function generateExample(options) {
|
|
148
|
-
const { language, fileMatcher } = options;
|
|
149
|
-
if (language === "import") {
|
|
150
|
-
const parsed = parseImport(options.source);
|
|
151
|
-
const filename = fileMatcher(parsed.filename, "when importing example");
|
|
152
|
-
const language2 = parsed.extension;
|
|
153
|
-
const comments = parsed.comments;
|
|
154
|
-
const content = fs__default.readFileSync(filename, "utf8");
|
|
155
|
-
const example = generateExample({
|
|
156
|
-
...options,
|
|
157
|
-
source: content,
|
|
158
|
-
language: language2,
|
|
159
|
-
filename
|
|
160
|
-
});
|
|
161
|
-
return { ...example, comments };
|
|
162
|
-
}
|
|
163
|
-
switch (language) {
|
|
164
|
-
case "vue":
|
|
165
|
-
return generateVueExample(options);
|
|
166
|
-
case "html":
|
|
167
|
-
return generateStaticExample(options);
|
|
168
|
-
default:
|
|
169
|
-
return generateStaticExample(options);
|
|
170
|
-
}
|
|
171
|
-
}
|
|
172
|
-
function generateVueExample(options) {
|
|
173
|
-
const { filename, source, parent, setupPath, tags } = options;
|
|
174
|
-
const fn = vueGenerator();
|
|
175
|
-
const slug = getExampleName(filename);
|
|
176
|
-
const fingerprint = getFingerprint(source);
|
|
177
|
-
const { markup, sourcecode, output } = fn({
|
|
178
|
-
filename,
|
|
179
|
-
slug,
|
|
180
|
-
fingerprint,
|
|
181
|
-
code: source,
|
|
182
|
-
setupPath
|
|
183
|
-
});
|
|
184
|
-
if (output) {
|
|
185
|
-
return {
|
|
186
|
-
source,
|
|
187
|
-
language: options.language,
|
|
188
|
-
comments: [],
|
|
189
|
-
tags,
|
|
190
|
-
markup,
|
|
191
|
-
output,
|
|
192
|
-
runtime: true,
|
|
193
|
-
task: {
|
|
194
|
-
outputFile: output,
|
|
195
|
-
sourcecode,
|
|
196
|
-
sourceFile: filename,
|
|
197
|
-
parent
|
|
198
|
-
}
|
|
199
|
-
};
|
|
200
|
-
}
|
|
201
|
-
return {
|
|
202
|
-
source: sourcecode,
|
|
203
|
-
language: "plaintext",
|
|
204
|
-
comments: [],
|
|
205
|
-
tags,
|
|
206
|
-
markup,
|
|
207
|
-
output: null,
|
|
208
|
-
runtime: true,
|
|
209
|
-
task: null
|
|
210
|
-
};
|
|
211
|
-
}
|
|
212
|
-
function generateStaticExample(options) {
|
|
213
|
-
const { filename, source, language, tags } = options;
|
|
214
|
-
const slug = getExampleName(filename);
|
|
215
|
-
const fingerprint = getFingerprint(source);
|
|
216
|
-
const asset = `${slug}-${fingerprint}.${language}`;
|
|
217
|
-
const runtimeLanguages = ["html"];
|
|
218
|
-
const runtime = runtimeLanguages.includes(language);
|
|
219
|
-
return {
|
|
220
|
-
source,
|
|
221
|
-
language: options.language,
|
|
222
|
-
comments: [],
|
|
223
|
-
tags,
|
|
224
|
-
markup: source,
|
|
225
|
-
output: runtime ? asset : null,
|
|
226
|
-
runtime,
|
|
227
|
-
task: null
|
|
228
|
-
};
|
|
229
|
-
}
|
|
230
|
-
|
|
231
129
|
function normalizeLanguage(lang) {
|
|
232
130
|
switch (lang) {
|
|
233
131
|
case "ts":
|
|
@@ -359,9 +257,6 @@ function transformCode(code, lang) {
|
|
|
359
257
|
return code;
|
|
360
258
|
}
|
|
361
259
|
|
|
362
|
-
const url = new URL("./worker--TrTGmqL.mjs", import.meta.url);
|
|
363
|
-
const filePath = fileURLToPath(url);
|
|
364
|
-
|
|
365
260
|
class SoftError extends Error {
|
|
366
261
|
code;
|
|
367
262
|
details;
|
|
@@ -663,8 +558,11 @@ function codePreview(options) {
|
|
|
663
558
|
const standalonePath = getStandalonePath(example.output);
|
|
664
559
|
const showFullscreen = Boolean(standalonePath) && fullscreen;
|
|
665
560
|
const testIdAttr = testId ? `data-test="${testId}"` : "";
|
|
561
|
+
const hasRenderedPreview = liveExample || !staticCode;
|
|
562
|
+
const hasSolidBackground = hasRenderedPreview && findTag(tags, "background")?.value === "solid";
|
|
563
|
+
const backgroundAttr = hasSolidBackground ? 'data-background="solid"' : "";
|
|
666
564
|
const filteredTags = tags.filter((it) => {
|
|
667
|
-
if (it.startsWith("test-id=") || it.startsWith("name") || it.startsWith("compare")) {
|
|
565
|
+
if (it.startsWith("test-id=") || it.startsWith("name") || it.startsWith("compare") || hasSolidBackground && it === "background=solid") {
|
|
668
566
|
return false;
|
|
669
567
|
}
|
|
670
568
|
return true;
|
|
@@ -679,6 +577,7 @@ function codePreview(options) {
|
|
|
679
577
|
class="code-preview code-preview--borderless"
|
|
680
578
|
${testIdAttr}
|
|
681
579
|
${dataTagsAttr}
|
|
580
|
+
${backgroundAttr}
|
|
682
581
|
data-language="${example.language}"
|
|
683
582
|
>
|
|
684
583
|
${example.markup}
|
|
@@ -712,6 +611,7 @@ function codePreview(options) {
|
|
|
712
611
|
class="code-preview ${modifier}"
|
|
713
612
|
${testIdAttr}
|
|
714
613
|
${dataTagsAttr}
|
|
614
|
+
${backgroundAttr}
|
|
715
615
|
data-language="${example.language}"
|
|
716
616
|
>
|
|
717
617
|
${example.comments.join("\n")}
|
|
@@ -764,6 +664,7 @@ function codePreview(options) {
|
|
|
764
664
|
class="code-preview ${modifier}"
|
|
765
665
|
${testIdAttr}
|
|
766
666
|
${dataTagsAttr}
|
|
667
|
+
${backgroundAttr}
|
|
767
668
|
data-language="${example.language}"
|
|
768
669
|
>
|
|
769
670
|
${example.comments.join("\n")}
|
|
@@ -1237,5 +1138,5 @@ function createMarkdownRenderer(options) {
|
|
|
1237
1138
|
};
|
|
1238
1139
|
}
|
|
1239
1140
|
|
|
1240
|
-
export { SoftError as S, getFingerprint as a,
|
|
1241
|
-
//# sourceMappingURL=create-markdown-renderer-
|
|
1141
|
+
export { SoftError as S, getFingerprint as a, parseInfostring as b, createMarkdownRenderer as c, findTag as d, getOutputFilePath as e, formatCode as f, generateId as g, hasTag as h, isDocumentPage as i, findDocument as j, getDocumentBody as k, htmlencode as l, normalizePath as n, parseImport as p };
|
|
1142
|
+
//# sourceMappingURL=create-markdown-renderer-BlUpDhJP.mjs.map
|