src/eric7/Plugins/CheckerPlugins/CodeStyleChecker/DocStyle/DocStyleChecker.py

branch
eric7
changeset 10457
4bef44d7a378
parent 10455
bed8a0c90d11
child 10458
2074b8393649
equal deleted inserted replaced
10456:12c30c88ed05 10457:4bef44d7a378
185 "D262", 185 "D262",
186 "D263", 186 "D263",
187 "D270", 187 "D270",
188 "D271", 188 "D271",
189 "D272", 189 "D272",
190 "D273",
190 ] 191 ]
191 192
192 def __init__( 193 def __init__(
193 self, 194 self,
194 source, 195 source,
314 ("D244", "D245"), 315 ("D244", "D245"),
315 ), 316 ),
316 (self.__checkEricException, ("D250", "D251", "D252", "D253")), 317 (self.__checkEricException, ("D250", "D251", "D252", "D253")),
317 (self.__checkEricDocumentationSequence, ("D270", "D271")), 318 (self.__checkEricDocumentationSequence, ("D270", "D271")),
318 (self.__checkEricDocumentationDeprecatedTags, ("D272",)), 319 (self.__checkEricDocumentationDeprecatedTags, ("D272",)),
320 (self.__checkEricDocumentationIndent, ("D273",))
319 ], 321 ],
320 "docstring": [ 322 "docstring": [
321 (self.__checkTripleDoubleQuotes, ("D111",)), 323 (self.__checkTripleDoubleQuotes, ("D111",)),
322 (self.__checkBackslashes, ("D112",)), 324 (self.__checkBackslashes, ("D112",)),
323 (self.__checkIndent, ("D122",)), 325 (self.__checkIndent, ("D122",)),
1701 0, 1703 0,
1702 "D272", 1704 "D272",
1703 tag, 1705 tag,
1704 deprecationsList[tag], 1706 deprecationsList[tag],
1705 ) 1707 )
1708
1709 def __checkEricDocumentationIndent(
1710 self,
1711 docstringContext,
1712 context, # noqa: U100
1713 ):
1714 """
1715 Private method to check the the correct indentation of the tag lines.
1716
1717 @param docstringContext docstring context
1718 @type DocStyleContext
1719 @param context context of the docstring
1720 @type DocStyleContext
1721 """
1722 if docstringContext is None or not docstringContext.source():
1723 return
1724
1725 lines = docstringContext.source()
1726 for line in lines[1:]:
1727 if line.strip():
1728 indentationLength = len(line) - len(line.lstrip())
1729 break
1730 else:
1731 # only empty lines except the first one
1732 return
1733
1734 for lineno, line in enumerate(lines):
1735 strippedLine = line.lstrip()
1736 if strippedLine.startswith("@"):
1737 tag = strippedLine.split(None, 1)[0]
1738 currentIndentation = len(line) - len(strippedLine)
1739 if currentIndentation != indentationLength:
1740 self.__error(docstringContext.start() + lineno, 0, "D273", tag)

eric ide

mercurial