From 83e3bb899ed88c8ac32331d2f1b533e52d5ad8cd Mon Sep 17 00:00:00 2001 From: Fabio Berger Date: Tue, 14 Aug 2018 17:41:03 -0700 Subject: Move purging private underscored items to the doc json generation phase --- .../src/utils/doc_generate_and_upload_utils.ts | 31 +++++++++++++--------- 1 file changed, 19 insertions(+), 12 deletions(-) (limited to 'packages/monorepo-scripts/src/utils/doc_generate_and_upload_utils.ts') diff --git a/packages/monorepo-scripts/src/utils/doc_generate_and_upload_utils.ts b/packages/monorepo-scripts/src/utils/doc_generate_and_upload_utils.ts index 187358421..2bc5441fc 100644 --- a/packages/monorepo-scripts/src/utils/doc_generate_and_upload_utils.ts +++ b/packages/monorepo-scripts/src/utils/doc_generate_and_upload_utils.ts @@ -143,7 +143,10 @@ export async function generateAndUploadDocsAsync(packageName: string, isStaging: } }); - // For each entry, see if it was exported in index.ts. If not, remove it. + // For each entry, remove it if: + // - it was not exported in index.ts + // - the constructor is to be ignored + // - it begins with an underscore const exportPathToTypedocNames: ExportNameToTypedocNames = {}; _.each(typedocOutput.children, (file, i) => { const exportPath = findExportPathGivenTypedocName(exportPathToExportedItems, packageName, file.name); @@ -155,18 +158,22 @@ export async function generateAndUploadDocsAsync(packageName: string, isStaging: _.each(file.children, (child, j) => { if (!_.includes(exportItems, child.name)) { delete finalTypeDocOutput.children[i].children[j]; + return; } - if (child.kindString === 'Class' && _.includes(CLASSES_WITH_HIDDEN_CONSTRUCTORS, child.name)) { - const classChildren = typedocOutput.children[i].children[j].children; - _.each(classChildren, (classChild, k) => { - if (classChild.kindString === 'Constructor') { - delete finalTypeDocOutput.children[i].children[j].children[k]; - finalTypeDocOutput.children[i].children[j].children = _.compact( - finalTypeDocOutput.children[i].children[j].children, - ); - } - }); - } + const innerChildren = typedocOutput.children[i].children[j].children; + _.each(innerChildren, (innerChild, k) => { + const isHiddenConstructor = + child.kindString === 'Class' && + _.includes(CLASSES_WITH_HIDDEN_CONSTRUCTORS, child.name) && + innerChild.kindString === 'Constructor'; + const isPrivate = _.startsWith(innerChild.name, '_'); + if (isHiddenConstructor || isPrivate) { + delete finalTypeDocOutput.children[i].children[j].children[k]; + finalTypeDocOutput.children[i].children[j].children = _.compact( + finalTypeDocOutput.children[i].children[j].children, + ); + } + }); }); finalTypeDocOutput.children[i].children = _.compact(finalTypeDocOutput.children[i].children); }); -- cgit v1.2.3