@forsakringskassan/docs-generator 3.11.0 → 3.12.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 { r as runAsWorker, f as format2, a as resolveConfig } from './vendor-DIj4mOXS.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-DJSjofVE.mjs.map
57
+ //# sourceMappingURL=format-code.worker-CoZR-v_f.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"format-code.worker-DJSjofVE.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.d.mts CHANGED
@@ -910,6 +910,12 @@ export declare interface SourceFiles {
910
910
  exclude?: string | string[];
911
911
  basePath?: string;
912
912
  fileReader: FileReader_2;
913
+ /**
914
+ * Only documents for which filter returns true are used.
915
+ *
916
+ * Runs before `transform`.
917
+ */
918
+ filter?(this: void, doc: Document_2): boolean;
913
919
  /**
914
920
  * Transform document before further processing.
915
921
  *
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-DIj4mOXS.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--UwmwaiQ.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);
@@ -1091,15 +1092,16 @@ function motdProcessor(options = {}) {
1091
1092
  filename: "partials/motd-container.njk.html",
1092
1093
  data: useLegacyTemplate ? void 0 : data
1093
1094
  });
1094
- if (useLegacyTemplate) {
1095
- console.warn(
1096
- `[deprecated] using the "partial/version-banner.html" template for motdProcessor is deprecated`
1097
- );
1098
- context.addTemplateBlock(container, "version-banner", {
1099
- filename: "partials/version-banner.html",
1100
- data
1101
- });
1095
+ if (!useLegacyTemplate) {
1096
+ return;
1102
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
+ });
1103
1105
  }
1104
1106
  };
1105
1107
  }
@@ -2222,22 +2224,23 @@ function findTranslations(filename, content) {
2222
2224
  traverse(ast, {
2223
2225
  CallExpression(path) {
2224
2226
  const { node } = path;
2225
- if (isTranslateCall(node)) {
2226
- const [name, ...defaultOrParams] = node.arguments;
2227
- if (name.type !== "StringLiteral") {
2228
- return;
2229
- }
2230
- const textArgument = defaultOrParams.find(isStringLiteral);
2231
- const paramArgument = defaultOrParams.find(isObjectExpression);
2232
- const defaultTranslation = textArgument ? textArgument.value : null;
2233
- const docComment = findDocComment(path, node);
2234
- result.push({
2235
- name: name.value,
2236
- defaultTranslation,
2237
- description: getDescription(docComment),
2238
- parameters: getParameters(paramArgument)
2239
- });
2227
+ if (!isTranslateCall(node)) {
2228
+ return;
2240
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
+ });
2241
2244
  }
2242
2245
  });
2243
2246
  return result;
@@ -2766,7 +2769,7 @@ async function globAll(pattern) {
2766
2769
  return new Set(results.flat());
2767
2770
  }
2768
2771
  async function getDocumentsForSource(context, src, index) {
2769
- const { transform } = src;
2772
+ const { transform, filter = () => true } = src;
2770
2773
  const include = await globAll(src.include);
2771
2774
  const exclude = await globAll(src.exclude);
2772
2775
  const files = Array.from(difference(include, exclude));
@@ -2791,7 +2794,8 @@ async function getDocumentsForSource(context, src, index) {
2791
2794
  }
2792
2795
  return [];
2793
2796
  }
2794
- const docs2 = await src.fileReader(it, src.basePath);
2797
+ const allDocs = await src.fileReader(it, src.basePath);
2798
+ const docs2 = allDocs.filter(filter);
2795
2799
  if (transform) {
2796
2800
  return docs2.map((it2) => transform(it2));
2797
2801
  }