Skip to content

Commit 18da1fe

Browse files
committed
feat(app): JSDoc tag @internal correct support
fix #1101
1 parent bd28dd0 commit 18da1fe

File tree

5 files changed

+45
-17
lines changed

5 files changed

+45
-17
lines changed

src/app/compiler/angular-dependencies.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import ImportsUtil from '../../utils/imports.util';
1414

1515
import {
1616
getModuleWithProviders,
17-
isIgnore,
17+
isIgnoreOrInternal,
1818
isModuleWithProviders,
1919
JsdocParserUtil
2020
} from '../../utils';
@@ -623,7 +623,7 @@ export class AngularDependencies extends FrameworkDependencies {
623623
file: file
624624
};
625625

626-
if (!isIgnore(node)) {
626+
if (!isIgnoreOrInternal(node)) {
627627
this.debug(enumDeps);
628628
outputSymbols.miscellaneous.enumerations.push(enumDeps);
629629
}
@@ -660,7 +660,7 @@ export class AngularDependencies extends FrameworkDependencies {
660660
);
661661
}
662662

663-
if (!isIgnore(node)) {
663+
if (!isIgnoreOrInternal(node)) {
664664
outputSymbols.miscellaneous.typealiases.push(typeAliasDeps);
665665
}
666666

@@ -814,7 +814,7 @@ export class AngularDependencies extends FrameworkDependencies {
814814
);
815815
RouterParserUtil.addModule(name, [routingInitializer]);
816816
}
817-
if (!isIgnore(variableNode)) {
817+
if (!isIgnoreOrInternal(variableNode)) {
818818
this.debug(deps);
819819
outputSymbols.miscellaneous.variables.push(deps);
820820
}
@@ -849,7 +849,7 @@ export class AngularDependencies extends FrameworkDependencies {
849849
: undefined;
850850
}
851851

852-
if (!isIgnore(destructuredVariables[i])) {
852+
if (!isIgnoreOrInternal(destructuredVariables[i])) {
853853
this.debug(deps);
854854
outputSymbols.miscellaneous.variables.push(deps);
855855
}
@@ -884,7 +884,7 @@ export class AngularDependencies extends FrameworkDependencies {
884884
) {
885885
deps.rawtype = srcFile.text.substring(node.type.pos, node.type.end);
886886
}
887-
if (!isIgnore(node)) {
887+
if (!isIgnoreOrInternal(node)) {
888888
this.debug(deps);
889889
outputSymbols.miscellaneous.typealiases.push(deps);
890890
}
@@ -940,7 +940,7 @@ export class AngularDependencies extends FrameworkDependencies {
940940
this.visitEnumTypeAliasFunctionDeclarationDescription(node),
941941
file: file
942942
};
943-
if (!isIgnore(node)) {
943+
if (!isIgnoreOrInternal(node)) {
944944
this.debug(enumDeps);
945945
outputSymbols.miscellaneous.enumerations.push(enumDeps);
946946
}

src/app/compiler/angular/deps/helpers/class-helper.ts

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { ts, SyntaxKind } from 'ts-morph';
55
import { getNamesCompareFn, mergeTagsAndArgs, markedtags } from '../../../../../utils/utils';
66
import { kindToType } from '../../../../../utils/kind-to-type';
77
import { JsdocParserUtil } from '../../../../../utils/jsdoc-parser.util';
8-
import { isIgnore } from '../../../../../utils';
8+
import { isIgnoreOrInternal } from '../../../../../utils';
99
import AngularVersionUtil from '../../../../..//utils/angular-version.util';
1010
import BasicTypeUtil from '../../../../../utils/basic-type.util';
1111
import { StringifyObjectLiteralExpression } from '../../../../../utils/object-literal-expression.util';
@@ -478,7 +478,7 @@ export class ClassHelper {
478478
const comment = this.jsdocParserUtil.getMainCommentOfNode(classDeclaration, sourceFile);
479479
rawdescription = this.jsdocParserUtil.parseComment(comment);
480480
description = marked(rawdescription);
481-
if (symbol.valueDeclaration && isIgnore(symbol.valueDeclaration)) {
481+
if (symbol.valueDeclaration && isIgnoreOrInternal(symbol.valueDeclaration)) {
482482
return [{ ignore: true }];
483483
}
484484
if (symbol.declarations && symbol.declarations.length > 0) {
@@ -493,7 +493,7 @@ export class ClassHelper {
493493
deprecated = deprecation.deprecated;
494494
deprecationMessage = deprecation.deprecationMessage;
495495
}
496-
if (isIgnore(symbol.declarations[0])) {
496+
if (isIgnoreOrInternal(symbol.declarations[0])) {
497497
return [{ ignore: true }];
498498
}
499499
}
@@ -721,7 +721,7 @@ export class ClassHelper {
721721

722722
kind = member.kind;
723723

724-
if (isIgnore(member)) {
724+
if (isIgnoreOrInternal(member)) {
725725
continue;
726726
}
727727

@@ -1215,7 +1215,11 @@ export class ClassHelper {
12151215
let i = 0;
12161216
let len = constr.parameters.length;
12171217
for (i; i < len; i++) {
1218-
if (this.isPublic(constr.parameters[i])) {
1218+
const parameterOfConstructor = constr.parameters[i];
1219+
if (isIgnoreOrInternal(parameterOfConstructor)) {
1220+
continue;
1221+
}
1222+
if (this.isPublic(parameterOfConstructor)) {
12191223
_parameters.push(this.visitProperty(constr.parameters[i], sourceFile));
12201224
}
12211225
}

src/utils/utils.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -162,12 +162,15 @@ export function getNamesCompareFn(name?) {
162162
return t;
163163
}
164164

165-
export function isIgnore(member): boolean {
165+
export function isIgnoreOrInternal(member): boolean {
166166
if (member.jsDoc) {
167167
for (const doc of member.jsDoc) {
168168
if (doc.tags) {
169169
for (const tag of doc.tags) {
170-
if (tag.tagName.text.indexOf('ignore') > -1) {
170+
if (
171+
tag.tagName.text.indexOf('ignore') > -1 ||
172+
tag.tagName.text.indexOf('internal') > -1
173+
) {
171174
return true;
172175
}
173176
}

test/fixtures/todomvc-ng2-ignore/src/app/footer/footer.component.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,13 @@ export class FooterComponent {
3939
*
4040
* @param {TodoStore} todoStore A TodoStore
4141
*/
42-
constructor(todoStore: TodoStore) {
42+
constructor(
43+
todoStore: TodoStore,
44+
/**
45+
* @internal
46+
*/
47+
public internalConstructorProp: string = ''
48+
) {
4349
this.todoStore = todoStore;
4450
}
4551

@@ -85,6 +91,11 @@ export class FooterComponent {
8591
*/
8692
@Input() ignoredInput: string;
8793

94+
/**
95+
* @internal
96+
*/
97+
@Input() internalInput: string;
98+
8899
/**
89100
* @ignore
90101
*/

test/src/cli/cli-ignore.spec.ts renamed to test/src/cli/cli-ignore-internal.spec.ts

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ import { temporaryDir, shell, pkg, exists, exec, read, shellAsync } from '../hel
44
const expect = chai.expect;
55
const tmp = temporaryDir();
66

7-
describe('CLI ignore JSDoc tag support', () => {
8-
const distFolder = tmp.name + '-ignore-jsdoc';
7+
describe('CLI ignore/internal JSDoc tag support', () => {
8+
const distFolder = tmp.name + '-ignore-internal-jsdoc';
99

1010
describe('without --disableLifeCycleHooks', () => {
1111
before(done => {
@@ -46,6 +46,16 @@ describe('CLI ignore JSDoc tag support', () => {
4646
expect(file).to.not.contain('<code>ignoredInput');
4747
});
4848

49+
it('Component input @internal ignored', () => {
50+
const file = read(distFolder + '/components/FooterComponent.html');
51+
expect(file).to.not.contain('<code>internalInput');
52+
});
53+
54+
it('Component internal constructor property ignored', () => {
55+
const file = read(distFolder + '/components/FooterComponent.html');
56+
expect(file).to.not.contain('<b>internalConstructorProp</b>');
57+
});
58+
4959
it('Component output ignored', () => {
5060
const file = read(distFolder + '/components/FooterComponent.html');
5161
expect(file).to.not.contain('<code>ignoredOutput');

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy