1 | import * as tsdoc from '@microsoft/tsdoc';
|
2 | import * as tsm from 'ts-morph';
|
3 | import { getJSDocs } from './get-jsdocs';
|
4 |
|
5 | export function isInternalDeclaration({
|
6 | declaration,
|
7 | name = '',
|
8 | }: {
|
9 | declaration: tsm.Node;
|
10 | name?: string;
|
11 | }): boolean {
|
12 | return (
|
13 | name.startsWith('_') ||
|
14 | name.startsWith('#') ||
|
15 | hasPrivateModifier({ declaration }) ||
|
16 | hasInternalTagDoc({ declaration })
|
17 | );
|
18 | }
|
19 |
|
20 | function hasPrivateModifier({
|
21 | declaration,
|
22 | }: {
|
23 | declaration: tsm.Node;
|
24 | }): boolean {
|
25 | return (
|
26 | tsm.Node.isModifierable(declaration) &&
|
27 | declaration.hasModifier(tsm.SyntaxKind.PrivateKeyword)
|
28 | );
|
29 | }
|
30 |
|
31 | function hasInternalTagDoc({
|
32 | declaration,
|
33 | }: {
|
34 | declaration: tsm.Node;
|
35 | }): boolean {
|
36 | const firstDoc = getJSDocs({ declaration })[0];
|
37 | if (!firstDoc) {
|
38 | return false;
|
39 | }
|
40 |
|
41 | const parser = new tsdoc.TSDocParser();
|
42 | return parser.parseString(firstDoc).docComment.modifierTagSet.isInternal();
|
43 | }
|