src/eric7/QScintilla/DocstringGenerator/EricdocGenerator.py

branch
eric7
changeset 9221
bf71ee032bb4
parent 9209
b99e7fd55fd3
child 9486
5a8179763e38
diff -r e9e7eca7efee -r bf71ee032bb4 src/eric7/QScintilla/DocstringGenerator/EricdocGenerator.py
--- a/src/eric7/QScintilla/DocstringGenerator/EricdocGenerator.py	Wed Jul 13 11:16:20 2022 +0200
+++ b/src/eric7/QScintilla/DocstringGenerator/EricdocGenerator.py	Wed Jul 13 14:55:47 2022 +0200
@@ -11,10 +11,10 @@
 def generateEricDoc(functionInfo):
     """
     Function to generate the docstring line list iaw. eric documentation style.
-    
+
     Note: Partial English text is created with DESCRIPTION placeholders
     for descriptions and TYPE placeholders for type information
-    
+
     @param functionInfo object containing the function information to base
         the docstring on
     @type FunctionInfo
@@ -23,7 +23,7 @@
     """
     # __IGNORE_WARNING_D202__
     lines = []
-    
+
     # create a basic/partial function description
     if functionInfo.functionType == "classmethod":
         descr = "Class method "
@@ -42,10 +42,11 @@
             descr = "Special "
         else:
             descr = ""
-        
-        if (
-            len(functionInfo.argumentsList) > 0 and
-            functionInfo.argumentsList[0][0] in ("self", "cls", "this")
+
+        if len(functionInfo.argumentsList) > 0 and functionInfo.argumentsList[0][0] in (
+            "self",
+            "cls",
+            "this",
         ):
             if functionInfo.isAsync:
                 descr += "coroutine "
@@ -61,48 +62,49 @@
             else:
                 descr = "Function "
     lines.append(descr)
-    
+
     # remove 'self', 'this' or 'cls' from arguments list
-    if (
-        len(functionInfo.argumentsList) > 0 and
-        functionInfo.argumentsList[0][0] in ("self", "cls", "this")
+    if len(functionInfo.argumentsList) > 0 and functionInfo.argumentsList[0][0] in (
+        "self",
+        "cls",
+        "this",
     ):
         del functionInfo.argumentsList[0]
-    
+
     # add an empty line if there is one of the other sections
     if (
-        functionInfo.argumentsList or
-        functionInfo.hasYield or
-        functionInfo.returnTypeAnnotated or
-        functionInfo.returnValueInBody or
-        functionInfo.raiseList
+        functionInfo.argumentsList
+        or functionInfo.hasYield
+        or functionInfo.returnTypeAnnotated
+        or functionInfo.returnValueInBody
+        or functionInfo.raiseList
     ):
         lines.append("")
-    
+
     # add the parameters section
     tag = "@param"
     for argName, argType, argValue in functionInfo.argumentsList:
         if argName == "*":
             tag = "@keyparam"
             continue
-        
+
         argLine = "{0} {1} DESCRIPTION".format(tag, argName)
         if argValue:
             argLine += " (defaults to {0})".format(argValue)
         lines.append(argLine)
-        
+
         if argType is None:
             argType = "TYPE"
         argLine = "@type {0}".format(argType)
         if argValue:
             argLine += " (optional)"
         lines.append(argLine)
-    
+
     # add return section
     if (
-        functionInfo.hasYield or
-        functionInfo.returnValueInBody or
-        functionInfo.returnTypeAnnotated
+        functionInfo.hasYield
+        or functionInfo.returnValueInBody
+        or functionInfo.returnTypeAnnotated
     ):
         if functionInfo.hasYield:
             lines.append("@yield DESCRIPTION")
@@ -111,14 +113,13 @@
             lines.append("@return DESCRIPTION")
             rType = "@rtype"
         if functionInfo.returnTypeAnnotated:
-            lines.append("{0} {1}".format(
-                rType, functionInfo.returnTypeAnnotated))
+            lines.append("{0} {1}".format(rType, functionInfo.returnTypeAnnotated))
         else:
             lines.append("{0} TYPE".format(rType))
-    
+
     # add an exceptions section, if function raises something
     if functionInfo.raiseList:
         for exc in sorted(functionInfo.raiseList):
             lines.append("@exception {0} DESCRIPTION".format(exc))
-    
+
     return lines

eric ide

mercurial