Skip to content

Commit

Permalink
feat(app): JSDoc tag @internal correct support
Browse files Browse the repository at this point in the history
fix #1101
  • Loading branch information
vogloblinsky committed Feb 9, 2022
1 parent bd28dd0 commit 18da1fe
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 17 deletions.
14 changes: 7 additions & 7 deletions src/app/compiler/angular-dependencies.ts
Expand Up @@ -14,7 +14,7 @@ import ImportsUtil from '../../utils/imports.util';

import {
getModuleWithProviders,
isIgnore,
isIgnoreOrInternal,
isModuleWithProviders,
JsdocParserUtil
} from '../../utils';
Expand Down Expand Up @@ -623,7 +623,7 @@ export class AngularDependencies extends FrameworkDependencies {
file: file
};

if (!isIgnore(node)) {
if (!isIgnoreOrInternal(node)) {
this.debug(enumDeps);
outputSymbols.miscellaneous.enumerations.push(enumDeps);
}
Expand Down Expand Up @@ -660,7 +660,7 @@ export class AngularDependencies extends FrameworkDependencies {
);
}

if (!isIgnore(node)) {
if (!isIgnoreOrInternal(node)) {
outputSymbols.miscellaneous.typealiases.push(typeAliasDeps);
}

Expand Down Expand Up @@ -814,7 +814,7 @@ export class AngularDependencies extends FrameworkDependencies {
);
RouterParserUtil.addModule(name, [routingInitializer]);
}
if (!isIgnore(variableNode)) {
if (!isIgnoreOrInternal(variableNode)) {
this.debug(deps);
outputSymbols.miscellaneous.variables.push(deps);
}
Expand Down Expand Up @@ -849,7 +849,7 @@ export class AngularDependencies extends FrameworkDependencies {
: undefined;
}

if (!isIgnore(destructuredVariables[i])) {
if (!isIgnoreOrInternal(destructuredVariables[i])) {
this.debug(deps);
outputSymbols.miscellaneous.variables.push(deps);
}
Expand Down Expand Up @@ -884,7 +884,7 @@ export class AngularDependencies extends FrameworkDependencies {
) {
deps.rawtype = srcFile.text.substring(node.type.pos, node.type.end);
}
if (!isIgnore(node)) {
if (!isIgnoreOrInternal(node)) {
this.debug(deps);
outputSymbols.miscellaneous.typealiases.push(deps);
}
Expand Down Expand Up @@ -940,7 +940,7 @@ export class AngularDependencies extends FrameworkDependencies {
this.visitEnumTypeAliasFunctionDeclarationDescription(node),
file: file
};
if (!isIgnore(node)) {
if (!isIgnoreOrInternal(node)) {
this.debug(enumDeps);
outputSymbols.miscellaneous.enumerations.push(enumDeps);
}
Expand Down
14 changes: 9 additions & 5 deletions src/app/compiler/angular/deps/helpers/class-helper.ts
Expand Up @@ -5,7 +5,7 @@ import { ts, SyntaxKind } from 'ts-morph';
import { getNamesCompareFn, mergeTagsAndArgs, markedtags } from '../../../../../utils/utils';
import { kindToType } from '../../../../../utils/kind-to-type';
import { JsdocParserUtil } from '../../../../../utils/jsdoc-parser.util';
import { isIgnore } from '../../../../../utils';
import { isIgnoreOrInternal } from '../../../../../utils';
import AngularVersionUtil from '../../../../..//utils/angular-version.util';
import BasicTypeUtil from '../../../../../utils/basic-type.util';
import { StringifyObjectLiteralExpression } from '../../../../../utils/object-literal-expression.util';
Expand Down Expand Up @@ -478,7 +478,7 @@ export class ClassHelper {
const comment = this.jsdocParserUtil.getMainCommentOfNode(classDeclaration, sourceFile);
rawdescription = this.jsdocParserUtil.parseComment(comment);
description = marked(rawdescription);
if (symbol.valueDeclaration && isIgnore(symbol.valueDeclaration)) {
if (symbol.valueDeclaration && isIgnoreOrInternal(symbol.valueDeclaration)) {
return [{ ignore: true }];
}
if (symbol.declarations && symbol.declarations.length > 0) {
Expand All @@ -493,7 +493,7 @@ export class ClassHelper {
deprecated = deprecation.deprecated;
deprecationMessage = deprecation.deprecationMessage;
}
if (isIgnore(symbol.declarations[0])) {
if (isIgnoreOrInternal(symbol.declarations[0])) {
return [{ ignore: true }];
}
}
Expand Down Expand Up @@ -721,7 +721,7 @@ export class ClassHelper {

kind = member.kind;

if (isIgnore(member)) {
if (isIgnoreOrInternal(member)) {
continue;
}

Expand Down Expand Up @@ -1215,7 +1215,11 @@ export class ClassHelper {
let i = 0;
let len = constr.parameters.length;
for (i; i < len; i++) {
if (this.isPublic(constr.parameters[i])) {
const parameterOfConstructor = constr.parameters[i];
if (isIgnoreOrInternal(parameterOfConstructor)) {
continue;
}
if (this.isPublic(parameterOfConstructor)) {
_parameters.push(this.visitProperty(constr.parameters[i], sourceFile));
}
}
Expand Down
7 changes: 5 additions & 2 deletions src/utils/utils.ts
Expand Up @@ -162,12 +162,15 @@ export function getNamesCompareFn(name?) {
return t;
}

export function isIgnore(member): boolean {
export function isIgnoreOrInternal(member): boolean {
if (member.jsDoc) {
for (const doc of member.jsDoc) {
if (doc.tags) {
for (const tag of doc.tags) {
if (tag.tagName.text.indexOf('ignore') > -1) {
if (
tag.tagName.text.indexOf('ignore') > -1 ||
tag.tagName.text.indexOf('internal') > -1
) {
return true;
}
}
Expand Down
Expand Up @@ -39,7 +39,13 @@ export class FooterComponent {
*
* @param {TodoStore} todoStore A TodoStore
*/
constructor(todoStore: TodoStore) {
constructor(
todoStore: TodoStore,
/**
* @internal
*/
public internalConstructorProp: string = ''
) {
this.todoStore = todoStore;
}

Expand Down Expand Up @@ -85,6 +91,11 @@ export class FooterComponent {
*/
@Input() ignoredInput: string;

/**
* @internal
*/
@Input() internalInput: string;

/**
* @ignore
*/
Expand Down
Expand Up @@ -4,8 +4,8 @@ import { temporaryDir, shell, pkg, exists, exec, read, shellAsync } from '../hel
const expect = chai.expect;
const tmp = temporaryDir();

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

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

it('Component input @internal ignored', () => {
const file = read(distFolder + '/components/FooterComponent.html');
expect(file).to.not.contain('<code>internalInput');
});

it('Component internal constructor property ignored', () => {
const file = read(distFolder + '/components/FooterComponent.html');
expect(file).to.not.contain('<b>internalConstructorProp</b>');
});

it('Component output ignored', () => {
const file = read(distFolder + '/components/FooterComponent.html');
expect(file).to.not.contain('<code>ignoredOutput');
Expand Down

0 comments on commit 18da1fe

Please sign in to comment.