Changed the PydocstringGenerator to adhere to the formatting rule of the 'Black' tool. eric7

Wed, 19 Oct 2022 17:00:05 +0200

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Wed, 19 Oct 2022 17:00:05 +0200
branch
eric7
changeset 9422
cf2ea9c6316a
parent 9421
989ee2535d59
child 9423
f30b9e9819cc

Changed the PydocstringGenerator to adhere to the formatting rule of the 'Black' tool.

src/eric7/QScintilla/DocstringGenerator/PyDocstringGenerator.py file | annotate | diff | comparison | revisions
--- a/src/eric7/QScintilla/DocstringGenerator/PyDocstringGenerator.py	Wed Oct 19 13:39:16 2022 +0200
+++ b/src/eric7/QScintilla/DocstringGenerator/PyDocstringGenerator.py	Wed Oct 19 17:00:05 2022 +0200
@@ -214,15 +214,13 @@
                     docstringList[0] = self.__quote3 + docstringList[0]
                     newCursorLine = insertLine
                 docstringList.append(self.__quote3)
-                return (
-                    (
-                        indentation
-                        + "{0}{1}".format(sep, indentation).join(docstringList)
-                        + sep
-                    ),
-                    (insertLine, 0),
-                    newCursorLine,
-                )
+                for index, line in enumerate(docstringList):
+                    docstringList[index] = (
+                        indentation + line
+                        if bool(line.strip())
+                        else ""
+                    )
+                return sep.join(docstringList) + sep, (insertLine, 0), newCursorLine
 
         return "", (0, 0), 0
 
@@ -290,7 +288,7 @@
 
     def __generateDocstringFromBelow(self, cursorPosition):
         """
-        Private method to generate a docstring when the gicen position is on
+        Private method to generate a docstring when the given position is on
         the line below the end of the definition.
 
         @param cursorPosition position of the cursor (line and index)
@@ -324,7 +322,13 @@
                         docstringList[0] = self.__quote3 + docstringList[0]
                         newCursorLine = cursorPosition[0]
                     docstringList.append(self.__quote3)
-                docstring = "{0}{1}".format(sep, indentation).join(docstringList)
+                for index, line in enumerate(docstringList):
+                    docstringList[index] = (
+                        indentation + line
+                        if bool(line.strip())
+                        else ""
+                    )
+                docstring = sep.join(docstringList) + indentation
                 return docstring, cursorPosition, newCursorLine
 
         return "", (0, 0), 0

eric ide

mercurial