|
1 <!DOCTYPE html> |
|
2 <html><head> |
|
3 <title>eric7.QScintilla.DocstringGenerator.BaseDocstringGenerator</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> |
|
22 <a NAME="top" ID="top"></a> |
|
23 <h1>eric7.QScintilla.DocstringGenerator.BaseDocstringGenerator</h1> |
|
24 |
|
25 <p> |
|
26 Module implementing a docstring generator base class. |
|
27 </p> |
|
28 <h3>Global Attributes</h3> |
|
29 |
|
30 <table> |
|
31 <tr><td>None</td></tr> |
|
32 </table> |
|
33 <h3>Classes</h3> |
|
34 |
|
35 <table> |
|
36 |
|
37 <tr> |
|
38 <td><a href="#BaseDocstringGenerator">BaseDocstringGenerator</a></td> |
|
39 <td>Class implementing a docstring generator base class.</td> |
|
40 </tr> |
|
41 <tr> |
|
42 <td><a href="#DocstringMenuForEnterOnly">DocstringMenuForEnterOnly</a></td> |
|
43 <td>Class implementing a special menu reacting to the enter/return keys only.</td> |
|
44 </tr> |
|
45 <tr> |
|
46 <td><a href="#FunctionInfo">FunctionInfo</a></td> |
|
47 <td>Class implementing an object to store function information.</td> |
|
48 </tr> |
|
49 </table> |
|
50 <h3>Functions</h3> |
|
51 |
|
52 <table> |
|
53 |
|
54 <tr> |
|
55 <td><a href="#getIndentStr">getIndentStr</a></td> |
|
56 <td>Function to get the indentation of a text.</td> |
|
57 </tr> |
|
58 </table> |
|
59 <hr /> |
|
60 <hr /> |
|
61 <a NAME="BaseDocstringGenerator" ID="BaseDocstringGenerator"></a> |
|
62 <h2>BaseDocstringGenerator</h2> |
|
63 |
|
64 <p> |
|
65 Class implementing a docstring generator base class. |
|
66 </p> |
|
67 <h3>Derived from</h3> |
|
68 None |
|
69 <h3>Class Attributes</h3> |
|
70 |
|
71 <table> |
|
72 <tr><td>None</td></tr> |
|
73 </table> |
|
74 <h3>Class Methods</h3> |
|
75 |
|
76 <table> |
|
77 <tr><td>None</td></tr> |
|
78 </table> |
|
79 <h3>Methods</h3> |
|
80 |
|
81 <table> |
|
82 |
|
83 <tr> |
|
84 <td><a href="#BaseDocstringGenerator.__init__">BaseDocstringGenerator</a></td> |
|
85 <td>Constructor</td> |
|
86 </tr> |
|
87 <tr> |
|
88 <td><a href="#BaseDocstringGenerator._generateDocstringList">_generateDocstringList</a></td> |
|
89 <td>Protected method to generate type specific docstrings based on the extracted function information.</td> |
|
90 </tr> |
|
91 <tr> |
|
92 <td><a href="#BaseDocstringGenerator.getDocstringType">getDocstringType</a></td> |
|
93 <td>Public method to determine the docstring type to be generated.</td> |
|
94 </tr> |
|
95 <tr> |
|
96 <td><a href="#BaseDocstringGenerator.hasFunctionDefinition">hasFunctionDefinition</a></td> |
|
97 <td>Public method to test, if the cursor is right below a function definition.</td> |
|
98 </tr> |
|
99 <tr> |
|
100 <td><a href="#BaseDocstringGenerator.insertDocstring">insertDocstring</a></td> |
|
101 <td>Public method to insert a docstring for the function at the cursor position.</td> |
|
102 </tr> |
|
103 <tr> |
|
104 <td><a href="#BaseDocstringGenerator.insertDocstringFromShortcut">insertDocstringFromShortcut</a></td> |
|
105 <td>Public method to insert a docstring for the function at the cursor position initiated via a keyboard shortcut.</td> |
|
106 </tr> |
|
107 <tr> |
|
108 <td><a href="#BaseDocstringGenerator.isDocstringIntro">isDocstringIntro</a></td> |
|
109 <td>Public function to test, if the line up to the cursor position might be introducing a docstring.</td> |
|
110 </tr> |
|
111 <tr> |
|
112 <td><a href="#BaseDocstringGenerator.isFunctionStart">isFunctionStart</a></td> |
|
113 <td>Public method to test, if a text is the start of a function or method definition.</td> |
|
114 </tr> |
|
115 </table> |
|
116 <h3>Static Methods</h3> |
|
117 |
|
118 <table> |
|
119 <tr><td>None</td></tr> |
|
120 </table> |
|
121 |
|
122 <a NAME="BaseDocstringGenerator.__init__" ID="BaseDocstringGenerator.__init__"></a> |
|
123 <h4>BaseDocstringGenerator (Constructor)</h4> |
|
124 <b>BaseDocstringGenerator</b>(<i>editor</i>) |
|
125 |
|
126 <p> |
|
127 Constructor |
|
128 </p> |
|
129 <dl> |
|
130 |
|
131 <dt><i>editor</i> (Editor)</dt> |
|
132 <dd> |
|
133 reference to the editor widget |
|
134 </dd> |
|
135 </dl> |
|
136 <a NAME="BaseDocstringGenerator._generateDocstringList" ID="BaseDocstringGenerator._generateDocstringList"></a> |
|
137 <h4>BaseDocstringGenerator._generateDocstringList</h4> |
|
138 <b>_generateDocstringList</b>(<i>functionInfo, docstringType</i>) |
|
139 |
|
140 <p> |
|
141 Protected method to generate type specific docstrings based on the |
|
142 extracted function information. |
|
143 </p> |
|
144 <dl> |
|
145 |
|
146 <dt><i>functionInfo</i> (FunctionInfo)</dt> |
|
147 <dd> |
|
148 reference to the function info object |
|
149 </dd> |
|
150 <dt><i>docstringType</i></dt> |
|
151 <dd> |
|
152 kind of docstring to be generated |
|
153 </dd> |
|
154 </dl> |
|
155 <dl> |
|
156 <dt>Return:</dt> |
|
157 <dd> |
|
158 list of docstring lines |
|
159 </dd> |
|
160 </dl> |
|
161 <dl> |
|
162 <dt>Return Type:</dt> |
|
163 <dd> |
|
164 str |
|
165 </dd> |
|
166 </dl> |
|
167 <a NAME="BaseDocstringGenerator.getDocstringType" ID="BaseDocstringGenerator.getDocstringType"></a> |
|
168 <h4>BaseDocstringGenerator.getDocstringType</h4> |
|
169 <b>getDocstringType</b>(<i></i>) |
|
170 |
|
171 <p> |
|
172 Public method to determine the docstring type to be generated. |
|
173 </p> |
|
174 <dl> |
|
175 <dt>Return:</dt> |
|
176 <dd> |
|
177 docstring type (one of 'ericdoc', 'numpydoc', 'googledoc', |
|
178 'sphinxdoc') |
|
179 </dd> |
|
180 </dl> |
|
181 <dl> |
|
182 <dt>Return Type:</dt> |
|
183 <dd> |
|
184 str |
|
185 </dd> |
|
186 </dl> |
|
187 <a NAME="BaseDocstringGenerator.hasFunctionDefinition" ID="BaseDocstringGenerator.hasFunctionDefinition"></a> |
|
188 <h4>BaseDocstringGenerator.hasFunctionDefinition</h4> |
|
189 <b>hasFunctionDefinition</b>(<i>cursorPosition</i>) |
|
190 |
|
191 <p> |
|
192 Public method to test, if the cursor is right below a function |
|
193 definition. |
|
194 </p> |
|
195 <dl> |
|
196 |
|
197 <dt><i>cursorPosition</i> (tuple of (int, int))</dt> |
|
198 <dd> |
|
199 current cursor position (line and column) |
|
200 </dd> |
|
201 </dl> |
|
202 <dl> |
|
203 <dt>Return:</dt> |
|
204 <dd> |
|
205 flag indicating cursor is right below a function definition |
|
206 </dd> |
|
207 </dl> |
|
208 <dl> |
|
209 <dt>Return Type:</dt> |
|
210 <dd> |
|
211 bool |
|
212 </dd> |
|
213 </dl> |
|
214 <a NAME="BaseDocstringGenerator.insertDocstring" ID="BaseDocstringGenerator.insertDocstring"></a> |
|
215 <h4>BaseDocstringGenerator.insertDocstring</h4> |
|
216 <b>insertDocstring</b>(<i>cursorPosition, fromStart=True</i>) |
|
217 |
|
218 <p> |
|
219 Public method to insert a docstring for the function at the cursor |
|
220 position. |
|
221 </p> |
|
222 <dl> |
|
223 |
|
224 <dt><i>cursorPosition</i> (tuple of (int, int))</dt> |
|
225 <dd> |
|
226 position of the cursor (line and index) |
|
227 </dd> |
|
228 <dt><i>fromStart</i> (bool)</dt> |
|
229 <dd> |
|
230 flag indicating that the editor text cursor is placed |
|
231 on the line starting the function definition |
|
232 </dd> |
|
233 </dl> |
|
234 <a NAME="BaseDocstringGenerator.insertDocstringFromShortcut" ID="BaseDocstringGenerator.insertDocstringFromShortcut"></a> |
|
235 <h4>BaseDocstringGenerator.insertDocstringFromShortcut</h4> |
|
236 <b>insertDocstringFromShortcut</b>(<i>cursorPosition</i>) |
|
237 |
|
238 <p> |
|
239 Public method to insert a docstring for the function at the cursor |
|
240 position initiated via a keyboard shortcut. |
|
241 </p> |
|
242 <dl> |
|
243 |
|
244 <dt><i>cursorPosition</i> (tuple of (int, int))</dt> |
|
245 <dd> |
|
246 position of the cursor (line and index) |
|
247 </dd> |
|
248 </dl> |
|
249 <a NAME="BaseDocstringGenerator.isDocstringIntro" ID="BaseDocstringGenerator.isDocstringIntro"></a> |
|
250 <h4>BaseDocstringGenerator.isDocstringIntro</h4> |
|
251 <b>isDocstringIntro</b>(<i>cursorPosition</i>) |
|
252 |
|
253 <p> |
|
254 Public function to test, if the line up to the cursor position might be |
|
255 introducing a docstring. |
|
256 </p> |
|
257 <dl> |
|
258 |
|
259 <dt><i>cursorPosition</i> (tuple of (int, int))</dt> |
|
260 <dd> |
|
261 current cursor position (line and column) |
|
262 </dd> |
|
263 </dl> |
|
264 <dl> |
|
265 <dt>Return:</dt> |
|
266 <dd> |
|
267 flag indicating a potential start of a docstring |
|
268 </dd> |
|
269 </dl> |
|
270 <dl> |
|
271 <dt>Return Type:</dt> |
|
272 <dd> |
|
273 bool |
|
274 </dd> |
|
275 </dl> |
|
276 <a NAME="BaseDocstringGenerator.isFunctionStart" ID="BaseDocstringGenerator.isFunctionStart"></a> |
|
277 <h4>BaseDocstringGenerator.isFunctionStart</h4> |
|
278 <b>isFunctionStart</b>(<i>text</i>) |
|
279 |
|
280 <p> |
|
281 Public method to test, if a text is the start of a function or method |
|
282 definition. |
|
283 </p> |
|
284 <dl> |
|
285 |
|
286 <dt><i>text</i> (str)</dt> |
|
287 <dd> |
|
288 line of text to be tested |
|
289 </dd> |
|
290 </dl> |
|
291 <dl> |
|
292 <dt>Return:</dt> |
|
293 <dd> |
|
294 flag indicating that the given text starts a function or |
|
295 method definition (always False) |
|
296 </dd> |
|
297 </dl> |
|
298 <dl> |
|
299 <dt>Return Type:</dt> |
|
300 <dd> |
|
301 bool |
|
302 </dd> |
|
303 </dl> |
|
304 <div align="right"><a href="#top">Up</a></div> |
|
305 <hr /> |
|
306 <hr /> |
|
307 <a NAME="DocstringMenuForEnterOnly" ID="DocstringMenuForEnterOnly"></a> |
|
308 <h2>DocstringMenuForEnterOnly</h2> |
|
309 |
|
310 <p> |
|
311 Class implementing a special menu reacting to the enter/return keys only. |
|
312 </p> |
|
313 <p> |
|
314 If a keyboard input is not the "enter key", the menu is closed and the |
|
315 input is inserted to the code editor. |
|
316 </p> |
|
317 <h3>Derived from</h3> |
|
318 QMenu |
|
319 <h3>Class Attributes</h3> |
|
320 |
|
321 <table> |
|
322 <tr><td>None</td></tr> |
|
323 </table> |
|
324 <h3>Class Methods</h3> |
|
325 |
|
326 <table> |
|
327 <tr><td>None</td></tr> |
|
328 </table> |
|
329 <h3>Methods</h3> |
|
330 |
|
331 <table> |
|
332 |
|
333 <tr> |
|
334 <td><a href="#DocstringMenuForEnterOnly.__init__">DocstringMenuForEnterOnly</a></td> |
|
335 <td>Constructor</td> |
|
336 </tr> |
|
337 <tr> |
|
338 <td><a href="#DocstringMenuForEnterOnly.keyPressEvent">keyPressEvent</a></td> |
|
339 <td>Protected method to handle key press events.</td> |
|
340 </tr> |
|
341 </table> |
|
342 <h3>Static Methods</h3> |
|
343 |
|
344 <table> |
|
345 <tr><td>None</td></tr> |
|
346 </table> |
|
347 |
|
348 <a NAME="DocstringMenuForEnterOnly.__init__" ID="DocstringMenuForEnterOnly.__init__"></a> |
|
349 <h4>DocstringMenuForEnterOnly (Constructor)</h4> |
|
350 <b>DocstringMenuForEnterOnly</b>(<i>editor</i>) |
|
351 |
|
352 <p> |
|
353 Constructor |
|
354 </p> |
|
355 <dl> |
|
356 |
|
357 <dt><i>editor</i> (Editor)</dt> |
|
358 <dd> |
|
359 reference to the editor |
|
360 </dd> |
|
361 </dl> |
|
362 <a NAME="DocstringMenuForEnterOnly.keyPressEvent" ID="DocstringMenuForEnterOnly.keyPressEvent"></a> |
|
363 <h4>DocstringMenuForEnterOnly.keyPressEvent</h4> |
|
364 <b>keyPressEvent</b>(<i>evt</i>) |
|
365 |
|
366 <p> |
|
367 Protected method to handle key press events. |
|
368 </p> |
|
369 <dl> |
|
370 |
|
371 <dt><i>evt</i> (QKeyEvent)</dt> |
|
372 <dd> |
|
373 reference to the key press event object |
|
374 </dd> |
|
375 </dl> |
|
376 <div align="right"><a href="#top">Up</a></div> |
|
377 <hr /> |
|
378 <hr /> |
|
379 <a NAME="FunctionInfo" ID="FunctionInfo"></a> |
|
380 <h2>FunctionInfo</h2> |
|
381 |
|
382 <p> |
|
383 Class implementing an object to store function information. |
|
384 </p> |
|
385 <p> |
|
386 Methods to extract the relevant information need to be implemented in |
|
387 language specific subclasses. |
|
388 </p> |
|
389 <h3>Derived from</h3> |
|
390 None |
|
391 <h3>Class Attributes</h3> |
|
392 |
|
393 <table> |
|
394 <tr><td>None</td></tr> |
|
395 </table> |
|
396 <h3>Class Methods</h3> |
|
397 |
|
398 <table> |
|
399 <tr><td>None</td></tr> |
|
400 </table> |
|
401 <h3>Methods</h3> |
|
402 |
|
403 <table> |
|
404 |
|
405 <tr> |
|
406 <td><a href="#FunctionInfo.__init__">FunctionInfo</a></td> |
|
407 <td>Constructor</td> |
|
408 </tr> |
|
409 </table> |
|
410 <h3>Static Methods</h3> |
|
411 |
|
412 <table> |
|
413 <tr><td>None</td></tr> |
|
414 </table> |
|
415 |
|
416 <a NAME="FunctionInfo.__init__" ID="FunctionInfo.__init__"></a> |
|
417 <h4>FunctionInfo (Constructor)</h4> |
|
418 <b>FunctionInfo</b>(<i></i>) |
|
419 |
|
420 <p> |
|
421 Constructor |
|
422 </p> |
|
423 <div align="right"><a href="#top">Up</a></div> |
|
424 <hr /> |
|
425 <hr /> |
|
426 <a NAME="getIndentStr" ID="getIndentStr"></a> |
|
427 <h2>getIndentStr</h2> |
|
428 <b>getIndentStr</b>(<i>text</i>) |
|
429 |
|
430 <p> |
|
431 Function to get the indentation of a text. |
|
432 </p> |
|
433 <dl> |
|
434 |
|
435 <dt><i>text</i> (str)</dt> |
|
436 <dd> |
|
437 text to extract indentation from |
|
438 </dd> |
|
439 </dl> |
|
440 <dl> |
|
441 <dt>Return:</dt> |
|
442 <dd> |
|
443 indentation string |
|
444 </dd> |
|
445 </dl> |
|
446 <dl> |
|
447 <dt>Return Type:</dt> |
|
448 <dd> |
|
449 str |
|
450 </dd> |
|
451 </dl> |
|
452 <div align="right"><a href="#top">Up</a></div> |
|
453 <hr /> |
|
454 </body></html> |