104 """ |
104 """ |
105 Codes = [ |
105 Codes = [ |
106 "D101", "D102", "D103", "D104", "D105", |
106 "D101", "D102", "D103", "D104", "D105", |
107 "D111", "D112", "D113", |
107 "D111", "D112", "D113", |
108 "D121", "D122", |
108 "D121", "D122", |
109 "D131", "D132", "D133", "D134", |
109 "D130", "D131", "D132", "D133", "D134", |
110 "D141", "D142", "D143", "D144", "D145", |
110 "D141", "D142", "D143", "D144", "D145", |
111 |
111 |
112 "D203", "D205", |
112 "D203", "D205", |
113 "D221", |
113 "D221", |
114 "D231", "D234", "D235", "D236", "D237", "D238", "D239", |
114 "D231", "D234", "D235", "D236", "D237", "D238", "D239", |
185 (self.__checkTripleDoubleQuotes, ("D111",)), |
185 (self.__checkTripleDoubleQuotes, ("D111",)), |
186 (self.__checkBackslashes, ("D112",)), |
186 (self.__checkBackslashes, ("D112",)), |
187 (self.__checkUnicode, ("D113",)), |
187 (self.__checkUnicode, ("D113",)), |
188 (self.__checkOneLiner, ("D121",)), |
188 (self.__checkOneLiner, ("D121",)), |
189 (self.__checkIndent, ("D122",)), |
189 (self.__checkIndent, ("D122",)), |
|
190 (self.__checkSummary, ("D130")), |
190 (self.__checkEndsWithPeriod, ("D131",)), |
191 (self.__checkEndsWithPeriod, ("D131",)), |
191 (self.__checkBlankAfterSummary, ("D144",)), |
192 (self.__checkBlankAfterSummary, ("D144",)), |
192 (self.__checkBlankAfterLastParagraph, ("D145",)), |
193 (self.__checkBlankAfterLastParagraph, ("D145",)), |
193 ], |
194 ], |
194 } |
195 } |
220 "docstring": [ |
221 "docstring": [ |
221 (self.__checkTripleDoubleQuotes, ("D111",)), |
222 (self.__checkTripleDoubleQuotes, ("D111",)), |
222 (self.__checkBackslashes, ("D112",)), |
223 (self.__checkBackslashes, ("D112",)), |
223 (self.__checkUnicode, ("D113",)), |
224 (self.__checkUnicode, ("D113",)), |
224 (self.__checkIndent, ("D122",)), |
225 (self.__checkIndent, ("D122",)), |
|
226 (self.__checkSummary, ("D130")), |
225 (self.__checkEricEndsWithPeriod, ("D231",)), |
227 (self.__checkEricEndsWithPeriod, ("D231",)), |
226 (self.__checkEricBlankAfterSummary, ("D246",)), |
228 (self.__checkEricBlankAfterSummary, ("D246",)), |
227 (self.__checkEricNBlankAfterLastParagraph, ("D247",)), |
229 (self.__checkEricNBlankAfterLastParagraph, ("D247",)), |
228 (self.__checkEricQuotesOnSeparateLines, ("D222", "D223")) |
230 (self.__checkEricQuotesOnSeparateLines, ("D222", "D223")) |
229 ], |
231 ], |
769 else: |
771 else: |
770 expectedIndent = len(context.indent()) + 4 |
772 expectedIndent = len(context.indent()) + 4 |
771 if indent != expectedIndent: |
773 if indent != expectedIndent: |
772 self.__error(docstringContext.start(), 0, "D122") |
774 self.__error(docstringContext.start(), 0, "D122") |
773 |
775 |
|
776 def __checkSummary(self, docstringContext, context): |
|
777 """ |
|
778 Private method to check, that docstring summaries contain some text. |
|
779 |
|
780 @param docstringContext docstring context (DocStyleContext) |
|
781 @param context context of the docstring (DocStyleContext) |
|
782 """ |
|
783 if docstringContext is None: |
|
784 return |
|
785 |
|
786 summary, lineNumber = self.__getSummaryLine(docstringContext) |
|
787 if summary == "": |
|
788 self.__error(docstringContext.start() + lineNumber, 0, "D130") |
|
789 |
774 def __checkEndsWithPeriod(self, docstringContext, context): |
790 def __checkEndsWithPeriod(self, docstringContext, context): |
775 """ |
791 """ |
776 Private method to check, that docstring summaries end with a period. |
792 Private method to check, that docstring summaries end with a period. |
777 |
793 |
778 @param docstringContext docstring context (DocStyleContext) |
794 @param docstringContext docstring context (DocStyleContext) |
795 """ |
811 """ |
796 if docstringContext is None: |
812 if docstringContext is None: |
797 return |
813 return |
798 |
814 |
799 summary, lineNumber = self.__getSummaryLine(docstringContext) |
815 summary, lineNumber = self.__getSummaryLine(docstringContext) |
800 firstWord = summary.strip().split()[0] |
816 if summary: |
801 if firstWord.endswith("s") and not firstWord.endswith("ss"): |
817 firstWord = summary.strip().split()[0] |
802 self.__error(docstringContext.start() + lineNumber, 0, "D132") |
818 if firstWord.endswith("s") and not firstWord.endswith("ss"): |
|
819 self.__error(docstringContext.start() + lineNumber, 0, "D132") |
803 |
820 |
804 def __checkNoSignature(self, docstringContext, context): |
821 def __checkNoSignature(self, docstringContext, context): |
805 """ |
822 """ |
806 Private method to check, that docstring summaries don't repeat |
823 Private method to check, that docstring summaries don't repeat |
807 the function's signature. |
824 the function's signature. |
970 """ |
987 """ |
971 if docstringContext is None: |
988 if docstringContext is None: |
972 return |
989 return |
973 |
990 |
974 summaryLines, lineNumber = self.__getSummaryLines(docstringContext) |
991 summaryLines, lineNumber = self.__getSummaryLines(docstringContext) |
975 if summaryLines[-1].lstrip().startswith("@"): |
992 if summaryLines: |
976 summaryLines.pop(-1) |
993 if summaryLines[-1].lstrip().startswith("@"): |
977 summary = " ".join([s.strip() for s in summaryLines if s]) |
994 summaryLines.pop(-1) |
978 if not summary.endswith(".") and \ |
995 summary = " ".join([s.strip() for s in summaryLines if s]) |
979 not summary.split(None, 1)[0].lower() == "constructor": |
996 if summary and not summary.endswith(".") and \ |
980 self.__error( |
997 not summary.split(None, 1)[0].lower() == "constructor": |
981 docstringContext.start() + lineNumber + len(summaryLines) - 1, |
998 self.__error( |
982 0, "D231") |
999 docstringContext.start() + lineNumber + |
|
1000 len(summaryLines) - 1, |
|
1001 0, "D231") |
983 |
1002 |
984 def __checkEricReturn(self, docstringContext, context): |
1003 def __checkEricReturn(self, docstringContext, context): |
985 """ |
1004 """ |
986 Private method to check, that docstrings contain an @return line |
1005 Private method to check, that docstrings contain an @return line |
987 if they return anything and don't otherwise. |
1006 if they return anything and don't otherwise. |