From 0523c373d5796336236508a8b8c754ed86f93d43 Mon Sep 17 00:00:00 2001 From: Shabbir Bhojani Date: Wed, 20 Dec 2017 20:36:48 +0500 Subject: [PATCH 1/2] Implemented '--excludeProtected' option similar to the '--excludePrivate' option. --- README.md | 2 ++ src/lib/converter/converter.ts | 7 +++++++ src/lib/converter/nodes/class.ts | 4 +++- src/lib/converter/nodes/constructor.ts | 5 +++++ src/test/renderer/specs/index.html | 2 ++ 5 files changed, 19 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 997aa1617..ca225f4f9 100644 --- a/README.md +++ b/README.md @@ -67,6 +67,8 @@ in order to change the behaviour of TypeDoc. Prevent externally resolved TypeScript files from being documented. * `--excludePrivate`
Prevent private members from being included in the generated documentation. +* `--excludeProtected`
+ Prevent protected members from being included in the generated documentation. #### TypeScript compiler * `--module `
diff --git a/src/lib/converter/converter.ts b/src/lib/converter/converter.ts index 7fd642260..625c2f7f3 100644 --- a/src/lib/converter/converter.ts +++ b/src/lib/converter/converter.ts @@ -74,6 +74,13 @@ export class Converter extends ChildableComponent}; diff --git a/src/lib/converter/nodes/class.ts b/src/lib/converter/nodes/class.ts index 30a092f99..cdddb8b88 100644 --- a/src/lib/converter/nodes/class.ts +++ b/src/lib/converter/nodes/class.ts @@ -40,7 +40,9 @@ export class ClassConverter extends ConverterNodeComponent 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; + let exclude = context.converter.excludePrivate ? privateMember : false; + exclude = exclude || (context.converter.excludeProtected ? protectedMember : false); if (!exclude) { this.owner.convertNode(context, member); diff --git a/src/lib/converter/nodes/constructor.ts b/src/lib/converter/nodes/constructor.ts index 06f931301..341926b6f 100644 --- a/src/lib/converter/nodes/constructor.ts +++ b/src/lib/converter/nodes/constructor.ts @@ -73,6 +73,11 @@ export class ConstructorConverter extends ConverterNodeComponentSource file handling Prevent externally resolved TypeScript files from being documented.
  • --excludePrivate
    Prevent private members from being included in the generated documentation.
  • +
  • --excludeProtected
    + Prevent protected members from being included in the generated documentation.
  • TypeScript compiler

      From f990bb07a44a2bd8427ad6fb13822c7ff1677993 Mon Sep 17 00:00:00 2001 From: aciccarello Date: Sun, 31 Dec 2017 15:05:03 -0700 Subject: [PATCH 2/2] adjust exclude protected logic --- src/lib/converter/nodes/class.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/lib/converter/nodes/class.ts b/src/lib/converter/nodes/class.ts index cdddb8b88..66d13be6f 100644 --- a/src/lib/converter/nodes/class.ts +++ b/src/lib/converter/nodes/class.ts @@ -41,8 +41,8 @@ export class ClassConverter extends ConverterNodeComponent const modifiers = ts.getCombinedModifierFlags(member); const privateMember = (modifiers & ts.ModifierFlags.Private) > 0; const protectedMember = (modifiers & ts.ModifierFlags.Protected) > 0; - let exclude = context.converter.excludePrivate ? privateMember : false; - exclude = exclude || (context.converter.excludeProtected ? protectedMember : false); + const exclude = (context.converter.excludePrivate && privateMember) + || (context.converter.excludeProtected && protectedMember); if (!exclude) { this.owner.convertNode(context, member);