Skip to content

Commit

Permalink
fix(core): improve accessor output (#711)
Browse files Browse the repository at this point in the history
  • Loading branch information
tgreyuk committed Nov 1, 2024
1 parent e9dcf48 commit 9460196
Show file tree
Hide file tree
Showing 6 changed files with 167 additions and 62 deletions.
5 changes: 5 additions & 0 deletions .changeset/pink-steaks-invent.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'typedoc-plugin-markdown': patch
---

- Enhanced the formatting and structure of accessor output (#711)
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@ export function accessor(
const md: string[] = [];

if (model.getSignature) {
md.push(
heading(
options.headingLevel,
this.internationalization.proxy.kind_get_signature(),
),
);
md.push(
this.partials.signatureTitle(model.getSignature, {
accessor: 'get',
Expand All @@ -18,46 +24,60 @@ export function accessor(
if (model.getSignature.comment) {
md.push(
this.partials.comment(model.getSignature.comment, {
headingLevel: options.headingLevel,
headingLevel: options.headingLevel + 1,
}),
);
}
if (model.getSignature?.type) {
md.push(
this.partials.signatureReturns(model.getSignature, {
headingLevel: options.headingLevel + 1,
}),
);
}
}
if (model.setSignature) {
md.push(
heading(
options.headingLevel,
this.internationalization.proxy.kind_set_signature(),
),
);
md.push(
this.partials.signatureTitle(model.setSignature, {
accessor: 'set',
}),
);

if (model.setSignature.comment) {
md.push(
this.partials.comment(model.setSignature.comment, {
headingLevel: options.headingLevel,
headingLevel: options.headingLevel + 1,
}),
);
}
}

if (model.setSignature?.parameters?.length) {
md.push(
heading(
options.headingLevel,
this.internationalization.kindPluralString(ReflectionKind.Parameter),
),
);
if (this.helpers.useTableFormat('parameters')) {
md.push(this.partials.parametersTable(model.setSignature.parameters));
} else {
md.push(this.partials.parametersList(model.setSignature.parameters));
if (model.setSignature?.parameters?.length) {
md.push(
heading(
options.headingLevel + 1,
this.internationalization.kindPluralString(ReflectionKind.Parameter),
),
);
if (this.helpers.useTableFormat('parameters')) {
md.push(this.partials.parametersTable(model.setSignature.parameters));
} else {
md.push(this.partials.parametersList(model.setSignature.parameters));
}
}
}

if (model.getSignature?.type) {
md.push(
this.partials.signatureReturns(model.getSignature, {
headingLevel: options.headingLevel,
}),
);
if (model.setSignature?.type) {
md.push(
this.partials.signatureReturns(model.setSignature, {
headingLevel: options.headingLevel + 1,
}),
);
}
}

if (model.comment) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export function signatureTitle(
}

if (options?.accessor) {
md.push(backTicks(options?.accessor) + ' ');
md.push(bold(options?.accessor) + ' ');
}

if (model.parent) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -556,35 +556,51 @@ comment for y.z
### accessorA
> \`get\` **accessorA**(): [\`Promise\`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise)\\<\`string\`\\>
#### Get Signature
> **get** **accessorA**(): [\`Promise\`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise)\\<\`string\`\\>
Comments for accessorA getter
> \`set\` **accessorA**(\`x\`: [\`Promise\`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise)\\<\`string\`\\>): \`void\`
##### Returns
[\`Promise\`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise)\\<\`string\`\\>
#### Set Signature
> **set** **accessorA**(\`x\`: [\`Promise\`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise)\\<\`string\`\\>): \`void\`
Comments for accessorA setter
#### Parameters
##### Parameters
• **x**: [\`Promise\`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise)\\<\`string\`\\>
#### Returns
##### Returns
[\`Promise\`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise)\\<\`string\`\\>
\`void\`
### accessorB
> \`get\` **accessorB**(): \`string\`
#### Get Signature
> \`set\` **accessorB**(\`x\`: \`string\`): \`void\`
> **get** **accessorB**(): \`string\`
#### Parameters
##### Returns
\`string\`
#### Set Signature
> **set** **accessorB**(\`x\`: \`string\`): \`void\`
##### Parameters
• **x**: \`string\`
#### Returns
##### Returns
\`string\`
\`void\`
### someFunction()
Expand Down Expand Up @@ -707,47 +723,63 @@ z: (x: string) => string;
### accessorA
#### Get Signature
\`\`\`ts
get accessorA(): Promise<string>
\`\`\`
Comments for accessorA getter
##### Returns
[\`Promise\`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise)\\<\`string\`\\>
#### Set Signature
\`\`\`ts
set accessorA(x: Promise<string>): void
\`\`\`
Comments for accessorA setter
#### Parameters
##### Parameters
| Parameter | Type |
| :------ | :------ |
| \`x\` | [\`Promise\`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise)\\<\`string\`\\> |
#### Returns
##### Returns
[\`Promise\`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise)\\<\`string\`\\>
\`void\`
### accessorB
#### Get Signature
\`\`\`ts
get accessorB(): string
\`\`\`
##### Returns
\`string\`
#### Set Signature
\`\`\`ts
set accessorB(x: string): void
\`\`\`
#### Parameters
##### Parameters
| Parameter | Type |
| :------ | :------ |
| \`x\` | \`string\` |
#### Returns
##### Returns
\`string\`
\`void\`
### someFunction()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -266,23 +266,31 @@ Comments for ClassWithAccessors
### accessor
> \`get\` **accessor**(): \`string\`
#### Get Signature
> **get** **accessor**(): \`string\`
Comments for getter
> \`set\` **accessor**(\`value\`): \`void\`
##### Returns
\`string\`
#### Set Signature
> **set** **accessor**(\`value\`): \`void\`
Comments for setter
#### Parameters
##### Parameters
• **value**: \`string\`
Param comments
#### Returns
##### Returns
\`string\`
\`void\`
#### Source
Expand All @@ -292,12 +300,18 @@ Param comments
### noGetter
> \`set\` **noGetter**(\`x\`): \`void\`
#### Set Signature
#### Parameters
> **set** **noGetter**(\`x\`): \`void\`
##### Parameters
• **x**: \`string\`
##### Returns
\`void\`
#### Source
[classes.ts:1](http://source-url)
Expand All @@ -306,9 +320,11 @@ Param comments
### noSetter
> \`get\` **noSetter**(): \`string\`
#### Get Signature
#### Returns
> **get** **noSetter**(): \`string\`
##### Returns
\`string\`
Expand Down Expand Up @@ -345,27 +361,35 @@ new ClassWithAccessors(): ClassWithAccessors
### accessor
#### Get Signature
\`\`\`ts
get accessor(): string
\`\`\`
Comments for getter
##### Returns
\`string\`
#### Set Signature
\`\`\`ts
set accessor(value: string): void
\`\`\`
Comments for setter
#### Parameters
##### Parameters
| Parameter | Type | Description |
| :------ | :------ | :------ |
| \`value\` | \`string\` | Param comments |
#### Returns
##### Returns
\`string\`
\`void\`
#### Source
Expand All @@ -375,16 +399,22 @@ Comments for setter
### noGetter
#### Set Signature
\`\`\`ts
set noGetter(x: string): void
\`\`\`
#### Parameters
##### Parameters
| Parameter | Type |
| :------ | :------ |
| \`x\` | \`string\` |
##### Returns
\`void\`
#### Source
[classes.ts:1](http://source-url)
Expand All @@ -393,11 +423,13 @@ set noGetter(x: string): void
### noSetter
#### Get Signature
\`\`\`ts
get noSetter(): string
\`\`\`
#### Returns
##### Returns
\`string\`
Expand Down
Loading

0 comments on commit 9460196

Please sign in to comment.