@forsakringskassan/docs-generator 3.14.0 → 3.15.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.
package/dist/index.d.mts CHANGED
@@ -184,6 +184,28 @@ export declare interface DocumentPartialReference {
184
184
  reference: string;
185
185
  }
186
186
 
187
+ /**
188
+ * Type representing the exported docs module when extracting markdown
189
+ * documents.
190
+ *
191
+ * @privateRemarks
192
+ *
193
+ * Changes to this interface must be kept in sync with the output generated in
194
+ * `writeDts()`.
195
+ *
196
+ * @public
197
+ * @since %version%
198
+ */
199
+ export declare interface ExtractedDocsModule {
200
+ readonly generatorVersion: string;
201
+ readonly basePath: string;
202
+ readonly exampleFolders: string[];
203
+ readonly filesPath: string;
204
+ readonly partialsPath: string;
205
+ readonly linksPath: string;
206
+ sourceFiles(src: Partial<SourceFiles>): SourceFiles[];
207
+ }
208
+
187
209
  /**
188
210
  * Options for `extractExamplesProcessor`.
189
211
  *
package/dist/index.mjs CHANGED
@@ -11,6 +11,7 @@ import { exec, execSync } from 'node:child_process';
11
11
  import { g as generateId, f as formatCode, p as parseImport, a as getFingerprint, b as parseInfostring, h as hasTag, d as findTag, e as getOutputFilePath, i as isDocumentPage, j as findDocument, k as getDocumentBody, n as normalizePath, l as htmlencode, c as createMarkdownRenderer } from './create-markdown-renderer-BlUpDhJP.mjs';
12
12
  import { DocExcerpt } from '@microsoft/tsdoc';
13
13
  import fs from 'node:fs/promises';
14
+ import pkg from '../package.json' with { type: "json" };
14
15
  import fs__default, { existsSync, readFileSync, copyFileSync } from 'node:fs';
15
16
  import { version } from 'vue';
16
17
  import { g as generateCode } from './vue3-DbJPWpmQ.mjs';
@@ -90,10 +91,11 @@ function memoize(callback) {
90
91
  };
91
92
  }
92
93
 
93
- function fileMatcher(patterns) {
94
+ function fileMatcher(patterns, options) {
95
+ const { ignore } = options;
94
96
  const fileList = ts(patterns, {
95
97
  posix: true,
96
- ignore: "**/node_modules/**"
98
+ ignore
97
99
  });
98
100
  return memoize((filename, context) => {
99
101
  const matches = fileList.filter((file) => {
@@ -1010,23 +1012,24 @@ async function writeIndex(options) {
1010
1012
  `import path from "node:path";`,
1011
1013
  `import { frontMatterFileReader, partialFileReader } from "@forsakringskassan/docs-generator";`,
1012
1014
  ``,
1013
- `export const basename = import.meta.dirname;`,
1014
- `export const exampleFolders = [path.join(basename, "files")];`,
1015
- `export const filesPath = path.join(basename, "files");`,
1016
- `export const partialsPath = [path.join(basename, "partials.json")];`,
1017
- `export const linksPath = [path.join(basename, "links.json")];`,
1015
+ `export const generatorVersion = "${pkg.version}";`,
1016
+ `export const basePath = import.meta.dirname;`,
1017
+ `export const exampleFolders = [path.join(basePath, "files")];`,
1018
+ `export const filesPath = path.join(basePath, "files");`,
1019
+ `export const partialsPath = [path.join(basePath, "partials.json")];`,
1020
+ `export const linksPath = [path.join(basePath, "links.json")];`,
1018
1021
  ``,
1019
1022
  `export function sourceFiles(src) {`,
1020
1023
  ` return [`,
1021
1024
  ` { `,
1022
- ` include: path.join(basename, "files/**/*.md"),`,
1023
- ` basename,`,
1025
+ ` include: path.join(filesPath, "**/*.md"),`,
1026
+ ` basePath: filesPath,`,
1024
1027
  ` fileReader: frontMatterFileReader,`,
