@virmator/docs 13.3.3 → 13.3.4

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/docs.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { NpmDepType, PackageType, VirmatorEnv } from '@virmator/core';
1
+ import { NpmDepType, PackageType, PluginLogger, VirmatorEnv } from '@virmator/core';
2
2
  /** A virmator plugin for checking and generating documentation. */
3
3
  export declare const virmatorDocsPlugin: Readonly<Readonly<{
4
4
  name: string;
@@ -99,3 +99,17 @@ export declare const virmatorDocsPlugin: Readonly<Readonly<{
99
99
  };
100
100
  }>>;
101
101
  }>;
102
+ /** Runs TypeDoc with a TypeScript config file just like `@virmator/docs` does. */
103
+ export declare function runTypedoc({ configPath, packageDir, checkOnly, log, }: {
104
+ /** Path to TS typedoc config file. */
105
+ configPath: string;
106
+ /**
107
+ * Path to the npm package which is running typedoc. This should be a path to a directory that
108
+ * directly contains a `package.json` file.
109
+ */
110
+ packageDir: string;
111
+ /** Set to `true` to only check current doc comments, rather than generating HTML from them. */
112
+ checkOnly?: boolean | undefined;
113
+ /** Optionally override the logger. */
114
+ log?: PluginLogger | undefined;
115
+ }): Promise<void>;
package/dist/docs.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { ensureError, isTruthy } from '@augment-vir/common';
2
2
  import { readPackageJson } from '@augment-vir/node-js';
3
- import { defineVirmatorPlugin, JsModuleType, NpmDepType, PackageType, VirmatorEnv, VirmatorNoTraceError, withImportedTsFile, } from '@virmator/core';
3
+ import { defaultPluginLogger, defineVirmatorPlugin, JsModuleType, NpmDepType, PackageType, VirmatorEnv, VirmatorNoTraceError, withImportedTsFile, } from '@virmator/core';
4
4
  import mri from 'mri';
5
5
  import { basename, join } from 'node:path';
6
6
  /** A virmator plugin for checking and generating documentation. */
@@ -131,22 +131,11 @@ export const virmatorDocsPlugin = defineVirmatorPlugin(import.meta.dirname, {
131
131
  log.faint(`Skipping typedoc ${typedocVerb} in private repo ${packageName}`);
132
132
  return;
133
133
  }
134
- await withImportedTsFile({
135
- inputPath: join(packageDir, configs.docs.configs.typedoc.copyToPath),
136
- outputPath: join(packageDir, 'node_modules', '.virmator', 'typedoc.config.cjs'),
137
- }, JsModuleType.Cjs, async (loadedConfig) => {
138
- const typedocOptions = loadedConfig.typeDocConfig;
139
- // dynamic imports are not branches
140
- /* node:coverage ignore next */
141
- const typedoc = await import('typedoc');
142
- const fullTypedocOptions = {
143
- ...typedocOptions,
144
- ...(checkOnly ? { emit: typedoc.Configuration.EmitStrategy.none } : {}),
145
- tsconfig: join(packageDir, 'tsconfig.json'),
146
- };
147
- if (!(await runTypedoc(fullTypedocOptions, typedoc, log))) {
148
- throw new VirmatorNoTraceError();
149
- }
134
+ await runTypedoc({
135
+ checkOnly,
136
+ packageDir,
137
+ configPath: join(packageDir, configs.docs.configs.typedoc.copyToPath),
138
+ log,
150
139
  });
151
140
  }
152
141
  /**
@@ -164,7 +153,27 @@ export const virmatorDocsPlugin = defineVirmatorPlugin(import.meta.dirname, {
164
153
  await runDocs(cwdPackagePath, cwdPackageJson.name || basename(cwdPackagePath), undefined);
165
154
  }
166
155
  });
167
- async function runTypedoc(options, typeDoc, log) {
156
+ /** Runs TypeDoc with a TypeScript config file just like `@virmator/docs` does. */
157
+ export async function runTypedoc({ configPath, packageDir, checkOnly = false, log = defaultPluginLogger, }) {
158
+ await withImportedTsFile({
159
+ inputPath: configPath,
160
+ outputPath: join(packageDir, 'node_modules', '.virmator', 'typedoc.config.cjs'),
161
+ }, JsModuleType.Cjs, async (loadedConfig) => {
162
+ const typedocOptions = loadedConfig.typeDocConfig;
163
+ // dynamic imports are not branches
164
+ /* node:coverage ignore next */
165
+ const typedoc = await import('typedoc');
166
+ const fullTypedocOptions = {
167
+ ...typedocOptions,
168
+ ...(checkOnly ? { emit: typedoc.Configuration.EmitStrategy.none } : {}),
169
+ tsconfig: join(packageDir, 'tsconfig.json'),
170
+ };
171
+ if (!(await runTypedocInternal(fullTypedocOptions, typedoc, log))) {
172
+ throw new VirmatorNoTraceError();
173
+ }
174
+ });
175
+ }
176
+ async function runTypedocInternal(options, typeDoc, log) {
168
177
  /** Lots of edge cases included in here to just make sure we fully run the typedoc API. */
169
178
  /* node:coverage disable */
170
179
  const app = await typeDoc.Application.bootstrapWithPlugins(options, [
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@virmator/docs",
3
- "version": "13.3.3",
3
+ "version": "13.3.4",
4
4
  "description": "Default TS docs plugin for virmator.",
5
5
  "keywords": [
6
6
  "virmator",
@@ -34,7 +34,7 @@
34
34
  "dependencies": {
35
35
  "@augment-vir/common": "^29.3.0",
36
36
  "@augment-vir/node-js": "^29.3.0",
37
- "@virmator/core": "^13.3.3",
37
+ "@virmator/core": "^13.3.4",
38
38
  "chalk": "^5.3.0",
39
39
  "mri": "^1.2.0",
40
40
  "run-time-assertions": "^1.5.2"