|
1 <!DOCTYPE html> |
|
2 <html><head> |
|
3 <title>eric5.Plugins.CheckerPlugins.Pep8.Pep257Checker</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>eric5.Plugins.CheckerPlugins.Pep8.Pep257Checker</h1> |
|
23 <p> |
|
24 Module implementing a checker for PEP-257 documentation string conventions. |
|
25 </p> |
|
26 <h3>Global Attributes</h3> |
|
27 <table> |
|
28 <tr><td>None</td></tr> |
|
29 </table> |
|
30 <h3>Classes</h3> |
|
31 <table> |
|
32 <tr> |
|
33 <td><a href="#Pep257Checker">Pep257Checker</a></td> |
|
34 <td>Class implementing a checker for PEP-257 documentation string conventions.</td> |
|
35 </tr><tr> |
|
36 <td><a href="#Pep257Context">Pep257Context</a></td> |
|
37 <td>Class implementing the source context.</td> |
|
38 </tr> |
|
39 </table> |
|
40 <h3>Functions</h3> |
|
41 <table> |
|
42 <tr><td>None</td></tr> |
|
43 </table> |
|
44 <hr /><hr /> |
|
45 <a NAME="Pep257Checker" ID="Pep257Checker"></a> |
|
46 <h2>Pep257Checker</h2> |
|
47 <p> |
|
48 Class implementing a checker for PEP-257 documentation string conventions. |
|
49 </p> |
|
50 <h3>Derived from</h3> |
|
51 object |
|
52 <h3>Class Attributes</h3> |
|
53 <table> |
|
54 <tr><td>Codes</td></tr><tr><td>Messages</td></tr> |
|
55 </table> |
|
56 <h3>Class Methods</h3> |
|
57 <table> |
|
58 <tr><td>None</td></tr> |
|
59 </table> |
|
60 <h3>Methods</h3> |
|
61 <table> |
|
62 <tr> |
|
63 <td><a href="#Pep257Checker.__init__">Pep257Checker</a></td> |
|
64 <td>Constructor (according to 'extended' pep8.py API)</td> |
|
65 </tr><tr> |
|
66 <td><a href="#Pep257Checker.__checkBackslashes">__checkBackslashes</a></td> |
|
67 <td>Private method to check, that all docstrings containing backslashes are surrounded by raw triple double quotes.</td> |
|
68 </tr><tr> |
|
69 <td><a href="#Pep257Checker.__checkBlankAfterLastParagraph">__checkBlankAfterLastParagraph</a></td> |
|
70 <td>Private method to check, that docstring summaries are followed by a blank line.</td> |
|
71 </tr><tr> |
|
72 <td><a href="#Pep257Checker.__checkBlankAfterSummary">__checkBlankAfterSummary</a></td> |
|
73 <td>Private method to check, that docstring summaries are followed by a blank line.</td> |
|
74 </tr><tr> |
|
75 <td><a href="#Pep257Checker.__checkBlankBeforeAndAfterClass">__checkBlankBeforeAndAfterClass</a></td> |
|
76 <td>Private method to check, that class docstrings have one blank line around them.</td> |
|
77 </tr><tr> |
|
78 <td><a href="#Pep257Checker.__checkClassDocstring">__checkClassDocstring</a></td> |
|
79 <td>Private method to check, that all public functions and methods have a docstring.</td> |
|
80 </tr><tr> |
|
81 <td><a href="#Pep257Checker.__checkEndsWithPeriod">__checkEndsWithPeriod</a></td> |
|
82 <td>Private method to check, that docstring summaries end with a period.</td> |
|
83 </tr><tr> |
|
84 <td><a href="#Pep257Checker.__checkFunctionDocstring">__checkFunctionDocstring</a></td> |
|
85 <td>Private method to check, that all public functions and methods have a docstring.</td> |
|
86 </tr><tr> |
|
87 <td><a href="#Pep257Checker.__checkImperativeMood">__checkImperativeMood</a></td> |
|
88 <td>Private method to check, that docstring summaries are in imperative mood.</td> |
|
89 </tr><tr> |
|
90 <td><a href="#Pep257Checker.__checkIndent">__checkIndent</a></td> |
|
91 <td>Private method to check, that docstrings are properly indented.</td> |
|
92 </tr><tr> |
|
93 <td><a href="#Pep257Checker.__checkModulesDocstrings">__checkModulesDocstrings</a></td> |
|
94 <td>Private method to check, if the module has a docstring.</td> |
|
95 </tr><tr> |
|
96 <td><a href="#Pep257Checker.__checkNoBlankLineBefore">__checkNoBlankLineBefore</a></td> |
|
97 <td>Private method to check, that function/method docstrings are not preceded by a blank line.</td> |
|
98 </tr><tr> |
|
99 <td><a href="#Pep257Checker.__checkNoSignature">__checkNoSignature</a></td> |
|
100 <td>Private method to check, that docstring summaries don't repeat the function's signature.</td> |
|
101 </tr><tr> |
|
102 <td><a href="#Pep257Checker.__checkOneLiner">__checkOneLiner</a></td> |
|
103 <td>Private method to check, that one-liner docstrings fit on one line with quotes.</td> |
|
104 </tr><tr> |
|
105 <td><a href="#Pep257Checker.__checkReturnType">__checkReturnType</a></td> |
|
106 <td>Private method to check, that docstrings mention the return value type.</td> |
|
107 </tr><tr> |
|
108 <td><a href="#Pep257Checker.__checkTripleDoubleQuotes">__checkTripleDoubleQuotes</a></td> |
|
109 <td>Private method to check, that all docstrings are surrounded by triple double quotes.</td> |
|
110 </tr><tr> |
|
111 <td><a href="#Pep257Checker.__checkUnicode">__checkUnicode</a></td> |
|
112 <td>Private method to check, that all docstrings containing unicode characters are surrounded by unicode triple double quotes.</td> |
|
113 </tr><tr> |
|
114 <td><a href="#Pep257Checker.__error">__error</a></td> |
|
115 <td>Private method to record an issue.</td> |
|
116 </tr><tr> |
|
117 <td><a href="#Pep257Checker.__getSummaryLine">__getSummaryLine</a></td> |
|
118 <td>Private method to extract the summary line.</td> |
|
119 </tr><tr> |
|
120 <td><a href="#Pep257Checker.__ignoreCode">__ignoreCode</a></td> |
|
121 <td>Private method to check if the error code should be ignored.</td> |
|
122 </tr><tr> |
|
123 <td><a href="#Pep257Checker.__parseClasses">__parseClasses</a></td> |
|
124 <td>Private method to extract top-level classes.</td> |
|
125 </tr><tr> |
|
126 <td><a href="#Pep257Checker.__parseContexts">__parseContexts</a></td> |
|
127 <td>Private method to extract a context from the source.</td> |
|
128 </tr><tr> |
|
129 <td><a href="#Pep257Checker.__parseDocstring">__parseDocstring</a></td> |
|
130 <td>Private method to extract a docstring given `def` or `class` source.</td> |
|
131 </tr><tr> |
|
132 <td><a href="#Pep257Checker.__parseFunctions">__parseFunctions</a></td> |
|
133 <td>Private method to extract top-level functions.</td> |
|
134 </tr><tr> |
|
135 <td><a href="#Pep257Checker.__parseMethods">__parseMethods</a></td> |
|
136 <td>Private method to extract methods of all classes.</td> |
|
137 </tr><tr> |
|
138 <td><a href="#Pep257Checker.__parseModuleDocstring">__parseModuleDocstring</a></td> |
|
139 <td>Private method to extract a docstring given a module source.</td> |
|
140 </tr><tr> |
|
141 <td><a href="#Pep257Checker.__parseTopLevel">__parseTopLevel</a></td> |
|
142 <td>Private method to extract top-level functions or classes.</td> |
|
143 </tr><tr> |
|
144 <td><a href="#Pep257Checker.__readline">__readline</a></td> |
|
145 <td>Private method to get the next line from the source.</td> |
|
146 </tr><tr> |
|
147 <td><a href="#Pep257Checker.__resetReadline">__resetReadline</a></td> |
|
148 <td>Private method to reset the internal readline function.</td> |
|
149 </tr><tr> |
|
150 <td><a href="#Pep257Checker.__skipIndentedBlock">__skipIndentedBlock</a></td> |
|
151 <td>Private method to skip over an indented block of source code.</td> |
|
152 </tr><tr> |
|
153 <td><a href="#Pep257Checker.getMessage">getMessage</a></td> |
|
154 <td>Public method to get a translated and formatted message for a given code.</td> |
|
155 </tr><tr> |
|
156 <td><a href="#Pep257Checker.run">run</a></td> |
|
157 <td>Public method to check the given source for violations of doc string conventions according to PEP-257.</td> |
|
158 </tr> |
|
159 </table> |
|
160 <h3>Static Methods</h3> |
|
161 <table> |
|
162 <tr><td>None</td></tr> |
|
163 </table> |
|
164 <a NAME="Pep257Checker.__init__" ID="Pep257Checker.__init__"></a> |
|
165 <h4>Pep257Checker (Constructor)</h4> |
|
166 <b>Pep257Checker</b>(<i>source, filename, select, ignore, expected, repeat, maxLineLength=79</i>) |
|
167 <p> |
|
168 Constructor (according to 'extended' pep8.py API) |
|
169 </p><dl> |
|
170 <dt><i>source</i></dt> |
|
171 <dd> |
|
172 source code to be checked (list of string) |
|
173 </dd><dt><i>filename</i></dt> |
|
174 <dd> |
|
175 name of the source file (string) |
|
176 </dd><dt><i>select</i></dt> |
|
177 <dd> |
|
178 list of selected codes (list of string) |
|
179 </dd><dt><i>ignore</i></dt> |
|
180 <dd> |
|
181 list of codes to be ignored (list of string) |
|
182 </dd><dt><i>expected</i></dt> |
|
183 <dd> |
|
184 list of expected codes (list of string) |
|
185 </dd><dt><i>repeat</i></dt> |
|
186 <dd> |
|
187 flag indicating to report each occurrence of a code |
|
188 (boolean) |
|
189 </dd><dt><i>maxLineLength</i></dt> |
|
190 <dd> |
|
191 allowed line length (integer) |
|
192 </dd> |
|
193 </dl><a NAME="Pep257Checker.__checkBackslashes" ID="Pep257Checker.__checkBackslashes"></a> |
|
194 <h4>Pep257Checker.__checkBackslashes</h4> |
|
195 <b>__checkBackslashes</b>(<i>docstringContext, context</i>) |
|
196 <p> |
|
197 Private method to check, that all docstrings containing |
|
198 backslashes are surrounded by raw triple double quotes. |
|
199 </p><dl> |
|
200 <dt><i>docstringContext</i></dt> |
|
201 <dd> |
|
202 docstring context (Pep257Context) |
|
203 </dd><dt><i>context</i></dt> |
|
204 <dd> |
|
205 context of the docstring (Pep257Context) |
|
206 </dd> |
|
207 </dl><a NAME="Pep257Checker.__checkBlankAfterLastParagraph" ID="Pep257Checker.__checkBlankAfterLastParagraph"></a> |
|
208 <h4>Pep257Checker.__checkBlankAfterLastParagraph</h4> |
|
209 <b>__checkBlankAfterLastParagraph</b>(<i>docstringContext, context</i>) |
|
210 <p> |
|
211 Private method to check, that docstring summaries are followed |
|
212 by a blank line. |
|
213 </p><dl> |
|
214 <dt><i>docstringContext</i></dt> |
|
215 <dd> |
|
216 docstring context (Pep257Context) |
|
217 </dd><dt><i>context</i></dt> |
|
218 <dd> |
|
219 context of the docstring (Pep257Context) |
|
220 </dd> |
|
221 </dl><a NAME="Pep257Checker.__checkBlankAfterSummary" ID="Pep257Checker.__checkBlankAfterSummary"></a> |
|
222 <h4>Pep257Checker.__checkBlankAfterSummary</h4> |
|
223 <b>__checkBlankAfterSummary</b>(<i>docstringContext, context</i>) |
|
224 <p> |
|
225 Private method to check, that docstring summaries are followed |
|
226 by a blank line. |
|
227 </p><dl> |
|
228 <dt><i>docstringContext</i></dt> |
|
229 <dd> |
|
230 docstring context (Pep257Context) |
|
231 </dd><dt><i>context</i></dt> |
|
232 <dd> |
|
233 context of the docstring (Pep257Context) |
|
234 </dd> |
|
235 </dl><a NAME="Pep257Checker.__checkBlankBeforeAndAfterClass" ID="Pep257Checker.__checkBlankBeforeAndAfterClass"></a> |
|
236 <h4>Pep257Checker.__checkBlankBeforeAndAfterClass</h4> |
|
237 <b>__checkBlankBeforeAndAfterClass</b>(<i>docstringContext, context</i>) |
|
238 <p> |
|
239 Private method to check, that class docstrings have one |
|
240 blank line around them. |
|
241 </p><dl> |
|
242 <dt><i>docstringContext</i></dt> |
|
243 <dd> |
|
244 docstring context (Pep257Context) |
|
245 </dd><dt><i>context</i></dt> |
|
246 <dd> |
|
247 context of the docstring (Pep257Context) |
|
248 </dd> |
|
249 </dl><a NAME="Pep257Checker.__checkClassDocstring" ID="Pep257Checker.__checkClassDocstring"></a> |
|
250 <h4>Pep257Checker.__checkClassDocstring</h4> |
|
251 <b>__checkClassDocstring</b>(<i>docstringContext, context</i>) |
|
252 <p> |
|
253 Private method to check, that all public functions and methods |
|
254 have a docstring. |
|
255 </p><dl> |
|
256 <dt><i>docstringContext</i></dt> |
|
257 <dd> |
|
258 docstring context (Pep257Context) |
|
259 </dd><dt><i>context</i></dt> |
|
260 <dd> |
|
261 context of the docstring (Pep257Context) |
|
262 </dd> |
|
263 </dl><a NAME="Pep257Checker.__checkEndsWithPeriod" ID="Pep257Checker.__checkEndsWithPeriod"></a> |
|
264 <h4>Pep257Checker.__checkEndsWithPeriod</h4> |
|
265 <b>__checkEndsWithPeriod</b>(<i>docstringContext, context</i>) |
|
266 <p> |
|
267 Private method to check, that docstring summaries end with a period. |
|
268 </p><dl> |
|
269 <dt><i>docstringContext</i></dt> |
|
270 <dd> |
|
271 docstring context (Pep257Context) |
|
272 </dd><dt><i>context</i></dt> |
|
273 <dd> |
|
274 context of the docstring (Pep257Context) |
|
275 </dd> |
|
276 </dl><a NAME="Pep257Checker.__checkFunctionDocstring" ID="Pep257Checker.__checkFunctionDocstring"></a> |
|
277 <h4>Pep257Checker.__checkFunctionDocstring</h4> |
|
278 <b>__checkFunctionDocstring</b>(<i>docstringContext, context</i>) |
|
279 <p> |
|
280 Private method to check, that all public functions and methods |
|
281 have a docstring. |
|
282 </p><dl> |
|
283 <dt><i>docstringContext</i></dt> |
|
284 <dd> |
|
285 docstring context (Pep257Context) |
|
286 </dd><dt><i>context</i></dt> |
|
287 <dd> |
|
288 context of the docstring (Pep257Context) |
|
289 </dd> |
|
290 </dl><a NAME="Pep257Checker.__checkImperativeMood" ID="Pep257Checker.__checkImperativeMood"></a> |
|
291 <h4>Pep257Checker.__checkImperativeMood</h4> |
|
292 <b>__checkImperativeMood</b>(<i>docstringContext, context</i>) |
|
293 <p> |
|
294 Private method to check, that docstring summaries are in |
|
295 imperative mood. |
|
296 </p><dl> |
|
297 <dt><i>docstringContext</i></dt> |
|
298 <dd> |
|
299 docstring context (Pep257Context) |
|
300 </dd><dt><i>context</i></dt> |
|
301 <dd> |
|
302 context of the docstring (Pep257Context) |
|
303 </dd> |
|
304 </dl><a NAME="Pep257Checker.__checkIndent" ID="Pep257Checker.__checkIndent"></a> |
|
305 <h4>Pep257Checker.__checkIndent</h4> |
|
306 <b>__checkIndent</b>(<i>docstringContext, context</i>) |
|
307 <p> |
|
308 Private method to check, that docstrings are properly indented. |
|
309 </p><dl> |
|
310 <dt><i>docstringContext</i></dt> |
|
311 <dd> |
|
312 docstring context (Pep257Context) |
|
313 </dd><dt><i>context</i></dt> |
|
314 <dd> |
|
315 context of the docstring (Pep257Context) |
|
316 </dd> |
|
317 </dl><a NAME="Pep257Checker.__checkModulesDocstrings" ID="Pep257Checker.__checkModulesDocstrings"></a> |
|
318 <h4>Pep257Checker.__checkModulesDocstrings</h4> |
|
319 <b>__checkModulesDocstrings</b>(<i>docstringContext, context</i>) |
|
320 <p> |
|
321 Private method to check, if the module has a docstring. |
|
322 </p><dl> |
|
323 <dt><i>docstringContext</i></dt> |
|
324 <dd> |
|
325 docstring context (Pep257Context) |
|
326 </dd><dt><i>context</i></dt> |
|
327 <dd> |
|
328 context of the docstring (Pep257Context) |
|
329 </dd> |
|
330 </dl><a NAME="Pep257Checker.__checkNoBlankLineBefore" ID="Pep257Checker.__checkNoBlankLineBefore"></a> |
|
331 <h4>Pep257Checker.__checkNoBlankLineBefore</h4> |
|
332 <b>__checkNoBlankLineBefore</b>(<i>docstringContext, context</i>) |
|
333 <p> |
|
334 Private method to check, that function/method docstrings are not |
|
335 preceded by a blank line. |
|
336 </p><dl> |
|
337 <dt><i>docstringContext</i></dt> |
|
338 <dd> |
|
339 docstring context (Pep257Context) |
|
340 </dd><dt><i>context</i></dt> |
|
341 <dd> |
|
342 context of the docstring (Pep257Context) |
|
343 </dd> |
|
344 </dl><a NAME="Pep257Checker.__checkNoSignature" ID="Pep257Checker.__checkNoSignature"></a> |
|
345 <h4>Pep257Checker.__checkNoSignature</h4> |
|
346 <b>__checkNoSignature</b>(<i>docstringContext, context</i>) |
|
347 <p> |
|
348 Private method to check, that docstring summaries don't repeat |
|
349 the function's signature. |
|
350 </p><dl> |
|
351 <dt><i>docstringContext</i></dt> |
|
352 <dd> |
|
353 docstring context (Pep257Context) |
|
354 </dd><dt><i>context</i></dt> |
|
355 <dd> |
|
356 context of the docstring (Pep257Context) |
|
357 </dd> |
|
358 </dl><a NAME="Pep257Checker.__checkOneLiner" ID="Pep257Checker.__checkOneLiner"></a> |
|
359 <h4>Pep257Checker.__checkOneLiner</h4> |
|
360 <b>__checkOneLiner</b>(<i>docstringContext, context</i>) |
|
361 <p> |
|
362 Private method to check, that one-liner docstrings fit on |
|
363 one line with quotes. |
|
364 </p><dl> |
|
365 <dt><i>docstringContext</i></dt> |
|
366 <dd> |
|
367 docstring context (Pep257Context) |
|
368 </dd><dt><i>context</i></dt> |
|
369 <dd> |
|
370 context of the docstring (Pep257Context) |
|
371 </dd> |
|
372 </dl><a NAME="Pep257Checker.__checkReturnType" ID="Pep257Checker.__checkReturnType"></a> |
|
373 <h4>Pep257Checker.__checkReturnType</h4> |
|
374 <b>__checkReturnType</b>(<i>docstringContext, context</i>) |
|
375 <p> |
|
376 Private method to check, that docstrings mention the return value type. |
|
377 </p><dl> |
|
378 <dt><i>docstringContext</i></dt> |
|
379 <dd> |
|
380 docstring context (Pep257Context) |
|
381 </dd><dt><i>context</i></dt> |
|
382 <dd> |
|
383 context of the docstring (Pep257Context) |
|
384 </dd> |
|
385 </dl><a NAME="Pep257Checker.__checkTripleDoubleQuotes" ID="Pep257Checker.__checkTripleDoubleQuotes"></a> |
|
386 <h4>Pep257Checker.__checkTripleDoubleQuotes</h4> |
|
387 <b>__checkTripleDoubleQuotes</b>(<i>docstringContext, context</i>) |
|
388 <p> |
|
389 Private method to check, that all docstrings are surrounded |
|
390 by triple double quotes. |
|
391 </p><dl> |
|
392 <dt><i>docstringContext</i></dt> |
|
393 <dd> |
|
394 docstring context (Pep257Context) |
|
395 </dd><dt><i>context</i></dt> |
|
396 <dd> |
|
397 context of the docstring (Pep257Context) |
|
398 </dd> |
|
399 </dl><a NAME="Pep257Checker.__checkUnicode" ID="Pep257Checker.__checkUnicode"></a> |
|
400 <h4>Pep257Checker.__checkUnicode</h4> |
|
401 <b>__checkUnicode</b>(<i>docstringContext, context</i>) |
|
402 <p> |
|
403 Private method to check, that all docstrings containing unicode |
|
404 characters are surrounded by unicode triple double quotes. |
|
405 </p><dl> |
|
406 <dt><i>docstringContext</i></dt> |
|
407 <dd> |
|
408 docstring context (Pep257Context) |
|
409 </dd><dt><i>context</i></dt> |
|
410 <dd> |
|
411 context of the docstring (Pep257Context) |
|
412 </dd> |
|
413 </dl><a NAME="Pep257Checker.__error" ID="Pep257Checker.__error"></a> |
|
414 <h4>Pep257Checker.__error</h4> |
|
415 <b>__error</b>(<i>lineNumber, offset, code, *args</i>) |
|
416 <p> |
|
417 Private method to record an issue. |
|
418 </p><dl> |
|
419 <dt><i>lineNumber</i></dt> |
|
420 <dd> |
|
421 line number of the issue (integer) |
|
422 </dd><dt><i>offset</i></dt> |
|
423 <dd> |
|
424 position within line of the issue (integer) |
|
425 </dd><dt><i>code</i></dt> |
|
426 <dd> |
|
427 message code (string) |
|
428 </dd><dt><i>args</i></dt> |
|
429 <dd> |
|
430 arguments for the message (list) |
|
431 </dd> |
|
432 </dl><a NAME="Pep257Checker.__getSummaryLine" ID="Pep257Checker.__getSummaryLine"></a> |
|
433 <h4>Pep257Checker.__getSummaryLine</h4> |
|
434 <b>__getSummaryLine</b>(<i>docstringContext</i>) |
|
435 <p> |
|
436 Private method to extract the summary line. |
|
437 </p><dl> |
|
438 <dt><i>docstringContext</i></dt> |
|
439 <dd> |
|
440 docstring context (Pep257Context) |
|
441 </dd> |
|
442 </dl><dl> |
|
443 <dt>Returns:</dt> |
|
444 <dd> |
|
445 summary line (string) and the line it was found on (integer) |
|
446 </dd> |
|
447 </dl><a NAME="Pep257Checker.__ignoreCode" ID="Pep257Checker.__ignoreCode"></a> |
|
448 <h4>Pep257Checker.__ignoreCode</h4> |
|
449 <b>__ignoreCode</b>(<i>code</i>) |
|
450 <p> |
|
451 Private method to check if the error code should be ignored. |
|
452 </p><dl> |
|
453 <dt><i>code</i></dt> |
|
454 <dd> |
|
455 message code to check for (string) |
|
456 </dd> |
|
457 </dl><dl> |
|
458 <dt>Returns:</dt> |
|
459 <dd> |
|
460 flag indicating to ignore the given code (boolean) |
|
461 </dd> |
|
462 </dl><a NAME="Pep257Checker.__parseClasses" ID="Pep257Checker.__parseClasses"></a> |
|
463 <h4>Pep257Checker.__parseClasses</h4> |
|
464 <b>__parseClasses</b>(<i></i>) |
|
465 <p> |
|
466 Private method to extract top-level classes. |
|
467 </p><dl> |
|
468 <dt>Returns:</dt> |
|
469 <dd> |
|
470 extracted class contexts (list of Pep257Context) |
|
471 </dd> |
|
472 </dl><a NAME="Pep257Checker.__parseContexts" ID="Pep257Checker.__parseContexts"></a> |
|
473 <h4>Pep257Checker.__parseContexts</h4> |
|
474 <b>__parseContexts</b>(<i>kind</i>) |
|
475 <p> |
|
476 Private method to extract a context from the source. |
|
477 </p><dl> |
|
478 <dt><i>kind</i></dt> |
|
479 <dd> |
|
480 kind of context to extract (string) |
|
481 </dd> |
|
482 </dl><dl> |
|
483 <dt>Returns:</dt> |
|
484 <dd> |
|
485 requested contexts (list of Pep257Context) |
|
486 </dd> |
|
487 </dl><a NAME="Pep257Checker.__parseDocstring" ID="Pep257Checker.__parseDocstring"></a> |
|
488 <h4>Pep257Checker.__parseDocstring</h4> |
|
489 <b>__parseDocstring</b>(<i>context, what=''</i>) |
|
490 <p> |
|
491 Private method to extract a docstring given `def` or `class` source. |
|
492 </p><dl> |
|
493 <dt><i>context</i></dt> |
|
494 <dd> |
|
495 context data to get the docstring from (Pep257Context) |
|
496 </dd> |
|
497 </dl><dl> |
|
498 <dt>Returns:</dt> |
|
499 <dd> |
|
500 context of extracted docstring (Pep257Context) |
|
501 </dd> |
|
502 </dl><a NAME="Pep257Checker.__parseFunctions" ID="Pep257Checker.__parseFunctions"></a> |
|
503 <h4>Pep257Checker.__parseFunctions</h4> |
|
504 <b>__parseFunctions</b>(<i></i>) |
|
505 <p> |
|
506 Private method to extract top-level functions. |
|
507 </p><dl> |
|
508 <dt>Returns:</dt> |
|
509 <dd> |
|
510 extracted function contexts (list of Pep257Context) |
|
511 </dd> |
|
512 </dl><a NAME="Pep257Checker.__parseMethods" ID="Pep257Checker.__parseMethods"></a> |
|
513 <h4>Pep257Checker.__parseMethods</h4> |
|
514 <b>__parseMethods</b>(<i></i>) |
|
515 <p> |
|
516 Private method to extract methods of all classes. |
|
517 </p><dl> |
|
518 <dt>Returns:</dt> |
|
519 <dd> |
|
520 extracted method contexts (list of Pep257Context) |
|
521 </dd> |
|
522 </dl><a NAME="Pep257Checker.__parseModuleDocstring" ID="Pep257Checker.__parseModuleDocstring"></a> |
|
523 <h4>Pep257Checker.__parseModuleDocstring</h4> |
|
524 <b>__parseModuleDocstring</b>(<i>source</i>) |
|
525 <p> |
|
526 Private method to extract a docstring given a module source. |
|
527 </p><dl> |
|
528 <dt><i>source</i></dt> |
|
529 <dd> |
|
530 source to parse (list of string) |
|
531 </dd> |
|
532 </dl><dl> |
|
533 <dt>Returns:</dt> |
|
534 <dd> |
|
535 context of extracted docstring (Pep257Context) |
|
536 </dd> |
|
537 </dl><a NAME="Pep257Checker.__parseTopLevel" ID="Pep257Checker.__parseTopLevel"></a> |
|
538 <h4>Pep257Checker.__parseTopLevel</h4> |
|
539 <b>__parseTopLevel</b>(<i>keyword</i>) |
|
540 <p> |
|
541 Private method to extract top-level functions or classes. |
|
542 </p><dl> |
|
543 <dt><i>keyword</i></dt> |
|
544 <dd> |
|
545 keyword signaling what to extract (string) |
|
546 </dd> |
|
547 </dl><dl> |
|
548 <dt>Returns:</dt> |
|
549 <dd> |
|
550 extracted function or class contexts (list of Pep257Context) |
|
551 </dd> |
|
552 </dl><a NAME="Pep257Checker.__readline" ID="Pep257Checker.__readline"></a> |
|
553 <h4>Pep257Checker.__readline</h4> |
|
554 <b>__readline</b>(<i></i>) |
|
555 <p> |
|
556 Private method to get the next line from the source. |
|
557 </p><dl> |
|
558 <dt>Returns:</dt> |
|
559 <dd> |
|
560 next line of source (string) |
|
561 </dd> |
|
562 </dl><a NAME="Pep257Checker.__resetReadline" ID="Pep257Checker.__resetReadline"></a> |
|
563 <h4>Pep257Checker.__resetReadline</h4> |
|
564 <b>__resetReadline</b>(<i></i>) |
|
565 <p> |
|
566 Private method to reset the internal readline function. |
|
567 </p><a NAME="Pep257Checker.__skipIndentedBlock" ID="Pep257Checker.__skipIndentedBlock"></a> |
|
568 <h4>Pep257Checker.__skipIndentedBlock</h4> |
|
569 <b>__skipIndentedBlock</b>(<i>tokenGenerator</i>) |
|
570 <p> |
|
571 Private method to skip over an indented block of source code. |
|
572 </p><dl> |
|
573 <dt><i>tokenGenerator</i></dt> |
|
574 <dd> |
|
575 token generator |
|
576 </dd> |
|
577 </dl><dl> |
|
578 <dt>Returns:</dt> |
|
579 <dd> |
|
580 last token of the indented block |
|
581 </dd> |
|
582 </dl><a NAME="Pep257Checker.getMessage" ID="Pep257Checker.getMessage"></a> |
|
583 <h4>Pep257Checker.getMessage</h4> |
|
584 <b>getMessage</b>(<i>code, *args</i>) |
|
585 <p> |
|
586 Public method to get a translated and formatted message for a |
|
587 given code. |
|
588 </p><dl> |
|
589 <dt><i>code</i></dt> |
|
590 <dd> |
|
591 message code (string) |
|
592 </dd><dt><i>args</i></dt> |
|
593 <dd> |
|
594 arguments for a formatted message (list) |
|
595 </dd> |
|
596 </dl><dl> |
|
597 <dt>Returns:</dt> |
|
598 <dd> |
|
599 translated and formatted message (string) |
|
600 </dd> |
|
601 </dl><a NAME="Pep257Checker.run" ID="Pep257Checker.run"></a> |
|
602 <h4>Pep257Checker.run</h4> |
|
603 <b>run</b>(<i></i>) |
|
604 <p> |
|
605 Public method to check the given source for violations of doc string |
|
606 conventions according to PEP-257. |
|
607 </p> |
|
608 <div align="right"><a href="#top">Up</a></div> |
|
609 <hr /><hr /> |
|
610 <a NAME="Pep257Context" ID="Pep257Context"></a> |
|
611 <h2>Pep257Context</h2> |
|
612 <p> |
|
613 Class implementing the source context. |
|
614 </p> |
|
615 <h3>Derived from</h3> |
|
616 object |
|
617 <h3>Class Attributes</h3> |
|
618 <table> |
|
619 <tr><td>None</td></tr> |
|
620 </table> |
|
621 <h3>Class Methods</h3> |
|
622 <table> |
|
623 <tr><td>None</td></tr> |
|
624 </table> |
|
625 <h3>Methods</h3> |
|
626 <table> |
|
627 <tr> |
|
628 <td><a href="#Pep257Context.__init__">Pep257Context</a></td> |
|
629 <td>Constructor</td> |
|
630 </tr><tr> |
|
631 <td><a href="#Pep257Context.contextType">contextType</a></td> |
|
632 <td>Public method to get the context type.</td> |
|
633 </tr><tr> |
|
634 <td><a href="#Pep257Context.end">end</a></td> |
|
635 <td>Public method to get the end line number.</td> |
|
636 </tr><tr> |
|
637 <td><a href="#Pep257Context.indent">indent</a></td> |
|
638 <td>Public method to get the indentation of the first line.</td> |
|
639 </tr><tr> |
|
640 <td><a href="#Pep257Context.source">source</a></td> |
|
641 <td>Public method to get the source.</td> |
|
642 </tr><tr> |
|
643 <td><a href="#Pep257Context.ssource">ssource</a></td> |
|
644 <td>Public method to get the joined source lines.</td> |
|
645 </tr><tr> |
|
646 <td><a href="#Pep257Context.start">start</a></td> |
|
647 <td>Public method to get the start line number.</td> |
|
648 </tr> |
|
649 </table> |
|
650 <h3>Static Methods</h3> |
|
651 <table> |
|
652 <tr><td>None</td></tr> |
|
653 </table> |
|
654 <a NAME="Pep257Context.__init__" ID="Pep257Context.__init__"></a> |
|
655 <h4>Pep257Context (Constructor)</h4> |
|
656 <b>Pep257Context</b>(<i>source, startLine, contextType</i>) |
|
657 <p> |
|
658 Constructor |
|
659 </p><dl> |
|
660 <dt><i>source</i></dt> |
|
661 <dd> |
|
662 source code of the context (list of string or string) |
|
663 </dd><dt><i>startLine</i></dt> |
|
664 <dd> |
|
665 line number the context starts in the source (integer) |
|
666 </dd><dt><i>contextType</i></dt> |
|
667 <dd> |
|
668 type of the context object (string) |
|
669 </dd> |
|
670 </dl><a NAME="Pep257Context.contextType" ID="Pep257Context.contextType"></a> |
|
671 <h4>Pep257Context.contextType</h4> |
|
672 <b>contextType</b>(<i></i>) |
|
673 <p> |
|
674 Public method to get the context type. |
|
675 </p><dl> |
|
676 <dt>Returns:</dt> |
|
677 <dd> |
|
678 context type (string) |
|
679 </dd> |
|
680 </dl><a NAME="Pep257Context.end" ID="Pep257Context.end"></a> |
|
681 <h4>Pep257Context.end</h4> |
|
682 <b>end</b>(<i></i>) |
|
683 <p> |
|
684 Public method to get the end line number. |
|
685 </p><dl> |
|
686 <dt>Returns:</dt> |
|
687 <dd> |
|
688 end line number (integer) |
|
689 </dd> |
|
690 </dl><a NAME="Pep257Context.indent" ID="Pep257Context.indent"></a> |
|
691 <h4>Pep257Context.indent</h4> |
|
692 <b>indent</b>(<i></i>) |
|
693 <p> |
|
694 Public method to get the indentation of the first line. |
|
695 </p><dl> |
|
696 <dt>Returns:</dt> |
|
697 <dd> |
|
698 indentation string (string) |
|
699 </dd> |
|
700 </dl><a NAME="Pep257Context.source" ID="Pep257Context.source"></a> |
|
701 <h4>Pep257Context.source</h4> |
|
702 <b>source</b>(<i></i>) |
|
703 <p> |
|
704 Public method to get the source. |
|
705 </p><dl> |
|
706 <dt>Returns:</dt> |
|
707 <dd> |
|
708 source (list of string) |
|
709 </dd> |
|
710 </dl><a NAME="Pep257Context.ssource" ID="Pep257Context.ssource"></a> |
|
711 <h4>Pep257Context.ssource</h4> |
|
712 <b>ssource</b>(<i></i>) |
|
713 <p> |
|
714 Public method to get the joined source lines. |
|
715 </p><dl> |
|
716 <dt>Returns:</dt> |
|
717 <dd> |
|
718 source (string) |
|
719 </dd> |
|
720 </dl><a NAME="Pep257Context.start" ID="Pep257Context.start"></a> |
|
721 <h4>Pep257Context.start</h4> |
|
722 <b>start</b>(<i></i>) |
|
723 <p> |
|
724 Public method to get the start line number. |
|
725 </p><dl> |
|
726 <dt>Returns:</dt> |
|
727 <dd> |
|
728 start line number (integer) |
|
729 </dd> |
|
730 </dl> |
|
731 <div align="right"><a href="#top">Up</a></div> |
|
732 <hr /> |
|
733 </body></html> |