347 .replace("'''", "") |
347 .replace("'''", "") |
348 .strip()) |
348 .strip()) |
349 |
349 |
350 if len(lines) == 1 or len(line) > 0: |
350 if len(lines) == 1 or len(line) > 0: |
351 return line, 0 |
351 return line, 0 |
352 return lines[1].strip(), 1 |
352 return lines[1].strip().replace('"""', "").replace("'''", ""), 1 |
353 |
353 |
354 ################################################################## |
354 ################################################################## |
355 ## Parsing functionality below |
355 ## Parsing functionality below |
356 ################################################################## |
356 ################################################################## |
357 |
357 |
661 if len(nonEmptyLines) == 1: |
661 if len(nonEmptyLines) == 1: |
662 modLen = len(context.indent() + '"""' + |
662 modLen = len(context.indent() + '"""' + |
663 nonEmptyLines[0].strip() + '"""') |
663 nonEmptyLines[0].strip() + '"""') |
664 if context.contextType() != "module": |
664 if context.contextType() != "module": |
665 modLen += 4 |
665 modLen += 4 |
|
666 if not nonEmptyLines[0].strip().endswith("."): |
|
667 # account for a trailing dot |
|
668 modLen += 1 |
666 if modLen <= self.__maxLineLength: |
669 if modLen <= self.__maxLineLength: |
667 self.__error(docstringContext.start(), 0, "D121") |
670 self.__error(docstringContext.start(), 0, "D121") |
668 |
671 |
669 def __checkIndent(self, docstringContext, context): |
672 def __checkIndent(self, docstringContext, context): |
670 """ |
673 """ |
797 cti = 0 |
800 cti = 0 |
798 while cti < len(contextLines) and \ |
801 while cti < len(contextLines) and \ |
799 not contextLines[cti].strip().startswith( |
802 not contextLines[cti].strip().startswith( |
800 ('"""', 'r"""', 'u"""', "'''", "r'''", "u'''")): |
803 ('"""', 'r"""', 'u"""', "'''", "r'''", "u'''")): |
801 cti += 1 |
804 cti += 1 |
802 |
|
803 if cti == len(contextLines): |
805 if cti == len(contextLines): |
804 return |
806 return |
805 |
807 |
806 start = cti |
808 start = cti |
807 if contextLines[cti].strip() in ( |
809 if contextLines[cti].strip() in ( |
811 |
813 |
812 while cti < len(contextLines) and \ |
814 while cti < len(contextLines) and \ |
813 not contextLines[cti].strip().endswith(('"""', "'''")): |
815 not contextLines[cti].strip().endswith(('"""', "'''")): |
814 cti += 1 |
816 cti += 1 |
815 end = cti |
817 end = cti |
|
818 if cti == len(contextLines): |
|
819 return |
816 |
820 |
817 if contextLines[start - 1].strip(): |
821 if contextLines[start - 1].strip(): |
818 self.__error(docstringContext.start(), 0, "D142") |
822 self.__error(docstringContext.start(), 0, "D142") |
819 if contextLines[end + 1].strip(): |
823 if contextLines[end + 1].strip(): |
820 self.__error(docstringContext.end(), 0, "D143") |
824 self.__error(docstringContext.end(), 0, "D143") |
834 if len(docstrings) in [1, 3]: |
838 if len(docstrings) in [1, 3]: |
835 # correct/invalid one-liner |
839 # correct/invalid one-liner |
836 return |
840 return |
837 |
841 |
838 summary, lineNumber = self.__getSummaryLine(docstringContext) |
842 summary, lineNumber = self.__getSummaryLine(docstringContext) |
839 if docstrings[lineNumber + 1].strip(): |
843 if len(docstrings) > 2: |
840 self.__error(docstringContext.start() + lineNumber, 0, "D144") |
844 if docstrings[lineNumber + 1].strip(): |
|
845 self.__error(docstringContext.start() + lineNumber, 0, "D144") |
841 |
846 |
842 def __checkBlankAfterLastParagraph(self, docstringContext, context): |
847 def __checkBlankAfterLastParagraph(self, docstringContext, context): |
843 """ |
848 """ |
844 Private method to check, that docstring summaries are followed |
849 Private method to check, that docstring summaries are followed |
845 by a blank line. |
850 by a blank line. |
849 """ |
854 """ |
850 if docstringContext is None: |
855 if docstringContext is None: |
851 return |
856 return |
852 |
857 |
853 docstrings = docstringContext.source() |
858 docstrings = docstringContext.source() |
854 if len(docstrings) in [1, 3]: |
859 if len(docstrings) <= 3: |
855 # correct/invalid one-liner |
860 # correct/invalid one-liner |
856 return |
861 return |
857 |
862 |
858 if docstrings[-2].strip(): |
863 if docstrings[-2].strip(): |
859 self.__error(docstringContext.end(), 0, "D145") |
864 self.__error(docstringContext.end(), 0, "D145") |