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

branch
eric7
changeset 10069
435cc5875135
parent 9653
e67609152c5e
child 10418
4573827e9815
equal deleted inserted replaced
10068:7febcdccb2a1 10069:435cc5875135
757 and docstring.strip("'\"").strip() == "Class documentation goes here." 757 and docstring.strip("'\"").strip() == "Class documentation goes here."
758 ): 758 ):
759 self.__error(docstringContext.end(), 0, "D206") 759 self.__error(docstringContext.end(), 0, "D206")
760 return 760 return
761 761
762 def __checkTripleDoubleQuotes(self, docstringContext, context): 762 def __checkTripleDoubleQuotes(self, docstringContext, context): # noqa: U100
763 """ 763 """
764 Private method to check, that all docstrings are surrounded 764 Private method to check, that all docstrings are surrounded
765 by triple double quotes. 765 by triple double quotes.
766 766
767 @param docstringContext docstring context (DocStyleContext) 767 @param docstringContext docstring context (DocStyleContext)
772 772
773 docstring = docstringContext.ssource().strip() 773 docstring = docstringContext.ssource().strip()
774 if not docstring.startswith(('"""', 'r"""', 'u"""')): 774 if not docstring.startswith(('"""', 'r"""', 'u"""')):
775 self.__error(docstringContext.start(), 0, "D111") 775 self.__error(docstringContext.start(), 0, "D111")
776 776
777 def __checkBackslashes(self, docstringContext, context): 777 def __checkBackslashes(self, docstringContext, context): # noqa: U100
778 """ 778 """
779 Private method to check, that all docstrings containing 779 Private method to check, that all docstrings containing
780 backslashes are surrounded by raw triple double quotes. 780 backslashes are surrounded by raw triple double quotes.
781 781
782 @param docstringContext docstring context (DocStyleContext) 782 @param docstringContext docstring context (DocStyleContext)
838 0 if context.contextType() == "module" else len(context.indent()) + 4 838 0 if context.contextType() == "module" else len(context.indent()) + 4
839 ) 839 )
840 if indent != expectedIndent: 840 if indent != expectedIndent:
841 self.__error(docstringContext.start(), 0, "D122") 841 self.__error(docstringContext.start(), 0, "D122")
842 842
843 def __checkSummary(self, docstringContext, context): 843 def __checkSummary(self, docstringContext, context): # noqa: U100
844 """ 844 """
845 Private method to check, that docstring summaries contain some text. 845 Private method to check, that docstring summaries contain some text.
846 846
847 @param docstringContext docstring context (DocStyleContext) 847 @param docstringContext docstring context (DocStyleContext)
848 @param context context of the docstring (DocStyleContext) 848 @param context context of the docstring (DocStyleContext)
852 852
853 summary, lineNumber = self.__getSummaryLine(docstringContext) 853 summary, lineNumber = self.__getSummaryLine(docstringContext)
854 if summary == "": 854 if summary == "":
855 self.__error(docstringContext.start() + lineNumber, 0, "D130") 855 self.__error(docstringContext.start() + lineNumber, 0, "D130")
856 856
857 def __checkEndsWithPeriod(self, docstringContext, context): 857 def __checkEndsWithPeriod(self, docstringContext, context): # noqa: U100
858 """ 858 """
859 Private method to check, that docstring summaries end with a period. 859 Private method to check, that docstring summaries end with a period.
860 860
861 @param docstringContext docstring context (DocStyleContext) 861 @param docstringContext docstring context (DocStyleContext)
862 @param context context of the docstring (DocStyleContext) 862 @param context context of the docstring (DocStyleContext)
866 866
867 summary, lineNumber = self.__getSummaryLine(docstringContext) 867 summary, lineNumber = self.__getSummaryLine(docstringContext)
868 if not summary.endswith("."): 868 if not summary.endswith("."):
869 self.__error(docstringContext.start() + lineNumber, 0, "D131") 869 self.__error(docstringContext.start() + lineNumber, 0, "D131")
870 870
871 def __checkImperativeMood(self, docstringContext, context): 871 def __checkImperativeMood(self, docstringContext, context): # noqa: U100
872 """ 872 """
873 Private method to check, that docstring summaries are in 873 Private method to check, that docstring summaries are in
874 imperative mood. 874 imperative mood.
875 875
876 @param docstringContext docstring context (DocStyleContext) 876 @param docstringContext docstring context (DocStyleContext)
988 if contextLines[start - 1].strip(): 988 if contextLines[start - 1].strip():
989 self.__error(docstringContext.start(), 0, "D142") 989 self.__error(docstringContext.start(), 0, "D142")
990 if contextLines[end + 1].strip(): 990 if contextLines[end + 1].strip():
991 self.__error(docstringContext.end(), 0, "D143") 991 self.__error(docstringContext.end(), 0, "D143")
992 992
993 def __checkBlankAfterSummary(self, docstringContext, context): 993 def __checkBlankAfterSummary(self, docstringContext, context): # noqa: U100
994 """ 994 """
995 Private method to check, that docstring summaries are followed 995 Private method to check, that docstring summaries are followed
996 by a blank line. 996 by a blank line.
997 997
998 @param docstringContext docstring context (DocStyleContext) 998 @param docstringContext docstring context (DocStyleContext)
1008 1008
1009 summary, lineNumber = self.__getSummaryLine(docstringContext) 1009 summary, lineNumber = self.__getSummaryLine(docstringContext)
1010 if len(docstrings) > 2 and docstrings[lineNumber + 1].strip(): 1010 if len(docstrings) > 2 and docstrings[lineNumber + 1].strip():
1011 self.__error(docstringContext.start() + lineNumber, 0, "D144") 1011 self.__error(docstringContext.start() + lineNumber, 0, "D144")
1012 1012
1013 def __checkBlankAfterLastParagraph(self, docstringContext, context): 1013 def __checkBlankAfterLastParagraph(self, docstringContext, context): # noqa: U100
1014 """ 1014 """
1015 Private method to check, that the last paragraph of docstrings is 1015 Private method to check, that the last paragraph of docstrings is
1016 followed by a blank line. 1016 followed by a blank line.
1017 1017
1018 @param docstringContext docstring context (DocStyleContext) 1018 @param docstringContext docstring context (DocStyleContext)
1031 1031
1032 ################################################################## 1032 ##################################################################
1033 ## Checking functionality below (eric specific ones) 1033 ## Checking functionality below (eric specific ones)
1034 ################################################################## 1034 ##################################################################
1035 1035
1036 def __checkEricQuotesOnSeparateLines(self, docstringContext, context): 1036 def __checkEricQuotesOnSeparateLines(self, docstringContext, context): # noqa: U100
1037 """ 1037 """
1038 Private method to check, that leading and trailing quotes are on 1038 Private method to check, that leading and trailing quotes are on
1039 a line by themselves. 1039 a line by themselves.
1040 1040
1041 @param docstringContext docstring context (DocStyleContext) 1041 @param docstringContext docstring context (DocStyleContext)
1048 if lines[0].strip().strip("ru\"'"): 1048 if lines[0].strip().strip("ru\"'"):
1049 self.__error(docstringContext.start(), 0, "D221") 1049 self.__error(docstringContext.start(), 0, "D221")
1050 if lines[-1].strip().strip("\"'"): 1050 if lines[-1].strip().strip("\"'"):
1051 self.__error(docstringContext.end(), 0, "D222") 1051 self.__error(docstringContext.end(), 0, "D222")
1052 1052
1053 def __checkEricEndsWithPeriod(self, docstringContext, context): 1053 def __checkEricEndsWithPeriod(self, docstringContext, context): # noqa: U100
1054 """ 1054 """
1055 Private method to check, that docstring summaries end with a period. 1055 Private method to check, that docstring summaries end with a period.
1056 1056
1057 @param docstringContext docstring context (DocStyleContext) 1057 @param docstringContext docstring context (DocStyleContext)
1058 @param context context of the docstring (DocStyleContext) 1058 @param context context of the docstring (DocStyleContext)
1293 # step 3: report undefined signals 1293 # step 3: report undefined signals
1294 for signal in documentedSignals: 1294 for signal in documentedSignals:
1295 if signal not in definedSignals: 1295 if signal not in definedSignals:
1296 self.__error(docstringContext.end(), 0, "D263", signal) 1296 self.__error(docstringContext.end(), 0, "D263", signal)
1297 1297
1298 def __checkEricBlankAfterSummary(self, docstringContext, context): 1298 def __checkEricBlankAfterSummary(self, docstringContext, context): # noqa: U100
1299 """ 1299 """
1300 Private method to check, that docstring summaries are followed 1300 Private method to check, that docstring summaries are followed
1301 by a blank line. 1301 by a blank line.
1302 1302
1303 @param docstringContext docstring context (DocStyleContext) 1303 @param docstringContext docstring context (DocStyleContext)
1372 ): 1372 ):
1373 return 1373 return
1374 1374
1375 self.__error(docstringContext.end(), 0, "D245") 1375 self.__error(docstringContext.end(), 0, "D245")
1376 1376
1377 def __checkEricNBlankAfterLastParagraph(self, docstringContext, context): 1377 def __checkEricNBlankAfterLastParagraph(
1378 self, docstringContext, context # noqa: U100
1379 ):
1378 """ 1380 """
1379 Private method to check, that the last paragraph of docstrings is 1381 Private method to check, that the last paragraph of docstrings is
1380 not followed by a blank line. 1382 not followed by a blank line.
1381 1383
1382 @param docstringContext docstring context (DocStyleContext) 1384 @param docstringContext docstring context (DocStyleContext)

eric ide

mercurial