1025
1028
  ` ...src`,
1026
1029
  ` },`,
1027
1030
  ` { `,
1028
- ` include: path.join(basename, "partials.json"),`,
1029
- ` basename,`,
1031
+ ` include: path.join(basePath, "partials.json"),`,
1032
+ ` basePath,`,
1030
1033
  ` fileReader: partialFileReader,`,
1031
1034
  ` }`,
1032
1035
  ` ];`,
@@ -1040,7 +1043,8 @@ async function writeDts(options) {
1040
1043
  const lines = [
1041
1044
  `import { SourceFiles } from "@forsakringskassan/docs-generator";`,
1042
1045
  ``,
1043
- `export declare const basename: string;`,
1046
+ `export declare const generatorVersion: string;`,
1047
+ `export declare const basePath: string;`,
1044
1048
  `export declare const exampleFolders: string[];`,
1045
1049
  `export declare const filesPath: string;`,
1046
1050
  `export declare const partialsPath: string;`,
@@ -1513,7 +1517,9 @@ function sourceUrlProcessor(...args) {
1513
1517
  componentFileExtension = "vue"
1514
1518
  } = options;
1515
1519
  const repository = getRepositoryUrl(pkg) ?? "";
1516
- const matcher = fileMatcher(sourceFiles);
1520
+ const matcher = fileMatcher(sourceFiles, {
1521
+ ignore: ["**/node_modules/**"]
1522
+ });
1517
1523
  return {
1518
1524
  after: "generate-docs",
1519
1525
  name: "source-url-processor",
@@ -2869,6 +2875,12 @@ async function vueFileReader(filePath) {
2869
2875
  return [vueApi, vueTranslation];
2870
2876
  }
2871
2877
 
2878
+ async function glob(pattern) {
2879
+ const cwd = process.cwd();
2880
+ const iterator = fs.glob(pattern, { withFileTypes: true });
2881
+ const ents = await Array.fromAsync(iterator);
2882
+ return ents.filter((st) => st.isFile()).map((st) => path__default.relative(cwd, path__default.join(st.parentPath, st.name)));
2883
+ }
2872
2884
  async function globAll(pattern) {
2873
2885
  if (!pattern) {
2874
2886
  return /* @__PURE__ */ new Set();
@@ -2876,9 +2888,7 @@ async function globAll(pattern) {
2876
2888
  if (!Array.isArray(pattern)) {
2877
2889
  pattern = [pattern];
2878
2890
  }
2879
- const results = await Promise.all(
2880
- pattern.map((it) => Ze(it, { nodir: true }))
2881
- );
2891
+ const results = await Promise.all(pattern.map(glob));
2882
2892
  return new Set(results.flat());
2883
2893
  }
2884
2894
  async function getDocumentsForSource(context, src, index) {
@@ -4372,7 +4382,7 @@ class Generator {
4372
4382
  ...this.processors
4373
4383
  ];
4374
4384
  const examplePatterns = this.exampleFolders.map((it) => `${it}/**/*`);
4375
- const exampleFileMatcher = fileMatcher(examplePatterns);
4385
+ const exampleFileMatcher = fileMatcher(examplePatterns, { ignore: [] });
4376
4386
  const templateLoader = createTemplateLoader([]);
4377
4387
  const context = createContext({
4378
4388
  outputFolder: "",
@@ -4445,7 +4455,7 @@ class Generator {
4445
4455
  const templateLoader = createTemplateLoader(templateFolders);
4446
4456
  const context = createContext({
4447
4457
  outputFolder,
4448
- exampleFileMatcher: fileMatcher(examplePatterns),
4458
+ exampleFileMatcher: fileMatcher(examplePatterns, { ignore: [] }),
4449
4459
  templateLoader
4450
4460
  });
4451
4461
  const generatedFiles = [