@forsakringskassan/docs-generator 2.17.1 → 2.19.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.
@@ -3,10 +3,10 @@
3
3
  var path$1 = require('node:path');
4
4
  var esbuild = require('esbuild');
5
5
  var vue = require('vue');
6
- var vue3 = require('./vue3-B1yNeGmz.js');
6
+ var vue3 = require('./vue3-BhdC7RZQ.js');
7
7
  var path = require('node:path/posix');
8
8
  require('@vue/compiler-sfc');
9
- require('./vendor-BeoVq2Sv.js');
9
+ require('./vendor-BHA4LIog.js');
10
10
  require('node:url');
11
11
  require('fs');
12
12
  require('node:fs');
@@ -56,7 +56,7 @@ function virtualEntryPlugin(entries) {
56
56
  namespace: pluginName
57
57
  };
58
58
  } else {
59
- return undefined;
59
+ return void 0;
60
60
  }
61
61
  });
62
62
  build.onLoad({ filter: /.*/, namespace: pluginName }, (args) => {
@@ -140,3 +140,4 @@ async function run() {
140
140
  await compileExample(batch);
141
141
  }
142
142
  run();
143
+ //# sourceMappingURL=compile-example.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"compile-example.js","sources":["../src/esbuild/virtual-entry-plugin.ts","../src/compile-example.ts"],"sourcesContent":["import path from \"node:path/posix\";\nimport { type Plugin } from \"esbuild\";\n\nconst pluginName = \"virtual-entry\";\n\nexport type VirtualEntries = Record<string, string>;\n\nexport function virtualEntryPlugin(entries: VirtualEntries): Plugin {\n function haveEntry(key: string): boolean {\n return Boolean(entries[key]);\n }\n\n function getEntry(key: string): string {\n return entries[key];\n }\n\n return {\n name: pluginName,\n setup(build) {\n build.onResolve({ filter: /.*/ }, (args) => {\n if (args.kind === \"entry-point\" && haveEntry(args.path)) {\n return {\n path: args.path,\n namespace: pluginName,\n };\n } else {\n return undefined;\n }\n });\n build.onLoad({ filter: /.*/, namespace: pluginName }, (args) => {\n const contents = getEntry(args.path);\n return {\n contents,\n loader: \"ts\",\n resolveDir: path.dirname(args.path),\n };\n });\n },\n };\n}\n","import path from \"node:path\";\nimport { type Plugin, build as esbuild } from \"esbuild\";\nimport { version } from \"vue\";\nimport { vuePlugin as Vue3Plugin } from \"plugin-vue3\";\nimport { virtualEntryPlugin } from \"./esbuild\";\nimport { type ExampleBatch } from \"./examples\";\n\nconst vueMajor = parseInt(version.split(\".\", 2)[0], 10) as 2 | 3;\nconst tsconfig = path.join(__dirname, \"../tsconfig-examples.json\");\n\nfunction stripExtension(filename: string): string {\n return filename.replace(\".js\", \"\");\n}\n\nfunction VuePlugin(): Plugin {\n switch (vueMajor) {\n case 2:\n throw new Error(\n \"Vue 2 is no longer supported, upgrade to Vue 3 or downgrade docs-generator\",\n );\n case 3:\n return Vue3Plugin();\n }\n}\n\nasync function compileExample(batch: ExampleBatch): Promise<void> {\n const { outputFolder: outdir, external, tasks } = batch;\n const entryPoints = tasks.map((it) => {\n return { in: it.sourceFile, out: stripExtension(it.outputFile) };\n });\n const virtualEntries = tasks.map((it): [key: string, value: string] => {\n return [`./${it.sourceFile}`, it.sourcecode];\n });\n const iconLib = process.env.DOCS_ICON_LIB ?? \"@fkui/icon-lib-default\";\n try {\n await esbuild({\n entryPoints,\n outdir,\n bundle: true,\n format: \"iife\",\n platform: \"browser\",\n external,\n tsconfig,\n define: {\n \"process.env.NODE_ENV\": JSON.stringify(\"development\"),\n \"process.env.DOCS_ICON_LIB\": JSON.stringify(iconLib),\n },\n plugins: [\n virtualEntryPlugin(Object.fromEntries(virtualEntries)),\n VuePlugin(),\n ],\n });\n } catch (err) {\n /* eslint-disable-next-line no-console -- expected to log */\n console.error(err);\n process.exitCode = 1;\n }\n}\n\nasync function readBatchData(): Promise<ExampleBatch> {\n const { stdin } = process;\n return new Promise((resolve, reject) => {\n const chunks: Buffer[] = [];\n stdin.on(\"data\", (chunk) => {\n chunks.push(chunk);\n });\n stdin.on(\"end\", () => {\n const content = Buffer.concat(chunks).toString(\"utf-8\");\n const parsed = JSON.parse(content);\n resolve(parsed);\n });\n stdin.on(\"error\", (error) => {\n reject(error);\n });\n });\n}\n\nasync function run(): Promise<void> {\n const batch = await readBatchData();\n await compileExample(batch);\n}\n\nrun();\n"],"names":["version","path","Vue3Plugin","esbuild"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGA,MAAM,UAAa,GAAA,eAAA;AAIZ,SAAS,mBAAmB,OAAiC,EAAA;AAChE,EAAA,SAAS,UAAU,GAAsB,EAAA;AACrC,IAAO,OAAA,OAAA,CAAQ,OAAQ,CAAA,GAAG,CAAC,CAAA;AAAA;AAG/B,EAAA,SAAS,SAAS,GAAqB,EAAA;AACnC,IAAA,OAAO,QAAQ,GAAG,CAAA;AAAA;AAGtB,EAAO,OAAA;AAAA,IACH,IAAM,EAAA,UAAA;AAAA,IACN,MAAM,KAAO,EAAA;AACT,MAAA,KAAA,CAAM,UAAU,EAAE,MAAA,EAAQ,IAAK,EAAA,EAAG,CAAC,IAAS,KAAA;AACxC,QAAA,IAAI,KAAK,IAAS,KAAA,aAAA,IAAiB,SAAU,CAAA,IAAA,CAAK,IAAI,CAAG,EAAA;AACrD,UAAO,OAAA;AAAA,YACH,MAAM,IAAK,CAAA,IAAA;AAAA,YACX,SAAW,EAAA;AAAA,WACf;AAAA,SACG,MAAA;AACH,UAAO,OAAA,MAAA;AAAA;AACX,OACH,CAAA;AACD,MAAM,KAAA,CAAA,MAAA,CAAO,EAAE,MAAQ,EAAA,IAAA,EAAM,WAAW,UAAW,EAAA,EAAG,CAAC,IAAS,KAAA;AAC5D,QAAM,MAAA,QAAA,GAAW,QAAS,CAAA,IAAA,CAAK,IAAI,CAAA;AACnC,QAAO,OAAA;AAAA,UACH,QAAA;AAAA,UACA,MAAQ,EAAA,IAAA;AAAA,UACR,UAAY,EAAA,IAAA,CAAK,OAAQ,CAAA,IAAA,CAAK,IAAI;AAAA,SACtC;AAAA,OACH,CAAA;AAAA;AACL,GACJ;AACJ;;AChCA,MAAM,QAAA,GAAW,SAASA,WAAQ,CAAA,KAAA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 @@
1
1
  'use strict';
2
2
 
3
- var vendor = require('./vendor-BeoVq2Sv.js');
3
+ var vendor = require('./vendor-BHA4LIog.js');
4
4
  var path = require('node:path/posix');
5
5
  var path$1 = require('node:path');
6
6
  require('crypto');
@@ -8,7 +8,11 @@ var crypto = require('node:crypto');
8
8
  require('node:child_process');
9
9
  var fs = require('node:fs');
10
10
  var vue = require('vue');
11
- var vue3 = require('./vue3-B1yNeGmz.js');
11
+ var vue3 = require('./vue3-BhdC7RZQ.js');
12
+
13
+ function isDocumentPage(doc) {
14
+ return doc.kind === "page";
15
+ }
12
16
 
13
17
  function findDocument(haystack, needle) {
14
18
  const match = haystack.find((it) => {
@@ -131,6 +135,105 @@ function getExampleName(filename) {
131
135
  return path$1.parse(filename).name;
132
136
  }
133
137
 
138
+ const vueMajor = parseInt(vue.version.split(".", 2)[0], 10);
139
+ function vueGenerator() {
140
+ switch (vueMajor) {
141
+ case 2:
142
+ throw new Error(
143
+ "Vue 2 is no longer supported, upgrade to Vue 3 or downgrade docs-generator"
144
+ );
145
+ case 3:
146
+ return vue3.generateCode;
147
+ }
148
+ }
149
+ function generateExample(options) {
150
+ const { language } = options;
151
+ if (language === "import") {
152
+ const parsed = parseImport(options.source);
153
+ const filename = getExampleImport(
154
+ options.exampleFolders,
155
+ parsed.filename
156
+ );
157
+ const language2 = parsed.extension;
158
+ const comments = parsed.comments;
159
+ const content = fs.readFileSync(filename, "utf-8");
160
+ const example = generateExample({
161
+ ...options,
162
+ source: content,
163
+ language: language2,
164
+ filename
165
+ });
166
+ return { ...example, comments };
167
+ }
168
+ switch (language) {
169
+ case "vue":
170
+ return generateVueExample(options);
171
+ case "html":
172
+ return generateStaticExample(options);
173
+ default:
174
+ return generateStaticExample(options);
175
+ }
176
+ }
177
+ function generateVueExample(options) {
178
+ const { filename, source, parent, setupPath, tags } = options;
179
+ const fn = vueGenerator();
180
+ const slug = getExampleName(filename);
181
+ const fingerprint = getFingerprint(source);
182
+ const { markup, sourcecode, output } = fn({
183
+ filename,
184
+ slug,
185
+ fingerprint,
186
+ code: source,
187
+ setupPath
188
+ });
189
+ if (output) {
190
+ return {
191
+ source,
192
+ language: options.language,
193
+ comments: [],
194
+ tags,
195
+ markup,
196
+ output,
197
+ runtime: true,
198
+ task: {
199
+ outputFile: output,
200
+ sourcecode,
201
+ sourceFile: filename,
202
+ parent
203
+ }
204
+ };
205
+ } else {
206
+ return {
207
+ source: sourcecode,
208
+ language: "plaintext",
209
+ comments: [],
210
+ tags,
211
+ markup,
212
+ output: null,
213
+ runtime: true,
214
+ task: null
215
+ };
216
+ }
217
+ }
218
+ function generateStaticExample(options) {
219
+ const { filename, source, language, tags } = options;
220
+ const slug = getExampleName(filename);
221
+ const fingerprint = getFingerprint(source);
222
+ const asset = `${slug}-${fingerprint}.${language}`;
223
+ const runtimeLanguages = ["html"];
224
+ const runtime = runtimeLanguages.includes(language);
225
+ return {
226
+ source,
227
+ language: options.language,
228
+ comments: [],
229
+ tags,
230
+ markup: source,
231
+ output: runtime ? asset : null,
232
+ runtime,
233
+ task: null
234
+ };
235
+ }
236
+
134
237
  function normalizeLanguage(lang) {
135
238
  switch (lang) {
136
239
  case "ts":
@@ -142,6 +245,14 @@ function normalizeLanguage(lang) {
142
245
  }
143
246
  }
144
247
 
248
+ function parseInfostring(infostring) {
249
+ const [rawLanguage, ...rawTags] = infostring.trim().split(/\s+/);
250
+ return {
251
+ language: normalizeLanguage(rawLanguage),
252
+ tags: rawTags
253
+ };
254
+ }
255
+
145
256
  function removeLinesInline(lines, { begin, end }) {
146
257
  for (let i = begin; i <= end; i++) {
147
258
  lines[i] = "";
@@ -238,114 +349,6 @@ function transformCode(code, lang) {
238
349
  return code;
239
350
  }
240
351
 
241
- const vueMajor = parseInt(vue.version.split(".", 2)[0], 10);
242
- function vueGenerator() {
243
- switch (vueMajor) {
244
- case 2:
245
- throw new Error(
246
- "Vue 2 is no longer supported, upgrade to Vue 3 or downgrade docs-generator"
247
- );
248
- case 3:
249
- return vue3.generateCode;
250
- }
251
- }
252
- function generateExample(options) {
253
- const { language } = options;
254
- if (language === "import") {
255
- const parsed = parseImport(options.source);
256
- const filename = getExampleImport(
257
- options.exampleFolders,
258
- parsed.filename
259
- );
260
- const language2 = parsed.extension;
261
- const comments = parsed.comments;
262
- const content = fs.readFileSync(filename, "utf-8");
263
- const source = transformCode(content, language2);
264
- const example = generateExample({
265
- ...options,
266
- source,
267
- language: language2,
268
- filename
269
- });
270
- return { ...example, comments };
271
- }
272
- switch (language) {
273
- case "vue":
274
- return generateVueExample(options);
275
- case "html":
276
- return generateStaticExample(options);
277
- default:
278
- return generateStaticExample(options);
279
- }
280
- }
281
- function generateVueExample(options) {
282
- const { filename, source, parent, setupPath, tags } = options;
283
- const fn = vueGenerator();
284
- const slug = getExampleName(filename);
285
- const fingerprint = getFingerprint(source);
286
- const { markup, sourcecode, output } = fn({
287
- filename,
288
- slug,
289
- fingerprint,
290
- code: source,
291
- setupPath
292
- });
293
- if (output) {
294
- return {
295
- source,
296
- language: options.language,
297
- comments: [],
298
- tags,
299
- markup,
300
- output,
301
- runtime: true,
302
- task: {
303
- outputFile: output,
304
- sourcecode,
305
- sourceFile: filename,
306
- parent
307
- }
308
- };
309
- } else {
310
- return {
311
- source: sourcecode,
312
- language: "plaintext",
313
- comments: [],
314
- tags,
315
- markup,
316
- output: null,
317
- runtime: true,
318
- task: null
319
- };
320
- }
321
- }
322
- function generateStaticExample(options) {
323
- const { filename, source, language, tags } = options;
324
- const slug = getExampleName(filename);
325
- const fingerprint = getFingerprint(source);
326
- const asset = `${slug}-${fingerprint}.${language}`;
327
- const runtimeLanguages = ["html"];
328
- const runtime = runtimeLanguages.includes(language);
329
- return {
330
- source,
331
- language: options.language,
332
- comments: [],
333
- tags,
334
- markup: source,
335
- output: runtime ? asset : null,
336
- runtime,
337
- task: null
338
- };
339
- }
340
-
341
- function parseInfostring(infostring) {
342
- const [rawLanguage, ...rawTags] = infostring.trim().split(/\s+/);
343
- return {
344
- language: normalizeLanguage(rawLanguage),
345
- tags: rawTags
346
- };
347
- }
348
-
349
352
  class SoftError extends Error {
350
353
  code;
351
354
  details;
@@ -447,6 +450,17 @@ const linkTag = {
447
450
  }
448
451
  );
449
452
  }
453
+ if (!isDocumentPage(linked)) {
454
+ throw new SoftError(
455
+ "ELINKPARTIAL",
456
+ `Cannot link to partial document "${key}"`,
457
+ {
458
+ key,
459
+ hash,
460
+ title: explicitTitle
461
+ }
462
+ );
463
+ }
450
464
  const url = getRelativeUrl(doc, linked);
451
465
  const title = getLinkTitle(linked, key, explicitTitle);
452
466
  return `<a href="${url}${hash ?? ""}">${title}</a>`;
@@ -538,13 +552,18 @@ function getStandalonePath(output) {
538
552
  function getSource(content, language, tags, { namedExamples }) {
539
553
  const compare = findTag(tags, "compare");
540
554
  if (compare && compare.value !== null) {
555
+ const { value: context } = findTag(tags, "context") ?? {};
541
556
  const reference = namedExamples.get(compare.value);
542
557
  if (!reference) {
543
558
  throw new Error(
544
559
  `Failed to find referenced example "${compare.value}"`
545
560
  );
546
561
  }
547
- const diff = vendor.createTwoFilesPatch("a", "b", reference.content, content).split("\n").slice(3).filter((it) => !it.startsWith("@@")).join("\n");
562
+ const a = transformCode(reference.content, reference.language);
563
+ const b = transformCode(content, language);
564
+ const diff = vendor.createTwoFilesPatch("a", "b", a, b, "", "", {
565
+ context: context ? parseInt(context, 10) : 3
566
+ }).split("\n").slice(4).join("\n");
548
567
  return {
549
568
  source: diff,
550
569
  language: "diff"
@@ -555,7 +574,7 @@ function getSource(content, language, tags, { namedExamples }) {
555
574
  function codePreview(options) {
556
575
  const { generateExample } = options;
557
576
  return (md) => {
558
- md.renderer.rules.fence = fence.bind(undefined, md);
577
+ md.renderer.rules.fence = fence.bind(void 0, md);
559
578
  };
560
579
  function fence(_md, tokens, idx, _options, env) {
561
580
  const { fileInfo } = env;
@@ -566,7 +585,8 @@ function codePreview(options) {
566
585
  env.namedExamples.set(name, {
567
586
  name,
568
587
  tags: rawTags,
569
- content: rawContent
588
+ content: rawContent,
589
+ language: rawLanguage
570
590
  });
571
591
  }
572
592
  if (hasTag(rawTags, "hidden")) {
@@ -599,7 +619,7 @@ function codePreview(options) {
599
619
  const highlightedCode = replaceAtLink(
600
620
  highlight({ source: transformedCode, language: example.language })
601
621
  );
602
- const testId = findTestId(tags);
622
+ const testId = findTestId(tags) ?? findTag(tags, "name")?.value;
603
623
  const liveExample = tags.includes("live-example");
604
624
  const staticCode = example.runtime === false || tags.includes("static");
605
625
  const noMarkup = tags.includes("nomarkup");
@@ -788,9 +808,11 @@ function altContainer(context) {
788
808
  return (tokens, index) => {
789
809
  const token = tokens[index];
790
810
  const needle = token.info;
811
+ const tags = token.info.trim().split(/\s+/);
791
812
  const doc = findDocument(docs, needle);
792
813
  if (doc && doc.format === "markdown") {
793
- return md.render(doc.body, env);
814
+ const body = typeof doc.body === "string" ? doc.body : doc.body(tags);
815
+ return md.render(body, env);
794
816
  }
795
817
  return md.render(token.content, env);
796
818
  };
@@ -801,6 +823,7 @@ function apiContainer(context) {
801
823
  return (tokens, index) => {
802
824
  const token = tokens[index];
803
825
  const needle = token.content.trim();
826
+ const tags = token.info.trim().split(/\s+/);
804
827
  const doc = findDocument(docs, needle);
805
828
  if (!doc) {
806
829
  return handleSoftError(
@@ -811,7 +834,9 @@ function apiContainer(context) {
811
834
  )
812
835
  );
813
836
  }
814
- if (included.has(doc.id)) {
837
+ const key = [doc.id, ...tags].join("|");
838
+ const loop = included.get(doc.id);
839
+ if (loop && loop !== context.doc.id) {
815
840
  return handleSoftError(
816
841
  new SoftError(
817
842
  "EINCLUDERECURSION",
@@ -819,15 +844,16 @@ function apiContainer(context) {
819
844
  )
820
845
  );
821
846
  }
822
- included.add(doc.id);
847
+ included.set(key, context.doc.id);
848
+ const body = typeof doc.body === "string" ? doc.body : doc.body(tags);
823
849
  if (doc.format === "html") {
824
- return doc.body.replace(
850
+ return body.replace(
825
851
  /* replace `<next-heading-level>` and `</next-heading-level>` with actual h-tags */
826
852
  /(?<=<\/?)next-heading-level/g,
827
853
  `h${String(env.currentHeading + 1)}`
828
854
  );
829
855
  }
830
- const content = md.render(doc.body, env);
856
+ const content = md.render(body, env);
831
857
  return (
832
858
  /* HTML */
833
859
  ` <div>${content}</div> `
@@ -982,11 +1008,14 @@ function containerParser(md, options) {
982
1008
  md.renderer.rules[`doc_${kind}`] = fn;
983
1009
  }
984
1010
  }
985
- function containerRenderer(docs, env, included, handleSoftError, options) {
1011
+ function containerRenderer(doc, docs, env, included, handleSoftError, options) {
986
1012
  return function(md) {
987
1013
  const context = {
988
1014
  md,
989
1015
  env,
1016
+ get doc() {
1017
+ return doc();
1018
+ },
990
1019
  docs,
991
1020
  included,
992
1021
  handleSoftError
@@ -1043,7 +1072,16 @@ function createMarkdownRenderer(options) {
1043
1072
  currentHeading: 1,
1044
1073
  namedExamples: /* @__PURE__ */ new Map()
1045
1074
  };
1046
- const included = /* @__PURE__ */ new Set();
1075
+ let currentDoc = null;
1076
+ const getCurrentDocument = () => {
1077
+ if (!currentDoc) {
1078
+ throw new Error(
1079
+ "Internal error: getting current document before rendering has started"
1080
+ );
1081
+ }
1082
+ return currentDoc;
1083
+ };
1084
+ const included = /* @__PURE__ */ new Map();
1047
1085
  const md = vendor.MarkdownIt({
1048
1086
  html: true
1049
1087
  });
@@ -1060,16 +1098,24 @@ function createMarkdownRenderer(options) {
1060
1098
  })
1061
1099
  );
1062
1100
  md.use(
1063
- containerRenderer(docs, env, included, options.handleSoftError, {
1064
- messagebox: { title: {}, ...options.messagebox }
1065
- })
1101
+ containerRenderer(
1102
+ getCurrentDocument,
1103
+ docs,
1104
+ env,
1105
+ included,
1106
+ options.handleSoftError,
1107
+ {
1108
+ messagebox: { title: {}, ...options.messagebox }
1109
+ }
1110
+ )
1066
1111
  );
1067
1112
  md.use(table());
1068
1113
  md.use(codeInline());
1069
1114
  return {
1070
1115
  render(doc, content) {
1116
+ currentDoc = doc;
1071
1117
  included.clear();
1072
- included.add(doc.id);
1118
+ included.set(doc.id, doc.id);
1073
1119
  env.fileInfo = doc.fileInfo;
1074
1120
  env.ids = /* @__PURE__ */ new Set();
1075
1121
  const html = md.render(content, env);
@@ -1093,5 +1139,7 @@ exports.getFingerprint = getFingerprint;
1093
1139
  exports.getOutputFilePath = getOutputFilePath;
1094
1140
  exports.hasTag = hasTag;
1095
1141
  exports.htmlencode = htmlencode;
1142
+ exports.isDocumentPage = isDocumentPage;
1096
1143
  exports.normalizePath = normalizePath;
1097
1144
  exports.parseInfostring = parseInfostring;
1145
+ //# sourceMappingURL=create-markdown-renderer-CbE5KJoX.js.map