--- a/src/eric7/Templates/TemplateViewer.py Wed Dec 20 19:28:22 2023 +0100 +++ b/src/eric7/Templates/TemplateViewer.py Thu Dec 21 12:03:40 2023 +0100 @@ -34,9 +34,12 @@ """ Constructor - @param parent parent widget of the template group (QWidget) - @param name name of the group (string) - @param language programming language for the group (string) + @param parent parent widget of the template group + @type QWidget + @param name name of the group + @type str + @param language programming language for the group + @type str """ self.name = name self.language = language @@ -51,7 +54,8 @@ """ Public method to update the name of the group. - @param name name of the group (string) + @param name name of the group + @type str """ self.name = name self.setText(0, name) @@ -60,7 +64,8 @@ """ Public method to get the name of the group. - @return name of the group (string) + @return name of the group + @rtype str """ return self.name @@ -68,7 +73,8 @@ """ Public method to update the name of the group. - @param language programming language for the group (string) + @param language programming language for the group + @type str """ self.language = language if Preferences.getTemplates("ShowTooltip"): @@ -78,7 +84,8 @@ """ Public method to get the name of the group. - @return language of the group (string) + @return language of the group + @rtype str """ return self.language @@ -86,10 +93,14 @@ """ Public method to add a template entry to this group. - @param name name of the entry (string) - @param description description of the entry to add (string) - @param template template text of the entry (string) - @param quiet flag indicating quiet operation (boolean) + @param name name of the entry + @type str + @param description description of the entry to add + @type str + @param template template text of the entry + @type str + @param quiet flag indicating quiet operation + @type bool """ if name in self.entries: if not quiet: @@ -113,7 +124,8 @@ """ Public method to remove a template entry from this group. - @param name name of the entry to be removed (string) + @param name name of the entry to be removed + @type str """ if name in self.entries: index = self.indexOfChild(self.entries[name]) @@ -138,8 +150,10 @@ """ Public method to check, if the group has an entry with the given name. - @param name name of the entry to check for (string) - @return flag indicating existence (boolean) + @param name name of the entry to check for + @type str + @return flag indicating existence + @rtype bool """ return name in self.entries @@ -147,8 +161,10 @@ """ Public method to get an entry. - @param name name of the entry to retrieve (string) - @return reference to the entry (TemplateEntry) + @param name name of the entry to retrieve + @type str + @return reference to the entry + @rtype TemplateEntry """ try: return self.entries[name] @@ -161,8 +177,9 @@ the given string. @param beginning string denoting the beginning of the template name - (string) - @return list of entry names found (list of strings) + @type str + @return list of entry names found + @rtype list of str """ names = [] for name in self.entries: @@ -175,7 +192,8 @@ """ Public method to retrieve all entries. - @return list of all entries (list of TemplateEntry) + @return list of all entries + @rtype list of TemplateEntry """ return list(self.entries.values()) @@ -189,10 +207,14 @@ """ Constructor - @param parent parent widget of the template entry (QWidget) - @param name name of the entry (string) - @param description descriptive text for the template (string) - @param templateText text of the template entry (string) + @param parent parent widget of the template entry + @type QWidget + @param name name of the entry + @type str + @param description descriptive text for the template + @type str + @param templateText text of the template entry + @type str """ self.name = name self.description = description @@ -207,7 +229,8 @@ """ Private method to generate the display text. - @return display text (string) + @return display text + @rtype str """ txt = ( "{0} - {1}".format(self.name, self.description) @@ -220,7 +243,8 @@ """ Public method to update the name of the entry. - @param name name of the entry (string) + @param name name of the entry + @type str """ self.name = name self.setText(0, self.__displayText()) @@ -229,7 +253,8 @@ """ Public method to get the name of the entry. - @return name of the entry (string) + @return name of the entry + @rtype str """ return self.name @@ -237,7 +262,8 @@ """ Public method to update the description of the entry. - @param description description of the entry (string) + @param description description of the entry + @type str """ self.description = description self.setText(0, self.__displayText()) @@ -246,7 +272,8 @@ """ Public method to get the description of the entry. - @return description of the entry (string) + @return description of the entry + @rtype str """ return self.description @@ -254,7 +281,8 @@ """ Public method to get the name of the group this entry belongs to. - @return name of the group containing this entry (string) + @return name of the group containing this entry + @rtype str """ return self.parent().getName() @@ -262,7 +290,8 @@ """ Public method to update the template text. - @param templateText text of the template entry (string) + @param templateText text of the template entry + @type str """ self.template = templateText self.__extractVariables() @@ -273,7 +302,8 @@ """ Public method to get the template text. - @return the template text (string) + @return the template text + @rtype str """ return self.template @@ -282,11 +312,14 @@ Public method to get the template text with all variables expanded. @param varDict dictionary containing the texts of each variable - with the variable name as key. + with the variable name as key + @type dict @param indent indentation of the line receiving he expanded - template text (string) - @return a tuple of the expanded template text (string), the - number of lines (integer) and the length of the last line (integer) + template text + @type str + @return a tuple of the expanded template text, the number of lines + and the length of the last line + @rtype tuple of (str, int, int) """ txt = self.template for var, val in varDict.items(): @@ -313,10 +346,14 @@ """ Private method to expand a template variable with special formatting. - @param var template variable name (string) - @param val value of the template variable (string) - @param txt template text (string) - @return expanded and formatted variable (string) + @param var template variable name + @type str + @param val value of the template variable + @type str + @param txt template text + @type str + @return expanded and formatted variable + @rtype str """ t = "" for line in txt.splitlines(): @@ -349,7 +386,8 @@ """ Public method to get the list of variables. - @return list of variables (list of strings) + @return list of variables + @rtype list of str """ return self.variables @@ -380,8 +418,10 @@ """ Constructor - @param parent the parent (QWidget) + @param parent the parent + @type QWidget @param viewmanager reference to the viewmanager object + @type ViewManager """ super().__init__(parent) @@ -450,8 +490,10 @@ """ Private slot to handle the activation of an item. - @param itm reference to the activated item (QTreeWidgetItem) - @param col column the item was activated in (integer) + @param itm reference to the activated item + @type QTreeWidgetItem + @param col column the item was activated in + @type int """ if not self.__activating: self.__activating = True @@ -464,7 +506,8 @@ """ Private slot to show the context menu of the list. - @param coord the position of the mouse pointer (QPoint) + @param coord the position of the mouse pointer + @type QPoint """ itm = self.itemAt(coord) coord = self.mapToGlobal(coord) @@ -653,6 +696,7 @@ Private method to return predefined variables. @return dictionary of predefined variables and their values + @rtype dict """ project = ericApp().getObject("Project") editor = self.viewmanager.activeWindow() @@ -712,7 +756,8 @@ """ Public method to apply the template. - @param itm reference to the template item to apply (TemplateEntry) + @param itm reference to the template item to apply + @type TemplateEntry """ from .TemplateMultipleVariablesDialog import TemplateMultipleVariablesDialog from .TemplateSingleVariableDialog import TemplateSingleVariableDialog @@ -819,10 +864,11 @@ """ Public method to apply a template given a template name. - @param templateName name of the template item to apply (string) - @param groupName name of the group to get the entry from (string). - None or empty means to apply the first template found with the - given name. + @param templateName name of the template item to apply + @type str + @param groupName name of the group to get the entry from. None or empty means + to apply the first template found with the given name. + @type str """ if groupName: if self.hasGroup(groupName): @@ -841,11 +887,16 @@ """ Public method to add a template entry. - @param groupName name of the group to add to (string) - @param name name of the entry to add (string) - @param description description of the entry to add (string) - @param template template text of the entry (string) - @param quiet flag indicating quiet operation (boolean) + @param groupName name of the group to add to + @type str + @param name name of the entry to add + @type str + @param description description of the entry to add + @type str + @param template template text of the entry + @type str + @param quiet flag indicating quiet operation + @type bool """ self.groups[groupName].addEntry(name, description, template, quiet=quiet) self.__resort() @@ -854,8 +905,10 @@ """ Public method to check, if a group with the given name exists. - @param name name of the group to be checked for (string) - @return flag indicating an existing group (boolean) + @param name name of the group to be checked for + @type str + @return flag indicating an existing group + @rtype bool """ return name in self.groups @@ -863,8 +916,10 @@ """ Public method to add a group. - @param name name of the group to be added (string) - @param language programming language for the group (string) + @param name name of the group to be added + @type str + @param language programming language for the group + @type str """ if name not in self.groups: self.groups[name] = TemplateGroup(self, name, language) @@ -874,9 +929,12 @@ """ Public method to rename a group. - @param oldname old name of the group (string) - @param newname new name of the group (string) - @param language programming language for the group (string) + @param oldname old name of the group + @type str + @param newname new name of the group + @type str + @param language programming language for the group + @type str """ if oldname != newname: if newname in self.groups: @@ -901,7 +959,8 @@ """ Public method to get all groups. - @return list of all groups (list of TemplateGroup) + @return list of all groups + @rtype list of TemplateGroup """ return list(self.groups.values()) @@ -909,7 +968,8 @@ """ Public method to get all group names. - @return list of all group names (list of strings) + @return list of all group names + @rtype list of str """ groups = sorted(self.groups) return groups @@ -918,7 +978,8 @@ """ Public method to remove a group. - @param itm template group to be removed (TemplateGroup) + @param itm template group to be removed + @type TemplateGroup """ name = itm.getName() itm.removeAllEntries() @@ -930,7 +991,8 @@ """ Public method to remove a template entry. - @param itm template entry to be removed (TemplateEntry) + @param itm template entry to be removed + @type TemplateEntry """ groupName = itm.getGroupName() self.groups[groupName].removeEntry(itm.getName()) @@ -939,12 +1001,16 @@ """ Public method to change a template entry. - @param itm template entry to be changed (TemplateEntry) - @param name new name for the entry (string) + @param itm template entry to be changed + @type TemplateEntry + @param name new name for the entry + @type str @param groupName name of the group the entry should belong to - (string) - @param description description of the entry (string) - @param template template text of the entry (string) + @type str + @param description description of the entry + @type str + @param template template text of the entry + @type str """ if itm.getGroupName() != groupName: # move entry to another group @@ -1020,10 +1086,13 @@ """ Public method to check, if an entry of the given name exists. - @param entryName name of the entry to check for (string) - @param groupName name of the group to check for the entry (string). - None or empty means to check all groups. - @return flag indicating the existence (boolean) + @param entryName name of the entry to check for + @type str + @param groupName name of the group to check for the entry. None or empty means + to check all groups. + @type str + @return flag indicating the existence + @rtype bool """ if groupName: if self.hasGroup(groupName): @@ -1040,10 +1109,13 @@ Public method to get the names of templates starting with the given string. - @param start start string of the name (string) - @param groupName name of the group to get the entry from (string). - None or empty means to look in all groups. - @return sorted list of matching template names (list of strings) + @param start start string of the name + @type str + @param groupName name of the group to get the entry from. None or empty + means to look in all groups. + @type str + @return sorted list of matching template names + @rtype list of str """ names = [] if groupName: