Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implemented '--excludeProtected' option similar to the '--excludePriv… #666

Merged
merged 2 commits into from
Dec 31, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ in order to change the behaviour of TypeDoc.
Prevent externally resolved TypeScript files from being documented.
* `--excludePrivate`<br>
Prevent private members from being included in the generated documentation.
* `--excludeProtected`<br>
Prevent protected members from being included in the generated documentation.

#### TypeScript compiler
* `--module <commonjs, amd, system or umd>`<br>
Expand Down
7 changes: 7 additions & 0 deletions src/lib/converter/converter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,13 @@ export class Converter extends ChildableComponent<Application, ConverterComponen
})
excludePrivate: boolean;

@Option({
name: 'excludeProtected',
help: 'Ignores protected variables and methods',
type: ParameterType.Boolean
})
excludeProtected: boolean;

private compilerHost: CompilerHost;

private nodeConverters: {[syntaxKind: number]: ConverterNodeComponent<ts.Node>};
Expand Down
4 changes: 3 additions & 1 deletion src/lib/converter/nodes/class.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,9 @@ export class ClassConverter extends ConverterNodeComponent<ts.ClassDeclaration>
node.members.forEach((member) => {
const modifiers = ts.getCombinedModifierFlags(member);
const privateMember = (modifiers & ts.ModifierFlags.Private) > 0;
const exclude = context.converter.excludePrivate ? privateMember : false;
const protectedMember = (modifiers & ts.ModifierFlags.Protected) > 0;
const exclude = (context.converter.excludePrivate && privateMember)
|| (context.converter.excludeProtected && protectedMember);

if (!exclude) {
this.owner.convertNode(context, member);
Expand Down
5 changes: 5 additions & 0 deletions src/lib/converter/nodes/constructor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,11 @@ export class ConstructorConverter extends ConverterNodeComponent<ts.ConstructorD
return;
}

const protectedParameter = modifiers & ts.ModifierFlags.Protected;
if (protectedParameter && context.converter.excludeProtected) {
return;
}

const property = createDeclaration(context, parameter, ReflectionKind.Property);
if (!property) {
return;
Expand Down
2 changes: 2 additions & 0 deletions src/test/renderer/specs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,8 @@ <h4 id="source-file-handling">Source file handling</h4>
Prevent externally resolved TypeScript files from being documented.</li>
<li><code>--excludePrivate</code><br>
Prevent private members from being included in the generated documentation.</li>
<li><code>--excludeProtected</code><br>
Prevent protected members from being included in the generated documentation.</li>
</ul>
<h4 id="typescript-compiler">TypeScript compiler</h4>
<ul>
Expand Down