Skip to content

Commit

Permalink
fix(core): fixed spacing around inline object declarations
Browse files Browse the repository at this point in the history
  • Loading branch information
tgreyuk committed Dec 5, 2024
1 parent 65ddaff commit 05197cc
Show file tree
Hide file tree
Showing 11 changed files with 48 additions and 40 deletions.
5 changes: 5 additions & 0 deletions .changeset/twenty-pots-sort.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'typedoc-plugin-markdown': patch
---

- Fixed spacing around inline object declarations.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { Comment } from 'typedoc';
export function getDescriptionForComment(
this: MarkdownThemeContext,
comment: Comment,
) {
): string | null {
if (comment?.summary?.length) {
return this.helpers
.getCommentParts(comment.summary)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export function getHierarchyType(
this: MarkdownThemeContext,
model: SomeType,
options?: { isTarget: boolean },
) {
): string {
return options?.isTarget
? backTicks(model.toString())
: this.partials.someType(model);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@ import { codeBlock } from '@plugin/libs/markdown/index.js';
import { MarkdownThemeContext } from '@plugin/theme/index.js';
import { ReflectionType, SomeType } from 'typedoc';

export function getReturnType(this: MarkdownThemeContext, model?: SomeType) {
export function getReturnType(
this: MarkdownThemeContext,
model?: SomeType,
): string {
if (model) {
const returnType = this.partials.someType(model);
if (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ export function declarationType(
});
}
return types
? `\\{${shouldFormat ? '\n' : ''}${types.join('')} \\}`
? `\\{${shouldFormat ? `\n${types.join('')}` : ` ${types.join(' ')}`} \\}`
: '\\{\\}';
}
return '\\{\\}';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -541,7 +541,7 @@ exports[`Comments should get tables for type declarations: (Output File Strategy
exports[`Comments should get tables for type declarations: (Output File Strategy "members") (Option Group "2") 1`] = `
"# Type Alias: TypeDeclarationTable
> **TypeDeclarationTable**: \\{\`declaration1\`: \`boolean\`;\`declaration2\`: \`boolean\`;\`declaration4\`: \`100\`; \\}
> **TypeDeclarationTable**: \\{ \`declaration1\`: \`boolean\`; \`declaration2\`: \`boolean\`; \`declaration4\`: \`100\`; \\}
## Type declaration
Expand Down Expand Up @@ -619,7 +619,7 @@ to generate the binary output for input validation.
exports[`Comments should get tables for type declarations: (Output File Strategy "members") (Option Group "2") 2`] = `
"# Variable: TypeDeclarationTable
> **TypeDeclarationTable**: \\{\`declaration1\`: \`string\`;\`declaration2\`: \`number\`; \\}
> **TypeDeclarationTable**: \\{ \`declaration1\`: \`string\`; \`declaration2\`: \`number\`; \\}
## Type declaration
Expand Down Expand Up @@ -707,7 +707,7 @@ Other block tags
exports[`Comments should get variable with block tags: (Output File Strategy "members") (Option Group "2") 1`] = `
"# Type Alias: typeWithBlockTags
> **typeWithBlockTags**: \\{\`x\`: \`string\`; \\}
> **typeWithBlockTags**: \\{ \`x\`: \`string\`; \\}
Variable with block tags summary
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ Comments for prop
### propReturningObjectDeclaration
> **propReturningObjectDeclaration**: \\{\`a\`: \`boolean\`;\`b\`: \`string\`; \\}
> **propReturningObjectDeclaration**: \\{ \`a\`: \`boolean\`; \`b\`: \`string\`; \\}
Comments for propReturningObjectDeclaration
Expand All @@ -79,7 +79,7 @@ Comments for propReturningObjectDeclaration
### propReturningObjectDeclarations
> **propReturningObjectDeclarations**: \\{\`a\`: \`boolean\`;\`b\`: \`string\`; \\} & \\{\`c\`: \`boolean\`;\`d\`: \`string\`; \\}
> **propReturningObjectDeclarations**: \\{ \`a\`: \`boolean\`; \`b\`: \`string\`; \\} & \\{ \`c\`: \`boolean\`; \`d\`: \`string\`; \\}
Comments for propReturningObjectDeclarations
Expand Down Expand Up @@ -127,7 +127,7 @@ Comments for propReturningSignatureDeclarations
### propWithFunction()
> **propWithFunction**: (\`options\`: \\{\`a\`: \`boolean\`;\`b\`: \`string\`; \\}) => \`boolean\`
> **propWithFunction**: (\`options\`: \\{ \`a\`: \`boolean\`; \`b\`: \`string\`; \\}) => \`boolean\`
Comments for propWithFunction
Expand All @@ -151,7 +151,7 @@ Comments for propWithFunction
### propWithProps
> **propWithProps**: \\{\`callbacks\`: \`Partial\`\\<[\`CallbacksOptions\`](../classes/CallbacksOptions.md)\\<[\`DisposableClass\`](../classes/DisposableClass.md), [\`ClassWithModifiers\`](../classes/ClassWithModifiers.md)\\>\\>;\`nestedPropA\`: \`string\`;\`nestedPropB\`: \`boolean\`;\`nestedPropC\`: \\{\`nestedPropCA\`: \`string\`; \\};\`nestedPropD\`: () => \`boolean\`; \\}
> **propWithProps**: \\{ \`callbacks\`: \`Partial\`\\<[\`CallbacksOptions\`](../classes/CallbacksOptions.md)\\<[\`DisposableClass\`](../classes/DisposableClass.md), [\`ClassWithModifiers\`](../classes/ClassWithModifiers.md)\\>\\>; \`nestedPropA\`: \`string\`; \`nestedPropB\`: \`boolean\`; \`nestedPropC\`: \\{ \`nestedPropCA\`: \`string\`; \\}; \`nestedPropD\`: () => \`boolean\`; \\}
Comments for propWithProps
Expand All @@ -175,7 +175,7 @@ Comments for nestedPropB
#### nestedPropC
> **nestedPropC**: \\{\`nestedPropCA\`: \`string\`; \\}
> **nestedPropC**: \\{ \`nestedPropCA\`: \`string\`; \\}
Comments for nestedPropC
Expand Down Expand Up @@ -234,13 +234,13 @@ Comments for BasicInterface
exports[`Objects And Params should compile function returning a promise: (Output File Strategy "members") (Option Group "1") 1`] = `
"# Function: functionReturningAPromise()
> **functionReturningAPromise**(): [\`Promise\`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise)\\<\\{\`prop\`: \`string\`; \\}\\>
> **functionReturningAPromise**(): [\`Promise\`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise)\\<\\{ \`prop\`: \`string\`; \\}\\>
Comments for function
## Returns
[\`Promise\`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise)\\<\\{\`prop\`: \`string\`; \\}\\>
[\`Promise\`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise)\\<\\{ \`prop\`: \`string\`; \\}\\>
Return comments
Expand Down Expand Up @@ -312,13 +312,13 @@ Return comments
exports[`Objects And Params should compile function returning an object: (Output File Strategy "members") (Option Group "1") 1`] = `
"# Function: functionReturningAnObject()
> **functionReturningAnObject**(): \\{\`x\`: \`number\`;\`y\`: \`number\`; \\}
> **functionReturningAnObject**(): \\{ \`x\`: \`number\`; \`y\`: \`number\`; \\}
Comments for function
## Returns
\\{\`x\`: \`number\`;\`y\`: \`number\`; \\}
\\{ \`x\`: \`number\`; \`y\`: \`number\`; \\}
Return comments
Expand Down Expand Up @@ -372,7 +372,7 @@ y: number = 2;
exports[`Objects And Params should compile function with nested parameters: (Output File Strategy "members") (Option Group "1") 1`] = `
"# Function: functionWithNestedParameters()
> **functionWithNestedParameters**(\`params\`: \\{\`name\`: \`string\`;\`nestedObj\`: \\{\`name\`: \`string\`;\`obj\`: \\{\`name\`: () => \`void\`; \\};\`value\`: \`number\`; \\};\`parent\`: \`number\`; \\}, \`context\`: \`any\`, \`somethingElse\`?: \`string\`): \`boolean\`
> **functionWithNestedParameters**(\`params\`: \\{ \`name\`: \`string\`; \`nestedObj\`: \\{ \`name\`: \`string\`; \`obj\`: \\{ \`name\`: () => \`void\`; \\}; \`value\`: \`number\`; \\}; \`parent\`: \`number\`; \\}, \`context\`: \`any\`, \`somethingElse\`?: \`string\`): \`boolean\`
Some nested params.
Expand All @@ -390,7 +390,7 @@ The name of the new group.
#### nestedObj
\\{\`name\`: \`string\`;\`obj\`: \\{\`name\`: () => \`void\`; \\};\`value\`: \`number\`; \\}
\\{ \`name\`: \`string\`; \`obj\`: \\{ \`name\`: () => \`void\`; \\}; \`value\`: \`number\`; \\}
A nested object.
Expand All @@ -400,7 +400,7 @@ A nested object.
#### nestedObj.obj
\\{\`name\`: () => \`void\`; \\}
\\{ \`name\`: () => \`void\`; \\}
#### nestedObj.obj.name
Expand Down Expand Up @@ -476,7 +476,7 @@ Some nested params.
exports[`Objects And Params should compile intersection type: (Output File Strategy "members") (Option Group "1") 1`] = `
"# Type Alias: IntersectionType
> **IntersectionType**: [\`TupleType\`](TupleType.md) & [\`ArrayType\`](ArrayType.md) & \\{\`bar\`: \`number\`; \\}
> **IntersectionType**: [\`TupleType\`](TupleType.md) & [\`ArrayType\`](ArrayType.md) & \\{ \`bar\`: \`number\`; \\}
Comments for IntersectionType
Expand Down Expand Up @@ -512,7 +512,7 @@ bar: number;
exports[`Objects And Params should compile literal type: (Output File Strategy "members") (Option Group "1") 1`] = `
"# Type Alias: LiteralType
> **LiteralType**: \\{\`someFunctionWithArrow\`: () => \`string\`;\`x\`: \`string\`;\`y\`: \\{\`x\`: \`string\`;\`y\`: \`boolean\` \\| \`string\`;\`z\`: (\`x\`: \`string\`) => \`string\`; \\};\`z\`: (\`x\`: \`string\`) => \`string\`;get set \`accessorA\`: [\`Promise\`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise)\\<\`string\`\\>;get set \`accessorB\`: \`string\`;\`someFunction\`: [\`Promise\`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise)\\<\`any\`\\>; \\}
> **LiteralType**: \\{ \`someFunctionWithArrow\`: () => \`string\`; \`x\`: \`string\`; \`y\`: \\{ \`x\`: \`string\`; \`y\`: \`boolean\` \\| \`string\`; \`z\`: (\`x\`: \`string\`) => \`string\`; \\}; \`z\`: (\`x\`: \`string\`) => \`string\`; get set \`accessorA\`: [\`Promise\`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise)\\<\`string\`\\>; get set \`accessorB\`: \`string\`; \`someFunction\`: [\`Promise\`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise)\\<\`any\`\\>; \\}
Comments for LiteralType
Expand All @@ -536,7 +536,7 @@ comment for x
### y
> **y**: \\{\`x\`: \`string\`;\`y\`: \`boolean\` \\| \`string\`;\`z\`: (\`x\`: \`string\`) => \`string\`; \\}
> **y**: \\{ \`x\`: \`string\`; \`y\`: \`boolean\` \\| \`string\`; \`z\`: (\`x\`: \`string\`) => \`string\`; \\}
comment for y
Expand Down Expand Up @@ -786,7 +786,7 @@ Comments for someFunction
exports[`Objects And Params should compile object with symbol: (Output File Strategy "members") (Option Group "1") 1`] = `
"# Variable: objectWithSymbol
> \`const\` **objectWithSymbol**: \\{\`[sym]\`: \`string\`; \\}
> \`const\` **objectWithSymbol**: \\{ \`[sym]\`: \`string\`; \\}
Comments variable with symbol
Expand Down Expand Up @@ -826,7 +826,7 @@ Comments for symbol
exports[`Objects And Params should compile union type: (Output File Strategy "members") (Option Group "1") 1`] = `
"# Type Alias: UnionType
> **UnionType**: \`string\` \\| \`boolean\` \\| \\{\`z\`: \`string\`; \\}
> **UnionType**: \`string\` \\| \`boolean\` \\| \\{ \`z\`: \`string\`; \\}
Comments for UnionType
"
Expand All @@ -848,7 +848,7 @@ Comments for UnionType
exports[`Objects And Params should compile variable assigned to an object literal: (Output File Strategy "members") (Option Group "1") 1`] = `
"# Variable: objectLiteralVariable
> \`const\` **objectLiteralVariable**: \\{\`valueA\`: \`number\`;\`valueB\`: \`boolean\`;\`valueX\`: \\{\`valueA\`: \`number\`[];\`valueY\`: (\`z\`: \`string\`) => \\{\`a\`: \`string\`;\`b\`: \`string\`;\`c\`: \\{\`a\`: \`number\`;\`b\`: \`number\`; \\}; \\};\`valueZ\`: \`string\`; \\};\`valueY\`: (\`unionParam\`: \`"a"\` \\| \`"b"\`, \`_undercoreParam_\`: \`string\`) => \`string\`; \\}
> \`const\` **objectLiteralVariable**: \\{ \`valueA\`: \`number\`; \`valueB\`: \`boolean\`; \`valueX\`: \\{ \`valueA\`: \`number\`[]; \`valueY\`: (\`z\`: \`string\`) => \\{ \`a\`: \`string\`; \`b\`: \`string\`; \`c\`: \\{ \`a\`: \`number\`; \`b\`: \`number\`; \\}; \\}; \`valueZ\`: \`string\`; \\}; \`valueY\`: (\`unionParam\`: \`"a"\` \\| \`"b"\`, \`_undercoreParam_\`: \`string\`) => \`string\`; \\}
Comments for objectLiteralVariable
Expand All @@ -870,7 +870,7 @@ Comments for valueA
### valueX
> **valueX**: \\{\`valueA\`: \`number\`[];\`valueY\`: (\`z\`: \`string\`) => \\{\`a\`: \`string\`;\`b\`: \`string\`;\`c\`: \\{\`a\`: \`number\`;\`b\`: \`number\`; \\}; \\};\`valueZ\`: \`string\`; \\}
> **valueX**: \\{ \`valueA\`: \`number\`[]; \`valueY\`: (\`z\`: \`string\`) => \\{ \`a\`: \`string\`; \`b\`: \`string\`; \`c\`: \\{ \`a\`: \`number\`; \`b\`: \`number\`; \\}; \\}; \`valueZ\`: \`string\`; \\}
Comments for valueX
Expand All @@ -882,7 +882,7 @@ Comment for valueX.valueA
#### valueX.valueY()
> **valueY**: (\`z\`: \`string\`) => \\{\`a\`: \`string\`;\`b\`: \`string\`;\`c\`: \\{\`a\`: \`number\`;\`b\`: \`number\`; \\}; \\}
> **valueY**: (\`z\`: \`string\`) => \\{ \`a\`: \`string\`; \`b\`: \`string\`; \`c\`: \\{ \`a\`: \`number\`; \`b\`: \`number\`; \\}; \\}
##### Parameters
Expand All @@ -892,7 +892,7 @@ Comment for valueX.valueA
##### Returns
\\{\`a\`: \`string\`;\`b\`: \`string\`;\`c\`: \\{\`a\`: \`number\`;\`b\`: \`number\`; \\}; \\}
\\{ \`a\`: \`string\`; \`b\`: \`string\`; \`c\`: \\{ \`a\`: \`number\`; \`b\`: \`number\`; \\}; \\}
###### a
Expand All @@ -904,7 +904,7 @@ Comment for valueX.valueA
###### c
> **c**: \\{\`a\`: \`number\`;\`b\`: \`number\`; \\}
> **c**: \\{ \`a\`: \`number\`; \`b\`: \`number\`; \\}
###### c.a
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -924,7 +924,7 @@ The name of the new group.
#### nestedObj
\\{\`name\`: \`string\`;\`obj\`: \\{\`name\`: () => \`void\`; \\};\`value\`: \`number\`; \\}
\\{ \`name\`: \`string\`; \`obj\`: \\{ \`name\`: () => \`void\`; \\}; \`value\`: \`number\`; \\}
A nested object.
Expand All @@ -934,7 +934,7 @@ A nested object.
#### nestedObj.obj
\\{\`name\`: () => \`void\`; \\}
\\{ \`name\`: () => \`void\`; \\}
#### nestedObj.obj.name
Expand Down Expand Up @@ -1268,15 +1268,15 @@ Comments for primitiveUnions
Comments for objectUnionsUseful
\\{\`a\`: \`string\`;\`b\`: \`1\`; \\} | \\{\`a\`: \`number\`;\`b\`: \`1\`;\`c\`: \\{\`x\`: \`string\`; \\}; \\}
\\{ \`a\`: \`string\`; \`b\`: \`1\`; \\} | \\{ \`a\`: \`number\`; \`b\`: \`1\`; \`c\`: \\{ \`x\`: \`string\`; \\}; \\}
### mixedUnions
Comments for mixedUnions
\`string\` | \`number\` |
\\{\`a\`: \`string\`;\`b\`: \`string\`; \\}
\\{ \`a\`: \`string\`; \`b\`: \`string\`; \\}
Comments for mixedUnions
Expand All @@ -1294,13 +1294,13 @@ b comments
|
\\{\`a\`: \\{\`y\`: \`string\`;\`z\`: \`string\`; \\}; \\}
\\{ \`a\`: \\{ \`y\`: \`string\`; \`z\`: \`string\`; \\}; \\}
Comments for mixedUnions
#### a
\\{\`y\`: \`string\`;\`z\`: \`string\`; \\}
\\{ \`y\`: \`string\`; \`z\`: \`string\`; \\}
Comments for a
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -765,7 +765,7 @@ Union with template strings
exports[`Type Alias Reflection should compile union type: (Output File Strategy "members") (Option Group "1") 1`] = `
"# Type Alias: UnionType
> **UnionType**: \`string\` \\| \`boolean\` \\| \\{\`z\`: \`string\`; \\}
> **UnionType**: \`string\` \\| \`boolean\` \\| \\{ \`z\`: \`string\`; \\}
Comments for UnionType
Expand Down Expand Up @@ -795,7 +795,7 @@ Comments for UnionType
exports[`Type Alias Reflection should compile useful union type: (Output File Strategy "members") (Option Group "1") 1`] = `
"# Type Alias: UsefulUnionType
> **UsefulUnionType**: \`string\` \\| \`boolean\` \\| \\{\`z\`: \`string\`; \\}
> **UsefulUnionType**: \`string\` \\| \`boolean\` \\| \\{ \`z\`: \`string\`; \\}
Comments for useful UnionType
Expand All @@ -805,7 +805,7 @@ Comments for useful UnionType
\`boolean\`
\\{\`z\`: \`string\`; \\}
\\{ \`z\`: \`string\`; \\}
### z
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ const originalDoubleQuote = "hello";
exports[`Utils should get variable with brackets: (Output File Strategy "members") (Option Group "1") 1`] = `
"# Variable: variableWithChars
> \`const\` **variableWithChars**: \\{\`<x>\`: \`string\`;\`<y>\`: \`string\`;\`<z>\`: \`string\`; \\}
> \`const\` **variableWithChars**: \\{ \`<x>\`: \`string\`; \`<y>\`: \`string\`; \`<z>\`: \`string\`; \\}
## Type declaration
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,6 @@ exports[`VitePress should output docs with vitepress theme 1`] = `
exports[`VitePress should output members that require anchor slugification 1`] = `
"# Interface: InterfaceA
See [InterfaceB._prop_with_underscore_](InterfaceB.md#prop-with-underscore)
See [InterfaceB.\\_prop\\_with\\_underscore\\_](InterfaceB.md#prop-with-underscore)
"
`;

0 comments on commit 05197cc

Please sign in to comment.