eric7.Plugins.CheckerPlugins.DocStyleChecker.DocStyleFixer

Module implementing a class to fix certain documentation style issues.

Global Attributes

FixableCodeStyleIssues

Classes

DocStyleFixer Class implementing a fixer for certain documentation style issues.

Functions

None


DocStyleFixer

Class implementing a fixer for certain documentation style issues.

Derived from

None

Class Attributes

None

Class Methods

None

Methods

DocStyleFixer Constructor
__codeMatch Private method to check, if the code should be fixed.
__fixD111 Private method to fix docstring enclosed in wrong quotes.
__fixD112 Private method to fix docstring 'r' in leading quotes.
__fixD121 Private method to fix a single line docstring on multiple lines.
__fixD131_D231 Private method to fix a docstring summary not ending with a period.
__fixD141 Private method to fix a function/method docstring preceded by a blank line.
__fixD142 Private method to fix a class docstring not preceded by a blank line.
__fixD143 Private method to fix a class docstring not followed by a blank line.
__fixD144_D246 Private method to fix a docstring summary not followed by a blank line.
__fixD145 Private method to fix the last paragraph of a multi-line docstring not followed by a blank line.
__fixD221_D222 Private method to fix leading and trailing quotes of docstring not on separate lines.
__fixD242_D244 Private method to fix a class or function/method docstring preceded by a blank line.
__fixD243_D245 Private method to fix a class or function/method docstring followed by a blank line.
__fixD247 Private method to fix a last paragraph of a docstring followed by a blank line.
__getID Private method to get the ID for a deferred fix.
__getIndent Private method to get the indentation string.
finalize Public method to apply all deferred fixes.
fixIssue Public method to fix the fixable issues.
mutualStartswith Local helper method to compare the beginnings of two strings against each other.
saveFile Public method to save the modified file.

Static Methods

None

DocStyleFixer (Constructor)

DocStyleFixer(filename, sourceLines, fixCodes, noFixCodes, maxLineLength, inPlace, eol, backup=False, )

Constructor

filename (str)
name of the file to be fixed
sourceLines (list of str)
list of source lines including eol marker
fixCodes (str)
list of codes to be fixed as a comma separated string
noFixCodes (str)
list of codes not to be fixed as a comma separated string
maxLineLength (int)
maximum allowed line length
inPlace (bool)
flag indicating to modify the file in place
eol (str)
end of line character(s)
backup (bool)
flag indicating to create a backup before fixing anything

DocStyleFixer.__codeMatch

__codeMatch(code)

Private method to check, if the code should be fixed.

code (str)
to check
Return:
flag indicating it should be fixed
Return Type:
bool

DocStyleFixer.__fixD111

__fixD111(_code, line, _pos)

Private method to fix docstring enclosed in wrong quotes.

Codes: D111

_code (str)
code of the issue (unused)
line (int)
line number of the issue
_pos (int)
position inside line (unused)
Return:
value indicating an applied/deferred fix (-1, 0, 1), a message code for the fix, a list of arguments for the message and an ID for a deferred fix
Return Type:
tuple of (int, str, list or int, int)

DocStyleFixer.__fixD112

__fixD112(code, line, _pos)

Private method to fix docstring 'r' in leading quotes.

Codes: D112

code (str)
code of the issue
line (int)
line number of the issue
_pos (int)
position inside line (unused)
Return:
value indicating an applied/deferred fix (-1, 0, 1), a message code for the fix, a list of arguments for the message and an ID for a deferred fix
Return Type:
tuple of (int, str, list or int, int)

DocStyleFixer.__fixD121

__fixD121(code, line, pos, apply=False)

Private method to fix a single line docstring on multiple lines.

Codes: D121

code (str)
code of the issue
line (int)
line number of the issue
pos (int)
position inside line
apply (bool)
flag indicating, that the fix should be applied
Return:
value indicating an applied/deferred fix (-1, 0, 1), a message code for the fix, a list of arguments for the message and an ID for a deferred fix
Return Type:
tuple of (int, str, list or int, int)

DocStyleFixer.__fixD131_D231

__fixD131_D231(code, line, _pos)

Private method to fix a docstring summary not ending with a period.

Codes: D131, D231

code (str)
code of the issue (unused)
line (int)
line number of the issue
_pos (int)
position inside line (unused)
Return:
value indicating an applied/deferred fix (-1, 0, 1), a message code for the fix, a list of arguments for the message and an ID for a deferred fix
Return Type:
tuple of (int, str, list or int, int)

DocStyleFixer.__fixD141

__fixD141(code, line, pos, apply=False)

Private method to fix a function/method docstring preceded by a blank line.

Codes: D141

code (str)
code of the issue
line (int)
line number of the issue
pos (int)
position inside line
apply (bool)
flag indicating, that the fix should be applied
Return:
value indicating an applied/deferred fix (-1, 0, 1), a message code for the fix, a list of arguments for the message and an ID for a deferred fix
Return Type:
tuple of (int, str, list or int, int)

DocStyleFixer.__fixD142

__fixD142(code, line, pos, apply=False)

Private method to fix a class docstring not preceded by a blank line.

Codes: D142

