diff --git a/src/plugins/typedoc/README.md b/src/plugins/typedoc/README.md index 327d5dac9..4d07dbc0b 100644 --- a/src/plugins/typedoc/README.md +++ b/src/plugins/typedoc/README.md @@ -16,7 +16,9 @@ or `devDependencies`: "typedoc.{js,cjs,json,jsonc}", "typedoc.config.{js,cjs}", ".config/typedoc.{js,cjs,json,jsonc}", - ".config/typedoc.config.{js,cjs}" + ".config/typedoc.config.{js,cjs}", + "package.json", + "tsconfig.json" ] } } diff --git a/src/plugins/typedoc/index.ts b/src/plugins/typedoc/index.ts index 635127385..2183df326 100644 --- a/src/plugins/typedoc/index.ts +++ b/src/plugins/typedoc/index.ts @@ -17,10 +17,16 @@ export const CONFIG_FILE_PATTERNS = [ 'typedoc.config.{js,cjs}', '.config/typedoc.{js,cjs,json,jsonc}', '.config/typedoc.config.{js,cjs}', + 'package.json', + 'tsconfig.json', ]; -const findTypeDocDependencies: GenericPluginCallback = async configFilePath => { - const config: PluginConfig = await load(configFilePath); +const findTypeDocDependencies: GenericPluginCallback = async (configFilePath, { manifest }) => { + const config: PluginConfig = configFilePath.endsWith('package.json') + ? manifest.typedocOptions + : configFilePath.endsWith('tsconfig.json') + ? (await load(configFilePath)).typedocOptions + : await load(configFilePath); return config?.plugin ?? []; }; diff --git a/tests/fixtures/plugins/typedoc/package.json b/tests/fixtures/plugins/typedoc/package.json new file mode 100644 index 000000000..7f9a06f7b --- /dev/null +++ b/tests/fixtures/plugins/typedoc/package.json @@ -0,0 +1,8 @@ +{ + "name": "typedoc", + "typedocOptions": { + "plugin": [ + "typedoc-plugin-umami" + ] + } +} diff --git a/tests/fixtures/plugins/typedoc/tsconfig.json b/tests/fixtures/plugins/typedoc/tsconfig.json new file mode 100644 index 000000000..523a433b6 --- /dev/null +++ b/tests/fixtures/plugins/typedoc/tsconfig.json @@ -0,0 +1,5 @@ +{ + "typedocOptions": { + "plugin": ["typedoc-plugin-zod"] + } +} diff --git a/tests/plugins/typedoc.test.ts b/tests/plugins/typedoc.test.ts index 9583625ce..b1c5cb67a 100644 --- a/tests/plugins/typedoc.test.ts +++ b/tests/plugins/typedoc.test.ts @@ -2,15 +2,29 @@ import assert from 'node:assert/strict'; import test from 'node:test'; import * as typedoc from '../../src/plugins/typedoc/index.js'; import { resolve, join } from '../../src/util/path.js'; +import { getManifest } from '../helpers/index.js'; const cwd = resolve('tests/fixtures/plugins/typedoc'); +const manifest = getManifest(cwd); test('Find dependencies in typedoc configuration (json)', async () => { const configFilePath = join(cwd, 'typedoc.json'); - const dependencies = await typedoc.findDependencies(configFilePath); + const dependencies = await typedoc.findDependencies(configFilePath, { manifest }); assert.deepEqual(dependencies, [ '@appium/typedoc-plugin-appium', 'typedoc-plugin-expand-object-like-types', './dist/index.cjs', ]); }); + +test('Find dependencies in typedoc configuration (package.json)', async () => { + const configFilePath = join(cwd, 'tsconfig.json'); + const dependencies = await typedoc.findDependencies(configFilePath, { manifest }); + assert.deepEqual(dependencies, ['typedoc-plugin-zod']); +}); + +test('Find dependencies in typedoc configuration (tsconfig.json)', async () => { + const configFilePath = join(cwd, 'package.json'); + const dependencies = await typedoc.findDependencies(configFilePath, { manifest }); + assert.deepEqual(dependencies, ['typedoc-plugin-umami']); +});