|
1 <!DOCTYPE html> |
|
2 <html><head> |
|
3 <title>eric7.Utilities.ClassBrowsers.jsclbr</title> |
|
4 <meta charset="UTF-8"> |
|
5 <link rel="stylesheet" href="styles.css"> |
|
6 </head> |
|
7 <body> |
|
8 <a NAME="top" ID="top"></a> |
|
9 <h1>eric7.Utilities.ClassBrowsers.jsclbr</h1> |
|
10 |
|
11 <p> |
|
12 Parse a JavaScript file and retrieve variables and functions. |
|
13 </p> |
|
14 <p> |
|
15 It uses the JavaScript parser contained in the jasy web framework. |
|
16 </p> |
|
17 <h3>Global Attributes</h3> |
|
18 |
|
19 <table> |
|
20 <tr><td>SUPPORTED_TYPES</td></tr><tr><td>_modules</td></tr> |
|
21 </table> |
|
22 <h3>Classes</h3> |
|
23 |
|
24 <table> |
|
25 |
|
26 <tr> |
|
27 <td><a href="#Attribute">Attribute</a></td> |
|
28 <td>Class to represent a class attribute.</td> |
|
29 </tr> |
|
30 <tr> |
|
31 <td><a href="#Function">Function</a></td> |
|
32 <td>Class to represent a Python function.</td> |
|
33 </tr> |
|
34 <tr> |
|
35 <td><a href="#VisibilityMixin">VisibilityMixin</a></td> |
|
36 <td>Mixin class implementing the notion of visibility.</td> |
|
37 </tr> |
|
38 <tr> |
|
39 <td><a href="#Visitor">Visitor</a></td> |
|
40 <td>Class implementing a visitor going through the parsed tree.</td> |
|
41 </tr> |
|
42 </table> |
|
43 <h3>Functions</h3> |
|
44 |
|
45 <table> |
|
46 |
|
47 <tr> |
|
48 <td><a href="#readmodule_ex">readmodule_ex</a></td> |
|
49 <td>Read a JavaScript file and return a dictionary of functions and variables.</td> |
|
50 </tr> |
|
51 <tr> |
|
52 <td><a href="#scan">scan</a></td> |
|
53 <td>Public method to scan the given source text.</td> |
|
54 </tr> |
|
55 </table> |
|
56 <hr /> |
|
57 <hr /> |
|
58 <a NAME="Attribute" ID="Attribute"></a> |
|
59 <h2>Attribute</h2> |
|
60 |
|
61 <p> |
|
62 Class to represent a class attribute. |
|
63 </p> |
|
64 <h3>Derived from</h3> |
|
65 ClbrBaseClasses.Attribute, VisibilityMixin |
|
66 <h3>Class Attributes</h3> |
|
67 |
|
68 <table> |
|
69 <tr><td>None</td></tr> |
|
70 </table> |
|
71 <h3>Class Methods</h3> |
|
72 |
|
73 <table> |
|
74 <tr><td>None</td></tr> |
|
75 </table> |
|
76 <h3>Methods</h3> |
|
77 |
|
78 <table> |
|
79 |
|
80 <tr> |
|
81 <td><a href="#Attribute.__init__">Attribute</a></td> |
|
82 <td>Constructor</td> |
|
83 </tr> |
|
84 </table> |
|
85 <h3>Static Methods</h3> |
|
86 |
|
87 <table> |
|
88 <tr><td>None</td></tr> |
|
89 </table> |
|
90 |
|
91 <a NAME="Attribute.__init__" ID="Attribute.__init__"></a> |
|
92 <h4>Attribute (Constructor)</h4> |
|
93 <b>Attribute</b>(<i>module, name, file, lineno</i>) |
|
94 |
|
95 <p> |
|
96 Constructor |
|
97 </p> |
|
98 <dl> |
|
99 |
|
100 <dt><i>module</i></dt> |
|
101 <dd> |
|
102 name of the module containing this class |
|
103 </dd> |
|
104 <dt><i>name</i></dt> |
|
105 <dd> |
|
106 name of this class |
|
107 </dd> |
|
108 <dt><i>file</i></dt> |
|
109 <dd> |
|
110 filename containing this attribute |
|
111 </dd> |
|
112 <dt><i>lineno</i></dt> |
|
113 <dd> |
|
114 linenumber of the class definition |
|
115 </dd> |
|
116 </dl> |
|
117 <div align="right"><a href="#top">Up</a></div> |
|
118 <hr /> |
|
119 <hr /> |
|
120 <a NAME="Function" ID="Function"></a> |
|
121 <h2>Function</h2> |
|
122 |
|
123 <p> |
|
124 Class to represent a Python function. |
|
125 </p> |
|
126 <h3>Derived from</h3> |
|
127 ClbrBaseClasses.Function, VisibilityMixin |
|
128 <h3>Class Attributes</h3> |
|
129 |
|
130 <table> |
|
131 <tr><td>None</td></tr> |
|
132 </table> |
|
133 <h3>Class Methods</h3> |
|
134 |
|
135 <table> |
|
136 <tr><td>None</td></tr> |
|
137 </table> |
|
138 <h3>Methods</h3> |
|
139 |
|
140 <table> |
|
141 |
|
142 <tr> |
|
143 <td><a href="#Function.__init__">Function</a></td> |
|
144 <td>Constructor</td> |
|
145 </tr> |
|
146 </table> |
|
147 <h3>Static Methods</h3> |
|
148 |
|
149 <table> |
|
150 <tr><td>None</td></tr> |
|
151 </table> |
|
152 |
|
153 <a NAME="Function.__init__" ID="Function.__init__"></a> |
|
154 <h4>Function (Constructor)</h4> |
|
155 <b>Function</b>(<i>module, name, file, lineno, signature='', separator=', '</i>) |
|
156 |
|
157 <p> |
|
158 Constructor |
|
159 </p> |
|
160 <dl> |
|
161 |
|
162 <dt><i>module</i></dt> |
|
163 <dd> |
|
164 name of the module containing this function |
|
165 </dd> |
|
166 <dt><i>name</i></dt> |
|
167 <dd> |
|
168 name of this function |
|
169 </dd> |
|
170 <dt><i>file</i></dt> |
|
171 <dd> |
|
172 filename containing this class |
|
173 </dd> |
|
174 <dt><i>lineno</i></dt> |
|
175 <dd> |
|
176 linenumber of the class definition |
|
177 </dd> |
|
178 <dt><i>signature</i></dt> |
|
179 <dd> |
|
180 parameterlist of the method |
|
181 </dd> |
|
182 <dt><i>separator</i></dt> |
|
183 <dd> |
|
184 string separating the parameters |
|
185 </dd> |
|
186 </dl> |
|
187 <div align="right"><a href="#top">Up</a></div> |
|
188 <hr /> |
|
189 <hr /> |
|
190 <a NAME="VisibilityMixin" ID="VisibilityMixin"></a> |
|
191 <h2>VisibilityMixin</h2> |
|
192 |
|
193 <p> |
|
194 Mixin class implementing the notion of visibility. |
|
195 </p> |
|
196 <h3>Derived from</h3> |
|
197 ClbrBaseClasses.ClbrVisibilityMixinBase |
|
198 <h3>Class Attributes</h3> |
|
199 |
|
200 <table> |
|
201 <tr><td>None</td></tr> |
|
202 </table> |
|
203 <h3>Class Methods</h3> |
|
204 |
|
205 <table> |
|
206 <tr><td>None</td></tr> |
|
207 </table> |
|
208 <h3>Methods</h3> |
|
209 |
|
210 <table> |
|
211 |
|
212 <tr> |
|
213 <td><a href="#VisibilityMixin.__init__">VisibilityMixin</a></td> |
|
214 <td>Constructor</td> |
|
215 </tr> |
|
216 </table> |
|
217 <h3>Static Methods</h3> |
|
218 |
|
219 <table> |
|
220 <tr><td>None</td></tr> |
|
221 </table> |
|
222 |
|
223 <a NAME="VisibilityMixin.__init__" ID="VisibilityMixin.__init__"></a> |
|
224 <h4>VisibilityMixin (Constructor)</h4> |
|
225 <b>VisibilityMixin</b>(<i></i>) |
|
226 |
|
227 <p> |
|
228 Constructor |
|
229 </p> |
|
230 <div align="right"><a href="#top">Up</a></div> |
|
231 <hr /> |
|
232 <hr /> |
|
233 <a NAME="Visitor" ID="Visitor"></a> |
|
234 <h2>Visitor</h2> |
|
235 |
|
236 <p> |
|
237 Class implementing a visitor going through the parsed tree. |
|
238 </p> |
|
239 <h3>Derived from</h3> |
|
240 None |
|
241 <h3>Class Attributes</h3> |
|
242 |
|
243 <table> |
|
244 <tr><td>None</td></tr> |
|
245 </table> |
|
246 <h3>Class Methods</h3> |
|
247 |
|
248 <table> |
|
249 <tr><td>None</td></tr> |
|
250 </table> |
|
251 <h3>Methods</h3> |
|
252 |
|
253 <table> |
|
254 |
|
255 <tr> |
|
256 <td><a href="#Visitor.__init__">Visitor</a></td> |
|
257 <td>Constructor</td> |
|
258 </tr> |
|
259 <tr> |
|
260 <td><a href="#Visitor.__visit">__visit</a></td> |
|
261 <td>Private method implementing the visit logic delegating to interesting methods.</td> |
|
262 </tr> |
|
263 <tr> |
|
264 <td><a href="#Visitor.call">call</a></td> |
|
265 <td></td> |
|
266 </tr> |
|
267 <tr> |
|
268 <td><a href="#Visitor.parse">parse</a></td> |
|
269 <td>Public method to parse the source.</td> |
|
270 </tr> |
|
271 <tr> |
|
272 <td><a href="#Visitor.visit_const">visit_const</a></td> |
|
273 <td>Public method to treat a constant node.</td> |
|
274 </tr> |
|
275 <tr> |
|
276 <td><a href="#Visitor.visit_function">visit_function</a></td> |
|
277 <td>Public method to treat a function node.</td> |
|
278 </tr> |
|
279 <tr> |
|
280 <td><a href="#Visitor.visit_noop">visit_noop</a></td> |
|
281 <td>Public method to ignore the given node.</td> |
|
282 </tr> |
|
283 <tr> |
|
284 <td><a href="#Visitor.visit_property_init">visit_property_init</a></td> |
|
285 <td>Public method to treat a property_init node.</td> |
|
286 </tr> |
|
287 <tr> |
|
288 <td><a href="#Visitor.visit_var">visit_var</a></td> |
|
289 <td>Public method to treat a variable node.</td> |
|
290 </tr> |
|
291 </table> |
|
292 <h3>Static Methods</h3> |
|
293 |
|
294 <table> |
|
295 <tr><td>None</td></tr> |
|
296 </table> |
|
297 |
|
298 <a NAME="Visitor.__init__" ID="Visitor.__init__"></a> |
|
299 <h4>Visitor (Constructor)</h4> |
|
300 <b>Visitor</b>(<i>src, module, filename</i>) |
|
301 |
|
302 <p> |
|
303 Constructor |
|
304 </p> |
|
305 <dl> |
|
306 |
|
307 <dt><i>src</i></dt> |
|
308 <dd> |
|
309 source to be parsed (string) |
|
310 </dd> |
|
311 <dt><i>module</i></dt> |
|
312 <dd> |
|
313 name of the module (string) |
|
314 </dd> |
|
315 <dt><i>filename</i></dt> |
|
316 <dd> |
|
317 file name (string) |
|
318 </dd> |
|
319 </dl> |
|
320 <a NAME="Visitor.__visit" ID="Visitor.__visit"></a> |
|
321 <h4>Visitor.__visit</h4> |
|
322 <b>__visit</b>(<i>root</i>) |
|
323 |
|
324 <p> |
|
325 Private method implementing the visit logic delegating to interesting |
|
326 methods. |
|
327 </p> |
|
328 <dl> |
|
329 |
|
330 <dt><i>root</i></dt> |
|
331 <dd> |
|
332 root node to visit |
|
333 </dd> |
|
334 </dl> |
|
335 <a NAME="Visitor.call" ID="Visitor.call"></a> |
|
336 <h4>Visitor.call</h4> |
|
337 <b>call</b>(<i></i>) |
|
338 |
|
339 <a NAME="Visitor.parse" ID="Visitor.parse"></a> |
|
340 <h4>Visitor.parse</h4> |
|
341 <b>parse</b>(<i></i>) |
|
342 |
|
343 <p> |
|
344 Public method to parse the source. |
|
345 </p> |
|
346 <dl> |
|
347 <dt>Return:</dt> |
|
348 <dd> |
|
349 dictionary containing the parsed information |
|
350 </dd> |
|
351 </dl> |
|
352 <a NAME="Visitor.visit_const" ID="Visitor.visit_const"></a> |
|
353 <h4>Visitor.visit_const</h4> |
|
354 <b>visit_const</b>(<i>node</i>) |
|
355 |
|
356 <p> |
|
357 Public method to treat a constant node. |
|
358 </p> |
|
359 <dl> |
|
360 |
|
361 <dt><i>node</i></dt> |
|
362 <dd> |
|
363 reference to the node (jasy.script.parse.Node.Node) |
|
364 </dd> |
|
365 </dl> |
|
366 <a NAME="Visitor.visit_function" ID="Visitor.visit_function"></a> |
|
367 <h4>Visitor.visit_function</h4> |
|
368 <b>visit_function</b>(<i>node</i>) |
|
369 |
|
370 <p> |
|
371 Public method to treat a function node. |
|
372 </p> |
|
373 <dl> |
|
374 |
|
375 <dt><i>node</i></dt> |
|
376 <dd> |
|
377 reference to the node (jasy.script.parse.Node.Node) |
|
378 </dd> |
|
379 </dl> |
|
380 <a NAME="Visitor.visit_noop" ID="Visitor.visit_noop"></a> |
|
381 <h4>Visitor.visit_noop</h4> |
|
382 <b>visit_noop</b>(<i>node</i>) |
|
383 |
|
384 <p> |
|
385 Public method to ignore the given node. |
|
386 </p> |
|
387 <dl> |
|
388 |
|
389 <dt><i>node</i></dt> |
|
390 <dd> |
|
391 reference to the node (jasy.script.parse.Node.Node) |
|
392 </dd> |
|
393 </dl> |
|
394 <a NAME="Visitor.visit_property_init" ID="Visitor.visit_property_init"></a> |
|
395 <h4>Visitor.visit_property_init</h4> |
|
396 <b>visit_property_init</b>(<i>node</i>) |
|
397 |
|
398 <p> |
|
399 Public method to treat a property_init node. |
|
400 </p> |
|
401 <dl> |
|
402 |
|
403 <dt><i>node</i></dt> |
|
404 <dd> |
|
405 reference to the node (jasy.script.parse.Node.Node) |
|
406 </dd> |
|
407 </dl> |
|
408 <a NAME="Visitor.visit_var" ID="Visitor.visit_var"></a> |
|
409 <h4>Visitor.visit_var</h4> |
|
410 <b>visit_var</b>(<i>node</i>) |
|
411 |
|
412 <p> |
|
413 Public method to treat a variable node. |
|
414 </p> |
|
415 <dl> |
|
416 |
|
417 <dt><i>node</i></dt> |
|
418 <dd> |
|
419 reference to the node (jasy.script.parse.Node.Node) |
|
420 </dd> |
|
421 </dl> |
|
422 <div align="right"><a href="#top">Up</a></div> |
|
423 <hr /> |
|
424 <hr /> |
|
425 <a NAME="readmodule_ex" ID="readmodule_ex"></a> |
|
426 <h2>readmodule_ex</h2> |
|
427 <b>readmodule_ex</b>(<i>module, path=None</i>) |
|
428 |
|
429 <p> |
|
430 Read a JavaScript file and return a dictionary of functions and variables. |
|
431 </p> |
|
432 <dl> |
|
433 |
|
434 <dt><i>module</i></dt> |
|
435 <dd> |
|
436 name of the JavaScript file (string) |
|
437 </dd> |
|
438 <dt><i>path</i></dt> |
|
439 <dd> |
|
440 path the file should be searched in (list of strings) |
|
441 </dd> |
|
442 </dl> |
|
443 <dl> |
|
444 <dt>Return:</dt> |
|
445 <dd> |
|
446 the resulting dictionary |
|
447 </dd> |
|
448 </dl> |
|
449 <div align="right"><a href="#top">Up</a></div> |
|
450 <hr /> |
|
451 <hr /> |
|
452 <a NAME="scan" ID="scan"></a> |
|
453 <h2>scan</h2> |
|
454 <b>scan</b>(<i>src, file, module</i>) |
|
455 |
|
456 <p> |
|
457 Public method to scan the given source text. |
|
458 </p> |
|
459 <dl> |
|
460 |
|
461 <dt><i>src</i> (str)</dt> |
|
462 <dd> |
|
463 source text to be scanned |
|
464 </dd> |
|
465 <dt><i>file</i> (str)</dt> |
|
466 <dd> |
|
467 file name associated with the source text |
|
468 </dd> |
|
469 <dt><i>module</i> (str)</dt> |
|
470 <dd> |
|
471 module name associated with the source text |
|
472 </dd> |
|
473 </dl> |
|
474 <dl> |
|
475 <dt>Return:</dt> |
|
476 <dd> |
|
477 dictionary containing the extracted data |
|
478 </dd> |
|
479 </dl> |
|
480 <dl> |
|
481 <dt>Return Type:</dt> |
|
482 <dd> |
|
483 dict |
|
484 </dd> |
|
485 </dl> |
|
486 <div align="right"><a href="#top">Up</a></div> |
|
487 <hr /> |
|
488 </body></html> |