@forsakringskassan/docs-generator 3.12.0 → 3.13.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-BesEHnwj.mjs';
5
+ import { r as runAsWorker, f as format2, a as resolveConfig } from './vendor-BLfCdre8.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-CoZR-v_f.mjs.map
57
+ //# sourceMappingURL=format-code.worker-C_xPgPcX.mjs.map
@@ -1 +1 @@
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;;"}
1
+ {"version":3,"file":"format-code.worker-C_xPgPcX.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
@@ -350,7 +350,32 @@ declare class Generator_2 {
350
350
  *
351
351
  * @public
352
352
  */
353
- manifest(sourceFiles: SourceFiles[]): Promise<Manifest>;
353
+ manifest(): Promise<Manifest>;
354
+ /**
355
+ * Generate a manifest listing all generated documents that will be present
356
+ * in `outputFolder`.
357
+ *
358
+ * Note: this only collects documents from the `generate-docs` stage,
359
+ * potential documents generated at later stages will not be present.
360
+ *
361
+ * @public
362
+ * @deprecated Pass in the sourceFiles in the construction options instead.
363
+ */
364
+ manifest(explicitSourceFiles: SourceFiles[]): Promise<Manifest>;
365
+ /**
366
+ * Build the documentation project.
367
+ *
368
+ * @public
369
+ * @returns A promise resolving to a list of generated files.
370
+ */
371
+ build(): Promise<string[]>;
372
+ /**
373
+ * Build the documentation project.
374
+ *
375
+ * @public
376
+ * @deprecated Pass in the sourceFiles in the construction options instead.
377
+ * @returns A promise resolving to a list of generated files.
378
+ */
354
379
  build(sourceFiles: SourceFiles[]): Promise<string[]>;
355
380
  /**
356
381
  * Start a development server hosting the generated documentation.
@@ -383,6 +408,10 @@ export declare interface GeneratorOptions {
383
408
  processors?: Processor[];
384
409
  /** List of vendor assets to compile */
385
410
  vendor?: VendorDefinition[];
411
+ /**
412
+ * List of source files to build documents from.
413
+ */
414
+ sourceFiles?: SourceFiles[];
386
415
  /** Path to file with exported `setup` function, responsible for mounting of component.
387
416
  * `function setup(options: { rootComponent: string, selector: string }): void`
388
417
  */
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-BesEHnwj.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-BLfCdre8.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-C7-7Tads.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-DwLB6VT1.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';
@@ -2049,6 +2049,7 @@ function parseFile$2(filePath, basePath, content) {
2049
2049
  path: ["", "."].includes(urlpath) ? "." : `./${normalizePath(urlpath)}`,
2050
2050
  name: filename,
2051
2051
  fullPath: normalizePath(filePath),
2052
+ /* eslint-disable-next-line unicorn/prefer-logical-operator-over-ternary -- false positive? */
2052
2053
  outputName: include ? `${filename}.html` : false
2053
2054
  }
2054
2055
  };
@@ -2983,9 +2984,10 @@ async function compileScript(options) {
2983
2984
  fs: fs$1 = fs
2984
2985
  } = options;
2985
2986
  const iconLib = process.env.DOCS_ICON_LIB ?? "@fkui/icon-lib-default";
2987
+ const sanitizedName = name.replaceAll(/[^a-z0-9-]+/gi, "_");
2986
2988
  try {
2987
2989
  const entryPoints = [src instanceof URL ? fileURLToPath(src) : src];
2988
- const outfile = path__default.join("temp", `asset-${name}.js`);
2990
+ const outfile = path__default.join("temp", `asset-${sanitizedName}.js`);
2989
2991
  const external = [...assets, ...vendor.map(toExternalVendor)];
2990
2992
  const format = buildOptions.format ?? "esm";
2991
2993
  await esbuild({
@@ -3005,7 +3007,7 @@ async function compileScript(options) {
3005
3007
  const content = await fs$1.readFile(outfile, "utf8");
3006
3008
  const fingerprint = getFingerprint(content);
3007
3009
  const integrity = getIntegrity(content);
3008
- const filename = `${outputName}.js`.replaceAll("[name]", () => name).replaceAll("[hash]", () => fingerprint);
3010
+ const filename = `${outputName}.js`.replaceAll("[name]", () => sanitizedName).replaceAll("[hash]", () => fingerprint);
3009
3011
  const dst = path__default.join(outputFolder, filename);
3010
3012
  const publicPath = path__default.posix.join(
3011
3013
  path__default.posix.relative(rootDir, outputFolder),
@@ -4154,7 +4156,7 @@ class Generator {
4154
4156
  this.scripts = [];
4155
4157
  this.styles = [];
4156
4158
  this.resources = [];
4157
- this.sourceFiles = [];
4159
+ this.sourceFiles = options.sourceFiles ?? [];
4158
4160
  this.markdownOptions = options.markdown;
4159
4161
  const bootstrapUrl = new URL("runtime-bootstrap.mjs", import.meta.url);
4160
4162
  this.compileScript(
@@ -4244,16 +4246,14 @@ class Generator {
4244
4246
  to: dst
4245
4247
  });
4246
4248
  }
4247
- /**
4248
- * Generate a manifest listing all generated documents that will be present
4249
- * in `outputFolder`.
4250
- *
4251
- * Note: this only collects documents from the `generate-docs` stage,
4252
- * potential documents generated at later stages will not be present.
4253
- *
4254
- * @public
4255
- */
4256
- async manifest(sourceFiles) {
4249
+ async manifest(explicitSourceFiles) {
4250
+ if (explicitSourceFiles) {
4251
+ this.sourceFiles = explicitSourceFiles;
4252
+ console.error(
4253
+ "[docs-generator] deprecated: passing in `sourceFiles` as a parameter to `Generator.manifest()` is deprecated, should be passed into the constructor options instead."
4254
+ );
4255
+ }
4256
+ const { sourceFiles } = this;
4257
4257
  const processors = [
4258
4258
  fileReaderProcessor(sourceFiles),
4259
4259
  redirectProcessor(),
@@ -4274,8 +4274,13 @@ class Generator {
4274
4274
  });
4275
4275
  return { pages };
4276
4276
  }
4277
- async build(sourceFiles) {
4278
- this.sourceFiles = sourceFiles;
4277
+ async build(explicitSourceFiles) {
4278
+ if (explicitSourceFiles) {
4279
+ this.sourceFiles = explicitSourceFiles;
4280
+ console.error(
4281
+ "[docs-generator] deprecated: passing in `sourceFiles` as a parameter to `Generator.build()` is deprecated, should be passed into the constructor options instead."
4282
+ );
4283
+ }
4279
4284
  const {
4280
4285
  site,
4281
4286
  outputFolder,
@@ -4284,6 +4289,7 @@ class Generator {
4284
4289
  exampleFolders,
4285
4290
  templateFolders,
4286
4291
  setupPath,
4292
+ sourceFiles,
4287
4293
  markdownOptions
4288
4294
  } = this;
4289
4295
  const examplePatterns = this.exampleFolders.map((it) => `${it}/**/*`);
@@ -4348,7 +4354,7 @@ class Generator {
4348
4354
  outputFolder,
4349
4355
  watch,
4350
4356
  rebuild: (_filePath) => {
4351
- return this.build(sourceFiles);
4357
+ return this.build();
4352
4358
  }
4353
4359
  });
4354
4360
  }