From 058ca592332d6642745f3b35633f94e43ac8f5cf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maximilian=20Kr=C3=B6g?= Date: Thu, 12 Mar 2020 21:36:19 +0100 Subject: [PATCH 1/3] Also correctly detect default exports without an identifier --- config/jsdoc/api/plugins/api.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/config/jsdoc/api/plugins/api.js b/config/jsdoc/api/plugins/api.js index 0c4d80e85e..2d4cc92432 100644 --- a/config/jsdoc/api/plugins/api.js +++ b/config/jsdoc/api/plugins/api.js @@ -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; } } }; From f2477622c38067ac9887ebead68361e8d9c2a01f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maximilian=20Kr=C3=B6g?= Date: Thu, 12 Mar 2020 22:23:28 +0100 Subject: [PATCH 2/3] Remove redundant check if doclet kind is typedef --- config/jsdoc/api/plugins/api.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/jsdoc/api/plugins/api.js b/config/jsdoc/api/plugins/api.js index 2d4cc92432..93ff1de5cb 100644 --- a/config/jsdoc/api/plugins/api.js +++ b/config/jsdoc/api/plugins/api.js @@ -181,7 +181,7 @@ exports.handlers = { doclet._hideConstructor = true; includeAugments(doclet); sortOtherMembers(doclet); - } else if (!doclet._hideConstructor && !(doclet.kind == 'typedef' && doclet.longname in types)) { + } else if (!doclet._hideConstructor) { // Remove all other undocumented symbols doclet.undocumented = true; } From 873cccc4f3c6b08cfd35b24e62d30a926700412c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maximilian=20Kr=C3=B6g?= Date: Thu, 12 Mar 2020 22:29:00 +0100 Subject: [PATCH 3/3] Add default exported enums to apidoc --- config/jsdoc/api/plugins/api.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/config/jsdoc/api/plugins/api.js b/config/jsdoc/api/plugins/api.js index 93ff1de5cb..c384d86dad 100644 --- a/config/jsdoc/api/plugins/api.js +++ b/config/jsdoc/api/plugins/api.js @@ -157,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) { @@ -181,7 +182,8 @@ exports.handlers = { doclet._hideConstructor = true; includeAugments(doclet); sortOtherMembers(doclet); - } else if (!doclet._hideConstructor) { + } else if (!doclet._hideConstructor + && !(doclet.longname in defaultExports && byLongname[doclet.longname].some(d => d.isEnum))) { // Remove all other undocumented symbols doclet.undocumented = true; }