|
1 <!DOCTYPE html> |
|
2 <html><head> |
|
3 <title>eric6.Utilities.ClassBrowsers.jsclbr</title> |
|
4 <meta charset="UTF-8"> |
|
5 <style> |
|
6 body { |
|
7 background: #EDECE6; |
|
8 margin: 0em 1em 10em 1em; |
|
9 color: black; |
|
10 } |
|
11 |
|
12 h1 { color: white; background: #85774A; } |
|
13 h2 { color: white; background: #85774A; } |
|
14 h3 { color: white; background: #9D936E; } |
|
15 h4 { color: white; background: #9D936E; } |
|
16 |
|
17 a { color: #BA6D36; } |
|
18 |
|
19 </style> |
|
20 </head> |
|
21 <body><a NAME="top" ID="top"></a> |
|
22 <h1>eric6.Utilities.ClassBrowsers.jsclbr</h1> |
|
23 <p> |
|
24 Parse a JavaScript file and retrieve variables and functions. |
|
25 </p><p> |
|
26 It uses the JavaScript parser contained in the jasy web framework. |
|
27 </p> |
|
28 <h3>Global Attributes</h3> |
|
29 <table> |
|
30 <tr><td>SUPPORTED_TYPES</td></tr><tr><td>_modules</td></tr> |
|
31 </table> |
|
32 <h3>Classes</h3> |
|
33 <table> |
|
34 <tr> |
|
35 <td><a href="#Attribute">Attribute</a></td> |
|
36 <td>Class to represent a class attribute.</td> |
|
37 </tr><tr> |
|
38 <td><a href="#Function">Function</a></td> |
|
39 <td>Class to represent a Python function.</td> |
|
40 </tr><tr> |
|
41 <td><a href="#VisibilityMixin">VisibilityMixin</a></td> |
|
42 <td>Mixin class implementing the notion of visibility.</td> |
|
43 </tr><tr> |
|
44 <td><a href="#Visitor">Visitor</a></td> |
|
45 <td>Class implementing a visitor going through the parsed tree.</td> |
|
46 </tr> |
|
47 </table> |
|
48 <h3>Functions</h3> |
|
49 <table> |
|
50 <tr> |
|
51 <td><a href="#readmodule_ex">readmodule_ex</a></td> |
|
52 <td>Read a JavaScript file and return a dictionary of functions and variables.</td> |
|
53 </tr> |
|
54 </table> |
|
55 <hr /><hr /> |
|
56 <a NAME="Attribute" ID="Attribute"></a> |
|
57 <h2>Attribute</h2> |
|
58 <p> |
|
59 Class to represent a class attribute. |
|
60 </p> |
|
61 <h3>Derived from</h3> |
|
62 ClbrBaseClasses.Attribute, VisibilityMixin |
|
63 <h3>Class Attributes</h3> |
|
64 <table> |
|
65 <tr><td>None</td></tr> |
|
66 </table> |
|
67 <h3>Class Methods</h3> |
|
68 <table> |
|
69 <tr><td>None</td></tr> |
|
70 </table> |
|
71 <h3>Methods</h3> |
|
72 <table> |
|
73 <tr> |
|
74 <td><a href="#Attribute.__init__">Attribute</a></td> |
|
75 <td>Constructor</td> |
|
76 </tr> |
|
77 </table> |
|
78 <h3>Static Methods</h3> |
|
79 <table> |
|
80 <tr><td>None</td></tr> |
|
81 </table> |
|
82 <a NAME="Attribute.__init__" ID="Attribute.__init__"></a> |
|
83 <h4>Attribute (Constructor)</h4> |
|
84 <b>Attribute</b>(<i>module, name, file, lineno</i>) |
|
85 <p> |
|
86 Constructor |
|
87 </p><dl> |
|
88 <dt><i>module</i></dt> |
|
89 <dd> |
|
90 name of the module containing this class |
|
91 </dd><dt><i>name</i></dt> |
|
92 <dd> |
|
93 name of this class |
|
94 </dd><dt><i>file</i></dt> |
|
95 <dd> |
|
96 filename containing this attribute |
|
97 </dd><dt><i>lineno</i></dt> |
|
98 <dd> |
|
99 linenumber of the class definition |
|
100 </dd> |
|
101 </dl> |
|
102 <div align="right"><a href="#top">Up</a></div> |
|
103 <hr /><hr /> |
|
104 <a NAME="Function" ID="Function"></a> |
|
105 <h2>Function</h2> |
|
106 <p> |
|
107 Class to represent a Python function. |
|
108 </p> |
|
109 <h3>Derived from</h3> |
|
110 ClbrBaseClasses.Function, VisibilityMixin |
|
111 <h3>Class Attributes</h3> |
|
112 <table> |
|
113 <tr><td>None</td></tr> |
|
114 </table> |
|
115 <h3>Class Methods</h3> |
|
116 <table> |
|
117 <tr><td>None</td></tr> |
|
118 </table> |
|
119 <h3>Methods</h3> |
|
120 <table> |
|
121 <tr> |
|
122 <td><a href="#Function.__init__">Function</a></td> |
|
123 <td>Constructor</td> |
|
124 </tr> |
|
125 </table> |
|
126 <h3>Static Methods</h3> |
|
127 <table> |
|
128 <tr><td>None</td></tr> |
|
129 </table> |
|
130 <a NAME="Function.__init__" ID="Function.__init__"></a> |
|
131 <h4>Function (Constructor)</h4> |
|
132 <b>Function</b>(<i>module, name, file, lineno, signature='', separator=', '</i>) |
|
133 <p> |
|
134 Constructor |
|
135 </p><dl> |
|
136 <dt><i>module</i></dt> |
|
137 <dd> |
|
138 name of the module containing this function |
|
139 </dd><dt><i>name</i></dt> |
|
140 <dd> |
|
141 name of this function |
|
142 </dd><dt><i>file</i></dt> |
|
143 <dd> |
|
144 filename containing this class |
|
145 </dd><dt><i>lineno</i></dt> |
|
146 <dd> |
|
147 linenumber of the class definition |
|
148 </dd><dt><i>signature</i></dt> |
|
149 <dd> |
|
150 parameterlist of the method |
|
151 </dd><dt><i>separator</i></dt> |
|
152 <dd> |
|
153 string separating the parameters |
|
154 </dd> |
|
155 </dl> |
|
156 <div align="right"><a href="#top">Up</a></div> |
|
157 <hr /><hr /> |
|
158 <a NAME="VisibilityMixin" ID="VisibilityMixin"></a> |
|
159 <h2>VisibilityMixin</h2> |
|
160 <p> |
|
161 Mixin class implementing the notion of visibility. |
|
162 </p> |
|
163 <h3>Derived from</h3> |
|
164 ClbrBaseClasses.ClbrVisibilityMixinBase |
|
165 <h3>Class Attributes</h3> |
|
166 <table> |
|
167 <tr><td>None</td></tr> |
|
168 </table> |
|
169 <h3>Class Methods</h3> |
|
170 <table> |
|
171 <tr><td>None</td></tr> |
|
172 </table> |
|
173 <h3>Methods</h3> |
|
174 <table> |
|
175 <tr> |
|
176 <td><a href="#VisibilityMixin.__init__">VisibilityMixin</a></td> |
|
177 <td>Constructor</td> |
|
178 </tr> |
|
179 </table> |
|
180 <h3>Static Methods</h3> |
|
181 <table> |
|
182 <tr><td>None</td></tr> |
|
183 </table> |
|
184 <a NAME="VisibilityMixin.__init__" ID="VisibilityMixin.__init__"></a> |
|
185 <h4>VisibilityMixin (Constructor)</h4> |
|
186 <b>VisibilityMixin</b>(<i></i>) |
|
187 <p> |
|
188 Constructor |
|
189 </p> |
|
190 <div align="right"><a href="#top">Up</a></div> |
|
191 <hr /><hr /> |
|
192 <a NAME="Visitor" ID="Visitor"></a> |
|
193 <h2>Visitor</h2> |
|
194 <p> |
|
195 Class implementing a visitor going through the parsed tree. |
|
196 </p> |
|
197 <h3>Derived from</h3> |
|
198 object |
|
199 <h3>Class Attributes</h3> |
|
200 <table> |
|
201 <tr><td>None</td></tr> |
|
202 </table> |
|
203 <h3>Class Methods</h3> |
|
204 <table> |
|
205 <tr><td>None</td></tr> |
|
206 </table> |
|
207 <h3>Methods</h3> |
|
208 <table> |
|
209 <tr> |
|
210 <td><a href="#Visitor.__init__">Visitor</a></td> |
|
211 <td>Constructor</td> |
|
212 </tr><tr> |
|
213 <td><a href="#Visitor.__visit">__visit</a></td> |
|
214 <td>Private method implementing the visit logic delegating to interesting methods.</td> |
|
215 </tr><tr> |
|
216 <td><a href="#Visitor.call">call</a></td> |
|
217 <td></td> |
|
218 </tr><tr> |
|
219 <td><a href="#Visitor.parse">parse</a></td> |
|
220 <td>Public method to parse the source.</td> |
|
221 </tr><tr> |
|
222 <td><a href="#Visitor.visit_const">visit_const</a></td> |
|
223 <td>Public method to treat a constant node.</td> |
|
224 </tr><tr> |
|
225 <td><a href="#Visitor.visit_function">visit_function</a></td> |
|
226 <td>Public method to treat a function node.</td> |
|
227 </tr><tr> |
|
228 <td><a href="#Visitor.visit_noop">visit_noop</a></td> |
|
229 <td>Public method to ignore the given node.</td> |
|
230 </tr><tr> |
|
231 <td><a href="#Visitor.visit_property_init">visit_property_init</a></td> |
|
232 <td>Public method to treat a property_init node.</td> |
|
233 </tr><tr> |
|
234 <td><a href="#Visitor.visit_var">visit_var</a></td> |
|
235 <td>Public method to treat a variable node.</td> |
|
236 </tr> |
|
237 </table> |
|
238 <h3>Static Methods</h3> |
|
239 <table> |
|
240 <tr><td>None</td></tr> |
|
241 </table> |
|
242 <a NAME="Visitor.__init__" ID="Visitor.__init__"></a> |
|
243 <h4>Visitor (Constructor)</h4> |
|
244 <b>Visitor</b>(<i>src, module, filename</i>) |
|
245 <p> |
|
246 Constructor |
|
247 </p><dl> |
|
248 <dt><i>src</i></dt> |
|
249 <dd> |
|
250 source to be parsed (string) |
|
251 </dd><dt><i>module</i></dt> |
|
252 <dd> |
|
253 name of the module (string) |
|
254 </dd><dt><i>filename</i></dt> |
|
255 <dd> |
|
256 file name (string) |
|
257 </dd> |
|
258 </dl><a NAME="Visitor.__visit" ID="Visitor.__visit"></a> |
|
259 <h4>Visitor.__visit</h4> |
|
260 <b>__visit</b>(<i>root</i>) |
|
261 <p> |
|
262 Private method implementing the visit logic delegating to interesting |
|
263 methods. |
|
264 </p><dl> |
|
265 <dt><i>root</i></dt> |
|
266 <dd> |
|
267 root node to visit |
|
268 </dd> |
|
269 </dl><a NAME="Visitor.call" ID="Visitor.call"></a> |
|
270 <h4>Visitor.call</h4> |
|
271 <b>call</b>(<i></i>) |
|
272 <a NAME="Visitor.parse" ID="Visitor.parse"></a> |
|
273 <h4>Visitor.parse</h4> |
|
274 <b>parse</b>(<i></i>) |
|
275 <p> |
|
276 Public method to parse the source. |
|
277 </p><dl> |
|
278 <dt>Returns:</dt> |
|
279 <dd> |
|
280 dictionary containing the parsed information |
|
281 </dd> |
|
282 </dl><a NAME="Visitor.visit_const" ID="Visitor.visit_const"></a> |
|
283 <h4>Visitor.visit_const</h4> |
|
284 <b>visit_const</b>(<i>node</i>) |
|
285 <p> |
|
286 Public method to treat a constant node. |
|
287 </p><dl> |
|
288 <dt><i>node</i></dt> |
|
289 <dd> |
|
290 reference to the node (jasy.script.parse.Node.Node) |
|
291 </dd> |
|
292 </dl><a NAME="Visitor.visit_function" ID="Visitor.visit_function"></a> |
|
293 <h4>Visitor.visit_function</h4> |
|
294 <b>visit_function</b>(<i>node</i>) |
|
295 <p> |
|
296 Public method to treat a function node. |
|
297 </p><dl> |
|
298 <dt><i>node</i></dt> |
|
299 <dd> |
|
300 reference to the node (jasy.script.parse.Node.Node) |
|
301 </dd> |
|
302 </dl><a NAME="Visitor.visit_noop" ID="Visitor.visit_noop"></a> |
|
303 <h4>Visitor.visit_noop</h4> |
|
304 <b>visit_noop</b>(<i>node</i>) |
|
305 <p> |
|
306 Public method to ignore the given node. |
|
307 </p><dl> |
|
308 <dt><i>node</i></dt> |
|
309 <dd> |
|
310 reference to the node (jasy.script.parse.Node.Node) |
|
311 </dd> |
|
312 </dl><a NAME="Visitor.visit_property_init" ID="Visitor.visit_property_init"></a> |
|
313 <h4>Visitor.visit_property_init</h4> |
|
314 <b>visit_property_init</b>(<i>node</i>) |
|
315 <p> |
|
316 Public method to treat a property_init node. |
|
317 </p><dl> |
|
318 <dt><i>node</i></dt> |
|
319 <dd> |
|
320 reference to the node (jasy.script.parse.Node.Node) |
|
321 </dd> |
|
322 </dl><a NAME="Visitor.visit_var" ID="Visitor.visit_var"></a> |
|
323 <h4>Visitor.visit_var</h4> |
|
324 <b>visit_var</b>(<i>node</i>) |
|
325 <p> |
|
326 Public method to treat a variable node. |
|
327 </p><dl> |
|
328 <dt><i>node</i></dt> |
|
329 <dd> |
|
330 reference to the node (jasy.script.parse.Node.Node) |
|
331 </dd> |
|
332 </dl> |
|
333 <div align="right"><a href="#top">Up</a></div> |
|
334 <hr /><hr /> |
|
335 <a NAME="readmodule_ex" ID="readmodule_ex"></a> |
|
336 <h2>readmodule_ex</h2> |
|
337 <b>readmodule_ex</b>(<i>module, path=None</i>) |
|
338 <p> |
|
339 Read a JavaScript file and return a dictionary of functions and variables. |
|
340 </p><dl> |
|
341 <dt><i>module</i></dt> |
|
342 <dd> |
|
343 name of the JavaScript file (string) |
|
344 </dd><dt><i>path</i></dt> |
|
345 <dd> |
|
346 path the file should be searched in (list of strings) |
|
347 </dd> |
|
348 </dl><dl> |
|
349 <dt>Returns:</dt> |
|
350 <dd> |
|
351 the resulting dictionary |
|
352 </dd> |
|
353 </dl> |
|
354 <div align="right"><a href="#top">Up</a></div> |
|
355 <hr /> |
|
356 </body></html> |