File tree 4 files changed +40
-2
lines changed
4 files changed +40
-2
lines changed Original file line number Diff line number Diff line change @@ -653,10 +653,12 @@ out/apilinks.json: $(wildcard lib/*.js) tools/doc/apilinks.js
653
653
$(call available-node, $(gen-apilink ) )
654
654
655
655
out/doc/api/% .json out/doc/api/% .html : doc/api/% .md tools/doc/generate.js \
656
- tools/doc/html.js tools/doc/json.js | out/apilinks.json
656
+ tools/doc/html.js tools/doc/json.js tools/doc/apilinks.js | \
657
+ out/apilinks.json
657
658
$(call available-node, $(gen-api ) )
658
659
659
- out/doc/api/all.html : $(apidocs_html ) tools/doc/allhtml.js
660
+ out/doc/api/all.html : $(apidocs_html ) tools/doc/allhtml.js \
661
+ tools/doc/apilinks.js
660
662
$(call available-node, tools/doc/allhtml.js)
661
663
662
664
out/doc/api/all.json : $(apidocs_json ) tools/doc/alljson.js
Original file line number Diff line number Diff line change
1
+ 'use strict' ;
2
+
3
+ // An exported class using ES2015 class syntax.
4
+
5
+ class Class {
6
+ constructor ( ) { } ;
7
+ method ( ) { } ;
8
+ }
9
+
10
+ module . exports = {
11
+ Class
12
+ } ;
Original file line number Diff line number Diff line change
1
+ {
2
+ "Class" : " class.js#L5" ,
3
+ "new Class" : " class.js#L6" ,
4
+ "class.method" : " class.js#L7"
5
+ }
Original file line number Diff line number Diff line change @@ -107,6 +107,7 @@ process.argv.slice(2).forEach((file) => {
107
107
// ClassName.foo = ...;
108
108
// ClassName.prototype.foo = ...;
109
109
// function Identifier(...) {...};
110
+ // class Foo {...}
110
111
//
111
112
const indirect = { } ;
112
113
@@ -153,6 +154,24 @@ process.argv.slice(2).forEach((file) => {
153
154
if ( basename . startsWith ( '_' ) ) return ;
154
155
definition [ `${ basename } .${ name } ` ] =
155
156
`${ link } #L${ statement . loc . start . line } ` ;
157
+
158
+ } else if ( statement . type === 'ClassDeclaration' ) {
159
+ if ( ! exported . constructors . includes ( statement . id . name ) ) return ;
160
+ definition [ statement . id . name ] = `${ link } #L${ statement . loc . start . line } ` ;
161
+
162
+ const name = statement . id . name . slice ( 0 , 1 ) . toLowerCase ( ) +
163
+ statement . id . name . slice ( 1 ) ;
164
+
165
+ statement . body . body . forEach ( ( defn ) => {
166
+ if ( defn . type !== 'MethodDefinition' ) return ;
167
+ if ( defn . kind === 'method' ) {
168
+ definition [ `${ name } .${ defn . key . name } ` ] =
169
+ `${ link } #L${ defn . loc . start . line } ` ;
170
+ } else if ( defn . kind === 'constructor' ) {
171
+ definition [ `new ${ statement . id . name } ` ] =
172
+ `${ link } #L${ defn . loc . start . line } ` ;
173
+ }
174
+ } ) ;
156
175
}
157
176
} ) ;
158
177
You can’t perform that action at this time.
0 commit comments