Skip to content

Commit

Permalink
fix: missing documentation with decorators.
Browse files Browse the repository at this point in the history
  • Loading branch information
h13i32maru committed Aug 15, 2015
1 parent 56c7877 commit 7c8c1c3
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 2 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## Next
- **Fix**
- Missing documentation with decorator ([#1](https://github.com/esdoc/esdoc-es7-plugin/issues/1))

## 0.0.1 (2015-08-09)
- **Feat**
- First Release
5 changes: 5 additions & 0 deletions src/Plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,11 @@ export function parser(code) {
*/
export function patchBabylonAST(ast) {
function patch(node, parent) {
// decorator
if (node.decorators && node.decorators[0].leadingComments && !node.leadingComments) {
node.leadingComments = [node.decorators[0].leadingComments[0]];
}

// for innerComments
if (node.innerComments) {
node.leadingComments = node.leadingComments || [];
Expand Down
15 changes: 13 additions & 2 deletions test/fixture/src/ES7Decorators.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
@decorator
/**
* this is ES7Decorators with decorators
*/
@decorator1
@decorator2
export class ES7Decorators {
/**
* this is method with decorators
*/
@decorator1
@decorator2
method(){}
}

function decorator(target){}
function decorator1(target){}
function decorator2(target){}
2 changes: 2 additions & 0 deletions test/src/ES7Test.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ describe('ES7', ()=>{

const html = fs.readFileSync('./test/fixture/esdoc/class/src/ES7Decorators.js~ES7Decorators.html').toString();
assert(html.includes('ES7Decorators'));
assert(html.includes('this is ES7Decorators with decorators'));
assert(html.includes('this is method with decorators'));
});

it('parse ES7 Exponentiation Operator', ()=>{
Expand Down

0 comments on commit 7c8c1c3

Please sign in to comment.