Merge pull request #10802 from MoonE/apidoc-add-default-export-enums
Apidoc add default-exported enums
This commit is contained in:
@@ -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.
|
// Tag default exported Identifiers because their name should be the same as the module name.
|
||||||
exports.astNodeVisitor = {
|
exports.astNodeVisitor = {
|
||||||
visitNode: function(node, e, parser, currentSourceName) {
|
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$/, '');
|
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) {
|
parseComplete: function(e) {
|
||||||
const doclets = e.doclets;
|
const doclets = e.doclets;
|
||||||
|
const byLongname = doclets.index.longname;
|
||||||
for (let i = doclets.length - 1; i >= 0; --i) {
|
for (let i = doclets.length - 1; i >= 0; --i) {
|
||||||
const doclet = doclets[i];
|
const doclet = doclets[i];
|
||||||
if (doclet.stability) {
|
if (doclet.stability) {
|
||||||
@@ -180,7 +182,8 @@ exports.handlers = {
|
|||||||
doclet._hideConstructor = true;
|
doclet._hideConstructor = true;
|
||||||
includeAugments(doclet);
|
includeAugments(doclet);
|
||||||
sortOtherMembers(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
|
// Remove all other undocumented symbols
|
||||||
doclet.undocumented = true;
|
doclet.undocumented = true;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user