Skip to content

Commit

Permalink
fix(core): expose comments to reflections with the accessor keyword (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
tgreyuk committed Aug 8, 2024
1 parent d22ab49 commit 2e1ef74
Show file tree
Hide file tree
Showing 9 changed files with 100 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/flat-grapes-cheer.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'typedoc-plugin-markdown': patch
---

- Expose comments to reflections with the accessor keyword (#664)
2 changes: 1 addition & 1 deletion devtools/packages/fixtures/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ export function writeHtml(key: string, entryPoints: string[]) {
'-options',
path.join(__dirname, 'typedoc.cjs'),
'-logLevel',
'Warn',
'None',
'-out',
fullPath,
'-readme',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,11 @@ export function comment(
const tags = blockTags
.filter((tag) => !filteredBlockTags.includes(tag.tag))
.filter((tag) => {
if (!opts.isTableColumn && blockTagsPreserveOrder.length) {
if (
!opts.isTableColumn &&
!(opts.showSummary && opts.showTags) &&
blockTagsPreserveOrder.length
) {
return opts.showSummary
? blockTagsPreserveOrder.includes(tag.tag)
: !blockTagsPreserveOrder.includes(tag.tag);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,14 @@ export function accessor(
);
}

if (model.comment?.blockTags?.length) {
md.push(
this.partials.comment(model.comment, {
headingLevel: options.headingLevel,
}),
);
}

md.push(
this.partials.inheritance(model, { headingLevel: options.headingLevel }),
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -262,3 +262,23 @@ export class ClassWithoutPropCategories {
method1(): void {}
method2(): void {}
}

export class ClassWithAccessorKeywords {
/**
* Accessor comments
*
* @example
* ```ts
* const x = 1;
* ```
*/

public accessor accessor1: string;

/**
* Accessor comments
*
* @remarks Remark comments
*/
public accessor accessor2: string;
}
Original file line number Diff line number Diff line change
Expand Up @@ -4083,6 +4083,11 @@ exports[`Navigation should gets Navigation Json for single entry point: (Output
"kind": 128,
"path": "classes/ChildClassB.md"
},
{
"title": "ClassWithAccessorKeywords",
"kind": 128,
"path": "classes/ClassWithAccessorKeywords.md"
},
{
"title": "ClassWithAccessors",
"kind": 128,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,51 @@ Comments for method
"
`;

exports[`Class Reflection should compile class with accessor keywords: (Output File Strategy "members") (Option Group "1") 1`] = `
"# Class: ClassWithAccessorKeywords
## Constructors
### new ClassWithAccessorKeywords()
> **new ClassWithAccessorKeywords**(): [\`ClassWithAccessorKeywords\`](ClassWithAccessorKeywords.md)
#### Returns
[\`ClassWithAccessorKeywords\`](ClassWithAccessorKeywords.md)
## Accessors
### accessor1
Accessor comments
#### Example
\`\`\`ts
const x = 1;
\`\`\`
#### Source
[classes.ts:1](http://source-url)
***
### accessor2
Accessor comments
#### Remarks
Remark comments
#### Source
[classes.ts:1](http://source-url)
"
`;

exports[`Class Reflection should compile class with accessors: (Output File Strategy "members") (Option Group "1") 1`] = `
"# Class: ClassWithAccessors
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -781,6 +781,7 @@ exports[`Urls should gets Urls for single entry points: outputFileStrategy: memb
"classes/CallbacksOptions.md",
"classes/ChildClassA.md",
"classes/ChildClassB.md",
"classes/ClassWithAccessorKeywords.md",
"classes/ClassWithAccessors.md",
"classes/ClassWithComplexProps.md",
"classes/ClassWithConstructorOverloads.md",
Expand Down Expand Up @@ -861,6 +862,7 @@ exports[`Urls should gets Urls for single entry points: outputFileStrategy: memb
"classes/CallbacksOptions.md",
"classes/ChildClassA.md",
"classes/ChildClassB.md",
"classes/ClassWithAccessorKeywords.md",
"classes/ClassWithAccessors.md",
"classes/ClassWithComplexProps.md",
"classes/ClassWithConstructorOverloads.md",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,4 +117,13 @@ describe(`Class Reflection`, () => {
1,
);
});

test(`should compile class with accessor keywords`, () => {
expectFileToEqual(
'reflections',
'members',
'classes/ClassWithAccessorKeywords.md',
1,
);
});
});

0 comments on commit 2e1ef74

Please sign in to comment.