eric6/Documentation/Source/eric6.DataViews.CodeMetrics.html

changeset 6942
2602857055c5
parent 5606
da305d172769
child 7273
391d6b7b1eff
equal deleted inserted replaced
6941:f99d60d6b59b 6942:2602857055c5
1 <!DOCTYPE html>
2 <html><head>
3 <title>eric6.DataViews.CodeMetrics</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.DataViews.CodeMetrics</h1>
23 <p>
24 Module implementing a simple Python code metrics analyzer.
25 </p><dl>
26 <dt>Raises <b>ValueError</b>:</dt>
27 <dd>
28 the tokenize module is too old
29 </dd>
30 </dl>
31 <h3>Global Attributes</h3>
32 <table>
33 <tr><td>COMMENT</td></tr><tr><td>DEDENT</td></tr><tr><td>EMPTY</td></tr><tr><td>INDENT</td></tr><tr><td>KEYWORD</td></tr><tr><td>NEWLINE</td></tr><tr><td>spacer</td></tr>
34 </table>
35 <h3>Classes</h3>
36 <table>
37 <tr>
38 <td><a href="#Parser">Parser</a></td>
39 <td>Class used to parse the source code of a Python file.</td>
40 </tr><tr>
41 <td><a href="#SourceStat">SourceStat</a></td>
42 <td>Class used to calculate and store the source code statistics.</td>
43 </tr><tr>
44 <td><a href="#Token">Token</a></td>
45 <td>Class to store the token related infos.</td>
46 </tr>
47 </table>
48 <h3>Functions</h3>
49 <table>
50 <tr>
51 <td><a href="#analyze">analyze</a></td>
52 <td>Module function used analyze the source of a Python file.</td>
53 </tr><tr>
54 <td><a href="#summarize">summarize</a></td>
55 <td>Module function used to collect overall statistics.</td>
56 </tr>
57 </table>
58 <hr /><hr />
59 <a NAME="Parser" ID="Parser"></a>
60 <h2>Parser</h2>
61 <p>
62 Class used to parse the source code of a Python file.
63 </p>
64 <h3>Derived from</h3>
65 object
66 <h3>Class Attributes</h3>
67 <table>
68 <tr><td>None</td></tr>
69 </table>
70 <h3>Class Methods</h3>
71 <table>
72 <tr><td>None</td></tr>
73 </table>
74 <h3>Methods</h3>
75 <table>
76 <tr>
77 <td><a href="#Parser.__addToken">__addToken</a></td>
78 <td>Private method used to add a token to our list of tokens.</td>
79 </tr><tr>
80 <td><a href="#Parser.parse">parse</a></td>
81 <td>Public method used to parse the source code.</td>
82 </tr>
83 </table>
84 <h3>Static Methods</h3>
85 <table>
86 <tr><td>None</td></tr>
87 </table>
88 <a NAME="Parser.__addToken" ID="Parser.__addToken"></a>
89 <h4>Parser.__addToken</h4>
90 <b>__addToken</b>(<i>toktype, toktext, srow, scol, line</i>)
91 <p>
92 Private method used to add a token to our list of tokens.
93 </p><dl>
94 <dt><i>toktype</i></dt>
95 <dd>
96 the type of the token (int)
97 </dd><dt><i>toktext</i></dt>
98 <dd>
99 the text of the token (string)
100 </dd><dt><i>srow</i></dt>
101 <dd>
102 starting row of the token (int)
103 </dd><dt><i>scol</i></dt>
104 <dd>
105 starting column of the token (int)
106 </dd><dt><i>line</i></dt>
107 <dd>
108 logical line the token was found (string)
109 </dd>
110 </dl><a NAME="Parser.parse" ID="Parser.parse"></a>
111 <h4>Parser.parse</h4>
112 <b>parse</b>(<i>text</i>)
113 <p>
114 Public method used to parse the source code.
115 </p><dl>
116 <dt><i>text</i></dt>
117 <dd>
118 the source code as read from a Python source file
119 </dd>
120 </dl>
121 <div align="right"><a href="#top">Up</a></div>
122 <hr /><hr />
123 <a NAME="SourceStat" ID="SourceStat"></a>
124 <h2>SourceStat</h2>
125 <p>
126 Class used to calculate and store the source code statistics.
127 </p>
128 <h3>Derived from</h3>
129 object
130 <h3>Class Attributes</h3>
131 <table>
132 <tr><td>None</td></tr>
133 </table>
134 <h3>Class Methods</h3>
135 <table>
136 <tr><td>None</td></tr>
137 </table>
138 <h3>Methods</h3>
139 <table>
140 <tr>
141 <td><a href="#SourceStat.__init__">SourceStat</a></td>
142 <td>Constructor</td>
143 </tr><tr>
144 <td><a href="#SourceStat.dedent">dedent</a></td>
145 <td>Public method used to decrement the indentation level.</td>
146 </tr><tr>
147 <td><a href="#SourceStat.getCounter">getCounter</a></td>
148 <td>Public method used to get a specific counter value.</td>
149 </tr><tr>
150 <td><a href="#SourceStat.inc">inc</a></td>
151 <td>Public method used to increment the value of a key.</td>
152 </tr><tr>
153 <td><a href="#SourceStat.indent">indent</a></td>
154 <td>Public method used to increment the indentation level.</td>
155 </tr><tr>
156 <td><a href="#SourceStat.push">push</a></td>
157 <td>Public method used to store an identifier.</td>
158 </tr>
159 </table>
160 <h3>Static Methods</h3>
161 <table>
162 <tr><td>None</td></tr>
163 </table>
164 <a NAME="SourceStat.__init__" ID="SourceStat.__init__"></a>
165 <h4>SourceStat (Constructor)</h4>
166 <b>SourceStat</b>(<i></i>)
167 <p>
168 Constructor
169 </p><a NAME="SourceStat.dedent" ID="SourceStat.dedent"></a>
170 <h4>SourceStat.dedent</h4>
171 <b>dedent</b>(<i>tok</i>)
172 <p>
173 Public method used to decrement the indentation level.
174 </p><dl>
175 <dt><i>tok</i></dt>
176 <dd>
177 the token to be processed (Token)
178 </dd>
179 </dl><dl>
180 <dt>Raises <b>ValueError</b>:</dt>
181 <dd>
182 raised to indicate an invalid indentation level
183 </dd>
184 </dl><a NAME="SourceStat.getCounter" ID="SourceStat.getCounter"></a>
185 <h4>SourceStat.getCounter</h4>
186 <b>getCounter</b>(<i>counterId, key</i>)
187 <p>
188 Public method used to get a specific counter value.
189 </p><dl>
190 <dt><i>counterId</i></dt>
191 <dd>
192 id of the counter (string)
193 </dd><dt><i>key</i></dt>
194 <dd>
195 key of the value to be retrieved (string)
196 </dd>
197 </dl><dl>
198 <dt>Returns:</dt>
199 <dd>
200 the value of the requested counter (int)
201 </dd>
202 </dl><a NAME="SourceStat.inc" ID="SourceStat.inc"></a>
203 <h4>SourceStat.inc</h4>
204 <b>inc</b>(<i>key, value=1</i>)
205 <p>
206 Public method used to increment the value of a key.
207 </p><dl>
208 <dt><i>key</i></dt>
209 <dd>
210 the key to be incremented
211 </dd><dt><i>value</i></dt>
212 <dd>
213 the increment (int)
214 </dd>
215 </dl><a NAME="SourceStat.indent" ID="SourceStat.indent"></a>
216 <h4>SourceStat.indent</h4>
217 <b>indent</b>(<i>tok</i>)
218 <p>
219 Public method used to increment the indentation level.
220 </p><dl>
221 <dt><i>tok</i></dt>
222 <dd>
223 a token (Token, ignored)
224 </dd>
225 </dl><a NAME="SourceStat.push" ID="SourceStat.push"></a>
226 <h4>SourceStat.push</h4>
227 <b>push</b>(<i>identifier, row</i>)
228 <p>
229 Public method used to store an identifier.
230 </p><dl>
231 <dt><i>identifier</i></dt>
232 <dd>
233 the identifier to be remembered (string)
234 </dd><dt><i>row</i></dt>
235 <dd>
236 the row, the identifier is defined in (int)
237 </dd>
238 </dl>
239 <div align="right"><a href="#top">Up</a></div>
240 <hr /><hr />
241 <a NAME="Token" ID="Token"></a>
242 <h2>Token</h2>
243 <p>
244 Class to store the token related infos.
245 </p>
246 <h3>Derived from</h3>
247 object
248 <h3>Class Attributes</h3>
249 <table>
250 <tr><td>None</td></tr>
251 </table>
252 <h3>Class Methods</h3>
253 <table>
254 <tr><td>None</td></tr>
255 </table>
256 <h3>Methods</h3>
257 <table>
258 <tr>
259 <td><a href="#Token.__init__">Token</a></td>
260 <td>Constructor</td>
261 </tr>
262 </table>
263 <h3>Static Methods</h3>
264 <table>
265 <tr><td>None</td></tr>
266 </table>
267 <a NAME="Token.__init__" ID="Token.__init__"></a>
268 <h4>Token (Constructor)</h4>
269 <b>Token</b>(<i>**kw</i>)
270 <p>
271 Constructor
272 </p><dl>
273 <dt><i>**kw=</i></dt>
274 <dd>
275 list of key, value pairs
276 </dd>
277 </dl>
278 <div align="right"><a href="#top">Up</a></div>
279 <hr /><hr />
280 <a NAME="analyze" ID="analyze"></a>
281 <h2>analyze</h2>
282 <b>analyze</b>(<i>filename, total</i>)
283 <p>
284 Module function used analyze the source of a Python file.
285 </p><dl>
286 <dt><i>filename</i></dt>
287 <dd>
288 name of the Python file to be analyzed (string)
289 </dd><dt><i>total</i></dt>
290 <dd>
291 dictionary receiving the overall code statistics
292 </dd>
293 </dl><dl>
294 <dt>Returns:</dt>
295 <dd>
296 a statistics object with the collected code statistics (SourceStat)
297 </dd>
298 </dl>
299 <div align="right"><a href="#top">Up</a></div>
300 <hr /><hr />
301 <a NAME="summarize" ID="summarize"></a>
302 <h2>summarize</h2>
303 <b>summarize</b>(<i>total, key, value</i>)
304 <p>
305 Module function used to collect overall statistics.
306 </p><dl>
307 <dt><i>total</i></dt>
308 <dd>
309 the dictionary for the overall statistics
310 </dd><dt><i>key</i></dt>
311 <dd>
312 the key to be summarize
313 </dd><dt><i>value</i></dt>
314 <dd>
315 the value to be added to the overall statistics
316 </dd>
317 </dl><dl>
318 <dt>Returns:</dt>
319 <dd>
320 the value added to the overall statistics
321 </dd>
322 </dl>
323 <div align="right"><a href="#top">Up</a></div>
324 <hr />
325 </body></html>

eric ide

mercurial