From 18f24592f14fc260bbc54e87e637d114c82a76d4 Mon Sep 17 00:00:00 2001 From: Jean-Christophe Hoelt Date: Wed, 15 Jun 2022 09:14:45 +0300 Subject: [PATCH] Ignore fields with "@private" or "@ignore" in description --- src/index.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/index.ts b/src/index.ts index c659165..c906e51 100644 --- a/src/index.ts +++ b/src/index.ts @@ -191,6 +191,7 @@ function setArrayElements ( ) { const field = values.field || getDecapitalized(interfaceName) const description = values.description || field + if (shouldIgnore(description)) return newElements.push(getApiElement(values.element, `{Object[]} ${field} ${description}`)) setInterfaceElements.call(this, matchedInterface, filename, newElements, values, field) } @@ -226,6 +227,7 @@ function setInterfaceElements ( const typeEnum = getPropTypeEnum(prop) const propLabel = getPropLabel(typeEnum, propTypeName) // Set the element + if (shouldIgnore(description)) return newElements.push(getApiElement(values.element, `{${propLabel}} ${typeDef} ${description}`)) // If property is an object or interface then we need to also display the objects properties @@ -261,6 +263,7 @@ function setNativeElements ( ) { const propLabel = getCapitalized(values.interface) // Set the element + if (shouldIgnore(values.description)) return newElements.push(getApiElement(values.element, `{${propLabel}} ${values.field} ${values.description}`)) return } @@ -287,6 +290,7 @@ function setObjectElements ( if (!isUserDefinedProperty) return // We don't want to include default members in the docs const documentationComments = property.compilerSymbol.getDocumentationComment(undefined).map((node) => node.text).join() + if (shouldIgnore(documentationComments)) return const desc = documentationComments ? `\`${typeDef}.${propName}\` - ${documentationComments}` @@ -507,3 +511,7 @@ function isUserDefinedSymbol (symbol: ts.Symbol): boolean { const declarationFile = symbol.valueDeclaration.parent.getSourceFile() return definitionFilesAddedByUser[declarationFile.fileName] } + +function shouldIgnore (description: string): boolean { + return !!description && ((description.match(/(\s|^)@private(\s|$)/) !== null) || (description.match(/(\s|^)@ignore(\s|$)/) !== null)) +}