Move purging private underscored items to the doc json generation phase

This commit is contained in:
Fabio Berger 2018-08-14 17:41:03 -07:00
parent cb5d8d75bf
commit 83e3bb899e
4 changed files with 27 additions and 30 deletions

View File

@ -61,8 +61,6 @@ export {
ErrorCallback, ErrorCallback,
} from '@0xproject/subproviders'; } from '@0xproject/subproviders';
export { Web3Wrapper, NodeType } from '@0xproject/web3-wrapper';
export { AbiDecoder } from '@0xproject/utils'; export { AbiDecoder } from '@0xproject/utils';
export { BigNumber } from '@0xproject/utils'; export { BigNumber } from '@0xproject/utils';

View File

@ -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 = {}; const exportPathToTypedocNames: ExportNameToTypedocNames = {};
_.each(typedocOutput.children, (file, i) => { _.each(typedocOutput.children, (file, i) => {
const exportPath = findExportPathGivenTypedocName(exportPathToExportedItems, packageName, file.name); const exportPath = findExportPathGivenTypedocName(exportPathToExportedItems, packageName, file.name);
@ -155,18 +158,22 @@ export async function generateAndUploadDocsAsync(packageName: string, isStaging:
_.each(file.children, (child, j) => { _.each(file.children, (child, j) => {
if (!_.includes(exportItems, child.name)) { if (!_.includes(exportItems, child.name)) {
delete finalTypeDocOutput.children[i].children[j]; delete finalTypeDocOutput.children[i].children[j];
return;
} }
if (child.kindString === 'Class' && _.includes(CLASSES_WITH_HIDDEN_CONSTRUCTORS, child.name)) { const innerChildren = typedocOutput.children[i].children[j].children;
const classChildren = typedocOutput.children[i].children[j].children; _.each(innerChildren, (innerChild, k) => {
_.each(classChildren, (classChild, k) => { const isHiddenConstructor =
if (classChild.kindString === 'Constructor') { 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]; delete finalTypeDocOutput.children[i].children[j].children[k];
finalTypeDocOutput.children[i].children[j].children = _.compact( finalTypeDocOutput.children[i].children[j].children = _.compact(
finalTypeDocOutput.children[i].children[j].children, finalTypeDocOutput.children[i].children[j].children,
); );
} }
}); });
}
}); });
finalTypeDocOutput.children[i].children = _.compact(finalTypeDocOutput.children[i].children); finalTypeDocOutput.children[i].children = _.compact(finalTypeDocOutput.children[i].children);
}); });

View File

@ -44,9 +44,6 @@ export class SignatureBlock extends React.Component<SignatureBlockProps, Signatu
} }
public render(): React.ReactNode { public render(): React.ReactNode {
const method = this.props.method; const method = this.props.method;
if (typeDocUtils.isPrivateOrProtectedProperty(method.name)) {
return null;
}
return ( return (
<div <div

View File

@ -43,9 +43,6 @@ export const typeDocUtils = {
isProperty(entity: TypeDocNode): boolean { isProperty(entity: TypeDocNode): boolean {
return entity.kindString === KindString.Property; return entity.kindString === KindString.Property;
}, },
isPrivateOrProtectedProperty(propertyName: string): boolean {
return _.startsWith(propertyName, '_');
},
getModuleDefinitionsBySectionName(versionDocObj: TypeDocNode, configModulePaths: string[]): TypeDocNode[] { getModuleDefinitionsBySectionName(versionDocObj: TypeDocNode, configModulePaths: string[]): TypeDocNode[] {
const moduleDefinitions: TypeDocNode[] = []; const moduleDefinitions: TypeDocNode[] = [];
const jsonModules = versionDocObj.children; const jsonModules = versionDocObj.children;
@ -217,7 +214,6 @@ export const typeDocUtils = {
break; break;
case KindString.Property: case KindString.Property:
if (!typeDocUtils.isPrivateOrProtectedProperty(entity.name)) {
const property = typeDocUtils._convertProperty( const property = typeDocUtils._convertProperty(
entity, entity,
docsInfo.sections, docsInfo.sections,
@ -226,7 +222,6 @@ export const typeDocUtils = {
classNames, classNames,
); );
docSection.properties.push(property); docSection.properties.push(property);
}
break; break;
case KindString.Variable: case KindString.Variable: