diff -r 159689297bc0 -r 47b15df088e4 eric6/ViewManager/ViewManager.py --- a/eric6/ViewManager/ViewManager.py Fri Jan 22 16:55:43 2021 +0100 +++ b/eric6/ViewManager/ViewManager.py Sat Jan 23 12:02:52 2021 +0100 @@ -1465,6 +1465,28 @@ self.sortAct.triggered.connect(self.__editSortSelectedLines) self.editActions.append(self.sortAct) + self.docstringAct = E5Action( + QCoreApplication.translate('ViewManager', 'Generate Docstring'), + QCoreApplication.translate('ViewManager', 'Generate Docstring'), + QKeySequence(QCoreApplication.translate( + 'ViewManager', "Ctrl+Alt+D", "Edit|Generate Docstring")), + 0, + self.editActGrp, 'vm_edit_generate_docstring') + self.docstringAct.setStatusTip(QCoreApplication.translate( + 'ViewManager', + 'Generate a docstring for the current function/method')) + self.docstringAct.setWhatsThis(QCoreApplication.translate( + 'ViewManager', + """<b>Generate Docstring</b>""" + """<p>Generate a docstring for the current function/method if""" + """ the cursor is placed on the line starting the function""" + """ definition or on the line thereafter. The docstring is""" + """ inserted at the appropriate position and the cursor is""" + """ placed at the end of the description line.</p>""" + )) + self.docstringAct.triggered.connect(self.__editInsertDocstring) + self.editActions.append(self.docstringAct) + self.editActGrp.setEnabled(False) self.copyActGrp.setEnabled(False) @@ -2805,6 +2827,8 @@ menu.addAction(self.streamCommentAct) menu.addAction(self.boxCommentAct) menu.addSeparator() + menu.addAction(self.docstringAct) + menu.addSeparator() menu.addAction(self.editUpperCaseAct) menu.addAction(self.editLowerCaseAct) menu.addAction(self.sortAct) @@ -7097,6 +7121,14 @@ if editor: editor.sortLines() + def __editInsertDocstring(self): + """ + Private method to insert a docstring. + """ + editor = self.activeWindow() + if editor: + editor.insertDocstring() + def showEditorInfo(self, editor): """ Public method to show some information for a given editor.