eric6/ViewManager/ViewManager.py

branch
maintenance
changeset 8043
0acf98cd089a
parent 7924
8a96736d465e
parent 8037
cf0e5b8cd23a
child 8142
43248bafe9b2
diff -r 866adc8c315b -r 0acf98cd089a eric6/ViewManager/ViewManager.py
--- a/eric6/ViewManager/ViewManager.py	Sun Jan 17 13:53:08 2021 +0100
+++ b/eric6/ViewManager/ViewManager.py	Mon Feb 01 10:38:16 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)
@@ -6627,14 +6651,13 @@
                             dictionaryFile, str(err)))
                     return
                 
-                if self.ui.notificationsEnabled():
-                    self.ui.showNotification(
-                        UI.PixmapCache.getPixmap("spellchecking48"),
-                        QCoreApplication.translate(
-                            'ViewManager', "Edit Spelling Dictionary"),
-                        QCoreApplication.translate(
-                            'ViewManager',
-                            "The spelling dictionary was saved successfully."))
+                self.ui.showNotification(
+                    UI.PixmapCache.getPixmap("spellchecking48"),
+                    QCoreApplication.translate(
+                        'ViewManager', "Edit Spelling Dictionary"),
+                    QCoreApplication.translate(
+                        'ViewManager',
+                        "The spelling dictionary was saved successfully."))
     
     ##################################################################
     ## Below are general utility methods
@@ -7098,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.

eric ide

mercurial