File tree Expand file tree Collapse file tree 6 files changed +191
-1
lines changed Expand file tree Collapse file tree 6 files changed +191
-1
lines changed Original file line number Diff line number Diff line change 11'use strict' ;
22
33var shouldSkipInference = require ( './should_skip_inference' ) ,
4+ generate = require ( 'babel-generator' ) . default ,
45 findClass = require ( './finders' ) . findClass ;
56
67/**
@@ -17,10 +18,16 @@ function inferAugments() {
1718
1819 var path = findClass ( comment . context . ast ) ;
1920
21+ /*
22+ * A superclass can be a single name, like React,
23+ * or a MemberExpression like React.Component,
24+ * so we generate code from the AST rather than assuming
25+ * we can access a name like `path.node.superClass.name`
26+ */
2027 if ( path && path . node . superClass ) {
2128 comment . augments = [ {
2229 title : 'augments' ,
23- name : path . node . superClass . name
30+ name : generate ( path . node . superClass ) . code
2431 } ] ;
2532 }
2633
Original file line number Diff line number Diff line change 99 "dependencies" : {
1010 "ansi-html" : " 0.0.5" ,
1111 "babel-core" : " ^6.17.0" ,
12+ "babel-generator" : " 6.19.0" ,
1213 "babel-plugin-system-import-transformer" : " 2.4.0" ,
1314 "babel-plugin-transform-decorators-legacy" : " ^1.3.4" ,
1415 "babel-preset-es2015" : " ^6.16.0" ,
Original file line number Diff line number Diff line change 1+ /**
2+ * This will fail.
3+ */
4+ class Foo extends React . Component { }
Original file line number Diff line number Diff line change 1+ [
2+ {
3+ "description" : {
4+ "type" : " root" ,
5+ "children" : [
6+ {
7+ "type" : " paragraph" ,
8+ "children" : [
9+ {
10+ "type" : " text" ,
11+ "value" : " This will fail." ,
12+ "position" : {
13+ "start" : {
14+ "line" : 1 ,
15+ "column" : 1 ,
16+ "offset" : 0
17+ },
18+ "end" : {
19+ "line" : 1 ,
20+ "column" : 16 ,
21+ "offset" : 15
22+ },
23+ "indent" : []
24+ }
25+ }
26+ ],
27+ "position" : {
28+ "start" : {
29+ "line" : 1 ,
30+ "column" : 1 ,
31+ "offset" : 0
32+ },
33+ "end" : {
34+ "line" : 1 ,
35+ "column" : 16 ,
36+ "offset" : 15
37+ },
38+ "indent" : []
39+ }
40+ }
41+ ],
42+ "position" : {
43+ "start" : {
44+ "line" : 1 ,
45+ "column" : 1 ,
46+ "offset" : 0
47+ },
48+ "end" : {
49+ "line" : 1 ,
50+ "column" : 16 ,
51+ "offset" : 15
52+ }
53+ }
54+ },
55+ "tags" : [],
56+ "loc" : {
57+ "start" : {
58+ "line" : 1 ,
59+ "column" : 0
60+ },
61+ "end" : {
62+ "line" : 3 ,
63+ "column" : 3
64+ }
65+ },
66+ "context" : {
67+ "loc" : {
68+ "start" : {
69+ "line" : 4 ,
70+ "column" : 0
71+ },
72+ "end" : {
73+ "line" : 4 ,
74+ "column" : 36
75+ }
76+ }
77+ },
78+ "errors" : [],
79+ "name" : " Foo" ,
80+ "augments" : [
81+ {
82+ "title" : " augments" ,
83+ "name" : " React.Component"
84+ }
85+ ],
86+ "kind" : " class" ,
87+ "members" : {
88+ "instance" : [],
89+ "static" : []
90+ },
91+ "path" : [
92+ {
93+ "name" : " Foo" ,
94+ "kind" : " class"
95+ }
96+ ],
97+ "namespace" : " Foo"
98+ }
99+ ]
Original file line number Diff line number Diff line change 1+ <!-- Generated by documentation.js. Update this documentation by updating the source code. -->
2+
3+ # Foo
4+
5+ ** Extends React.Component**
6+
7+ This will fail.
Original file line number Diff line number Diff line change 1+ {
2+ "type" : " root" ,
3+ "children" : [
4+ {
5+ "type" : " html" ,
6+ "value" : " <!-- Generated by documentation.js. Update this documentation by updating the source code. -->"
7+ },
8+ {
9+ "depth" : 1 ,
10+ "type" : " heading" ,
11+ "children" : [
12+ {
13+ "type" : " text" ,
14+ "value" : " Foo"
15+ }
16+ ]
17+ },
18+ {
19+ "type" : " paragraph" ,
20+ "children" : [
21+ {
22+ "type" : " strong" ,
23+ "children" : [
24+ {
25+ "type" : " text" ,
26+ "value" : " Extends "
27+ },
28+ {
29+ "type" : " text" ,
30+ "value" : " React.Component"
31+ }
32+ ]
33+ }
34+ ]
35+ },
36+ {
37+ "type" : " paragraph" ,
38+ "children" : [
39+ {
40+ "type" : " text" ,
41+ "value" : " This will fail." ,
42+ "position" : {
43+ "start" : {
44+ "line" : 1 ,
45+ "column" : 1 ,
46+ "offset" : 0
47+ },
48+ "end" : {
49+ "line" : 1 ,
50+ "column" : 16 ,
51+ "offset" : 15
52+ },
53+ "indent" : []
54+ }
55+ }
56+ ],
57+ "position" : {
58+ "start" : {
59+ "line" : 1 ,
60+ "column" : 1 ,
61+ "offset" : 0
62+ },
63+ "end" : {
64+ "line" : 1 ,
65+ "column" : 16 ,
66+ "offset" : 15
67+ },
68+ "indent" : []
69+ }
70+ }
71+ ]
72+ }
You can’t perform that action at this time.
0 commit comments