Skip to content

Commit 3fc0cd0

Browse files
committed
handle exported ES2015 classes correctly (jsdoc#1137)
1 parent 571ca67 commit 3fc0cd0

File tree

3 files changed

+27
-0
lines changed

3 files changed

+27
-0
lines changed

lib/jsdoc/src/astnode.js

+4
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,10 @@ var nodeToValue = exports.nodeToValue = function(node) {
134134
str = nodeToValue(node.left);
135135
break;
136136

137+
case Syntax.ClassDeclaration:
138+
str = nodeToValue(node.id);
139+
break;
140+
137141
case Syntax.ExportAllDeclaration:
138142
// falls through
139143

test/fixtures/exportclass.js

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
/**
2+
* Foo module
3+
* @module foo
4+
*/
5+
6+
/** Class description */
7+
export class Bar {
8+
}
+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
'use strict';
2+
3+
describe('export class', function() {
4+
var docSet = jasmine.getDocSetFromFile('test/fixtures/exportclass.js');
5+
var bar = docSet.getByLongname('module:foo.Bar')[0];
6+
7+
it('should name exported classes correctly', function() {
8+
expect(bar).toBeDefined();
9+
expect(bar.name).toBe('Bar');
10+
});
11+
12+
it('should merge the class description with the doclet for the class', function() {
13+
expect(bar.classdesc).toBe('Class description');
14+
});
15+
});

0 commit comments

Comments
 (0)