diff --git a/tests/theme/fixtures/input.js b/tests/theme/fixtures/input.js index 1594e188..e221b5bd 100644 --- a/tests/theme/fixtures/input.js +++ b/tests/theme/fixtures/input.js @@ -5,6 +5,12 @@ */ export class WebpackTest {} +/** + * Interface demonstrating Webpack as an interface. + * @interface + */ +export class WebpackInterface {} + /** * Class demonstrating overload signatures. */ @@ -89,3 +95,68 @@ export class TypedListTest extends WebpackTest { */ typedListMethod(name, count) {} } + +/** + * Complex array type. + * @typedef {Array<{ name: string, age: number }>} ComplexArrayType + */ + +/** + * Simple array type. + * @typedef {Array} SimpleArrayType + */ + +/** + * Complex union type. + * @typedef {string | { advanced: boolean, timeout: number }} ComplexUnionType + */ + +/** + * Simple union type. + * @typedef {string | number} SimpleUnionType + */ + +/** + * Complex intersection type. + * @typedef {{ id: string } & { metadata: object }} ComplexIntersectionType + */ + +/** + * Simple intersection type. + * @typedef {number & string} SimpleIntersectionType + */ + +/** + * Variable demonstrating declarationTitle formatting. + * @type {string} + */ +export const declarationTitleTest = 'pass me'; + +/** + * Class demonstrating indexSignature rendering. + */ +export class IndexSignatureTest { + /** + * An object property to trigger indexSignature. + * @type {{ [key: string]: number }} + */ + dictionaryProperty; +} + +/** + * Class demonstrating Implements and Constructor grouping. + * @implements {WebpackInterface} + */ +export class MemberGroupsTest { + /** + * The constructor for MemberGroupsTest. + * @param {any} data + */ + constructor(data) {} + + /** + * A categorized method. + * @category Lifecycle + */ + init() {} +} diff --git a/tests/theme/fixtures/tsconfig.json b/tests/theme/fixtures/tsconfig.json index caddb7f2..ff8f0ace 100644 --- a/tests/theme/fixtures/tsconfig.json +++ b/tests/theme/fixtures/tsconfig.json @@ -3,7 +3,9 @@ "compilerOptions": { "allowJs": true, "esModuleInterop": true, - "noEmit": true, + "declaration": true, + "emitDeclarationOnly": true, + "outDir": "../.temp/types", "skipLibCheck": true } } diff --git a/tests/theme/theme.test.mjs b/tests/theme/theme.test.mjs index 8243c696..982eff27 100644 --- a/tests/theme/theme.test.mjs +++ b/tests/theme/theme.test.mjs @@ -1,21 +1,27 @@ import { test } from 'node:test'; import { Application } from 'typedoc'; -import { readdirSync, readFileSync, rmSync } from 'node:fs'; +import { readdirSync, readFileSync, rmSync, writeFileSync } from 'node:fs'; import { join } from 'node:path/posix'; +import { execSync } from 'node:child_process'; import { typeDocConfig } from '../../scripts/markdown/api/utils.mjs'; const fixturesDir = './tests/theme/fixtures'; const outputDir = './tests/theme/.temp'; +const typesDir = './tests/theme/.temp/types'; +const tsconfig = { include: ['**/*.d.ts'] }; test('TypeDoc Theme - Edge Cases Fixture', async t => { - const inputFilePath = join(fixturesDir, 'input.js'); + execSync(`npx tsc -p ${join(fixturesDir, 'tsconfig.json')}`, { + stdio: 'inherit', + }); + writeFileSync(join(typesDir, 'tsconfig.json'), JSON.stringify(tsconfig)); const app = await Application.bootstrapWithPlugins({ ...typeDocConfig, - entryPoints: [inputFilePath], + entryPoints: [join(typesDir, 'input.d.ts')], out: outputDir, publicPath: '/', - tsconfig: join(fixturesDir, 'tsconfig.json'), + tsconfig: join(typesDir, 'tsconfig.json'), }); const project = await app.convert(); diff --git a/tests/theme/theme.test.mjs.snapshot b/tests/theme/theme.test.mjs.snapshot index df06a1ee..3c36dda3 100644 --- a/tests/theme/theme.test.mjs.snapshot +++ b/tests/theme/theme.test.mjs.snapshot @@ -1,3 +1,3 @@ exports[`TypeDoc Theme - Edge Cases Fixture 1`] = ` -"# Class: \`webpack.js.org.ExamplesTest\`\\n\\nClass demonstrating the formatting of JSDoc example blocks.\\n\\n## Constructors\\n\\n### \`new ExamplesTest()\`\\n\\n* Returns: {ExamplesTest}\\n\\n## Methods\\n\\n### \`exampleMethod(name)\`\\n\\n* \`name\` {string} A simple string parameter\\n* Returns: {void} \\n\\nA sample method for the ExamplesTest class.\\n\`\`\`ts\\nexampleMethod('example-1');\\n\`\`\`\\n\\n\`\`\`ts\\nexampleMethod('example-2');\\n\`\`\`\\n\\n\\n---\\n\\n# Class: \`webpack.js.org.OverloadTest\`\\n\\nClass demonstrating overload signatures.\\n\\n## Constructors\\n\\n### \`new OverloadTest()\`\\n\\n* Returns: {OverloadTest}\\n\\n## Methods\\n\\n### \`overloadMethod(name, count)\`\\n\\n#### Call Signature\\n\\n* \`name\` {string} A simple string parameter\\n* \`count\` {number} A simple number parameter\\n* Returns: {void} \\n\\nFirst overload signature.\\n\\n#### Call Signature\\n\\n* \`isEnabled\` {boolean} A simple boolean parameter\\n* Returns: {string} \\n\\nSecond overload signature.\\n\\n#### Call Signature\\n\\n* \`id\` {number} A simple string parameter\\n* \`isEnabled\` {boolean} A simple boolean parameter\\n* Returns: {void} \\n\\nThird overload signature.\\n\\n\\n---\\n\\n# Class: \`webpack.js.org.StabilityTest\`\\n\\nClass demonstrating stability for deprecated, experimental, and legacy APIs.\\n\\n## Constructors\\n\\n### \`new StabilityTest()\`\\n\\n* Returns: {StabilityTest}\\n\\n## Methods\\n\\n### \`deprecatedMethod()\`\\n\\n> Stability: 0 - Deprecated: Use the new API instead.\\n\\n* Returns: {void}\\n\\n***\\n\\n### \`experimentalMethod()\`\\n\\n> Stability: 1 - Experimental\\n\\n* Returns: {void}\\n\\n**\`Experimental\`**\\n\\n***\\n\\n### \`legacyMethod()\`\\n\\n> Stability: 3 - Legacy: This is a legacy Webpack v4 API.\\n\\n* Returns: {void}\\n\\n\\n---\\n\\n# Class: \`webpack.js.org.TypedListTest\`\\n\\nClass demonstrating properties and typed lists.\\n\\n* Extends: {WebpackTest}\\n\\n## Constructors\\n\\n### \`new TypedListTest()\`\\n\\n* Returns: {TypedListTest}\\n\\n## Properties\\n\\n* \`typedListProperty\` {string} A sample property for the TypedListTest class.\\n\\n## Methods\\n\\n### \`typedListMethod(name, count)\`\\n\\n* \`name\` {string} The name of the instance\\n* \`count\` {number} The count of items\\n* Returns: {boolean} A boolean indicating success\\n\\nA sample method for the TypedListTest class.\\n\\n\\n---\\n\\n# Class: \`webpack.js.org.WebpackTest\`\\n\\nClass demonstrating Webpack as a parent class.\\n\\n## Constructors\\n\\n### \`new WebpackTest()\`\\n\\n* Returns: {WebpackTest}\\n" +"# Class: \`webpack.js.org.ExamplesTest\`\\n\\nClass demonstrating the formatting of JSDoc example blocks.\\n\\n## Constructors\\n\\n### \`new ExamplesTest()\`\\n\\n* Returns: {ExamplesTest}\\n\\n## Methods\\n\\n### \`exampleMethod(name)\`\\n\\n* \`name\` {string} A simple string parameter\\n* Returns: {void} \\n\\nA sample method for the ExamplesTest class.\\n\`\`\`ts\\nexampleMethod('example-1');\\n\`\`\`\\n\\n\`\`\`ts\\nexampleMethod('example-2');\\n\`\`\`\\n\\n\\n---\\n\\n# Class: \`webpack.js.org.IndexSignatureTest\`\\n\\nClass demonstrating indexSignature rendering.\\n\\n## Constructors\\n\\n### \`new IndexSignatureTest()\`\\n\\n* Returns: {IndexSignatureTest}\\n\\n## Properties\\n\\n* \`dictionaryProperty\` {{ [key: string]: number }} An object property to trigger indexSignature.\\n\\n\\n---\\n\\n# Class: \`webpack.js.org.MemberGroupsTest\`\\n\\nClass demonstrating Implements and Constructor grouping.\\n\\n## Implements\\n\\n* {WebpackInterface}\\n\\n## Constructors\\n\\n### \`new MemberGroupsTest(data)\`\\n\\n* \`data\` {any} \\n* Returns: {MemberGroupsTest}\\n\\nThe constructor for MemberGroupsTest.\\n\\n## Lifecycle\\n\\n### \`init()\`\\n\\n* Returns: {void}\\n\\nA categorized method.\\n\\n\\n---\\n\\n# Class: \`webpack.js.org.OverloadTest\`\\n\\nClass demonstrating overload signatures.\\n\\n## Constructors\\n\\n### \`new OverloadTest()\`\\n\\n* Returns: {OverloadTest}\\n\\n## Methods\\n\\n### \`overloadMethod(name, count)\`\\n\\n#### Call Signature\\n\\n* \`name\` {string} A simple string parameter\\n* \`count\` {number} A simple number parameter\\n* Returns: {void} \\n\\nFirst overload signature.\\n\\n#### Call Signature\\n\\n* \`isEnabled\` {boolean} A simple boolean parameter\\n* Returns: {string} \\n\\nSecond overload signature.\\n\\n#### Call Signature\\n\\n* \`id\` {number} A simple string parameter\\n* \`isEnabled\` {boolean} A simple boolean parameter\\n* Returns: {void} \\n\\nThird overload signature.\\n\\n\\n---\\n\\n# Class: \`webpack.js.org.StabilityTest\`\\n\\nClass demonstrating stability for deprecated, experimental, and legacy APIs.\\n\\n## Constructors\\n\\n### \`new StabilityTest()\`\\n\\n* Returns: {StabilityTest}\\n\\n## Methods\\n\\n### \`deprecatedMethod()\`\\n\\n> Stability: 0 - Deprecated: Use the new API instead.\\n\\n* Returns: {void}\\n\\n***\\n\\n### \`experimentalMethod()\`\\n\\n> Stability: 1 - Experimental\\n\\n* Returns: {void}\\n\\n**\`Experimental\`**\\n\\n***\\n\\n### \`legacyMethod()\`\\n\\n> Stability: 3 - Legacy: This is a legacy Webpack v4 API.\\n\\n* Returns: {void}\\n\\n\\n---\\n\\n# Class: \`webpack.js.org.TypedListTest\`\\n\\nClass demonstrating properties and typed lists.\\n\\n* Extends: {WebpackTest}\\n\\n## Constructors\\n\\n### \`new TypedListTest()\`\\n\\n* Returns: {TypedListTest}\\n\\n## Properties\\n\\n* \`typedListProperty\` {string} A sample property for the TypedListTest class.\\n\\n## Methods\\n\\n### \`typedListMethod(name, count)\`\\n\\n* \`name\` {string} The name of the instance\\n* \`count\` {number} The count of items\\n* Returns: {boolean} A boolean indicating success\\n\\nA sample method for the TypedListTest class.\\n\\n\\n---\\n\\n# Class: \`webpack.js.org.WebpackInterface\`\\n\\n**\`Interface\`**\\n\\nInterface demonstrating Webpack as an interface.\\n\\n## Constructors\\n\\n### \`new WebpackInterface()\`\\n\\n* Returns: {WebpackInterface}\\n\\n\\n---\\n\\n# Class: \`webpack.js.org.WebpackTest\`\\n\\nClass demonstrating Webpack as a parent class.\\n\\n## Constructors\\n\\n### \`new WebpackTest()\`\\n\\n* Returns: {WebpackTest}\\n\\n\\n---\\n\\n# \`webpack\` Types\\n\\nThese types are not exported by webpack, but they are available to TypeScript consumers.\\n\\n## Type: \`ComplexArrayType\`\\n\\n* Type: {{ age: number; name: string }[]}\\n\\nComplex array type.\\n\\n### Type Declaration\\n\\n* \`age\` {number}\\n* \`name\` {string}\\n\\n***\\n\\n## Type: \`ComplexIntersectionType\`\\n\\n* Type: {{ id: string } & { metadata: object }}\\n\\nComplex intersection type.\\n\\n### Type Declaration\\n\\n* \`id\` {string}\\n\\n### Type Declaration\\n\\n* \`metadata\` {object}\\n\\n***\\n\\n## Type: \`ComplexUnionType\`\\n\\n* Type: {string | { advanced: boolean; timeout: number }}\\n\\nComplex union type.\\n\\n***\\n\\n## Type: \`SimpleArrayType\`\\n\\n* Type: {string[]}\\n\\nSimple array type.\\n\\n***\\n\\n## Type: \`SimpleIntersectionType\`\\n\\n* Type: {number & string}\\n\\nSimple intersection type.\\n\\n***\\n\\n## Type: \`SimpleUnionType\`\\n\\n* Type: {string | number}\\n\\nSimple union type.\\n" `;