Documentation/Source/eric5.UtilitiesPython2.DocStyleCheckerPy2.html

changeset 2985
177b1858245f
child 3165
400234200cd6
equal deleted inserted replaced
2984:031cceaa8b01 2985:177b1858245f
1 <!DOCTYPE html>
2 <html><head>
3 <title>eric5.UtilitiesPython2.DocStyleCheckerPy2</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.UtilitiesPython2.DocStyleCheckerPy2</h1>
23 <p>
24 Module implementing a checker for 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="#DocStyleChecker">DocStyleChecker</a></td>
34 <td>Class implementing a checker for documentation string conventions.</td>
35 </tr><tr>
36 <td><a href="#DocStyleContext">DocStyleContext</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="DocStyleChecker" ID="DocStyleChecker"></a>
46 <h2>DocStyleChecker</h2>
47 <p>
48 Class implementing a checker for 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>
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="#DocStyleChecker.__init__">DocStyleChecker</a></td>
64 <td>Constructor</td>
65 </tr><tr>
66 <td><a href="#DocStyleChecker.__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="#DocStyleChecker.__checkBlankAfterLastParagraph">__checkBlankAfterLastParagraph</a></td>
70 <td>Private method to check, that the last paragraph of docstrings is followed by a blank line.</td>
71 </tr><tr>
72 <td><a href="#DocStyleChecker.__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="#DocStyleChecker.__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="#DocStyleChecker.__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="#DocStyleChecker.__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="#DocStyleChecker.__checkEricBlankAfterSummary">__checkEricBlankAfterSummary</a></td>
85 <td>Private method to check, that docstring summaries are followed by a blank line.</td>
86 </tr><tr>
87 <td><a href="#DocStyleChecker.__checkEricEndsWithPeriod">__checkEricEndsWithPeriod</a></td>
88 <td>Private method to check, that docstring summaries end with a period.</td>
89 </tr><tr>
90 <td><a href="#DocStyleChecker.__checkEricException">__checkEricException</a></td>
91 <td>Private method to check, that docstrings contain an &#64;exception line if they raise an exception and don't otherwise.</td>
92 </tr><tr>
93 <td><a href="#DocStyleChecker.__checkEricFunctionArguments">__checkEricFunctionArguments</a></td>
94 <td>Private method to check, that docstrings contain an &#64;param and/or &#64;keyparam line for each argument.</td>
95 </tr><tr>
96 <td><a href="#DocStyleChecker.__checkEricNBlankAfterLastParagraph">__checkEricNBlankAfterLastParagraph</a></td>
97 <td>Private method to check, that the last paragraph of docstrings is not followed by a blank line.</td>
98 </tr><tr>
99 <td><a href="#DocStyleChecker.__checkEricNoBlankBeforeAndAfterClassOrFunction">__checkEricNoBlankBeforeAndAfterClassOrFunction</a></td>
100 <td>Private method to check, that class and function/method docstrings have no blank line around them.</td>
101 </tr><tr>
102 <td><a href="#DocStyleChecker.__checkEricQuotesOnSeparateLines">__checkEricQuotesOnSeparateLines</a></td>
103 <td>Private method to check, that leading and trailing quotes are on a line by themselves.</td>
104 </tr><tr>
105 <td><a href="#DocStyleChecker.__checkEricReturn">__checkEricReturn</a></td>
106 <td>Private method to check, that docstrings contain an &#64;return line if they return anything and don't otherwise.</td>
107 </tr><tr>
108 <td><a href="#DocStyleChecker.__checkFunctionDocstring">__checkFunctionDocstring</a></td>
109 <td>Private method to check, that all public functions and methods have a docstring.</td>
110 </tr><tr>
111 <td><a href="#DocStyleChecker.__checkImperativeMood">__checkImperativeMood</a></td>
112 <td>Private method to check, that docstring summaries are in imperative mood.</td>
113 </tr><tr>
114 <td><a href="#DocStyleChecker.__checkIndent">__checkIndent</a></td>
115 <td>Private method to check, that docstrings are properly indented.</td>
116 </tr><tr>
117 <td><a href="#DocStyleChecker.__checkModulesDocstrings">__checkModulesDocstrings</a></td>
118 <td>Private method to check, if the module has a docstring.</td>
119 </tr><tr>
120 <td><a href="#DocStyleChecker.__checkNoBlankLineBefore">__checkNoBlankLineBefore</a></td>
121 <td>Private method to check, that function/method docstrings are not preceded by a blank line.</td>
122 </tr><tr>
123 <td><a href="#DocStyleChecker.__checkNoSignature">__checkNoSignature</a></td>
124 <td>Private method to check, that docstring summaries don't repeat the function's signature.</td>
125 </tr><tr>
126 <td><a href="#DocStyleChecker.__checkOneLiner">__checkOneLiner</a></td>
127 <td>Private method to check, that one-liner docstrings fit on one line with quotes.</td>
128 </tr><tr>
129 <td><a href="#DocStyleChecker.__checkReturnType">__checkReturnType</a></td>
130 <td>Private method to check, that docstrings mention the return value type.</td>
131 </tr><tr>
132 <td><a href="#DocStyleChecker.__checkTripleDoubleQuotes">__checkTripleDoubleQuotes</a></td>
133 <td>Private method to check, that all docstrings are surrounded by triple double quotes.</td>
134 </tr><tr>
135 <td><a href="#DocStyleChecker.__checkUnicode">__checkUnicode</a></td>
136 <td>Private method to check, that all docstrings containing unicode characters are surrounded by unicode triple double quotes.</td>
137 </tr><tr>
138 <td><a href="#DocStyleChecker.__error">__error</a></td>
139 <td>Private method to record an issue.</td>
140 </tr><tr>
141 <td><a href="#DocStyleChecker.__getArgNames">__getArgNames</a></td>
142 <td></td>
143 </tr><tr>
144 <td><a href="#DocStyleChecker.__getSummaryLine">__getSummaryLine</a></td>
145 <td>Private method to extract the summary line.</td>
146 </tr><tr>
147 <td><a href="#DocStyleChecker.__getSummaryLines">__getSummaryLines</a></td>
148 <td>Private method to extract the summary lines.</td>
149 </tr><tr>
150 <td><a href="#DocStyleChecker.__ignoreCode">__ignoreCode</a></td>
151 <td>Private method to check if the error code should be ignored.</td>
152 </tr><tr>
153 <td><a href="#DocStyleChecker.__parseClasses">__parseClasses</a></td>
154 <td>Private method to extract top-level classes.</td>
155 </tr><tr>
156 <td><a href="#DocStyleChecker.__parseContexts">__parseContexts</a></td>
157 <td>Private method to extract a context from the source.</td>
158 </tr><tr>
159 <td><a href="#DocStyleChecker.__parseDocstring">__parseDocstring</a></td>
160 <td>Private method to extract a docstring given `def` or `class` source.</td>
161 </tr><tr>
162 <td><a href="#DocStyleChecker.__parseFunctions">__parseFunctions</a></td>
163 <td>Private method to extract top-level functions.</td>
164 </tr><tr>
165 <td><a href="#DocStyleChecker.__parseMethods">__parseMethods</a></td>
166 <td>Private method to extract methods of all classes.</td>
167 </tr><tr>
168 <td><a href="#DocStyleChecker.__parseModuleDocstring">__parseModuleDocstring</a></td>
169 <td>Private method to extract a docstring given a module source.</td>
170 </tr><tr>
171 <td><a href="#DocStyleChecker.__parseTopLevel">__parseTopLevel</a></td>
172 <td>Private method to extract top-level functions or classes.</td>
173 </tr><tr>
174 <td><a href="#DocStyleChecker.__readline">__readline</a></td>
175 <td>Private method to get the next line from the source.</td>
176 </tr><tr>
177 <td><a href="#DocStyleChecker.__resetReadline">__resetReadline</a></td>
178 <td>Private method to reset the internal readline function.</td>
179 </tr><tr>
180 <td><a href="#DocStyleChecker.__skipIndentedBlock">__skipIndentedBlock</a></td>
181 <td>Private method to skip over an indented block of source code.</td>
182 </tr><tr>
183 <td><a href="#DocStyleChecker.run">run</a></td>
184 <td>Public method to check the given source for violations of doc string conventions.</td>
185 </tr><tr>
186 <td><a href="#DocStyleChecker.unpackArgs">unpackArgs</a></td>
187 <td>Local helper function to unpack function argument names.</td>
188 </tr>
189 </table>
190 <h3>Static Methods</h3>
191 <table>
192 <tr><td>None</td></tr>
193 </table>
194 <a NAME="DocStyleChecker.__init__" ID="DocStyleChecker.__init__"></a>
195 <h4>DocStyleChecker (Constructor)</h4>
196 <b>DocStyleChecker</b>(<i>source, filename, select, ignore, expected, repeat, maxLineLength=79, docType="pep257"</i>)
197 <p>
198 Constructor
199 </p><dl>
200 <dt><i>source</i></dt>
201 <dd>
202 source code to be checked (list of string)
203 </dd><dt><i>filename</i></dt>
204 <dd>
205 name of the source file (string)
206 </dd><dt><i>select</i></dt>
207 <dd>
208 list of selected codes (list of string)
209 </dd><dt><i>ignore</i></dt>
210 <dd>
211 list of codes to be ignored (list of string)
212 </dd><dt><i>expected</i></dt>
213 <dd>
214 list of expected codes (list of string)
215 </dd><dt><i>repeat</i></dt>
216 <dd>
217 flag indicating to report each occurrence of a code
218 (boolean)
219 </dd><dt><i>maxLineLength=</i></dt>
220 <dd>
221 allowed line length (integer)
222 </dd><dt><i>docType=</i></dt>
223 <dd>
224 type of the documentation strings
225 (string, one of 'eric' or 'pep257')
226 </dd>
227 </dl><a NAME="DocStyleChecker.__checkBackslashes" ID="DocStyleChecker.__checkBackslashes"></a>
228 <h4>DocStyleChecker.__checkBackslashes</h4>
229 <b>__checkBackslashes</b>(<i>docstringContext, context</i>)
230 <p>
231 Private method to check, that all docstrings containing
232 backslashes are surrounded by raw triple double quotes.
233 </p><dl>
234 <dt><i>docstringContext</i></dt>
235 <dd>
236 docstring context (DocStyleContext)
237 </dd><dt><i>context</i></dt>
238 <dd>
239 context of the docstring (DocStyleContext)
240 </dd>
241 </dl><a NAME="DocStyleChecker.__checkBlankAfterLastParagraph" ID="DocStyleChecker.__checkBlankAfterLastParagraph"></a>
242 <h4>DocStyleChecker.__checkBlankAfterLastParagraph</h4>
243 <b>__checkBlankAfterLastParagraph</b>(<i>docstringContext, context</i>)
244 <p>
245 Private method to check, that the last paragraph of docstrings is
246 followed by a blank line.
247 </p><dl>
248 <dt><i>docstringContext</i></dt>
249 <dd>
250 docstring context (DocStyleContext)
251 </dd><dt><i>context</i></dt>
252 <dd>
253 context of the docstring (DocStyleContext)
254 </dd>
255 </dl><a NAME="DocStyleChecker.__checkBlankAfterSummary" ID="DocStyleChecker.__checkBlankAfterSummary"></a>
256 <h4>DocStyleChecker.__checkBlankAfterSummary</h4>
257 <b>__checkBlankAfterSummary</b>(<i>docstringContext, context</i>)
258 <p>
259 Private method to check, that docstring summaries are followed
260 by a blank line.
261 </p><dl>
262 <dt><i>docstringContext</i></dt>
263 <dd>
264 docstring context (DocStyleContext)
265 </dd><dt><i>context</i></dt>
266 <dd>
267 context of the docstring (DocStyleContext)
268 </dd>
269 </dl><a NAME="DocStyleChecker.__checkBlankBeforeAndAfterClass" ID="DocStyleChecker.__checkBlankBeforeAndAfterClass"></a>
270 <h4>DocStyleChecker.__checkBlankBeforeAndAfterClass</h4>
271 <b>__checkBlankBeforeAndAfterClass</b>(<i>docstringContext, context</i>)
272 <p>
273 Private method to check, that class docstrings have one
274 blank line around them.
275 </p><dl>
276 <dt><i>docstringContext</i></dt>
277 <dd>
278 docstring context (DocStyleContext)
279 </dd><dt><i>context</i></dt>
280 <dd>
281 context of the docstring (DocStyleContext)
282 </dd>
283 </dl><a NAME="DocStyleChecker.__checkClassDocstring" ID="DocStyleChecker.__checkClassDocstring"></a>
284 <h4>DocStyleChecker.__checkClassDocstring</h4>
285 <b>__checkClassDocstring</b>(<i>docstringContext, context</i>)
286 <p>
287 Private method to check, that all public functions and methods
288 have a docstring.
289 </p><dl>
290 <dt><i>docstringContext</i></dt>
291 <dd>
292 docstring context (DocStyleContext)
293 </dd><dt><i>context</i></dt>
294 <dd>
295 context of the docstring (DocStyleContext)
296 </dd>
297 </dl><a NAME="DocStyleChecker.__checkEndsWithPeriod" ID="DocStyleChecker.__checkEndsWithPeriod"></a>
298 <h4>DocStyleChecker.__checkEndsWithPeriod</h4>
299 <b>__checkEndsWithPeriod</b>(<i>docstringContext, context</i>)
300 <p>
301 Private method to check, that docstring summaries end with a period.
302 </p><dl>
303 <dt><i>docstringContext</i></dt>
304 <dd>
305 docstring context (DocStyleContext)
306 </dd><dt><i>context</i></dt>
307 <dd>
308 context of the docstring (DocStyleContext)
309 </dd>
310 </dl><a NAME="DocStyleChecker.__checkEricBlankAfterSummary" ID="DocStyleChecker.__checkEricBlankAfterSummary"></a>
311 <h4>DocStyleChecker.__checkEricBlankAfterSummary</h4>
312 <b>__checkEricBlankAfterSummary</b>(<i>docstringContext, context</i>)
313 <p>
314 Private method to check, that docstring summaries are followed
315 by a blank line.
316 </p><dl>
317 <dt><i>docstringContext</i></dt>
318 <dd>
319 docstring context (DocStyleContext)
320 </dd><dt><i>context</i></dt>
321 <dd>
322 context of the docstring (DocStyleContext)
323 </dd>
324 </dl><a NAME="DocStyleChecker.__checkEricEndsWithPeriod" ID="DocStyleChecker.__checkEricEndsWithPeriod"></a>
325 <h4>DocStyleChecker.__checkEricEndsWithPeriod</h4>
326 <b>__checkEricEndsWithPeriod</b>(<i>docstringContext, context</i>)
327 <p>
328 Private method to check, that docstring summaries end with a period.
329 </p><dl>
330 <dt><i>docstringContext</i></dt>
331 <dd>
332 docstring context (DocStyleContext)
333 </dd><dt><i>context</i></dt>
334 <dd>
335 context of the docstring (DocStyleContext)
336 </dd>
337 </dl><a NAME="DocStyleChecker.__checkEricException" ID="DocStyleChecker.__checkEricException"></a>
338 <h4>DocStyleChecker.__checkEricException</h4>
339 <b>__checkEricException</b>(<i>docstringContext, context</i>)
340 <p>
341 Private method to check, that docstrings contain an &#64;exception line
342 if they raise an exception and don't otherwise.
343 </p><dl>
344 <dt><i>docstringContext</i></dt>
345 <dd>
346 docstring context (DocStyleContext)
347 </dd><dt><i>context</i></dt>
348 <dd>
349 context of the docstring (DocStyleContext)
350 </dd>
351 </dl><a NAME="DocStyleChecker.__checkEricFunctionArguments" ID="DocStyleChecker.__checkEricFunctionArguments"></a>
352 <h4>DocStyleChecker.__checkEricFunctionArguments</h4>
353 <b>__checkEricFunctionArguments</b>(<i>docstringContext, context</i>)
354 <p>
355 Private method to check, that docstrings contain an &#64;param and/or
356 &#64;keyparam line for each argument.
357 </p><dl>
358 <dt><i>docstringContext</i></dt>
359 <dd>
360 docstring context (DocStyleContext)
361 </dd><dt><i>context</i></dt>
362 <dd>
363 context of the docstring (DocStyleContext)
364 </dd>
365 </dl><a NAME="DocStyleChecker.__checkEricNBlankAfterLastParagraph" ID="DocStyleChecker.__checkEricNBlankAfterLastParagraph"></a>
366 <h4>DocStyleChecker.__checkEricNBlankAfterLastParagraph</h4>
367 <b>__checkEricNBlankAfterLastParagraph</b>(<i>docstringContext, context</i>)
368 <p>
369 Private method to check, that the last paragraph of docstrings is
370 not followed by a blank line.
371 </p><dl>
372 <dt><i>docstringContext</i></dt>
373 <dd>
374 docstring context (DocStyleContext)
375 </dd><dt><i>context</i></dt>
376 <dd>
377 context of the docstring (DocStyleContext)
378 </dd>
379 </dl><a NAME="DocStyleChecker.__checkEricNoBlankBeforeAndAfterClassOrFunction" ID="DocStyleChecker.__checkEricNoBlankBeforeAndAfterClassOrFunction"></a>
380 <h4>DocStyleChecker.__checkEricNoBlankBeforeAndAfterClassOrFunction</h4>
381 <b>__checkEricNoBlankBeforeAndAfterClassOrFunction</b>(<i>docstringContext, context</i>)
382 <p>
383 Private method to check, that class and function/method docstrings
384 have no blank line around them.
385 </p><dl>
386 <dt><i>docstringContext</i></dt>
387 <dd>
388 docstring context (DocStyleContext)
389 </dd><dt><i>context</i></dt>
390 <dd>
391 context of the docstring (DocStyleContext)
392 </dd>
393 </dl><a NAME="DocStyleChecker.__checkEricQuotesOnSeparateLines" ID="DocStyleChecker.__checkEricQuotesOnSeparateLines"></a>
394 <h4>DocStyleChecker.__checkEricQuotesOnSeparateLines</h4>
395 <b>__checkEricQuotesOnSeparateLines</b>(<i>docstringContext, context</i>)
396 <p>
397 Private method to check, that leading and trailing quotes are on
398 a line by themselves.
399 </p><dl>
400 <dt><i>docstringContext</i></dt>
401 <dd>
402 docstring context (DocStyleContext)
403 </dd><dt><i>context</i></dt>
404 <dd>
405 context of the docstring (DocStyleContext)
406 </dd>
407 </dl><a NAME="DocStyleChecker.__checkEricReturn" ID="DocStyleChecker.__checkEricReturn"></a>
408 <h4>DocStyleChecker.__checkEricReturn</h4>
409 <b>__checkEricReturn</b>(<i>docstringContext, context</i>)
410 <p>
411 Private method to check, that docstrings contain an &#64;return line
412 if they return anything and don't otherwise.
413 </p><dl>
414 <dt><i>docstringContext</i></dt>
415 <dd>
416 docstring context (DocStyleContext)
417 </dd><dt><i>context</i></dt>
418 <dd>
419 context of the docstring (DocStyleContext)
420 </dd>
421 </dl><a NAME="DocStyleChecker.__checkFunctionDocstring" ID="DocStyleChecker.__checkFunctionDocstring"></a>
422 <h4>DocStyleChecker.__checkFunctionDocstring</h4>
423 <b>__checkFunctionDocstring</b>(<i>docstringContext, context</i>)
424 <p>
425 Private method to check, that all public functions and methods
426 have a docstring.
427 </p><dl>
428 <dt><i>docstringContext</i></dt>
429 <dd>
430 docstring context (DocStyleContext)
431 </dd><dt><i>context</i></dt>
432 <dd>
433 context of the docstring (DocStyleContext)
434 </dd>
435 </dl><a NAME="DocStyleChecker.__checkImperativeMood" ID="DocStyleChecker.__checkImperativeMood"></a>
436 <h4>DocStyleChecker.__checkImperativeMood</h4>
437 <b>__checkImperativeMood</b>(<i>docstringContext, context</i>)
438 <p>
439 Private method to check, that docstring summaries are in
440 imperative mood.
441 </p><dl>
442 <dt><i>docstringContext</i></dt>
443 <dd>
444 docstring context (DocStyleContext)
445 </dd><dt><i>context</i></dt>
446 <dd>
447 context of the docstring (DocStyleContext)
448 </dd>
449 </dl><a NAME="DocStyleChecker.__checkIndent" ID="DocStyleChecker.__checkIndent"></a>
450 <h4>DocStyleChecker.__checkIndent</h4>
451 <b>__checkIndent</b>(<i>docstringContext, context</i>)
452 <p>
453 Private method to check, that docstrings are properly indented.
454 </p><dl>
455 <dt><i>docstringContext</i></dt>
456 <dd>
457 docstring context (DocStyleContext)
458 </dd><dt><i>context</i></dt>
459 <dd>
460 context of the docstring (DocStyleContext)
461 </dd>
462 </dl><a NAME="DocStyleChecker.__checkModulesDocstrings" ID="DocStyleChecker.__checkModulesDocstrings"></a>
463 <h4>DocStyleChecker.__checkModulesDocstrings</h4>
464 <b>__checkModulesDocstrings</b>(<i>docstringContext, context</i>)
465 <p>
466 Private method to check, if the module has a docstring.
467 </p><dl>
468 <dt><i>docstringContext</i></dt>
469 <dd>
470 docstring context (DocStyleContext)
471 </dd><dt><i>context</i></dt>
472 <dd>
473 context of the docstring (DocStyleContext)
474 </dd>
475 </dl><a NAME="DocStyleChecker.__checkNoBlankLineBefore" ID="DocStyleChecker.__checkNoBlankLineBefore"></a>
476 <h4>DocStyleChecker.__checkNoBlankLineBefore</h4>
477 <b>__checkNoBlankLineBefore</b>(<i>docstringContext, context</i>)
478 <p>
479 Private method to check, that function/method docstrings are not
480 preceded by a blank line.
481 </p><dl>
482 <dt><i>docstringContext</i></dt>
483 <dd>
484 docstring context (DocStyleContext)
485 </dd><dt><i>context</i></dt>
486 <dd>
487 context of the docstring (DocStyleContext)
488 </dd>
489 </dl><a NAME="DocStyleChecker.__checkNoSignature" ID="DocStyleChecker.__checkNoSignature"></a>
490 <h4>DocStyleChecker.__checkNoSignature</h4>
491 <b>__checkNoSignature</b>(<i>docstringContext, context</i>)
492 <p>
493 Private method to check, that docstring summaries don't repeat
494 the function's signature.
495 </p><dl>
496 <dt><i>docstringContext</i></dt>
497 <dd>
498 docstring context (DocStyleContext)
499 </dd><dt><i>context</i></dt>
500 <dd>
501 context of the docstring (DocStyleContext)
502 </dd>
503 </dl><a NAME="DocStyleChecker.__checkOneLiner" ID="DocStyleChecker.__checkOneLiner"></a>
504 <h4>DocStyleChecker.__checkOneLiner</h4>
505 <b>__checkOneLiner</b>(<i>docstringContext, context</i>)
506 <p>
507 Private method to check, that one-liner docstrings fit on
508 one line with quotes.
509 </p><dl>
510 <dt><i>docstringContext</i></dt>
511 <dd>
512 docstring context (DocStyleContext)
513 </dd><dt><i>context</i></dt>
514 <dd>
515 context of the docstring (DocStyleContext)
516 </dd>
517 </dl><a NAME="DocStyleChecker.__checkReturnType" ID="DocStyleChecker.__checkReturnType"></a>
518 <h4>DocStyleChecker.__checkReturnType</h4>
519 <b>__checkReturnType</b>(<i>docstringContext, context</i>)
520 <p>
521 Private method to check, that docstrings mention the return value type.
522 </p><dl>
523 <dt><i>docstringContext</i></dt>
524 <dd>
525 docstring context (DocStyleContext)
526 </dd><dt><i>context</i></dt>
527 <dd>
528 context of the docstring (DocStyleContext)
529 </dd>
530 </dl><a NAME="DocStyleChecker.__checkTripleDoubleQuotes" ID="DocStyleChecker.__checkTripleDoubleQuotes"></a>
531 <h4>DocStyleChecker.__checkTripleDoubleQuotes</h4>
532 <b>__checkTripleDoubleQuotes</b>(<i>docstringContext, context</i>)
533 <p>
534 Private method to check, that all docstrings are surrounded
535 by triple double quotes.
536 </p><dl>
537 <dt><i>docstringContext</i></dt>
538 <dd>
539 docstring context (DocStyleContext)
540 </dd><dt><i>context</i></dt>
541 <dd>
542 context of the docstring (DocStyleContext)
543 </dd>
544 </dl><a NAME="DocStyleChecker.__checkUnicode" ID="DocStyleChecker.__checkUnicode"></a>
545 <h4>DocStyleChecker.__checkUnicode</h4>
546 <b>__checkUnicode</b>(<i>docstringContext, context</i>)
547 <p>
548 Private method to check, that all docstrings containing unicode
549 characters are surrounded by unicode triple double quotes.
550 </p><dl>
551 <dt><i>docstringContext</i></dt>
552 <dd>
553 docstring context (DocStyleContext)
554 </dd><dt><i>context</i></dt>
555 <dd>
556 context of the docstring (DocStyleContext)
557 </dd>
558 </dl><a NAME="DocStyleChecker.__error" ID="DocStyleChecker.__error"></a>
559 <h4>DocStyleChecker.__error</h4>
560 <b>__error</b>(<i>lineNumber, offset, code, *args</i>)
561 <p>
562 Private method to record an issue.
563 </p><dl>
564 <dt><i>lineNumber</i></dt>
565 <dd>
566 line number of the issue (integer)
567 </dd><dt><i>offset</i></dt>
568 <dd>
569 position within line of the issue (integer)
570 </dd><dt><i>code</i></dt>
571 <dd>
572 message code (string)
573 </dd><dt><i>args</i></dt>
574 <dd>
575 arguments for the message (list)
576 </dd>
577 </dl><a NAME="DocStyleChecker.__getArgNames" ID="DocStyleChecker.__getArgNames"></a>
578 <h4>DocStyleChecker.__getArgNames</h4>
579 <b>__getArgNames</b>(<i>node</i>)
580 <a NAME="DocStyleChecker.__getSummaryLine" ID="DocStyleChecker.__getSummaryLine"></a>
581 <h4>DocStyleChecker.__getSummaryLine</h4>
582 <b>__getSummaryLine</b>(<i>docstringContext</i>)
583 <p>
584 Private method to extract the summary line.
585 </p><dl>
586 <dt><i>docstringContext</i></dt>
587 <dd>
588 docstring context (DocStyleContext)
589 </dd>
590 </dl><dl>
591 <dt>Returns:</dt>
592 <dd>
593 summary line (string) and the line it was found on (integer)
594 </dd>
595 </dl><a NAME="DocStyleChecker.__getSummaryLines" ID="DocStyleChecker.__getSummaryLines"></a>
596 <h4>DocStyleChecker.__getSummaryLines</h4>
597 <b>__getSummaryLines</b>(<i>docstringContext</i>)
598 <p>
599 Private method to extract the summary lines.
600 </p><dl>
601 <dt><i>docstringContext</i></dt>
602 <dd>
603 docstring context (DocStyleContext)
604 </dd>
605 </dl><dl>
606 <dt>Returns:</dt>
607 <dd>
608 summary lines (list of string) and the line it was found on
609 (integer)
610 </dd>
611 </dl><a NAME="DocStyleChecker.__ignoreCode" ID="DocStyleChecker.__ignoreCode"></a>
612 <h4>DocStyleChecker.__ignoreCode</h4>
613 <b>__ignoreCode</b>(<i>code</i>)
614 <p>
615 Private method to check if the error code should be ignored.
616 </p><dl>
617 <dt><i>code</i></dt>
618 <dd>
619 message code to check for (string)
620 </dd>
621 </dl><dl>
622 <dt>Returns:</dt>
623 <dd>
624 flag indicating to ignore the given code (boolean)
625 </dd>
626 </dl><a NAME="DocStyleChecker.__parseClasses" ID="DocStyleChecker.__parseClasses"></a>
627 <h4>DocStyleChecker.__parseClasses</h4>
628 <b>__parseClasses</b>(<i></i>)
629 <p>
630 Private method to extract top-level classes.
631 </p><dl>
632 <dt>Returns:</dt>
633 <dd>
634 extracted class contexts (list of DocStyleContext)
635 </dd>
636 </dl><a NAME="DocStyleChecker.__parseContexts" ID="DocStyleChecker.__parseContexts"></a>
637 <h4>DocStyleChecker.__parseContexts</h4>
638 <b>__parseContexts</b>(<i>kind</i>)
639 <p>
640 Private method to extract a context from the source.
641 </p><dl>
642 <dt><i>kind</i></dt>
643 <dd>
644 kind of context to extract (string)
645 </dd>
646 </dl><dl>
647 <dt>Returns:</dt>
648 <dd>
649 requested contexts (list of DocStyleContext)
650 </dd>
651 </dl><a NAME="DocStyleChecker.__parseDocstring" ID="DocStyleChecker.__parseDocstring"></a>
652 <h4>DocStyleChecker.__parseDocstring</h4>
653 <b>__parseDocstring</b>(<i>context, what=''</i>)
654 <p>
655 Private method to extract a docstring given `def` or `class` source.
656 </p><dl>
657 <dt><i>context</i></dt>
658 <dd>
659 context data to get the docstring from (DocStyleContext)
660 </dd><dt><i>what</i></dt>
661 <dd>
662 string denoting what is being parsed (string)
663 </dd>
664 </dl><dl>
665 <dt>Returns:</dt>
666 <dd>
667 context of extracted docstring (DocStyleContext)
668 </dd>
669 </dl><a NAME="DocStyleChecker.__parseFunctions" ID="DocStyleChecker.__parseFunctions"></a>
670 <h4>DocStyleChecker.__parseFunctions</h4>
671 <b>__parseFunctions</b>(<i></i>)
672 <p>
673 Private method to extract top-level functions.
674 </p><dl>
675 <dt>Returns:</dt>
676 <dd>
677 extracted function contexts (list of DocStyleContext)
678 </dd>
679 </dl><a NAME="DocStyleChecker.__parseMethods" ID="DocStyleChecker.__parseMethods"></a>
680 <h4>DocStyleChecker.__parseMethods</h4>
681 <b>__parseMethods</b>(<i></i>)
682 <p>
683 Private method to extract methods of all classes.
684 </p><dl>
685 <dt>Returns:</dt>
686 <dd>
687 extracted method contexts (list of DocStyleContext)
688 </dd>
689 </dl><a NAME="DocStyleChecker.__parseModuleDocstring" ID="DocStyleChecker.__parseModuleDocstring"></a>
690 <h4>DocStyleChecker.__parseModuleDocstring</h4>
691 <b>__parseModuleDocstring</b>(<i>source</i>)
692 <p>
693 Private method to extract a docstring given a module source.
694 </p><dl>
695 <dt><i>source</i></dt>
696 <dd>
697 source to parse (list of string)
698 </dd>
699 </dl><dl>
700 <dt>Returns:</dt>
701 <dd>
702 context of extracted docstring (DocStyleContext)
703 </dd>
704 </dl><a NAME="DocStyleChecker.__parseTopLevel" ID="DocStyleChecker.__parseTopLevel"></a>
705 <h4>DocStyleChecker.__parseTopLevel</h4>
706 <b>__parseTopLevel</b>(<i>keyword</i>)
707 <p>
708 Private method to extract top-level functions or classes.
709 </p><dl>
710 <dt><i>keyword</i></dt>
711 <dd>
712 keyword signaling what to extract (string)
713 </dd>
714 </dl><dl>
715 <dt>Returns:</dt>
716 <dd>
717 extracted function or class contexts (list of DocStyleContext)
718 </dd>
719 </dl><a NAME="DocStyleChecker.__readline" ID="DocStyleChecker.__readline"></a>
720 <h4>DocStyleChecker.__readline</h4>
721 <b>__readline</b>(<i></i>)
722 <p>
723 Private method to get the next line from the source.
724 </p><dl>
725 <dt>Returns:</dt>
726 <dd>
727 next line of source (string)
728 </dd>
729 </dl><a NAME="DocStyleChecker.__resetReadline" ID="DocStyleChecker.__resetReadline"></a>
730 <h4>DocStyleChecker.__resetReadline</h4>
731 <b>__resetReadline</b>(<i></i>)
732 <p>
733 Private method to reset the internal readline function.
734 </p><a NAME="DocStyleChecker.__skipIndentedBlock" ID="DocStyleChecker.__skipIndentedBlock"></a>
735 <h4>DocStyleChecker.__skipIndentedBlock</h4>
736 <b>__skipIndentedBlock</b>(<i>tokenGenerator</i>)
737 <p>
738 Private method to skip over an indented block of source code.
739 </p><dl>
740 <dt><i>tokenGenerator</i></dt>
741 <dd>
742 token generator
743 </dd>
744 </dl><dl>
745 <dt>Returns:</dt>
746 <dd>
747 last token of the indented block
748 </dd>
749 </dl><a NAME="DocStyleChecker.run" ID="DocStyleChecker.run"></a>
750 <h4>DocStyleChecker.run</h4>
751 <b>run</b>(<i></i>)
752 <p>
753 Public method to check the given source for violations of doc string
754 conventions.
755 </p><a NAME="DocStyleChecker.unpackArgs" ID="DocStyleChecker.unpackArgs"></a>
756 <h4>DocStyleChecker.unpackArgs</h4>
757 <b>unpackArgs</b>(<i></i>)
758 <p>
759 Local helper function to unpack function argument names.
760 </p><dl>
761 <dt><i>args</i></dt>
762 <dd>
763 list of AST node arguments
764 </dd>
765 </dl><dl>
766 <dt>Returns:</dt>
767 <dd>
768 list of argument names (list of string)
769 </dd>
770 </dl>
771 <div align="right"><a href="#top">Up</a></div>
772 <hr /><hr />
773 <a NAME="DocStyleContext" ID="DocStyleContext"></a>
774 <h2>DocStyleContext</h2>
775 <p>
776 Class implementing the source context.
777 </p>
778 <h3>Derived from</h3>
779 object
780 <h3>Class Attributes</h3>
781 <table>
782 <tr><td>None</td></tr>
783 </table>
784 <h3>Class Methods</h3>
785 <table>
786 <tr><td>None</td></tr>
787 </table>
788 <h3>Methods</h3>
789 <table>
790 <tr>
791 <td><a href="#DocStyleContext.__init__">DocStyleContext</a></td>
792 <td>Constructor</td>
793 </tr><tr>
794 <td><a href="#DocStyleContext.contextType">contextType</a></td>
795 <td>Public method to get the context type.</td>
796 </tr><tr>
797 <td><a href="#DocStyleContext.end">end</a></td>
798 <td>Public method to get the end line number.</td>
799 </tr><tr>
800 <td><a href="#DocStyleContext.indent">indent</a></td>
801 <td>Public method to get the indentation of the first line.</td>
802 </tr><tr>
803 <td><a href="#DocStyleContext.source">source</a></td>
804 <td>Public method to get the source.</td>
805 </tr><tr>
806 <td><a href="#DocStyleContext.ssource">ssource</a></td>
807 <td>Public method to get the joined source lines.</td>
808 </tr><tr>
809 <td><a href="#DocStyleContext.start">start</a></td>
810 <td>Public method to get the start line number.</td>
811 </tr>
812 </table>
813 <h3>Static Methods</h3>
814 <table>
815 <tr><td>None</td></tr>
816 </table>
817 <a NAME="DocStyleContext.__init__" ID="DocStyleContext.__init__"></a>
818 <h4>DocStyleContext (Constructor)</h4>
819 <b>DocStyleContext</b>(<i>source, startLine, contextType</i>)
820 <p>
821 Constructor
822 </p><dl>
823 <dt><i>source</i></dt>
824 <dd>
825 source code of the context (list of string or string)
826 </dd><dt><i>startLine</i></dt>
827 <dd>
828 line number the context starts in the source (integer)
829 </dd><dt><i>contextType</i></dt>
830 <dd>
831 type of the context object (string)
832 </dd>
833 </dl><a NAME="DocStyleContext.contextType" ID="DocStyleContext.contextType"></a>
834 <h4>DocStyleContext.contextType</h4>
835 <b>contextType</b>(<i></i>)
836 <p>
837 Public method to get the context type.
838 </p><dl>
839 <dt>Returns:</dt>
840 <dd>
841 context type (string)
842 </dd>
843 </dl><a NAME="DocStyleContext.end" ID="DocStyleContext.end"></a>
844 <h4>DocStyleContext.end</h4>
845 <b>end</b>(<i></i>)
846 <p>
847 Public method to get the end line number.
848 </p><dl>
849 <dt>Returns:</dt>
850 <dd>
851 end line number (integer)
852 </dd>
853 </dl><a NAME="DocStyleContext.indent" ID="DocStyleContext.indent"></a>
854 <h4>DocStyleContext.indent</h4>
855 <b>indent</b>(<i></i>)
856 <p>
857 Public method to get the indentation of the first line.
858 </p><dl>
859 <dt>Returns:</dt>
860 <dd>
861 indentation string (string)
862 </dd>
863 </dl><a NAME="DocStyleContext.source" ID="DocStyleContext.source"></a>
864 <h4>DocStyleContext.source</h4>
865 <b>source</b>(<i></i>)
866 <p>
867 Public method to get the source.
868 </p><dl>
869 <dt>Returns:</dt>
870 <dd>
871 source (list of string)
872 </dd>
873 </dl><a NAME="DocStyleContext.ssource" ID="DocStyleContext.ssource"></a>
874 <h4>DocStyleContext.ssource</h4>
875 <b>ssource</b>(<i></i>)
876 <p>
877 Public method to get the joined source lines.
878 </p><dl>
879 <dt>Returns:</dt>
880 <dd>
881 source (string)
882 </dd>
883 </dl><a NAME="DocStyleContext.start" ID="DocStyleContext.start"></a>
884 <h4>DocStyleContext.start</h4>
885 <b>start</b>(<i></i>)
886 <p>
887 Public method to get the start line number.
888 </p><dl>
889 <dt>Returns:</dt>
890 <dd>
891 start line number (integer)
892 </dd>
893 </dl>
894 <div align="right"><a href="#top">Up</a></div>
895 <hr />
896 </body></html>

eric ide

mercurial