Skip to content

Commit

Permalink
Merge pull request #159 from karelmaxa/fix-158
Browse files Browse the repository at this point in the history
Fix generating of comments for sequence function declarations (#158)
  • Loading branch information
fossamagna committed Jun 24, 2020
2 parents 419fede + e073a8b commit b30bf99
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 1 deletion.
3 changes: 2 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ function _generateStubs(data, options) {
node.expression.expressions.forEach(function (expression) {
if (isGlobalAssignmentExpression(expression)) {
functionName = expression.left.property.name;
stubs.push(createStubFunctionASTNode(functionName, node.leadingComments, expression.right.params));
stubs.push(createStubFunctionASTNode(functionName, expression.leadingComments ?
expression.leadingComments : node.leadingComments, expression.right.params));
}
});
}
Expand Down
12 changes: 12 additions & 0 deletions test/fixtures/expected.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,18 @@ function foo() {
// leading line comment for boo
function boo(message) {
}
/**
* Leading Block Comment for bar.
*/
// leading line comment for bar
function bar() {
}
/**
* Leading Block Comment for baz.
*/
// leading line comment for baz
function baz() {
}
function test() {
}
function X() {
Expand Down
12 changes: 12 additions & 0 deletions test/fixtures/source.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,18 @@ global.foo = function () {
// leading line comment for boo
global.boo = function (message) {
};
/**
* Leading Block Comment for bar.
*/
// leading line comment for bar
global.bar = function() {
},
/**
* Leading Block Comment for baz.
*/
// leading line comment for baz
global.baz = function() {
};
function test() {
};
var X = 'x';
Expand Down

0 comments on commit b30bf99

Please sign in to comment.