src/eric7/DocumentationTools/APIGenerator.py

branch
eric7
changeset 9221
bf71ee032bb4
parent 9209
b99e7fd55fd3
child 9413
80c06d472826
diff -r e9e7eca7efee -r bf71ee032bb4 src/eric7/DocumentationTools/APIGenerator.py
--- a/src/eric7/DocumentationTools/APIGenerator.py	Wed Jul 13 11:16:20 2022 +0200
+++ b/src/eric7/DocumentationTools/APIGenerator.py	Wed Jul 13 14:55:47 2022 +0200
@@ -12,18 +12,19 @@
     """
     Class implementing the builtin documentation generator.
     """
+
     def __init__(self, module):
         """
         Constructor
-        
+
         @param module The information of the parsed Python file.
         """
         self.module = module
-        
+
     def genAPI(self, newStyle, basePackage, includePrivate):
         """
         Public method to generate the API information.
-        
+
         @param newStyle flag indicating the api generation for QScintilla 1.7
             and newer (boolean) (ignored)
         @param basePackage name of the base package (string)
@@ -32,22 +33,22 @@
         @return API information (list of strings)
         """
         self.includePrivate = includePrivate
-        modulePath = self.module.name.split('.')
-        if modulePath[-1] == '__init__':
+        modulePath = self.module.name.split(".")
+        if modulePath[-1] == "__init__":
             del modulePath[-1]
         if basePackage:
             modulePath[0] = basePackage
-        self.moduleName = "{0}.".format('.'.join(modulePath))
+        self.moduleName = "{0}.".format(".".join(modulePath))
         self.api = []
         self.__addGlobalsAPI()
         self.__addClassesAPI()
         self.__addFunctionsAPI()
         return self.api
-        
+
     def genBases(self, includePrivate):
         """
         Public method to generate the base classes information.
-        
+
         @param includePrivate flag indicating to include private classes
             (boolean)
         @return base classes information (dictionary of list of strings)
@@ -57,32 +58,32 @@
         classNames = sorted(self.module.classes.keys())
         for className in classNames:
             if (
-                not self.__isPrivate(self.module.classes[className]) and
-                className not in bases
+                not self.__isPrivate(self.module.classes[className])
+                and className not in bases
             ):
                 bases[className] = [
-                    b for b in self.module.classes[className].super
-                    if b != "object"]
+                    b for b in self.module.classes[className].super if b != "object"
+                ]
         return bases
-        
+
     def __isPrivate(self, obj):
         """
         Private method to check, if an object is considered private.
-        
+
         @param obj reference to the object to be checked
         @return flag indicating, that object is considered private (boolean)
         """
         private = obj.isPrivate() and not self.includePrivate
         return private
-        
+
     def __addGlobalsAPI(self):
         """
         Private method to generate the api section for global variables.
         """
         from QScintilla.Editor import Editor
-        
+
         moduleNameStr = "{0}".format(self.moduleName)
-        
+
         for globalName in sorted(self.module.globals.keys()):
             if not self.__isPrivate(self.module.globals[globalName]):
                 if self.module.globals[globalName].isPublic():
@@ -91,9 +92,10 @@
                     iconId = Editor.AttributeProtectedID
                 else:
                     iconId = Editor.AttributePrivateID
-                self.api.append("{0}{1}?{2:d}".format(
-                    moduleNameStr, globalName, iconId))
-        
+                self.api.append(
+                    "{0}{1}?{2:d}".format(moduleNameStr, globalName, iconId)
+                )
+
     def __addClassesAPI(self):
         """
         Private method to generate the api section for classes.
@@ -103,19 +105,19 @@
             if not self.__isPrivate(self.module.classes[className]):
                 self.__addClassVariablesAPI(className)
                 self.__addMethodsAPI(className)
-        
+
     def __addMethodsAPI(self, className):
         """
         Private method to generate the api section for class methods.
-        
+
         @param className name of the class containing the method (string)
         """
         from QScintilla.Editor import Editor
-        
+
         _class = self.module.classes[className]
         methods = sorted(_class.methods.keys())
-        if '__init__' in methods:
-            methods.remove('__init__')
+        if "__init__" in methods:
+            methods.remove("__init__")
             if _class.isPublic():
                 iconId = Editor.ClassID
             elif _class.isProtected():
@@ -123,10 +125,14 @@
             else:
                 iconId = Editor.ClassPrivateID
             self.api.append(
-                '{0}{1}?{2:d}({3})'.format(
-                    self.moduleName, _class.name, iconId,
-                    ', '.join(_class.methods['__init__'].parameters[1:])))
-            
+                "{0}{1}?{2:d}({3})".format(
+                    self.moduleName,
+                    _class.name,
+                    iconId,
+                    ", ".join(_class.methods["__init__"].parameters[1:]),
+                )
+            )
+
         classNameStr = "{0}{1}.".format(self.moduleName, className)
         for method in methods:
             if not self.__isPrivate(_class.methods[method]):
@@ -137,19 +143,23 @@
                 else:
                     iconId = Editor.MethodPrivateID
                 self.api.append(
-                    '{0}{1}?{2:d}({3})'.format(
-                        classNameStr, method, iconId,
-                        ', '.join(_class.methods[method].parameters[1:])))
-        
+                    "{0}{1}?{2:d}({3})".format(
+                        classNameStr,
+                        method,
+                        iconId,
+                        ", ".join(_class.methods[method].parameters[1:]),
+                    )
+                )
+
     def __addClassVariablesAPI(self, className):
         """
         Private method to generate class api section for class variables.
-        
+
         @param className name of the class containing the class variables
             (string)
         """
         from QScintilla.Editor import Editor
-        
+
         _class = self.module.classes[className]
         classNameStr = "{0}{1}.".format(self.moduleName, className)
         for variable in sorted(_class.globals.keys()):
@@ -160,15 +170,14 @@
                     iconId = Editor.AttributeProtectedID
                 else:
                     iconId = Editor.AttributePrivateID
-                self.api.append('{0}{1}?{2:d}'.format(
-                    classNameStr, variable, iconId))
-        
+                self.api.append("{0}{1}?{2:d}".format(classNameStr, variable, iconId))
+
     def __addFunctionsAPI(self):
         """
         Private method to generate the api section for functions.
         """
         from QScintilla.Editor import Editor
-        
+
         funcNames = sorted(self.module.functions.keys())
         for funcName in funcNames:
             if not self.__isPrivate(self.module.functions[funcName]):
@@ -179,7 +188,10 @@
                 else:
                     iconId = Editor.MethodPrivateID
                 self.api.append(
-                    '{0}{1}?{2:d}({3})'.format(
-                        self.moduleName, self.module.functions[funcName].name,
+                    "{0}{1}?{2:d}({3})".format(
+                        self.moduleName,
+                        self.module.functions[funcName].name,
                         iconId,
-                        ', '.join(self.module.functions[funcName].parameters)))
+                        ", ".join(self.module.functions[funcName].parameters),
+                    )
+                )

eric ide

mercurial