From 790e8568ec8dd3c64201ecdeaf521bd1d0c1afa8 Mon Sep 17 00:00:00 2001 From: Christine Heller Date: Wed, 8 Aug 2018 11:39:54 +0200 Subject: [PATCH] fixes for callbacks and inner members in modules --- exampleProject/src/core/myModule2.js | 22 ++++++++++++++++++++++ exampleProject/src/core/myModule3.js | 21 +++++++++++++++++++++ src/core/jsdoc-tsd-parser.ts | 9 +++++---- 3 files changed, 48 insertions(+), 4 deletions(-) create mode 100644 exampleProject/src/core/myModule2.js create mode 100644 exampleProject/src/core/myModule3.js diff --git a/exampleProject/src/core/myModule2.js b/exampleProject/src/core/myModule2.js new file mode 100644 index 0000000..bb0e8d1 --- /dev/null +++ b/exampleProject/src/core/myModule2.js @@ -0,0 +1,22 @@ +/** + * @module myModule2 + */ +/** + * exported function + * @function myFunction1 + * @param {string} myString + * @param {testCallback} myCallback + * @static + */ +/** + * exported callback + * @callback testCallback + * @param {string} testCBParam + * @static + */ + +/** + * inner function + * @function myFunction2 + * @param {string} myString + */ diff --git a/exampleProject/src/core/myModule3.js b/exampleProject/src/core/myModule3.js new file mode 100644 index 0000000..0ec739d --- /dev/null +++ b/exampleProject/src/core/myModule3.js @@ -0,0 +1,21 @@ +/** + * @module myModule3 + */ +module.exports = { + /** + * exported function + * @param {string} param1 + * @return {string} + */ + myFunction1: function(param1, color2) { + // ... + }, + /** + * inner function + * @param {string} param2 + * @inner + */ + myFunction2: function(param2) { + // ... + }, +}; diff --git a/src/core/jsdoc-tsd-parser.ts b/src/core/jsdoc-tsd-parser.ts index 1008fde..b804938 100644 --- a/src/core/jsdoc-tsd-parser.ts +++ b/src/core/jsdoc-tsd-parser.ts @@ -211,7 +211,7 @@ export class JSDocTsdParser { case "const": let constDeclaration = dom.create.const((namespaceMember as dom.ConstDeclaration).name, (namespaceMember as dom.ConstDeclaration).type); - if (!parsedItem.flags || 0 === (parsedItem.flags & dom.DeclarationFlags.Private)) { + if (parsedItem.flags && ((parsedItem.flags & dom.DeclarationFlags.Export) || (parsedItem.flags & dom.DeclarationFlags.Static))) { constDeclaration.flags = dom.DeclarationFlags.Export; } constDeclaration.comment = namespaceMember.comment; @@ -221,7 +221,7 @@ export class JSDocTsdParser { case "property": let variableDeclaration = dom.create.variable((namespaceMember as dom.VariableDeclaration).name, (namespaceMember as dom.VariableDeclaration).type); - if (!parsedItem.flags || 0 === (parsedItem.flags & dom.DeclarationFlags.Private)) { + if (parsedItem.flags && ((parsedItem.flags & dom.DeclarationFlags.Export) || (parsedItem.flags & dom.DeclarationFlags.Static))) { variableDeclaration.flags = dom.DeclarationFlags.Export; } variableDeclaration.comment = namespaceMember.comment; @@ -320,7 +320,7 @@ export class JSDocTsdParser { case "property": let variableDeclaration = dom.create.variable((moduleMember as dom.VariableDeclaration).name, (moduleMember as dom.VariableDeclaration).type); - if (!parsedItem.flags || 0 === (parsedItem.flags & dom.DeclarationFlags.Private)) { + if (parsedItem.flags && ((parsedItem.flags & dom.DeclarationFlags.Export) || (parsedItem.flags & dom.DeclarationFlags.Static))) { variableDeclaration.flags = dom.DeclarationFlags.Export; } variableDeclaration.comment = moduleMember.comment; @@ -329,7 +329,8 @@ export class JSDocTsdParser { break; case "function": - if (!parsedItem.flags || 0 === (parsedItem.flags & dom.DeclarationFlags.Private)) { + case "alias": + if (parsedItem.flags && ((parsedItem.flags & dom.DeclarationFlags.Export) || (parsedItem.flags & dom.DeclarationFlags.Static))) { moduleMember.flags = dom.DeclarationFlags.Export; } (parentItem as dom.ModuleDeclaration).members.push(moduleMember);