@forsakringskassan/docs-generator 3.11.1 → 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.
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
@@ -2769,7 +2769,7 @@ async function globAll(pattern) {
2769
2769
  return new Set(results.flat());
2770
2770
  }
2771
2771
  async function getDocumentsForSource(context, src, index) {
2772
- const { transform } = src;
2772
+ const { transform, filter = () => true } = src;
2773
2773
  const include = await globAll(src.include);
2774
2774
  const exclude = await globAll(src.exclude);
2775
2775
  const files = Array.from(difference(include, exclude));
@@ -2794,7 +2794,8 @@ async function getDocumentsForSource(context, src, index) {
2794
2794
  }
2795
2795
  return [];
2796
2796
  }
2797
- const docs2 = await src.fileReader(it, src.basePath);
2797
+ const allDocs = await src.fileReader(it, src.basePath);
2798
+ const docs2 = allDocs.filter(filter);
2798
2799
  if (transform) {
2799
2800
  return docs2.map((it2) => transform(it2));
2800
2801
  }