code (str)
code of the issue
line (int)
line number of the issue
pos (int)
position inside line
apply (bool)
flag indicating, that the fix should be applied
Return:
value indicating an applied/deferred fix (-1, 0, 1), a message code for the fix, a list of arguments for the message and an ID for a deferred fix
Return Type:
tuple of (int, str, list or int, int)

DocStyleFixer.__fixD143

__fixD143(code, line, pos, apply=False)

Private method to fix a class docstring not followed by a blank line.

Codes: D143

code (str)
code of the issue
line (int)
line number of the issue
pos (int)
position inside line
apply (bool)
flag indicating, that the fix should be applied
Return:
value indicating an applied/deferred fix (-1, 0, 1), a message code for the fix, a list of arguments for the message and an ID for a deferred fix
Return Type:
tuple of (int, str, list or int, int)

DocStyleFixer.__fixD144_D246

__fixD144_D246(code, line, pos, apply=False)

Private method to fix a docstring summary not followed by a blank line.

Codes: D144, D246

code (str)
code of the issue
line (int)
line number of the issue
pos (int)
position inside line
apply (bool)
flag indicating, that the fix should be applied
Return:
value indicating an applied/deferred fix (-1, 0, 1), a message code for the fix, a list of arguments for the message and an ID for a deferred fix
Return Type:
tuple of (int, str, list or int, int)

DocStyleFixer.__fixD145

__fixD145(code, line, pos, apply=False)

Private method to fix the last paragraph of a multi-line docstring not followed by a blank line.

Codes: D143

code (str)
code of the issue
line (int)
line number of the issue
pos (int)
position inside line
apply (bool)
flag indicating, that the fix should be applied
Return:
value indicating an applied/deferred fix (-1, 0, 1), a message code for the fix, a list of arguments for the message and an ID for a deferred fix
Return Type:
tuple of (int, str, list or int, int)

DocStyleFixer.__fixD221_D222

__fixD221_D222(code, line, pos, apply=False)

Private method to fix leading and trailing quotes of docstring not on separate lines.

Codes: D221, D222

code (str)
code of the issue
line (int)
line number of the issue
pos (int)
position inside line
apply (bool)
flag indicating, that the fix should be applied
Return:
value indicating an applied/deferred fix (-1, 0, 1), a message code for the fix, a list of arguments for the message and an ID for a deferred fix
Return Type:
tuple of (int, str, list or int, int)

DocStyleFixer.__fixD242_D244

__fixD242_D244(code, line, pos, apply=False)

Private method to fix a class or function/method docstring preceded by a blank line.

Codes: D242, D244

code (str)
code of the issue
line (int)
line number of the issue
pos (int)
position inside line
apply (bool)
flag indicating, that the fix should be applied
Return:
value indicating an applied/deferred fix (-1, 0, 1), a message code for the fix, a list of arguments for the message and an ID for a deferred fix
Return Type:
tuple of (int, str, list or int, int)

DocStyleFixer.__fixD243_D245

__fixD243_D245(code, line, pos, apply=False)

Private method to fix a class or function/method docstring followed by a blank line.

Codes: D243, D245

code (str)
code of the issue
line (int)
line number of the issue
pos (int)
position inside line
apply (bool)
flag indicating, that the fix should be applied
Return:
value indicating an applied/deferred fix (-1, 0, 1), a message code for the fix, a list of arguments for the message and an ID for a deferred fix
Return Type:
tuple of (int, str, list or int, int)

DocStyleFixer.__fixD247

__fixD247(code, line, pos, apply=False)

Private method to fix a last paragraph of a docstring followed by a blank line.

Codes: D247

code (str)
code of the issue
line (int)
line number of the issue
pos (int)
position inside line
apply (bool)
flag indicating, that the fix should be applied
Return:
value indicating an applied/deferred fix (-1, 0, 1), a message code for the fix, a list of arguments for the message and an ID for a deferred fix
Return Type:
tuple of (int, str, list or int, int)

DocStyleFixer.__getID

__getID()

Private method to get the ID for a deferred fix.

Return:
ID for a deferred fix
Return Type:
int

DocStyleFixer.__getIndent

__getIndent(line)

Private method to get the indentation string.

line (str)
line to determine the indentation string from
Return:
indentation string
Return Type:
str

DocStyleFixer.finalize

finalize()

Public method to apply all deferred fixes.

Return:
dictionary containing the fix results
Return Type:
dict

DocStyleFixer.fixIssue

fixIssue(line, pos, code)

Public method to fix the fixable issues.

line (int)
line number of the issue
pos (int)
position inside line
code (str)
code of the issue
Return:
value indicating an applied/deferred fix (-1, 0, 1), a message code for the fix, arguments list for the message and an ID for a deferred fix
Return Type:
tuple of (int, str, list, int)

DocStyleFixer.mutualStartswith

mutualStartswith(b)

Local helper method to compare the beginnings of two strings against each other.

Return:
flag indicating that one string starts with the other
Return Type:
bool

DocStyleFixer.saveFile

saveFile(encoding)

Public method to save the modified file.

encoding (str)
encoding of the source file
Return:
error message on failure
Return Type:
tuple of (str, [str])
Up