Fixes the docstring always being inserted with an indentation of 4 spaces from the line start. This causes trouble when documenting nested functions or class methods.
Old, incorrect behavior:
class IndexedText:
def concordance(self, word: str, width=40):
"""
Prints the concordance of a given word in the text.
Args:
self: The instance of the class.
word (str): The word to find the concordance for.
width (int): The width of the context to display. Default is 40.
Returns:
None
Raises:
None
Example:
>>> obj = ClassName()
>>> obj.concordance('example', width=50)
Context before the word: '...context before the word...'
Context after the word: '...context after the word...'
"""
key = wordnet.synsets(word)[0].offset()
wc = int(width / 4)
for i in self._index[key]:
lcontext = ' '.join(self._text[i-wc:i])
rcontext = ' '.join(self._text[i:i+wc])
New, correct behavior:
class IndexedText:
def concordance(self, word: str, width=40):
"""
Prints the concordance of a given word in the text.
Args:
self: The instance of the class.
word (str): The word to find the concordance for.
width (int): The width of the context to display. Default is 40.
Returns:
None
Raises:
None
Example:
>>> obj = ClassName()
>>> obj.concordance('example', width=50)
Context before the word: '...context before the word...'
Context after the word: '...context after the word...'
"""
key = wordnet.synsets(word)[0].offset()
wc = int(width / 4)
for i in self._index[key]:
lcontext = ' '.join(self._text[i-wc:i])
rcontext = ' '.join(self._text[i:i+wc])
In the preview window the docstring is now also displayed with no indentation. Correct indentation is added after user confirms the insert.
Fixes the docstring always being inserted with an indentation of 4 spaces from the line start. This causes trouble when documenting nested functions or class methods.
Old, incorrect behavior:
New, correct behavior:
In the preview window the docstring is now also displayed with no indentation. Correct indentation is added after user confirms the insert.
@petrvecera check this out