--- a/src/eric7/QScintilla/SpellChecker.py Wed Dec 20 19:28:22 2023 +0100 +++ b/src/eric7/QScintilla/SpellChecker.py Thu Dec 21 12:03:40 2023 +0100 @@ -33,13 +33,16 @@ """ Constructor - @param editor reference to the editor object (QScintilla.Editor) + @param editor reference to the editor object + @type QScintilla.Editor @param indicator spell checking indicator - @param defaultLanguage the language to be used as the default - (string). The string should be in language locale format - (e.g. en_US, de). + @type int + @param defaultLanguage the language to be used as the default. The string + should be in language locale format (e.g. en_US, de). + @type str @param checkRegion reference to a function to check for a valid region + @type function """ super().__init__(editor) @@ -62,7 +65,8 @@ """ Class method to get all available languages. - @return list of available languages (list of strings) + @return list of available languages + @rtype list of str """ with contextlib.suppress(NameError): return enchant.list_languages() @@ -73,7 +77,8 @@ """ Class method to check, if spellchecking is available. - @return flag indicating availability (boolean) + @return flag indicating availability + @rtype bool """ if Preferences.getEditor("SpellCheckingEnabled"): with contextlib.suppress(NameError, AttributeError): @@ -86,9 +91,11 @@ Class method to get the default path names of the user dictionaries. @param isException flag indicating to return the name of the default - exception dictionary (boolean) + exception dictionary + @type bool @return file name of the default user dictionary or the default user - exception dictionary (string) + exception dictionary + @rtype str """ if isException: return os.path.join(Globals.getConfigDir(), "spelling", "pel.dic") @@ -101,9 +108,11 @@ Class method to get the path name of a user dictionary file. @param isException flag indicating to return the name of the user - exception dictionary (boolean) + exception dictionary + @type bool @return file name of the user dictionary or the user exception - dictionary (string) + dictionary + @rtype str """ if isException: dicFile = Preferences.getEditor("SpellCheckingPersonalExcludeList") @@ -120,11 +129,15 @@ """ Protected class method to get a new dictionary. - @param lang the language to be used as the default (string). - The string should be in language locale format (e.g. en_US, de). - @param pwl name of the personal/project word list (string) - @param pel name of the personal/project exclude list (string) - @return reference to the dictionary (enchant.Dict) + @param lang the language to be used as the default. The string should + be in language locale format (e.g. en_US, de). + @type str + @param pwl name of the personal/project word list + @type str + @param pel name of the personal/project exclude list + @type str + @return reference to the dictionary + @rtype enchant.Dict """ if not pwl: pwl = SpellChecker.getUserDictionaryPath() @@ -151,8 +164,9 @@ """ Class method to set the default language. - @param language the language to be used as the default (string). - The string should be in language locale format (e.g. en_US, de). + @param language the language to be used as the default. The string should + be in language locale format (e.g. en_US, de). + @type str """ cls._spelling_lang = language cls._spelling_dict = cls._getDict(language) @@ -161,10 +175,13 @@ """ Public method to set the current language. - @param language the language to be used as the default (string). - The string should be in language locale format (e.g. en_US, de). - @param pwl name of the personal/project word list (string) - @param pel name of the personal/project exclude list (string) + @param language the language to be used as the default. The string should + be in language locale format (e.g. en_US, de). + @type str + @param pwl name of the personal/project word list + @type str + @param pel name of the personal/project exclude list + @type str """ self._spelling_lang = language self._spelling_dict = self._getDict(language, pwl=pwl, pel=pel) @@ -173,7 +190,8 @@ """ Public method to get the current language. - @return current language in language locale format (string) + @return current language in language locale format + @rtype str """ return self._spelling_lang @@ -181,7 +199,8 @@ """ Public method to set the minimum word size. - @param size minimum word size (integer) + @param size minimum word size + @type int """ if size > 0: self.minimumWordSize = size @@ -191,10 +210,12 @@ Private method to get the next word in the text after the given position. - @param pos position to start word extraction (integer) - @param endPosition position to stop word extraction (integer) - @return tuple of three values (the extracted word (string), - start position (integer), end position (integer)) + @param pos position to start word extraction + @type int + @param endPosition position to stop word extraction + @type int + @return tuple of three values (the extracted word, start position, end position) + @rtype tuple of (str, int, int) """ if pos < 0 or pos >= endPosition: return "", -1, -1 @@ -224,9 +245,12 @@ """ Public method to get the context of a faulty word. - @param wordStart the starting position of the word (integer) - @param wordEnd the ending position of the word (integer) - @return tuple of the leading and trailing context (string, string) + @param wordStart the starting position of the word + @type int + @param wordEnd the ending position of the word + @type int + @return tuple of the leading and trailing context + @rtype tuple of (str, str) """ sline, sindex = self.editor.lineIndexFromPosition(wordStart) eline, eindex = self.editor.lineIndexFromPosition(wordEnd) @@ -237,9 +261,9 @@ """ Public method to get information about the last error found. - @return tuple of last faulty word (string), starting position of the - faulty word (integer) and ending position of the faulty word - (integer) + @return tuple of last faulty word, starting position of the + faulty word and ending position of the faulty word + @rtype tuple of (str, int, int) """ return (self.word, self.wordStart, self.wordEnd) @@ -247,9 +271,12 @@ """ Public method to initialize a spell check. - @param startPos position to start at (integer) - @param endPos position to end at (integer) - @return flag indicating successful initialization (boolean) + @param startPos position to start at + @type int + @param endPos position to end at + @type int + @return flag indicating successful initialization + @rtype bool """ if startPos == endPos: return False @@ -271,8 +298,10 @@ """ Private method to check some part of the document. - @param startPos position to start at (integer) - @param endPos position to end at (integer) + @param startPos position to start at + @type int + @param endPos position to end at + @type int """ if not self.initCheck(startPos, endPos): return @@ -307,9 +336,10 @@ """ Public method to check the word at position pos. - @param pos position to check at (integer) - @param atEnd flag indicating the position is at the end of the word - to check (boolean) + @param pos position to check at + @type int + @param atEnd flag indicating the position is at the end of the word to check + @type bool """ spell = self._spelling_dict if spell is None: @@ -353,8 +383,10 @@ """ Public method to check some lines of text. - @param firstLine line number of first line to check (integer) - @param lastLine line number of last line to check (integer) + @param firstLine line number of first line to check + @type int + @param lastLine line number of last line to check + @type int """ startPos = self.editor.positionFromLineIndex(firstLine, 0) @@ -421,8 +453,10 @@ """ Public method to get suggestions for the given word. - @param word word to get suggestions for (string) - @return list of suggestions (list of strings) + @param word word to get suggestions for + @type str + @return list of suggestions + @rtype list of str """ suggestions = [] spell = self._spelling_dict @@ -435,7 +469,8 @@ """ Public method to add a word to the personal word list. - @param word word to add (string) + @param word word to add + @type str """ spell = self._spelling_dict if spell: @@ -447,7 +482,8 @@ """ Public method to add a word to the personal exclude list. - @param word word to add (string) + @param word word to add + @type str """ spell = self._spelling_dict if spell: @@ -458,7 +494,8 @@ Public method to tell the checker, to always ignore the given word or the current word. - @param word word to be ignored (string) + @param word word to be ignored + @type str """ if word is None: word = self.word @@ -470,7 +507,8 @@ Public method to tell the checker to replace the current word with the replacement string. - @param replacement replacement string (string) + @param replacement replacement string + @type str """ sline, sindex = self.editor.lineIndexFromPosition(self.wordStart) eline, eindex = self.editor.lineIndexFromPosition(self.wordEnd) @@ -486,7 +524,8 @@ Public method to tell the checker to always replace the current word with the replacement string. - @param replacement replacement string (string) + @param replacement replacement string + @type str """ self.__replaceWords[self.word] = replacement self.replace(replacement) @@ -500,6 +539,7 @@ Special method to create an iterator. @return self + @rtype SpellChecker """ return self @@ -508,6 +548,7 @@ Special method to advance to the next error. @return self + @rtype SpellChecker @exception StopIteration raised to indicate the end of the iteration """ spell = self._spelling_dict