@forsakringskassan/docs-generator 3.12.1 → 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';
@@ -4156,7 +4156,7 @@ class Generator {
4156
4156
  this.scripts = [];
4157
4157
  this.styles = [];
4158
4158
  this.resources = [];
4159
- this.sourceFiles = [];
4159
+ this.sourceFiles = options.sourceFiles ?? [];
4160
4160
  this.markdownOptions = options.markdown;
4161
4161
  const bootstrapUrl = new URL("runtime-bootstrap.mjs", import.meta.url);
4162
4162
  this.compileScript(
@@ -4246,16 +4246,14 @@ class Generator {
4246
4246
  to: dst
4247
4247
  });
4248
4248
  }
4249
- /**
4250
- * Generate a manifest listing all generated documents that will be present
4251
- * in `outputFolder`.
4252
- *
4253
- * Note: this only collects documents from the `generate-docs` stage,
4254
- * potential documents generated at later stages will not be present.
4255
- *
4256
- * @public
4257
- */
4258
- 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;
4259
4257
  const processors = [
4260
4258
  fileReaderProcessor(sourceFiles),
4261
4259
  redirectProcessor(),
@@ -4276,8 +4274,13 @@ class Generator {
4276
4274
  });
4277
4275
  return { pages };
4278
4276
  }
4279
- async build(sourceFiles) {
4280
- 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
+ }
4281
4284
  const {
4282
4285
  site,
4283
4286
  outputFolder,
@@ -4286,6 +4289,7 @@ class Generator {
4286
4289
  exampleFolders,
4287
4290
  templateFolders,
4288
4291
  setupPath,
4292
+ sourceFiles,
4289
4293
  markdownOptions
4290
4294
  } = this;
4291
4295
  const examplePatterns = this.exampleFolders.map((it) => `${it}/**/*`);
@@ -4350,7 +4354,7 @@ class Generator {
4350
4354
  outputFolder,
4351
4355
  watch,
4352
4356
  rebuild: (_filePath) => {
4353
- return this.build(sourceFiles);
4357
+ return this.build();
4354
4358
  }
4355
4359
  });
4356
4360
  }