--- a/src/eric7/Utilities/ModuleParser.py Thu Dec 21 15:46:22 2023 +0100 +++ b/src/eric7/Utilities/ModuleParser.py Thu Dec 21 19:50:01 2023 +0100 @@ -55,8 +55,10 @@ """ Module function to determine the module type given the module type name. - @param name module type name (string) - @return module type or -1 for failure (integer) + @param name module type name + @type str + @return module type or -1 for failure + @rtype int """ if name in TYPE_MAPPING: return TYPE_MAPPING[name] @@ -381,7 +383,8 @@ """ Public method to check, if the visibility is Private. - @return flag indicating Private visibility (boolean) + @return flag indicating Private visibility + @rtype bool """ return self.visibility == 0 @@ -389,7 +392,8 @@ """ Public method to check, if the visibility is Protected. - @return flag indicating Protected visibility (boolean) + @return flag indicating Protected visibility + @rtype bool """ return self.visibility == 1 @@ -397,7 +401,8 @@ """ Public method to check, if the visibility is Public. - @return flag indicating Public visibility (boolean) + @return flag indicating Public visibility + @rtype bool """ return self.visibility == 2 @@ -429,9 +434,12 @@ """ Constructor - @param name name of this module (string) - @param file filename of file containing this module (string) + @param name name of this module + @type str + @param file filename of file containing this module + @type str @param moduleType type of this module + @type int """ self.name = name self.file = file @@ -458,8 +466,10 @@ """ Public method to add information about a class. - @param name name of class to be added (string) + @param name name of class to be added + @type str @param _class Class object to be added + @type Class """ if name in self.classes: self.classes_counts[name] += 1 @@ -472,8 +482,10 @@ """ Public method to add information about a Ruby module. - @param name name of module to be added (string) + @param name name of module to be added + @type str @param module Module object to be added + @type Module """ if name in self.modules: self.modules_counts[name] += 1 @@ -486,8 +498,10 @@ """ Public method to add information about a function. - @param name name of function to be added (string) + @param name name of function to be added + @type str @param function Function object to be added + @type Function """ if name in self.functions: self.functions_counts[name] += 1 @@ -500,8 +514,10 @@ """ Public method to add information about global variables. - @param name name of the global to add (string) + @param name name of the global to add + @type str @param attr Attribute object to be added + @type Attribute """ if name not in self.globals: self.globals[name] = attr @@ -512,7 +528,8 @@ """ Public method to store the modules docstring. - @param description the docstring to be stored (string) + @param description the docstring to be stored + @type str """ self.description = description @@ -521,7 +538,8 @@ Public method to scan the source text and retrieve the relevant information. - @param src the source text to be scanned (string) + @param src the source text to be scanned + @type str """ # convert eol markers the Python style src = src.replace("\r\n", "\n").replace("\r", "\n") @@ -534,7 +552,8 @@ """ Private method to set the visibility of an object. - @param objectRef reference to the object (Attribute, Class or Function) + @param objectRef reference to the object + @type Attribute, Class or Function """ if objectRef.name.startswith("__"): objectRef.setPrivate() @@ -548,7 +567,8 @@ Private method to scan the source text of a Python module and retrieve the relevant information. - @param src the source text to be scanned (string) + @param src the source text to be scanned + @type str """ # __IGNORE_WARNING_D234__ def calculateEndline(lineno, lines, indent): @@ -1254,6 +1274,7 @@ this module. @return A dictionary with inheritance hierarchies. + @rtype dict """ hierarchy = {} for class_ in self.classes: @@ -1272,10 +1293,14 @@ This code is borrowed from Boa Constructor. - @param name name of class to assemble hierarchy (string) + @param name name of class to assemble hierarchy + @type str @param classes A dictionary of classes to look in. - @param path + @type dict + @param path path of classes + @type list of str @param result The resultant hierarchy + @type dict """ rv = {} if name in classes: @@ -1300,9 +1325,12 @@ Public method to put the exhausted path into the result dictionary. @param path the exhausted path of classes + @type list of str @param result the result dictionary + @type dict @param fn function to call for classe that are already part of the result dictionary + @type function """ if path[0] in result: if len(path) > 1: @@ -1316,7 +1344,8 @@ """ Public method to retrieve the modules name. - @return module name (string) + @return module name + @rtype str """ return self.name @@ -1324,7 +1353,8 @@ """ Public method to retrieve the modules filename. - @return module filename (string) + @return module filename + @rtype str """ return self.file @@ -1332,7 +1362,8 @@ """ Public method to get the type of the module's source. - @return type of the modules's source (string) + @return type of the modules's source + @rtype str """ if self.type in [PY_SOURCE, PTL_SOURCE]: moduleType = "Python3" @@ -1352,12 +1383,16 @@ """ Constructor - @param module name of module containing this class (string) - @param name name of the class (string) + @param module name of module containing this class + @type str + @param name name of the class + @type str @param superClasses list of classnames this class is inherited from - (list of strings) - @param file name of file containing this class (string) - @param lineno linenumber of the class definition (integer) + @type list of str + @param file name of file containing this class + @type str + @param lineno linenumber of the class definition + @type int """ self.module = module self.name = name @@ -1377,8 +1412,10 @@ """ Public method to add information about a method. - @param name name of method to be added (string) + @param name name of method to be added + @type str @param function Function object to be added + @type Function """ self.methods[name] = function @@ -1386,8 +1423,10 @@ """ Public method to retrieve a method by name. - @param name name of the method (string) + @param name name of the method + @type str @return the named method or None + @rtype Function """ try: return self.methods[name] @@ -1398,8 +1437,10 @@ """ Public method to add information about attributes. - @param name name of the attribute to add (string) + @param name name of the attribute to add + @type str @param attr Attribute object to be added + @type Attribute """ if name not in self.attributes: self.attributes[name] = attr @@ -1410,8 +1451,10 @@ """ Public method to retrieve an attribute by name. - @param name name of the attribute (string) + @param name name of the attribute + @type str @return the named attribute or None + @rtype Attribute """ try: return self.attributes[name] @@ -1422,8 +1465,10 @@ """ Public method to add information about global (class) variables. - @param name name of the global to add (string) + @param name name of the global to add + @type str @param attr Attribute object to be added + @type Attribute """ if name not in self.globals: self.globals[name] = attr @@ -1434,7 +1479,8 @@ """ Public method to store the class docstring. - @param description the docstring to be stored (string) + @param description the docstring to be stored + @type str """ self.description = description @@ -1442,7 +1488,8 @@ """ Public method to record the number of the last line of a class. - @param endLineNo number of the last line (integer) + @param endLineNo number of the last line + @type int """ self.endlineno = endLineNo @@ -1456,10 +1503,14 @@ """ Constructor - @param module name of module containing this class (string) - @param name name of the class (string) - @param file name of file containing this class (string) - @param lineno linenumber of the class definition (integer) + @param module name of module containing this class + @type str + @param name name of the class + @type str + @param file name of file containing this class + @type str + @param lineno linenumber of the class definition + @type int """ Class.__init__(self, module, name, None, file, lineno) self.classes = {} @@ -1468,8 +1519,10 @@ """ Public method to add information about a class. - @param name name of class to be added (string) + @param name name of class to be added + @type str @param _class Class object to be added + @type Class """ self.classes[name] = _class @@ -1497,14 +1550,22 @@ """ Constructor - @param module name of module containing this function (string) - @param name name of the function (string) - @param file name of file containing this function (string) - @param lineno linenumber of the function definition (integer) - @param signature the functions call signature (string) - @param pyqtSignature the functions PyQt signature (string) + @param module name of module containing this function + @type str + @param name name of the function + @type str + @param file name of file containing this function + @type str + @param lineno linenumber of the function definition + @type int + @param signature the functions call signature + @type str + @param pyqtSignature the functions PyQt signature + @type str @param modifierType type of the function + @type int @param annotation return annotation + @type str """ self.module = module self.name = name @@ -1523,7 +1584,8 @@ """ Public method to store the functions docstring. - @param description the docstring to be stored (string) + @param description the docstring to be stored + @type str """ self.description = description @@ -1531,7 +1593,8 @@ """ Public method to record the number of the last line of a class. - @param endLineNo number of the last line (integer) + @param endLineNo number of the last line + @type int """ self.endlineno = endLineNo @@ -1545,11 +1608,16 @@ """ Constructor - @param module name of module containing this function (string) - @param name name of the function (string) - @param file name of file containing this function (string) - @param lineno linenumber of the first attribute assignment (integer) - @param isSignal flag indicating a signal definition (boolean) + @param module name of module containing this function + @type str + @param name name of the function + @type str + @param file name of file containing this function + @type str + @param lineno linenumber of the first attribute assignment + @type int + @param isSignal flag indicating a signal definition + @type bool """ self.module = module self.name = name @@ -1564,7 +1632,7 @@ Public method to add another assignment line number. @param lineno linenumber of the additional attribute assignment - (integer) + @type int """ if lineno not in self.linenos: self.linenos.append(lineno) @@ -1586,20 +1654,27 @@ If the module was parsed before, the information is taken from a cache in order to speed up processing. - @param module name of the module to be parsed (string) - @param path search path for the module (list of strings) + @param module name of the module to be parsed + @type str + @param path search path for the module + @type list of str @param inpackage flag indicating that module is inside a - package (boolean) + package + @type bool @param basename a path basename that is deleted from the filename of - the module file to be read (string) + the module file to be read + @type str @param extensions list of extensions, which should be considered valid - source file extensions (list of strings) + source file extensions + @type list of str @param caching flag indicating that the parsed module should be - cached (boolean) + cached + @type bool @param ignoreBuiltinModules flag indicating to ignore the builtin modules - (boolean) + @type bool @return reference to a Module object containing the parsed - module information (Module) + module information + @rtype Module """ global _modules @@ -1679,8 +1754,10 @@ """ Protected function to determine the indent width of a whitespace string. - @param ws The whitespace string to be cheked. (string) - @return Length of the whitespace string after tab expansion. + @param ws The whitespace string to be cheked. + @type str + @return length of the whitespace string after tab expansion + @rtype int """ return len(ws.expandtabs(TABWIDTH)) @@ -1694,12 +1771,16 @@ implemented in the imp module is used. For all other supported files only path is searched. - @param name filename or modulename to search for (string) - @param path search path (list of strings) + @param name filename or modulename to search for + @type str + @param path search path + @type list of str @param extensions list of extensions, which should be considered valid - source file extensions (list of strings) + source file extensions + @type list of str @return tuple of the open file, pathname and description. Description is a tuple of file suffix, file mode and file type) + @rtype tuple @exception ImportError The file or module wasn't found. """ for ext in extensions: @@ -1754,9 +1835,11 @@ """ Module function to clear one module from the list of parsed modules. - @param module Name of the module to be parsed (string) + @param module Name of the module to be parsed + @type str @param basename a path basename. This basename is deleted from - the filename of the module file to be cleared. (string) + the filename of the module file to be cleared. + @type str """ modname = module