@forsakringskassan/docs-generator 2.41.1 → 2.43.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.
@@ -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 { c as createSyncFn, d as dedent, H as HighlightJS, b as createTwoFilesPatch, M as MarkdownIt, e as deflist_plugin } from './vendor-DX88DJvo.mjs';
5
+ import { c as createSyncFn, d as dedent, H as HighlightJS, b as createTwoFilesPatch, M as MarkdownIt, e as deflist_plugin } from './vendor-BImorfXU.mjs';
6
6
  import path from 'node:path/posix';
7
7
  import path__default from 'node:path';
8
8
  import crypto from 'node:crypto';
@@ -12,24 +12,19 @@ import fs__default from 'node:fs';
12
12
  import { version } from 'vue';
13
13
  import { g as generateCode } from './vue3-fRI2JWNs.mjs';
14
14
 
15
- function isDocumentPage(doc) {
16
- return doc.kind === "page";
17
- }
18
-
19
15
  function findDocument(haystack, needle) {
20
- const match = haystack.find((it) => {
21
- if (it.id === needle) {
22
- return true;
16
+ for (const document of haystack) {
17
+ if (document.id === needle) {
18
+ return { document, kind: "id", reference: needle };
23
19
  }
24
- if (it.name === needle) {
25
- return true;
20
+ if (document.name === needle) {
21
+ return { document, kind: "name", reference: needle };
26
22
  }
27
- if (it.alias.includes(needle)) {
28
- return true;
23
+ if (document.alias.includes(needle)) {
24
+ return { document, kind: "alias", reference: needle };
29
25
  }
30
- return false;
31
- });
32
- return match ?? null;
26
+ }
27
+ return { document: null, kind: null, reference: null };
33
28
  }
34
29
 
35
30
  function findTag(tags, tag) {
@@ -89,10 +84,10 @@ function getOutputFilePath(outputFolder, fileInfo) {
89
84
  return normalizePath(outputFolder, path, outputName);
90
85
  }
91
86
 
92
- const url$1 = new URL("./format-code.worker-CsOAnpUF.mjs", import.meta.url);
87
+ const url$1 = new URL("./format-code.worker-D7IOA5jE.mjs", import.meta.url);
93
88
  const filePath$1 = fileURLToPath(url$1);
94
89
 
95
- createSyncFn(filePath$1);
90
+ const formatCode = createSyncFn(filePath$1);
96
91
 
97
92
  function hasTag(tags, tag) {
98
93
  const match = tags.find((it) => it === tag || it.startsWith(`${tag}=`));
@@ -132,6 +127,14 @@ function parseImport(raw) {
132
127
  };
133
128
  }
134
129
 
130
+ function getDocumentBody(document, tags, reference) {
131
+ return typeof document.body === "string" ? document.body : document.body(tags, reference);
132
+ }
133
+
134
+ function isDocumentPage(doc) {
135
+ return doc.kind === "page";
136
+ }
137
+
135
138
  function getExampleName(filename) {
136
139
  return path__default.parse(filename).name;
137
140
  }
@@ -271,13 +274,17 @@ function cutSnippets(code) {
271
274
  ` : it);
272
275
  const directive = (
273
276
  /* eslint-disable-next-line sonarjs/regex-complexity -- not to bad for a regexp */
274
- /\/\* +--- +cut (?<js>above|below|begin|end) +--- +\*\/|<!---? +cut (?<html>above|below|begin|end) +---?>/
277
+ /\/\* +--- +cut (?<jsBlock>above|below|begin|end) +--- +\*\/|\/\/ +--- +cut (?<jsLine>above|below|begin|end) +---|<!---? +cut (?<html>above|below|begin|end) +---?>/
275
278
  );
276
279
  let buffer = -1;
277
280
  for (const [index, line] of lines.entries()) {
278
281
  const match = directive.exec(line);
279
- const { js, html } = match?.groups ?? { js: null, html: null };
280
- const instruction = js ?? html;
282
+ const { jsBlock, jsLine, html } = match?.groups ?? {
283
+ jsBlock: null,
284
+ jsLine: null,
285
+ html: null
286
+ };
287
+ const instruction = jsBlock ?? jsLine ?? html;
281
288
  if (!instruction) {
282
289
  continue;
283
290
  }
@@ -426,7 +433,7 @@ const linkTag = {
426
433
  if (key.startsWith("http://") || key.startsWith("https://")) {
427
434
  return `<a href="${key}${hash ?? ""}">${explicitTitle ?? key}</a>`;
428
435
  }
429
- const linked = findDocument(docs, key);
436
+ const { document: linked } = findDocument(docs, key);
430
437
  if (!linked) {
431
438
  throw new SoftError(
432
439
  "ELINKTARGET",
@@ -835,9 +842,13 @@ function altContainer(context) {
835
842
  const token = tokens[index];
836
843
  const needle = token.info;
837
844
  const tags = token.info.trim().split(/\s+/);
838
- const doc = findDocument(docs, needle);
839
- if (doc?.format === "markdown") {
840
- const body = typeof doc.body === "string" ? doc.body : doc.body(tags);
845
+ const result = findDocument(docs, needle);
846
+ if (!result.document) {
847
+ return md.render(token.content, env);
848
+ }
849
+ const { document, kind, reference } = result;
850
+ if (result.document.format === "markdown") {
851
+ const body = getDocumentBody(document, tags, { kind, reference });
841
852
  return md.render(body, env);
842
853
  }
843
854
  return md.render(token.content, env);
@@ -850,8 +861,8 @@ function apiContainer(context) {
850
861
  const token = tokens[index];
851
862
  const needle = token.content.trim();
852
863
  const tags = token.info.trim().split(/\s+/);
853
- const doc = findDocument(docs, needle);
854
- if (!doc) {
864
+ const result = findDocument(docs, needle);
865
+ if (!result.document) {
855
866
  return handleSoftError(
856
867
  new SoftError(
857
868
  "EINCLUDETARGET",
@@ -860,19 +871,20 @@ function apiContainer(context) {
860
871
  )
861
872
  );
862
873
  }
863
- const key = [doc.id, ...tags].join("|");
864
- const loop = included.get(doc.id);
874
+ const { document, kind, reference } = result;
875
+ const key = [document.id, ...tags].join("|");
876
+ const loop = included.get(document.id);
865
877
  if (loop && loop !== context.doc.id) {
866
878
  return handleSoftError(
867
879
  new SoftError(
868
880
  "EINCLUDERECURSION",
869
- `Recursion detected when including document "${doc.id}"`
881
+ `Recursion detected when including document "${document.id}"`
870
882
  )
871
883
  );
872
884
  }
873
885
  included.set(key, context.doc.id);
874
- const body = typeof doc.body === "string" ? doc.body : doc.body(tags);
875
- if (doc.format === "html") {
886
+ const body = getDocumentBody(document, tags, { kind, reference });
887
+ if (document.format === "html") {
876
888
  const { currentHeading } = env;
877
889
  const nextHeadingLevel = currentHeading + 1;
878
890
  return body.replaceAll(
@@ -1211,5 +1223,5 @@ function createMarkdownRenderer(options) {
1211
1223
  };
1212
1224
  }
1213
1225
 
1214
- export { SoftError as S, getFingerprint as a, getOutputFilePath as b, createMarkdownRenderer as c, htmlencode as d, filePath as e, findTag as f, generateId as g, hasTag as h, isDocumentPage as i, generateExample as j, normalizePath as n, parseInfostring as p };
1215
- //# sourceMappingURL=create-markdown-renderer-Dr2VfIYy.mjs.map
1226
+ export { SoftError as S, getFingerprint as a, findTag as b, createMarkdownRenderer as c, getOutputFilePath as d, htmlencode as e, formatCode as f, generateId as g, hasTag as h, isDocumentPage as i, filePath as j, generateExample as k, normalizePath as n, parseInfostring as p };
1227
+ //# sourceMappingURL=create-markdown-renderer-CO5Te-tH.mjs.map