Skip to content

Commit

Permalink
fix(core): always display inline object for tuple type
Browse files Browse the repository at this point in the history
  • Loading branch information
tgreyuk committed Dec 24, 2024
1 parent 81dbb4a commit 09f6e97
Show file tree
Hide file tree
Showing 9 changed files with 268 additions and 11 deletions.
5 changes: 5 additions & 0 deletions .changeset/eleven-boats-give.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'typedoc-plugin-markdown': patch
---

- Always display inline object for tuple types (#745).
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export function tupleType(
this: MarkdownThemeContext,
model: TupleType,
): string {
return `[${model.elements
.map((element) => this.partials.someType(element))
.join(', ')}]`;
return `\\[${model.elements
.map((element) => this.partials.someType(element, { forceCollapse: true }))
.join(', ')}\\]`;
}
Original file line number Diff line number Diff line change
Expand Up @@ -280,3 +280,38 @@ export const functionWithArrayOfUnionStuff = (
* Comments for array of stuff?
*/
export const functionWithArrayOfOptionalStuff = (a: [Stuff?]) => {};

export const typedef = {
/**
* Comments for a
*/
a: '',
b: '',
};

/**
* @inline
*/
export type TypeDefOptions = typeof typedef;

/**
* @inline
*/
export type ExplicitTypeDefOptions = {
a: string;
b: string;
};

export const tupleTypeFunction = (
/**
* opts comments
*/
opts: [TypeDefOptions],
) => {};
export const tupleTypeFunctionOptional = (
opts: [(TypeDefOptions | null | undefined)?],
) => {};

export const tupleTypeFunctionInlineExplicit = (
opts: [ExplicitTypeDefOptions],
) => {};
Original file line number Diff line number Diff line change
Expand Up @@ -4421,6 +4421,11 @@ exports[`Navigation should gets Navigation Json for single entry point: (Output
"kind": 2097152,
"path": "type-aliases/ConditionalType.md"
},
{
"title": "ExplicitTypeDefOptions",
"kind": 2097152,
"path": "type-aliases/ExplicitTypeDefOptions.md"
},
{
"title": "ExternalReferenceType",
"kind": 2097152,
Expand Down Expand Up @@ -4491,6 +4496,11 @@ exports[`Navigation should gets Navigation Json for single entry point: (Output
"kind": 2097152,
"path": "type-aliases/TupleType.md"
},
{
"title": "TypeDefOptions",
"kind": 2097152,
"path": "type-aliases/TypeDefOptions.md"
},
{
"title": "TypeWithExternalSymbolLinkMapping",
"kind": 2097152,
Expand Down Expand Up @@ -4551,6 +4561,11 @@ exports[`Navigation should gets Navigation Json for single entry point: (Output
"kind": 32,
"path": "variables/templateVariableString.md"
},
{
"title": "typedef",
"kind": 32,
"path": "variables/typedef.md"
},
{
"title": "typeOperatorVariable",
"kind": 32,
Expand Down Expand Up @@ -4660,6 +4675,21 @@ exports[`Navigation should gets Navigation Json for single entry point: (Output
"title": "functionWithUnionParams",
"kind": 64,
"path": "functions/functionWithUnionParams.md"
},
{
"title": "tupleTypeFunction",
"kind": 64,
"path": "functions/tupleTypeFunction.md"
},
{
"title": "tupleTypeFunctionInlineExplicit",
"kind": 64,
"path": "functions/tupleTypeFunctionInlineExplicit.md"
},
{
"title": "tupleTypeFunctionOptional",
"kind": 64,
"path": "functions/tupleTypeFunctionOptional.md"
}
]
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -453,7 +453,7 @@ Comments for array of stuff?
### a
[[\`Stuff\`](../type-aliases/Stuff.md)?]
\\[[\`Stuff\`](../type-aliases/Stuff.md)?\\]
## Returns
Expand All @@ -478,7 +478,7 @@ Comments for array of stuff?
| Parameter | Type |
| :------ | :------ |
| \`a\` | [[\`Stuff\`](../type-aliases/Stuff.md)?] |
| \`a\` | \\[[\`Stuff\`](../type-aliases/Stuff.md)?\\] |
## Returns
Expand All @@ -501,7 +501,7 @@ Comments for array of stuff
### a
[[\`Stuff\`](../type-aliases/Stuff.md)]
\\[[\`Stuff\`](../type-aliases/Stuff.md)\\]
## Returns
Expand All @@ -526,7 +526,7 @@ Comments for array of stuff
| Parameter | Type |
| :------ | :------ |
| \`a\` | [[\`Stuff\`](../type-aliases/Stuff.md)] |
| \`a\` | \\[[\`Stuff\`](../type-aliases/Stuff.md)\\] |
## Returns
Expand All @@ -549,7 +549,7 @@ Comments for array of union stuff
### a
[(\`null\` \\| [\`Stuff\`](../type-aliases/Stuff.md))?]
\\[(\`null\` \\| [\`Stuff\`](../type-aliases/Stuff.md))?\\]
## Returns
Expand All @@ -574,7 +574,7 @@ Comments for array of union stuff
| Parameter | Type |
| :------ | :------ |
| \`a\` | [(\`null\` \\| [\`Stuff\`](../type-aliases/Stuff.md))?] |
| \`a\` | \\[(\`null\` \\| [\`Stuff\`](../type-aliases/Stuff.md))?\\] |
## Returns
Expand Down Expand Up @@ -731,6 +731,53 @@ This is a function with a parameter that has a default value.
"
`;
exports[`Function Reflection should compile function with explicit inline tuple type optional params: (Output File Strategy "members") (Option Group "1") 1`] = `
"# Function: tupleTypeFunctionInlineExplicit()
> **tupleTypeFunctionInlineExplicit**(\`opts\`): \`void\`
## Parameters
### opts
\\[\\{ \`a\`: \`string\`; \`b\`: \`string\`; \\}\\]
## Returns
\`void\`
## Source
[functions.ts:1](http://source-url)
"
`;
exports[`Function Reflection should compile function with explicit inline tuple type optional params: (Output File Strategy "members") (Option Group "2") 1`] = `
"# Function: tupleTypeFunctionInlineExplicit()
\`\`\`ts
function tupleTypeFunctionInlineExplicit(opts: [{
a: string;
b: string;
}]): void
\`\`\`
## Parameters
| Parameter | Type |
| :------ | :------ |
| \`opts\` | \\[\\{ \`a\`: \`string\`; \`b\`: \`string\`; \\}\\] |
## Returns
\`void\`
## Source
[functions.ts:1](http://source-url)
"
`;
exports[`Function Reflection should compile function with multiple signatures: (Output File Strategy "members") (Option Group "1") 1`] = `
"# Function: functionWithMultipleSignatures()
Expand Down Expand Up @@ -1196,6 +1243,104 @@ Function with reset parmas
"
`;
exports[`Function Reflection should compile function with tuple type optional params: (Output File Strategy "members") (Option Group "1") 1`] = `
"# Function: tupleTypeFunctionOptional()
> **tupleTypeFunctionOptional**(\`opts\`): \`void\`
## Parameters
### opts
\\[(\`null\` \\| \\{ \`a\`: \`string\`; \`b\`: \`string\`; \\})?\\]
## Returns
\`void\`
## Source
[functions.ts:1](http://source-url)
"
`;
exports[`Function Reflection should compile function with tuple type optional params: (Output File Strategy "members") (Option Group "2") 1`] = `
"# Function: tupleTypeFunctionOptional()
\`\`\`ts
function tupleTypeFunctionOptional(opts: [(
| null
| {
a: string;
b: string;
})?]): void
\`\`\`
## Parameters
| Parameter | Type |
| :------ | :------ |
| \`opts\` | \\[( \\| \`null\` \\| \\{ \`a\`: \`string\`; \`b\`: \`string\`; \\})?\\] |
## Returns
\`void\`
## Source
[functions.ts:1](http://source-url)
"
`;
exports[`Function Reflection should compile function with tuple type params: (Output File Strategy "members") (Option Group "1") 1`] = `
"# Function: tupleTypeFunction()
> **tupleTypeFunction**(\`opts\`): \`void\`
## Parameters
### opts
\\[\\{ \`a\`: \`string\`; \`b\`: \`string\`; \\}\\]
opts comments
## Returns
\`void\`
## Source
[functions.ts:1](http://source-url)
"
`;
exports[`Function Reflection should compile function with tuple type params: (Output File Strategy "members") (Option Group "2") 1`] = `
"# Function: tupleTypeFunction()
\`\`\`ts
function tupleTypeFunction(opts: [{
a: string;
b: string;
}]): void
\`\`\`
## Parameters
| Parameter | Type | Description |
| :------ | :------ | :------ |
| \`opts\` | \\[\\{ \`a\`: \`string\`; \`b\`: \`string\`; \\}\\] | opts comments |
## Returns
\`void\`
## Source
[functions.ts:1](http://source-url)
"
`;
exports[`Function Reflection should compile function with type parameters: (Output File Strategy "members") (Option Group "1") 1`] = `
"# Function: functionWithTypeParameters()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ Module comments
| [ArrayOfObjectsType](type-aliases/ArrayOfObjectsType.md) | - |
| [ArrayType](type-aliases/ArrayType.md) | Comments for ArrayType |
| [ConditionalType](type-aliases/ConditionalType.md) | Comments for ConditionalType |
| [ExplicitTypeDefOptions](type-aliases/ExplicitTypeDefOptions.md) | - |
| [ExternalReferenceType](type-aliases/ExternalReferenceType.md) | Comments for ExternalReferenceType |
| [FunctionType](type-aliases/FunctionType.md) | Comments for FunctionType |
| [IndexAccessType](type-aliases/IndexAccessType.md) | Comments for IndexAccessType |
Expand All @@ -88,6 +89,7 @@ Module comments
| [StringLiteralType](type-aliases/StringLiteralType.md) | Comments for StringLiteralType |
| [Stuff](type-aliases/Stuff.md) | - |
| [TupleType](type-aliases/TupleType.md) | Comments for TupleType |
| [TypeDefOptions](type-aliases/TypeDefOptions.md) | - |
| [TypeWithExternalSymbolLinkMapping](type-aliases/TypeWithExternalSymbolLinkMapping.md) | Comments for TypeWithExternalSymbolLinkMapping |
| [TypeWithReturns](type-aliases/TypeWithReturns.md) | Comments for TypeWithReturns |
| [TypeWithTypeParams](type-aliases/TypeWithTypeParams.md) | Comments for TypeWithTypeParams |
Expand All @@ -104,6 +106,7 @@ Module comments
| [someQuery](variables/someQuery.md) | - |
| [stringVariable](variables/stringVariable.md) | A simple string variable |
| [templateVariableString](variables/templateVariableString.md) | A template variable string |
| [typedef](variables/typedef.md) | - |
| [typeOperatorVariable](variables/typeOperatorVariable.md) | Comments for typeOperatorVariable |
## Functions
Expand All @@ -130,5 +133,8 @@ Module comments
| [functionWithRestParams](functions/functionWithRestParams.md) | Function with reset parmas |
| [functionWithTypeParameters](functions/functionWithTypeParameters.md) | Function with type parameters |
| [functionWithUnionParams](functions/functionWithUnionParams.md) | - |
| [tupleTypeFunction](functions/tupleTypeFunction.md) | - |
| [tupleTypeFunctionInlineExplicit](functions/tupleTypeFunctionInlineExplicit.md) | - |
| [tupleTypeFunctionOptional](functions/tupleTypeFunctionOptional.md) | - |
"
`;
Original file line number Diff line number Diff line change
Expand Up @@ -646,7 +646,7 @@ Comments for StringLiteralType
exports[`Type Alias Reflection should compile string tuple type: (Output File Strategy "members") (Option Group "1") 1`] = `
"# Type Alias: TupleType
> **TupleType**: [\`string\`, \`number\`]
> **TupleType**: \\[\`string\`, \`number\`\\]
Comments for TupleType
Expand Down Expand Up @@ -674,7 +674,7 @@ Comments for TupleType
exports[`Type Alias Reflection should compile type parameter type: (Output File Strategy "members") (Option Group "1") 1`] = `
"# Type Alias: TypeWithTypeParams\\<T, R\\>
> **TypeWithTypeParams**\\<\`T\`, \`R\`\\>: [\`T\`, \`R\`]
> **TypeWithTypeParams**\\<\`T\`, \`R\`\\>: \\[\`T\`, \`R\`\\]
Comments for TypeWithTypeParams
Expand Down
Loading

0 comments on commit 09f6e97

Please sign in to comment.