@forsakringskassan/docs-generator 3.21.1 → 3.22.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-DBujHFR5.mjs';
5
+ import { r as runAsWorker, f as format2, a as resolveConfig } from './vendor-D1q9wBug.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-BsMUHGd2.mjs.map
57
+ //# sourceMappingURL=format-code.worker-Ce20Jr32.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"format-code.worker-BsMUHGd2.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-Ce20Jr32.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
@@ -217,7 +217,7 @@ export declare interface ExtractedDocsModule {
217
217
  readonly filesPath: string;
218
218
  readonly partialsPath: string;
219
219
  readonly linksPath: string;
220
- sourceFiles(src?: Partial<SourceFiles>): SourceFiles[];
220
+ sourceFiles(this: void, src?: Partial<SourceFiles>): SourceFiles[];
221
221
  }
222
222
 
223
223
  /**
@@ -353,13 +353,17 @@ declare class Generator_2 {
353
353
  private sourceFiles;
354
354
  private markdownOptions;
355
355
  /**
356
- * @deprecated Pass in `import.meta.url` as first argument instead.
356
+ * @deprecated Pass in `import.meta.dirname` as first argument instead.
357
357
  */
358
358
  constructor(options: GeneratorOptions);
359
359
  /**
360
360
  * Create a new Generator instance.
361
+ *
362
+ * @param workingDirectory - Working directory, typically `import.meta.dirname`,
363
+ * or a file URL whose directory is used.
364
+ * @param options - Generator options.
361
365
  */
362
- constructor(importMetaUrl: string | URL, options: GeneratorOptions);
366
+ constructor(workingDirectory: string | URL, options: GeneratorOptions);
363
367
  compileScript(name: string, src: string | URL, options?: Partial<CompileOptions>, buildOptions?: {
364
368
  format?: "iife" | "cjs" | "esm";
365
369
  define?: Record<string, string>;
package/dist/index.mjs CHANGED
@@ -3,19 +3,19 @@ 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 { 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, t as tinylr, w as watch, n as createInstance, o as fse, p as inter } from './vendor-DBujHFR5.mjs';
6
+ import { 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, t as tinylr, w as watch, n as createInstance, o as fse, p as inter } from './vendor-D1q9wBug.mjs';
7
7
  import path__default from 'node:path';
8
8
  import fs from 'node:fs/promises';
9
9
  import crypto from 'node:crypto';
10
10
  import path from 'node:path/posix';
11
11
  import { exec, execSync } from 'node:child_process';
12
- 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, c as createMarkdownRenderer } from './create-markdown-renderer-CX0kOizk.mjs';
12
+ import { g as generateId, n as normalizePath, 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, l as htmlencode, c as createMarkdownRenderer } from './create-markdown-renderer-Bdz-A22S.mjs';
13
+ import { fileURLToPath } from 'node:url';
13
14
  import { DocExcerpt } from '@microsoft/tsdoc';
14
15
  import pkg from '../package.json' with { type: "json" };
15
16
  import fs__default, { existsSync, readFileSync, copyFileSync } from 'node:fs';
16
17
  import { version } from 'vue';
17
- import { g as generateCode } from './vue3-DbJPWpmQ.mjs';
18
- import { fileURLToPath } from 'node:url';
18
+ import { g as generateCode } from './vue3-B2fm2G4T.mjs';
19
19
  import util, { promisify, styleText } from 'node:util';
20
20
  import { codeFrameColumns } from '@babel/code-frame';
21
21
  import { parse as parse$1 } from '@babel/parser';
@@ -23,7 +23,7 @@ import traverseModule from '@babel/traverse';
23
23
  import { parse, compileScript as compileScript$1, compileTemplate } from 'vue/compiler-sfc';
24
24
  import { parse as parse$2 } from 'vue-docgen-api';
25
25
  import { compileAsync, NodePackageImporter } from 'sass';
26
- import { t as tsconfigPath } from './tsconfig-path-bG7G_cK8.mjs';
26
+ import { t as tsconfigPath } from './tsconfig-path-ZL5FzYwU.mjs';
27
27
  import esbuild$1, { build } from 'esbuild';
28
28
  import { Worker } from 'node:worker_threads';
29
29
  import nunjucks from 'nunjucks';
@@ -261,6 +261,20 @@ function naturalJoin(values, conjunction = "or") {
261
261
  }
262
262
  }
