@forsakringskassan/docs-generator 2.35.5 → 2.35.7

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
@@ -156,7 +156,19 @@ export declare interface DocumentPartial {
156
156
  * @public
157
157
  */
158
158
  export declare interface ExtractExamplesOptions extends ProcessorOptions {
159
+ /**
160
+ * Folder to write examples to. The output folder would typically be git
161
+ * ignored except for configuration files such as `tsconfig.json.`
162
+ */
159
163
  outputFolder: string;
164
+ /**
165
+ * Array of languages to extract.
166
+ *
167
+ * - `"javascript"`
168
+ * - `"typescript"`
169
+ * - `"css"`
170
+ * - `"scss"`
171
+ */
160
172
  languages?: string[];
161
173
  }
162
174
 
@@ -558,6 +570,9 @@ export declare interface ProcessorHandler {
558
570
  before?: ProcessorStage;
559
571
  stage?: ProcessorStage;
560
572
  after?: ProcessorStage;
573
+ /**
574
+ * Name of this processor. Only used for logging purposes.
575
+ */
561
576
  name: string;
562
577
  enabled?: boolean;
563
578
  /** List of runtime client scripts required by this processor */
package/dist/index.mjs CHANGED
@@ -4,9 +4,9 @@ const require = $createRequire(import.meta.url);
4
4
 
5
5
  import fs from 'node:fs/promises';
6
6
  import path from 'node:path/posix';
7
- import { g as globSync, m as minimatch, M as MarkdownIt, d as dedent, b as closest, e as distance, f as fm, i as isCI, h as glob, j as moduleImporter, k as cliProgress, t as tinylr, w as watch, l as createInstance, n as fse, o as inter } from './vendor-Q6b0E6UP.mjs';
8
- import { g as generateId, p as parseInfostring, i as isDocumentPage, n as normalizePath, a as getFingerprint, h as hasTag, f as findTag, b as getOutputFilePath, d as htmlencode, e as exampleWorkerUrl, c as createMarkdownRenderer, j as generateExample } from './create-markdown-renderer-Bx9oXbtZ.mjs';
9
- import sp__default from 'node:path';
7
+ import { g as globSync, m as minimatch, M as MarkdownIt, d as dedent, h as closest, i as distance, j as fm, k as isCI, l as glob, n as moduleImporter, o as cliProgress, t as tinylr, w as watch, p as createInstance, q as fse, s as inter } from './vendor-Ct1QNfWX.mjs';
8
+ import { g as generateId, p as parseInfostring, i as isDocumentPage, n as normalizePath, a as getFingerprint, h as hasTag, f as findTag, b as getOutputFilePath, d as htmlencode, e as exampleWorkerUrl, c as createMarkdownRenderer, j as generateExample } from './create-markdown-renderer-Dq8YIKgp.mjs';
9
+ import path__default from 'node:path';
10
10
  import require$$1 from 'crypto';
11
11
  import 'node:crypto';
12
12
  import { exec, execSync } from 'node:child_process';
@@ -27,12 +27,12 @@ import 'fs';
27
27
  import 'node:events';
28
28
  import 'node:stream';
29
29
  import 'node:string_decoder';
30
+ import 'node:module';
30
31
  import 'constants';
31
32
  import 'stream';
32
33
  import 'util';
33
34
  import 'assert';
34
35
  import 'path';
35
- import 'node:module';
36
36
  import 'readline';
37
37
  import 'events';
38
38
  import 'node:os';
@@ -45,6 +45,10 @@ import 'tls';
45
45
  import 'tty';
46
46
  import 'os';
47
47
  import 'querystring';
48
+ import 'module';
49
+ import 'fs/promises';
50
+ import 'process';
51
+ import 'v8';
48
52
  import 'vue';
49
53
  import './vue3-DtTC1eal.mjs';
50
54
 
@@ -1009,7 +1013,7 @@ function toArray$1(value) {
1009
1013
  return Array.isArray(value) ? value : [value];
1010
1014
  }
1011
1015
  function isIndexPage(parsed) {
1012
- const folder = sp__default.basename(parsed.dir);
1016
+ const folder = path__default.basename(parsed.dir);
1013
1017
  if (parsed.name === folder) {
1014
1018
  return true;
1015
1019
  }
@@ -1079,8 +1083,8 @@ function getComponent(attrs) {
1079
1083
  return toArray$1(attrs.component).map(normalizeComponent);
1080
1084
  }
1081
1085
  function parseFile$1(filePath, basePath, content) {
1082
- const relative = basePath ? sp__default.relative(basePath, normalizePath(filePath)) : normalizePath(filePath);
1083
- const parsed = sp__default.parse(relative);
1086
+ const relative = basePath ? path__default.relative(basePath, normalizePath(filePath)) : normalizePath(filePath);
1087
+ const parsed = path__default.parse(relative);
1084
1088
  const blocks = fm(content);
1085
1089
  const attributes = blocks.attributes;
1086
1090
  const isIndex = isIndexPage(parsed);
@@ -1777,7 +1781,7 @@ async function translateAPI(filePath) {
1777
1781
 
1778
1782
  function parseAPI(filePath, api) {
1779
1783
  const relative = normalizePath(filePath);
1780
- const parsedPath = sp__default.parse(relative);
1784
+ const parsedPath = path__default.parse(relative);
1781
1785
  const componentName = parsedPath.name;
1782
1786
  let html = "";
1783
1787
  if (api.models.length) {
@@ -1806,7 +1810,7 @@ function parseAPI(filePath, api) {
1806
1810
  }
1807
1811
  async function parseTranslation(slug, filePath) {
1808
1812
  const relative = normalizePath(filePath);
1809
- const parsedPath = sp__default.parse(relative);
1813
+ const parsedPath = path__default.parse(relative);
1810
1814
  const componentName = parsedPath.name;
1811
1815
  const content = await fs.readFile(filePath, "utf-8");
1812
1816
  return {
@@ -1881,8 +1885,8 @@ function parseFile(filePath, basePath, content) {
1881
1885
  if (!title) {
1882
1886
  throw new Error(`No title property set in "${filePath}"`);
1883
1887
  }
1884
- const relative = basePath ? sp__default.relative(basePath, normalizePath(filePath)) : normalizePath(filePath);
1885
- const parsed = sp__default.parse(relative);
1888
+ const relative = basePath ? path__default.relative(basePath, normalizePath(filePath)) : normalizePath(filePath);
1889
+ const parsed = path__default.parse(relative);
1886
1890
  const filename = parsed.name.toLowerCase();
1887
1891
  const name = parsed.name;
1888
1892
  const urlpath = parsed.dir;
@@ -1923,7 +1927,7 @@ async function compileSassString(dst, style) {
1923
1927
  style: "expanded",
1924
1928
  importers: [new NodePackageImporter(), moduleImporter]
1925
1929
  });
1926
- await fs.mkdir(sp__default.dirname(dst), { recursive: true });
1930
+ await fs.mkdir(path__default.dirname(dst), { recursive: true });
1927
1931
  await fs.writeFile(dst, result.css, "utf-8");
1928
1932
  }
1929
1933
 
@@ -2016,7 +2020,7 @@ async function compileScript(options) {
2016
2020
  const iconLib = process.env.DOCS_ICON_LIB ?? "@fkui/icon-lib-default";
2017
2021
  try {
2018
2022
  const entryPoints = [src instanceof URL ? fileURLToPath(src) : src];
2019
- const outfile = sp__default.join("temp", `asset-${name}.js`);
2023
+ const outfile = path__default.join("temp", `asset-${name}.js`);
2020
2024
  const external = [...assets, ...vendor.map(toExternalVendor)];
2021
2025
  const format = buildOptions.format ?? "esm";
2022
2026
  await esbuild({
@@ -2037,8 +2041,8 @@ async function compileScript(options) {
2037
2041
  const fingerprint = getFingerprint(content);
2038
2042
  const integrity = getIntegrity(content);
2039
2043
  const filename = `${name}-${fingerprint}.js`;
2040
- const dst = sp__default.join(assetFolder, filename);
2041
- await fs$1.mkdir(sp__default.dirname(dst), { recursive: true });
2044
+ const dst = path__default.join(assetFolder, filename);
2045
+ await fs$1.mkdir(path__default.dirname(dst), { recursive: true });
2042
2046
  await fs$1.rename(outfile, dst);
2043
2047
  const stat = await fs$1.stat(dst);
2044
2048
  return {
@@ -2138,7 +2142,7 @@ function compileProcessorRuntime(generator, distDir, processors) {
2138
2142
  const assetName = [
2139
2143
  "processors",
2140
2144
  processor.name.replace(/-processor/, ""),
2141
- entry.name ?? sp__default.parse(entry.src).name
2145
+ entry.name ?? path__default.parse(entry.src).name
2142
2146
  ].join("/");
2143
2147
  const name = processorRuntimeName(processor, entry);
2144
2148
  const bundled = new URL(`${name}.mjs`, distDir);
@@ -2204,7 +2208,7 @@ function pathFromDoc({ fileInfo }) {
2204
2208
  return [fileInfo.path.replace(/\\/g, "/"), true];
2205
2209
  } else {
2206
2210
  return [
2207
- `./${sp__default.join(fileInfo.path, fileInfo.name).replace(/\\/g, "/")}`,
2211
+ `./${path__default.join(fileInfo.path, fileInfo.name).replace(/\\/g, "/")}`,
2208
2212
  false
2209
2213
  ];
2210
2214
  }
@@ -2439,7 +2443,7 @@ function findTemplate(folders, from, src, format) {
2439
2443
  folders = [...folders, templateDirectory];
2440
2444
  const template = `${layout}.template.${format}`;
2441
2445
  const searchPaths = folders.map((it) => {
2442
- return sp__default.join(it, template);
2446
+ return path__default.join(it, template);
2443
2447
  });
2444
2448
  const found = searchPaths.find((it) => fs__default.existsSync(it));
2445
2449
  if (!found) {
@@ -2506,7 +2510,7 @@ Make sure the name is correct and the template file exists in one of the listed
2506
2510
  }
2507
2511
  findTemplateFile(name) {
2508
2512
  const { folders } = this;
2509
- const searchPaths = folders.map((it) => sp__default.join(it, name));
2513
+ const searchPaths = folders.map((it) => path__default.join(it, name));
2510
2514
  return searchPaths.find((it) => existsSync(it));
2511
2515
  }
2512
2516
  }
@@ -2577,8 +2581,8 @@ function findSidenav(doc, tree) {
2577
2581
  }
2578
2582
  function cache(cacheFolder, outputFolder) {
2579
2583
  return (it) => {
2580
- const cacheFile = sp__default.join(cacheFolder, it.outputFile);
2581
- const outputFile = sp__default.join(outputFolder, it.outputFile);
2584
+ const cacheFile = path__default.join(cacheFolder, it.outputFile);
2585
+ const outputFile = path__default.join(outputFolder, it.outputFile);
2582
2586
  if (existsSync(cacheFile)) {
2583
2587
  copyFileSync(cacheFile, outputFile);
2584
2588
  return false;
@@ -2596,8 +2600,8 @@ async function compileExamples(options) {
2596
2600
  ...assets.map((it) => it.name),
2597
2601
  ...vendors.map((it) => it.package)
2598
2602
  ];
2599
- const cacheFolder = sp__default.posix.join(options.cacheFolder, fileInfo.path);
2600
- const outputFolder = sp__default.posix.join(options.outputFolder, fileInfo.path);
2603
+ const cacheFolder = path__default.posix.join(options.cacheFolder, fileInfo.path);
2604
+ const outputFolder = path__default.posix.join(options.outputFolder, fileInfo.path);
2601
2605
  const cacheMiss = cache(cacheFolder, outputFolder);
2602
2606
  const dirtyTasks = tasks.filter(cacheMiss);
2603
2607
  if (dirtyTasks.length === 0) {
@@ -2632,8 +2636,8 @@ async function compileStandalones(options) {
2632
2636
  if (tasks.length === 0) {
2633
2637
  return;
2634
2638
  }
2635
- const cacheFolder = sp__default.posix.join(options.cacheFolder, fileInfo.path);
2636
- const outputFolder = sp__default.posix.join(options.outputFolder, fileInfo.path);
2639
+ const cacheFolder = path__default.posix.join(options.cacheFolder, fileInfo.path);
2640
+ const outputFolder = path__default.posix.join(options.outputFolder, fileInfo.path);
2637
2641
  const cacheMiss = cache(cacheFolder, outputFolder);
2638
2642
  const dirtyTasks = tasks.filter(cacheMiss);
2639
2643
  const standaloneTemplate = findTemplate(
@@ -2642,7 +2646,7 @@ async function compileStandalones(options) {
2642
2646
  "example"
2643
2647
  );
2644
2648
  for (const task of dirtyTasks) {
2645
- const outputFile = sp__default.join(outputFolder, task.outputFile);
2649
+ const outputFile = path__default.join(outputFolder, task.outputFile);
2646
2650
  const content = await renderTemplate(standaloneTemplate, {
2647
2651
  ...templateData,
2648
2652
  content: task.content
@@ -2664,7 +2668,7 @@ async function render(doc, docs, nav, vendors, options) {
2664
2668
  return null;
2665
2669
  }
2666
2670
  const dst = getOutputFilePath(outputFolder, fileInfo);
2667
- const mkdir = fs.mkdir(sp__default.dirname(dst), { recursive: true });
2671
+ const mkdir = fs.mkdir(path__default.dirname(dst), { recursive: true });
2668
2672
  const topnav = nav.topnav;
2669
2673
  const sidenav = findSidenav(doc, nav.sidenav);
2670
2674
  if (sidenav && isNavigationSection(sidenav)) {
@@ -2730,12 +2734,12 @@ async function render(doc, docs, nav, vendors, options) {
2730
2734
  fileMatcher
2731
2735
  });
2732
2736
  if (example.output) {
2733
- const { dir, name } = sp__default.parse(example.output);
2737
+ const { dir, name } = path__default.parse(example.output);
2734
2738
  if (example.task) {
2735
2739
  generatedExamples.push(example.task);
2736
2740
  }
2737
2741
  generatedStandalone.push({
2738
- outputFile: sp__default.join(dir, `${name}.html`),
2742
+ outputFile: path__default.join(dir, `${name}.html`),
2739
2743
  content: example.markup
2740
2744
  });
2741
2745
  }
@@ -3029,7 +3033,7 @@ function getAssetSource(asset) {
3029
3033
  return lines.join("\n");
3030
3034
  }
3031
3035
  async function compileVendor(assetFolder, vendor, options) {
3032
- const name = sp__default.isAbsolute(vendor.package) ? sp__default.basename(vendor.package) : vendor.package;
3036
+ const name = path__default.isAbsolute(vendor.package) ? path__default.basename(vendor.package) : vendor.package;
3033
3037
  const slug = slugify(name);
3034
3038
  const outfile = `temp/vendor-${slug}.out.js`;
3035
3039
  const tmpfile = `temp/vendor-${slug}.in.js`;
@@ -3055,7 +3059,7 @@ async function compileVendor(assetFolder, vendor, options) {
3055
3059
  const fingerprint = getFingerprint(content);
3056
3060
  const integrity = getIntegrity(content);
3057
3061
  const filename = `vendor-${slug}-${fingerprint}.js`;
3058
- const dst = sp__default.join(assetFolder, filename).replace(/\\/g, "/");
3062
+ const dst = path__default.join(assetFolder, filename).replace(/\\/g, "/");
3059
3063
  await fs.rename(outfile, dst);
3060
3064
  const stat = await fs.stat(dst);
3061
3065
  return {
@@ -3258,7 +3262,7 @@ function getWorkingDir(value) {
3258
3262
  if (value) {
3259
3263
  const url = typeof value === "string" ? new URL(value) : value;
3260
3264
  const normalized = normalizePath(fileURLToPath(url));
3261
- return sp__default.posix.dirname(normalized);
3265
+ return path__default.posix.dirname(normalized);
3262
3266
  } else {
3263
3267
  return normalizePath(process.cwd());
3264
3268
  }
@@ -3296,7 +3300,7 @@ class Generator {
3296
3300
  this.bundleDefaultFont = options.bundleDefaultFont ?? true;
3297
3301
  this.outputFolder = options.outputFolder ?? "./public";
3298
3302
  this.cacheFolder = options.cacheFolder ?? "./temp/docs";
3299
- this.assetFolder = sp__default.posix.join(this.outputFolder, "assets");
3303
+ this.assetFolder = path__default.posix.join(this.outputFolder, "assets");
3300
3304
  this.exampleFolders = options.exampleFolders ?? [];
3301
3305
  this.templateFolders = options.templateFolders ?? [];
3302
3306
  this.processors = options.processors ?? [];
@@ -3456,7 +3460,7 @@ class Generator {
3456
3460
  const { outputFolder, cacheFolder, assetFolder } = this;
3457
3461
  await fs.rm(cacheFolder, { force: true, recursive: true });
3458
3462
  if (existsSync(outputFolder)) {
3459
- await fs.mkdir(sp__default.dirname(cacheFolder), { recursive: true });
3463
+ await fs.mkdir(path__default.dirname(cacheFolder), { recursive: true });
3460
3464
  await fse.copy(outputFolder, cacheFolder);
3461
3465
  await fs.rm(outputFolder, { recursive: true });
3462
3466
  }
@@ -3473,7 +3477,7 @@ class Generator {
3473
3477
  const filename = `inter-${subset}-wght-normal.woff2`;
3474
3478
  const module = `@fontsource-variable/inter/files/${filename}`;
3475
3479
  const src = fileURLToPath(import.meta.resolve(module));
3476
- const dst = sp__default.join(assetFolder, filename);
3480
+ const dst = path__default.join(assetFolder, filename);
3477
3481
  return fs.copyFile(src, dst);
3478
3482
  });
3479
3483
  await Promise.all(files);