Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
71 changes: 71 additions & 0 deletions tests/theme/fixtures/input.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@
*/
export class WebpackTest {}

/**
* Interface demonstrating Webpack as an interface.
* @interface
*/
export class WebpackInterface {}

/**
* Class demonstrating overload signatures.
*/
Expand Down Expand Up @@ -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<string>} 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() {}
}
4 changes: 3 additions & 1 deletion tests/theme/fixtures/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
"compilerOptions": {
"allowJs": true,
"esModuleInterop": true,
"noEmit": true,
"declaration": true,
"emitDeclarationOnly": true,
"outDir": "../.temp/types",
"skipLibCheck": true
}
}
14 changes: 10 additions & 4 deletions tests/theme/theme.test.mjs
Original file line number Diff line number Diff line change
@@ -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();
Expand Down
2 changes: 1 addition & 1 deletion tests/theme/theme.test.mjs.snapshot
Original file line number Diff line number Diff line change
@@ -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"
`;