Skip to content

Commit dccb52c

Browse files
committed
fix(core): fixed spacing around inline object declarations
1 parent eba0d60 commit dccb52c

File tree

7 files changed

+41
-36
lines changed

7 files changed

+41
-36
lines changed

.changeset/twenty-pots-sort.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'typedoc-plugin-markdown': patch
3+
---
4+
5+
- Fixed spacing around inline object declarations.

packages/typedoc-plugin-markdown/src/theme/context/partials/type.reflection.declaration.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ export function declarationType(
5858
});
5959
}
6060
return types
61-
? `\\{${shouldFormat ? '\n' : ''}${types.join('')} \\}`
61+
? `\\{${shouldFormat ? `\n${types.join('')}` : ` ${types.join(' ')}`} \\}`
6262
: '\\{\\}';
6363
}
6464
return '\\{\\}';

packages/typedoc-plugin-markdown/test/specs/__snapshots__/comments.spec.ts.snap

+3-3
Original file line numberDiff line numberDiff line change
@@ -541,7 +541,7 @@ exports[`Comments should get tables for type declarations: (Output File Strategy
541541
exports[`Comments should get tables for type declarations: (Output File Strategy "members") (Option Group "2") 1`] = `
542542
"# Type Alias: TypeDeclarationTable
543543
544-
> **TypeDeclarationTable**: \\{\`declaration1\`: \`boolean\`;\`declaration2\`: \`boolean\`;\`declaration4\`: \`100\`; \\}
544+
> **TypeDeclarationTable**: \\{ \`declaration1\`: \`boolean\`; \`declaration2\`: \`boolean\`; \`declaration4\`: \`100\`; \\}
545545
546546
## Type declaration
547547
@@ -619,7 +619,7 @@ to generate the binary output for input validation.
619619
exports[`Comments should get tables for type declarations: (Output File Strategy "members") (Option Group "2") 2`] = `
620620
"# Variable: TypeDeclarationTable
621621
622-
> **TypeDeclarationTable**: \\{\`declaration1\`: \`string\`;\`declaration2\`: \`number\`; \\}
622+
> **TypeDeclarationTable**: \\{ \`declaration1\`: \`string\`; \`declaration2\`: \`number\`; \\}
623623
624624
## Type declaration
625625
@@ -707,7 +707,7 @@ Other block tags
707707
exports[`Comments should get variable with block tags: (Output File Strategy "members") (Option Group "2") 1`] = `
708708
"# Type Alias: typeWithBlockTags
709709
710-
> **typeWithBlockTags**: \\{\`x\`: \`string\`; \\}
710+
> **typeWithBlockTags**: \\{ \`x\`: \`string\`; \\}
711711
712712
Variable with block tags summary
713713

packages/typedoc-plugin-markdown/test/specs/__snapshots__/objects-and-params.spec.ts.snap

+22-22
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ Comments for prop
6363
6464
### propReturningObjectDeclaration
6565
66-
> **propReturningObjectDeclaration**: \\{\`a\`: \`boolean\`;\`b\`: \`string\`; \\}
66+
> **propReturningObjectDeclaration**: \\{ \`a\`: \`boolean\`; \`b\`: \`string\`; \\}
6767
6868
Comments for propReturningObjectDeclaration
6969
@@ -79,7 +79,7 @@ Comments for propReturningObjectDeclaration
7979
8080
### propReturningObjectDeclarations
8181
82-
> **propReturningObjectDeclarations**: \\{\`a\`: \`boolean\`;\`b\`: \`string\`; \\} & \\{\`c\`: \`boolean\`;\`d\`: \`string\`; \\}
82+
> **propReturningObjectDeclarations**: \\{ \`a\`: \`boolean\`; \`b\`: \`string\`; \\} & \\{ \`c\`: \`boolean\`; \`d\`: \`string\`; \\}
8383
8484
Comments for propReturningObjectDeclarations
8585
@@ -127,7 +127,7 @@ Comments for propReturningSignatureDeclarations
127127
128128
### propWithFunction()
129129
130-
> **propWithFunction**: (\`options\`: \\{\`a\`: \`boolean\`;\`b\`: \`string\`; \\}) => \`boolean\`
130+
> **propWithFunction**: (\`options\`: \\{ \`a\`: \`boolean\`; \`b\`: \`string\`; \\}) => \`boolean\`
131131
132132
Comments for propWithFunction
133133
@@ -151,7 +151,7 @@ Comments for propWithFunction
151151
152152
### propWithProps
153153
154-
> **propWithProps**: \\{\`callbacks\`: \`Partial\`\\<[\`CallbacksOptions\`](../classes/CallbacksOptions.md)\\<[\`DisposableClass\`](../classes/DisposableClass.md), [\`ClassWithModifiers\`](../classes/ClassWithModifiers.md)\\>\\>;\`nestedPropA\`: \`string\`;\`nestedPropB\`: \`boolean\`;\`nestedPropC\`: \\{\`nestedPropCA\`: \`string\`; \\};\`nestedPropD\`: () => \`boolean\`; \\}
154+
> **propWithProps**: \\{ \`callbacks\`: \`Partial\`\\<[\`CallbacksOptions\`](../classes/CallbacksOptions.md)\\<[\`DisposableClass\`](../classes/DisposableClass.md), [\`ClassWithModifiers\`](../classes/ClassWithModifiers.md)\\>\\>; \`nestedPropA\`: \`string\`; \`nestedPropB\`: \`boolean\`; \`nestedPropC\`: \\{ \`nestedPropCA\`: \`string\`; \\}; \`nestedPropD\`: () => \`boolean\`; \\}
155155
156156
Comments for propWithProps
157157
@@ -175,7 +175,7 @@ Comments for nestedPropB
175175
176176
#### nestedPropC
177177
178-
> **nestedPropC**: \\{\`nestedPropCA\`: \`string\`; \\}
178+
> **nestedPropC**: \\{ \`nestedPropCA\`: \`string\`; \\}
179179
180180
Comments for nestedPropC
181181
@@ -234,13 +234,13 @@ Comments for BasicInterface
234234
exports[`Objects And Params should compile function returning a promise: (Output File Strategy "members") (Option Group "1") 1`] = `
235235
"# Function: functionReturningAPromise()
236236
237-
> **functionReturningAPromise**(): [\`Promise\`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise)\\<\\{\`prop\`: \`string\`; \\}\\>
237+
> **functionReturningAPromise**(): [\`Promise\`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise)\\<\\{ \`prop\`: \`string\`; \\}\\>
238238
239239
Comments for function
240240
241241
## Returns
242242
243-
[\`Promise\`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise)\\<\\{\`prop\`: \`string\`; \\}\\>
243+
[\`Promise\`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise)\\<\\{ \`prop\`: \`string\`; \\}\\>
244244
245245
Return comments
246246
@@ -312,13 +312,13 @@ Return comments
312312
exports[`Objects And Params should compile function returning an object: (Output File Strategy "members") (Option Group "1") 1`] = `
313313
"# Function: functionReturningAnObject()
314314
315-
> **functionReturningAnObject**(): \\{\`x\`: \`number\`;\`y\`: \`number\`; \\}
315+
> **functionReturningAnObject**(): \\{ \`x\`: \`number\`; \`y\`: \`number\`; \\}
316316
317317
Comments for function
318318
319319
## Returns
320320
321-
\\{\`x\`: \`number\`;\`y\`: \`number\`; \\}
321+
\\{ \`x\`: \`number\`; \`y\`: \`number\`; \\}
322322
323323
Return comments
324324
@@ -372,7 +372,7 @@ y: number = 2;
372372
exports[`Objects And Params should compile function with nested parameters: (Output File Strategy "members") (Option Group "1") 1`] = `
373373
"# Function: functionWithNestedParameters()
374374
375-
> **functionWithNestedParameters**(\`params\`: \\{\`name\`: \`string\`;\`nestedObj\`: \\{\`name\`: \`string\`;\`obj\`: \\{\`name\`: () => \`void\`; \\};\`value\`: \`number\`; \\};\`parent\`: \`number\`; \\}, \`context\`: \`any\`, \`somethingElse\`?: \`string\`): \`boolean\`
375+
> **functionWithNestedParameters**(\`params\`: \\{ \`name\`: \`string\`; \`nestedObj\`: \\{ \`name\`: \`string\`; \`obj\`: \\{ \`name\`: () => \`void\`; \\}; \`value\`: \`number\`; \\}; \`parent\`: \`number\`; \\}, \`context\`: \`any\`, \`somethingElse\`?: \`string\`): \`boolean\`
376376
377377
Some nested params.
378378
@@ -390,7 +390,7 @@ The name of the new group.
390390
391391
#### nestedObj
392392
393-
\\{\`name\`: \`string\`;\`obj\`: \\{\`name\`: () => \`void\`; \\};\`value\`: \`number\`; \\}
393+
\\{ \`name\`: \`string\`; \`obj\`: \\{ \`name\`: () => \`void\`; \\}; \`value\`: \`number\`; \\}
394394
395395
A nested object.
396396
@@ -400,7 +400,7 @@ A nested object.
400400
401401
#### nestedObj.obj
402402
403-
\\{\`name\`: () => \`void\`; \\}
403+
\\{ \`name\`: () => \`void\`; \\}
404404
405405
#### nestedObj.obj.name
406406
@@ -476,7 +476,7 @@ Some nested params.
476476
exports[`Objects And Params should compile intersection type: (Output File Strategy "members") (Option Group "1") 1`] = `
477477
"# Type Alias: IntersectionType
478478
479-
> **IntersectionType**: [\`TupleType\`](TupleType.md) & [\`ArrayType\`](ArrayType.md) & \\{\`bar\`: \`number\`; \\}
479+
> **IntersectionType**: [\`TupleType\`](TupleType.md) & [\`ArrayType\`](ArrayType.md) & \\{ \`bar\`: \`number\`; \\}
480480
481481
Comments for IntersectionType
482482
@@ -512,7 +512,7 @@ bar: number;
512512
exports[`Objects And Params should compile literal type: (Output File Strategy "members") (Option Group "1") 1`] = `
513513
"# Type Alias: LiteralType
514514
515-
> **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\`\\>; \\}
515+
> **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\`\\>; \\}
516516
517517
Comments for LiteralType
518518
@@ -536,7 +536,7 @@ comment for x
536536
537537
### y
538538
539-
> **y**: \\{\`x\`: \`string\`;\`y\`: \`boolean\` \\| \`string\`;\`z\`: (\`x\`: \`string\`) => \`string\`; \\}
539+
> **y**: \\{ \`x\`: \`string\`; \`y\`: \`boolean\` \\| \`string\`; \`z\`: (\`x\`: \`string\`) => \`string\`; \\}
540540
541541
comment for y
542542
@@ -786,7 +786,7 @@ Comments for someFunction
786786
exports[`Objects And Params should compile object with symbol: (Output File Strategy "members") (Option Group "1") 1`] = `
787787
"# Variable: objectWithSymbol
788788
789-
> \`const\` **objectWithSymbol**: \\{\`[sym]\`: \`string\`; \\}
789+
> \`const\` **objectWithSymbol**: \\{ \`[sym]\`: \`string\`; \\}
790790
791791
Comments variable with symbol
792792
@@ -826,7 +826,7 @@ Comments for symbol
826826
exports[`Objects And Params should compile union type: (Output File Strategy "members") (Option Group "1") 1`] = `
827827
"# Type Alias: UnionType
828828
829-
> **UnionType**: \`string\` \\| \`boolean\` \\| \\{\`z\`: \`string\`; \\}
829+
> **UnionType**: \`string\` \\| \`boolean\` \\| \\{ \`z\`: \`string\`; \\}
830830
831831
Comments for UnionType
832832
"
@@ -848,7 +848,7 @@ Comments for UnionType
848848
exports[`Objects And Params should compile variable assigned to an object literal: (Output File Strategy "members") (Option Group "1") 1`] = `
849849
"# Variable: objectLiteralVariable
850850
851-
> \`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\`; \\}
851+
> \`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\`; \\}
852852
853853
Comments for objectLiteralVariable
854854
@@ -870,7 +870,7 @@ Comments for valueA
870870
871871
### valueX
872872
873-
> **valueX**: \\{\`valueA\`: \`number\`[];\`valueY\`: (\`z\`: \`string\`) => \\{\`a\`: \`string\`;\`b\`: \`string\`;\`c\`: \\{\`a\`: \`number\`;\`b\`: \`number\`; \\}; \\};\`valueZ\`: \`string\`; \\}
873+
> **valueX**: \\{ \`valueA\`: \`number\`[]; \`valueY\`: (\`z\`: \`string\`) => \\{ \`a\`: \`string\`; \`b\`: \`string\`; \`c\`: \\{ \`a\`: \`number\`; \`b\`: \`number\`; \\}; \\}; \`valueZ\`: \`string\`; \\}
874874
875875
Comments for valueX
876876
@@ -882,7 +882,7 @@ Comment for valueX.valueA
882882
883883
#### valueX.valueY()
884884
885-
> **valueY**: (\`z\`: \`string\`) => \\{\`a\`: \`string\`;\`b\`: \`string\`;\`c\`: \\{\`a\`: \`number\`;\`b\`: \`number\`; \\}; \\}
885+
> **valueY**: (\`z\`: \`string\`) => \\{ \`a\`: \`string\`; \`b\`: \`string\`; \`c\`: \\{ \`a\`: \`number\`; \`b\`: \`number\`; \\}; \\}
886886
887887
##### Parameters
888888
@@ -892,7 +892,7 @@ Comment for valueX.valueA
892892
893893
##### Returns
894894
895-
\\{\`a\`: \`string\`;\`b\`: \`string\`;\`c\`: \\{\`a\`: \`number\`;\`b\`: \`number\`; \\}; \\}
895+
\\{ \`a\`: \`string\`; \`b\`: \`string\`; \`c\`: \\{ \`a\`: \`number\`; \`b\`: \`number\`; \\}; \\}
896896
897897
###### a
898898
@@ -904,7 +904,7 @@ Comment for valueX.valueA
904904
905905
###### c
906906
907-
> **c**: \\{\`a\`: \`number\`;\`b\`: \`number\`; \\}
907+
> **c**: \\{ \`a\`: \`number\`; \`b\`: \`number\`; \\}
908908
909909
###### c.a
910910

packages/typedoc-plugin-markdown/test/specs/__snapshots__/reflection.function.spec.ts.snap

+6-6
Original file line numberDiff line numberDiff line change
@@ -924,7 +924,7 @@ The name of the new group.
924924
925925
#### nestedObj
926926
927-
\\{\`name\`: \`string\`;\`obj\`: \\{\`name\`: () => \`void\`; \\};\`value\`: \`number\`; \\}
927+
\\{ \`name\`: \`string\`; \`obj\`: \\{ \`name\`: () => \`void\`; \\}; \`value\`: \`number\`; \\}
928928
929929
A nested object.
930930
@@ -934,7 +934,7 @@ A nested object.
934934
935935
#### nestedObj.obj
936936
937-
\\{\`name\`: () => \`void\`; \\}
937+
\\{ \`name\`: () => \`void\`; \\}
938938
939939
#### nestedObj.obj.name
940940
@@ -1268,15 +1268,15 @@ Comments for primitiveUnions
12681268
12691269
Comments for objectUnionsUseful
12701270
1271-
\\{\`a\`: \`string\`;\`b\`: \`1\`; \\} | \\{\`a\`: \`number\`;\`b\`: \`1\`;\`c\`: \\{\`x\`: \`string\`; \\}; \\}
1271+
\\{ \`a\`: \`string\`; \`b\`: \`1\`; \\} | \\{ \`a\`: \`number\`; \`b\`: \`1\`; \`c\`: \\{ \`x\`: \`string\`; \\}; \\}
12721272
12731273
### mixedUnions
12741274
12751275
Comments for mixedUnions
12761276
12771277
\`string\` | \`number\` |
12781278
1279-
\\{\`a\`: \`string\`;\`b\`: \`string\`; \\}
1279+
\\{ \`a\`: \`string\`; \`b\`: \`string\`; \\}
12801280
12811281
Comments for mixedUnions
12821282
@@ -1294,13 +1294,13 @@ b comments
12941294
12951295
|
12961296
1297-
\\{\`a\`: \\{\`y\`: \`string\`;\`z\`: \`string\`; \\}; \\}
1297+
\\{ \`a\`: \\{ \`y\`: \`string\`; \`z\`: \`string\`; \\}; \\}
12981298
12991299
Comments for mixedUnions
13001300
13011301
#### a
13021302
1303-
\\{\`y\`: \`string\`;\`z\`: \`string\`; \\}
1303+
\\{ \`y\`: \`string\`; \`z\`: \`string\`; \\}
13041304
13051305
Comments for a
13061306

packages/typedoc-plugin-markdown/test/specs/__snapshots__/reflection.type-alias.spec.ts.snap

+3-3
Original file line numberDiff line numberDiff line change
@@ -765,7 +765,7 @@ Union with template strings
765765
exports[`Type Alias Reflection should compile union type: (Output File Strategy "members") (Option Group "1") 1`] = `
766766
"# Type Alias: UnionType
767767
768-
> **UnionType**: \`string\` \\| \`boolean\` \\| \\{\`z\`: \`string\`; \\}
768+
> **UnionType**: \`string\` \\| \`boolean\` \\| \\{ \`z\`: \`string\`; \\}
769769
770770
Comments for UnionType
771771
@@ -795,7 +795,7 @@ Comments for UnionType
795795
exports[`Type Alias Reflection should compile useful union type: (Output File Strategy "members") (Option Group "1") 1`] = `
796796
"# Type Alias: UsefulUnionType
797797
798-
> **UsefulUnionType**: \`string\` \\| \`boolean\` \\| \\{\`z\`: \`string\`; \\}
798+
> **UsefulUnionType**: \`string\` \\| \`boolean\` \\| \\{ \`z\`: \`string\`; \\}
799799
800800
Comments for useful UnionType
801801
@@ -805,7 +805,7 @@ Comments for useful UnionType
805805
806806
\`boolean\`
807807
808-
\\{\`z\`: \`string\`; \\}
808+
\\{ \`z\`: \`string\`; \\}
809809
810810
### z
811811

packages/typedoc-plugin-markdown/test/specs/__snapshots__/utils.spec.ts.snap

+1-1
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ const originalDoubleQuote = "hello";
205205
exports[`Utils should get variable with brackets: (Output File Strategy "members") (Option Group "1") 1`] = `
206206
"# Variable: variableWithChars
207207
208-
> \`const\` **variableWithChars**: \\{\`<x>\`: \`string\`;\`<y>\`: \`string\`;\`<z>\`: \`string\`; \\}
208+
> \`const\` **variableWithChars**: \\{ \`<x>\`: \`string\`; \`<y>\`: \`string\`; \`<z>\`: \`string\`; \\}
209209
210210
## Type declaration
211211

0 commit comments

Comments
 (0)