Merge pull request #10802 from MoonE/apidoc-add-default-export-enums

Apidoc add default-exported enums
This commit is contained in:
Andreas Hocevar
2020-03-27 12:07:12 +01:00
committed by GitHub

View File

@@ -113,9 +113,10 @@ const moduleRoot = path.join(process.cwd(), 'src');
// Tag default exported Identifiers because their name should be the same as the module name.
exports.astNodeVisitor = {
visitNode: function(node, e, parser, currentSourceName) {
if (node.type === 'Identifier' && node.parent.type === 'ExportDefaultDeclaration') {
if (node.parent && node.parent.type === 'ExportDefaultDeclaration') {
const modulePath = path.relative(moduleRoot, currentSourceName).replace(/\.js$/, '');
defaultExports['module:' + modulePath.replace(/\\/g, '/') + '~' + node.name] = true;
const exportName = 'module:' + modulePath.replace(/\\/g, '/') + (node.name ? '~' + node.name : '');
defaultExports[exportName] = true;
}
}
};
@@ -156,6 +157,7 @@ exports.handlers = {
parseComplete: function(e) {
const doclets = e.doclets;
const byLongname = doclets.index.longname;
for (let i = doclets.length - 1; i >= 0; --i) {
const doclet = doclets[i];
if (doclet.stability) {
@@ -180,7 +182,8 @@ exports.handlers = {
doclet._hideConstructor = true;
includeAugments(doclet);
sortOtherMembers(doclet);
} else if (!doclet._hideConstructor && !(doclet.kind == 'typedef' && doclet.longname in types)) {
} else if (!doclet._hideConstructor
&& !(doclet.longname in defaultExports && byLongname[doclet.longname].some(d => d.isEnum))) {
// Remove all other undocumented symbols
doclet.undocumented = true;
}