@forsakringskassan/docs-generator 3.10.1 → 3.11.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.
@@ -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-DPuGyhL4.mjs';
5
+ import { r as runAsWorker, f as format2, a as resolveConfig } from './vendor-BesEHnwj.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-BsG38cNK.mjs.map
57
+ //# sourceMappingURL=format-code.worker-CoZR-v_f.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"format-code.worker-BsG38cNK.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;;"}
1
+ {"version":3,"file":"format-code.worker-CoZR-v_f.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,12 +3,12 @@ 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 { t as ts, 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, n as tinylr, w as watch, o as createInstance, p as fse, q as inter } from './vendor-DPuGyhL4.mjs';
6
+ import { t as ts, 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, n as tinylr, w as watch, o as createInstance, p as fse, q as inter } from './vendor-BesEHnwj.mjs';
7
7
  import path__default from 'node:path';
8
8
  import crypto from 'node:crypto';
9
9
  import path from 'node:path/posix';
10
10
  import { exec, execSync } from 'node:child_process';
11
- 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, m as filePath, c as createMarkdownRenderer, o as generateExample } from './create-markdown-renderer-CXtEyRCU.mjs';
11
+ 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, m as filePath, c as createMarkdownRenderer, o as generateExample } from './create-markdown-renderer-C7-7Tads.mjs';
12
12
  import { DocExcerpt } from '@microsoft/tsdoc';
13
13
  import fs from 'node:fs/promises';
14
14
  import util, { promisify, styleText } from 'node:util';
@@ -402,10 +402,11 @@ function getInheritance(item) {
402
402
  for (const { excerpt } of current.extendsTypes) {
403
403
  const name = getNameFromExcerpt(excerpt);
404
404
  const parentInterface = findMemberByName(name, pkg2);
405
- if (parentInterface) {
406
- traverseParents(parentInterface, pkg2);
407
- hierarchy.push(parentInterface);
405
+ if (!parentInterface) {
406
+ continue;
408
407
  }
408
+ traverseParents(parentInterface, pkg2);
409
+ hierarchy.push(parentInterface);
409
410
  }
410
411
  }
411
412
  traverseParents(item, pkg);
@@ -898,18 +899,26 @@ async function writeIndex(options) {
898
899
  `import { frontMatterFileReader, partialFileReader } from "@forsakringskassan/docs-generator";`,
899
900
  ``,
900
901
  `export const basename = import.meta.dirname;`,
901
- `export const sourceFiles = [`,
902
- ` { `,
903
- ` include: path.join(basename, "files/**/*.md"),`,
904
- ` basename,`,
905
- ` fileReader: frontMatterFileReader,`,
906
- ` }`,
907
- ` { `,
908
- ` include: path.join(basename, "partials.json"),`,
909
- ` basename,`,
910
- ` fileReader: partialFileReader,`,
911
- ` }`,
912
- `];`
902
+ `export const exampleFolders = [path.join(basename, "files")];`,
903
+ `export const filesPath = path.join(basename, "files");`,
904
+ `export const partialsPath = [path.join(basename, "partials.json")];`,
905
+ `export const linksPath = [path.join(basename, "links.json")];`,
906
+ ``,
907
+ `export function sourceFiles(src) {`,
908
+ ` return [`,
909
+ ` { `,
910
+ ` include: path.join(basename, "files/**/*.md"),`,
911
+ ` basename,`,
912
+ ` fileReader: frontMatterFileReader,`,
913
+ ` ...src`,
914
+ ` },`,
915
+ ` { `,
916
+ ` include: path.join(basename, "partials.json"),`,
917
+ ` basename,`,
918
+ ` fileReader: partialFileReader,`,
919
+ ` }`,
920
+ ` ];`,
921
+ `}`
913
922
  ];
914
923
  await fs.writeFile(dst, lines.join("\n"), "utf8");
915
924
  }
@@ -920,7 +929,12 @@ async function writeDts(options) {
920
929
  `import { SourceFiles } from "@forsakringskassan/docs-generator";`,
921
930
  ``,
922
931
  `export declare const basename: string;`,
923
- `export declare const sourceFiles: SourceFiles[];`
932
+ `export declare const exampleFolders: string[];`,
933
+ `export declare const filesPath: string;`,
934
+ `export declare const partialsPath: string;`,
935
+ `export declare const linksPath: string;`,
936
+ ``,
937
+ `export declare function sourceFiles(src: Partial<SourceFiles>): SourceFiles[];`
924
938
  ];
925
939
  await fs.writeFile(dst, lines.join("\n"), "utf8");
926
940
  }
@@ -1078,15 +1092,16 @@ function motdProcessor(options = {}) {
1078
1092
  filename: "partials/motd-container.njk.html",
1079
1093
  data: useLegacyTemplate ? void 0 : data
1080
1094
  });
1081
- if (useLegacyTemplate) {
1082
- console.warn(
1083
- `[deprecated] using the "partial/version-banner.html" template for motdProcessor is deprecated`
1084
- );
1085
- context.addTemplateBlock(container, "version-banner", {
1086
- filename: "partials/version-banner.html",
1087
- data
1088
- });
1095
+ if (!useLegacyTemplate) {
1096
+ return;
1089
1097
  }
1098
+ console.warn(
1099
+ `[deprecated] using the "partial/version-banner.html" template for motdProcessor is deprecated`
1100
+ );
1101
+ context.addTemplateBlock(container, "version-banner", {
1102
+ filename: "partials/version-banner.html",
1103
+ data
1104
+ });
1090
1105
  }
1091
1106
  };
1092
1107
  }
@@ -2209,22 +2224,23 @@ function findTranslations(filename, content) {
2209
2224
  traverse(ast, {
2210
2225
  CallExpression(path) {
2211
2226
  const { node } = path;
2212
- if (isTranslateCall(node)) {
2213
- const [name, ...defaultOrParams] = node.arguments;
2214
- if (name.type !== "StringLiteral") {
2215
- return;
2216
- }
2217
- const textArgument = defaultOrParams.find(isStringLiteral);
2218
- const paramArgument = defaultOrParams.find(isObjectExpression);
2219
- const defaultTranslation = textArgument ? textArgument.value : null;
2220
- const docComment = findDocComment(path, node);
2221
- result.push({
2222
- name: name.value,
2223
- defaultTranslation,
2224
- description: getDescription(docComment),
2225
- parameters: getParameters(paramArgument)
2226
- });
2227
+ if (!isTranslateCall(node)) {
2228
+ return;
2227
2229
  }
2230
+ const [name, ...defaultOrParams] = node.arguments;
2231
+ if (name.type !== "StringLiteral") {
2232
+ return;
2233
+ }
2234
+ const textArgument = defaultOrParams.find(isStringLiteral);
2235
+ const paramArgument = defaultOrParams.find(isObjectExpression);
2236
+ const defaultTranslation = textArgument ? textArgument.value : null;
2237
+ const docComment = findDocComment(path, node);
2238
+ result.push({
2239
+ name: name.value,
2240
+ defaultTranslation,
2241
+ description: getDescription(docComment),
2242
+ parameters: getParameters(paramArgument)
2243
+ });
2228
2244
  }
2229
2245
  });
2230
2246
  return result;