Skip to content

Commit c54f850

Browse files
committed
feat: exclude interface properties with the @exclude-docs annotation from ArgTypes
1 parent a425ee4 commit c54f850

File tree

4 files changed

+26
-2
lines changed

4 files changed

+26
-2
lines changed

packages/angular-demo/src/app/app.component.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ export class AppComponent {
2323
amount: 5.99,
2424
unit: '€',
2525
},
26+
hiddenProperty: '',
2627
};
2728

2829
/**

packages/angular-demo/src/app/stories/interface.mdx

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,20 @@ Interfaces need to be annotated with `@include-docs` for the type information to
1515
>
1616
> Add at least one **used** constant or function declaration to the file containing the interface.
1717
18+
To exclude certain properties, annotate them with the `@exclude-docs` annotation:
19+
20+
```typescript
21+
/**
22+
* @include-docs Product
23+
*/
24+
export interface Product {
25+
/**
26+
* @exclude-docs
27+
*/
28+
hiddenProperty: unknown;
29+
}
30+
```
31+
1832
<ArgTypes of="Product" />
1933

2034
## Aliases

packages/angular-demo/src/app/types.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,11 @@ export interface Item {
3131
description?: string;
3232
size?: Size3;
3333
meta?: object;
34+
35+
/**
36+
* @exclude-docs
37+
*/
38+
hiddenProperty: unknown;
3439
}
3540

3641
export interface Size3 extends Size2 {

packages/storybook-webpack-angular-types-plugin/src/lib/webpack-angular-types-plugin/type-extraction/interface-type-extraction.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { EntitiesByCategory, Entity, InterfaceInformation } from '../../types';
22
import { InterfaceDeclaration } from 'ts-morph';
3-
import { groupBy } from '../utils';
4-
import { collectBaseInterfaces, getJsDocsIncludeDocsAliases } from './ast-utils';
3+
import { EXCLUDE_DOCS_JS_DOCS_PARAM, groupBy } from '../utils';
4+
import { collectBaseInterfaces, getJsDocsIncludeDocsAliases, hasJsDocsTag } from './ast-utils';
55
import { mapSignatureToEntity } from './signature-mappers';
66
import { getterOrSetterInputExists, mergeEntities } from './utils';
77

@@ -17,6 +17,10 @@ function getInterfaceEntities(
1717
const entities = new Map<string, Entity>();
1818

1919
for (const signature of [...properties, ...methods]) {
20+
if (hasJsDocsTag(signature, EXCLUDE_DOCS_JS_DOCS_PARAM)) {
21+
continue;
22+
}
23+
2024
// do not include the property if it passes the exclusion test
2125
if (propertiesToExclude?.test(signature.getName())) {
2226
continue;

0 commit comments

Comments
 (0)