@forsakringskassan/docs-generator 2.42.0 → 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-BoRn-ubH.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-E71lNJrD.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
  }
@@ -430,7 +433,7 @@ const linkTag = {
430
433
  if (key.startsWith("http://") || key.startsWith("https://")) {
431
434
  return `<a href="${key}${hash ?? ""}">${explicitTitle ?? key}</a>`;
432
435
  }
433
- const linked = findDocument(docs, key);
436
+ const { document: linked } = findDocument(docs, key);
434
437
  if (!linked) {
435
438
  throw new SoftError(
436
439
  "ELINKTARGET",
@@ -839,9 +842,13 @@ function altContainer(context) {
839
842
  const token = tokens[index];
840
843
  const needle = token.info;
841
844
  const tags = token.info.trim().split(/\s+/);
842
- const doc = findDocument(docs, needle);
843
- if (doc?.format === "markdown") {
844
- 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 });
845
852
  return md.render(body, env);
846
853
  }
847
854
  return md.render(token.content, env);
@@ -854,8 +861,8 @@ function apiContainer(context) {
854
861
  const token = tokens[index];
855
862
  const needle = token.content.trim();
856
863
  const tags = token.info.trim().split(/\s+/);
857
- const doc = findDocument(docs, needle);
858
- if (!doc) {
864
+ const result = findDocument(docs, needle);
865
+ if (!result.document) {
859
866
  return handleSoftError(
860
867
  new SoftError(
861
868
  "EINCLUDETARGET",
@@ -864,19 +871,20 @@ function apiContainer(context) {
864
871
  )
865
872
  );
866
873
  }
867
- const key = [doc.id, ...tags].join("|");
868
- 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);
869
877
  if (loop && loop !== context.doc.id) {
870
878
  return handleSoftError(
871
879
  new SoftError(
872
880
  "EINCLUDERECURSION",
873
- `Recursion detected when including document "${doc.id}"`
881
+ `Recursion detected when including document "${document.id}"`
874
882
  )
875
883
  );
876
884
  }
877
885
  included.set(key, context.doc.id);
878
- const body = typeof doc.body === "string" ? doc.body : doc.body(tags);
879
- if (doc.format === "html") {
886
+ const body = getDocumentBody(document, tags, { kind, reference });
887
+ if (document.format === "html") {
880
888
  const { currentHeading } = env;
881
889
  const nextHeadingLevel = currentHeading + 1;
882
890
  return body.replaceAll(
@@ -1215,5 +1223,5 @@ function createMarkdownRenderer(options) {
1215
1223
  };
1216
1224
  }
1217
1225
 
1218
- 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 };
1219
- //# sourceMappingURL=create-markdown-renderer-DX0B9T-x.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