263
263
 
264
+ function normalizeDirectory(path) {
265
+ const normalized = normalizePath(path, ".");
266
+ return normalized === "/" ? normalized : normalized.replace(/\/$/, "");
267
+ }
268
+ function normalizeWorkingDirectory(value) {
269
+ if (!value) {
270
+ return normalizeDirectory(process.cwd());
271
+ }
272
+ if (typeof value === "string") {
273
+ return /^file:/i.test(value) ? normalizeWorkingDirectory(new URL(value)) : normalizeDirectory(value);
274
+ }
275
+ return normalizeDirectory(fileURLToPath(new URL(".", value)));
276
+ }
277
+
264
278
  function quote(text) {
265
279
  return String(text).replaceAll('"', "&quot;");
266
280
  }
@@ -1115,7 +1129,7 @@ function generateStaticExample(options) {
1115
1129
  };
1116
1130
  }
1117
1131
 
1118
- const url = new URL("./worker-DfUDllYf.mjs", import.meta.url);
1132
+ const url = new URL("./worker-CNOMn6wO.mjs", import.meta.url);
1119
1133
  const filePath = fileURLToPath(url);
1120
1134
 
1121
1135
  const md$5 = MarkdownItCallable();
@@ -1602,12 +1616,12 @@ function getParentKey(name) {
1602
1616
  }
1603
1617
  function generateNavtree(docs) {
1604
1618
  const section = {};
1605
- function createSection(key, title, sortorder, { visible } = {}) {
1619
+ function createSection(key, title, sortorder, { visible = true } = {}) {
1606
1620
  const existing = section[key];
1607
1621
  if (existing) {
1608
1622
  existing.title = title;
1609
1623
  existing.sortorder = sortorder;
1610
- existing.visible = visible ?? true;
1624
+ existing.visible = visible;
1611
1625
  } else {
1612
1626
  const node = {
1613
1627
  key,
@@ -1615,7 +1629,7 @@ function generateNavtree(docs) {
1615
1629
  path: "",
1616
1630
  sortorder,
1617
1631
  children: [],
1618
- visible: visible ?? true
1632
+ visible
1619
1633
  };
1620
1634
  section[key] = node;
1621
1635
  if (key !== ".") {
@@ -2214,7 +2228,6 @@ function parseFile$2(filePath, basePath, content) {
2214
2228
  path: ["", "."].includes(urlpath) ? "." : `./${normalizePath(urlpath)}`,
2215
2229
  name: filename,
2216
2230
  fullPath: normalizePath(filePath),
2217
- /* eslint-disable-next-line unicorn/prefer-logical-operator-over-ternary -- false positive? */
2218
2231
  outputName: include ? `${filename}.html` : false
2219
2232
  }
2220
2233
  };
@@ -4279,14 +4292,6 @@ function createContext(options) {
4279
4292
  }
4280
4293
  };
4281
4294
  }
4282
- function getWorkingDir(value) {
4283
- if (value) {
4284
- const url = typeof value === "string" ? new URL(value) : value;
4285
- const normalized = normalizePath(fileURLToPath(url));
4286
- return path__default.posix.dirname(normalized);
4287
- }
4288
- return normalizePath(process.cwd());
4289
- }
4290
4295
  class Generator {
4291
4296
  cwd;
4292
4297
  site;
@@ -4305,11 +4310,13 @@ class Generator {
4305
4310
  sourceFiles;
4306
4311
  markdownOptions;
4307
4312
  constructor(...args) {
4308
- const cwd = getWorkingDir(args.length === 2 ? args[0] : null);
4313
+ const cwd = normalizeWorkingDirectory(
4314
+ args.length === 2 ? args[0] : null
4315
+ );
4309
4316
  const options = args.length === 2 ? args[1] : args[0];
4310
4317
  if (args.length === 1) {
4311
4318
  console.error(
4312
- "[docs-generator] deprecated: not passing import.meta.url as the first argument is deprecated, assuming `process.cwd()`."
4319
+ "[docs-generator] deprecated: not passing import.meta.dirname as the first argument is deprecated, assuming `process.cwd()`."
4313
4320
  );
4314
4321
  }
4315
4322
  if (options.site === void 0) {