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