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