|
79 | 79 | 'GL07': 'Sections are in the wrong order. Correct order is: ' |
80 | 80 | '{correct_sections}', |
81 | 81 | 'GL08': 'The object does not have a docstring', |
| 82 | + 'GL09': 'Deprecation warning should precede extended summary', |
82 | 83 | 'SS01': 'No summary found (a short summary in a single line should be ' |
83 | 84 | 'present at the beginning of the docstring)', |
84 | 85 | 'SS02': 'Summary does not start with a capital letter', |
@@ -492,12 +493,14 @@ def first_line_ends_in_dot(self): |
492 | 493 | if self.doc: |
493 | 494 | return self.doc.split('\n')[0][-1] == '.' |
494 | 495 |
|
| 496 | + @property |
| 497 | + def deprecated_with_directive(self): |
| 498 | + return '.. deprecated:: ' in (self.summary + self.extended_summary) |
| 499 | + |
495 | 500 | @property |
496 | 501 | def deprecated(self): |
497 | | - pattern = re.compile('.. deprecated:: ') |
498 | 502 | return (self.name.startswith('pandas.Panel') |
499 | | - or bool(pattern.search(self.summary)) |
500 | | - or bool(pattern.search(self.extended_summary))) |
| 503 | + or self.deprecated_with_directive) |
501 | 504 |
|
502 | 505 | @property |
503 | 506 | def mentioned_private_classes(self): |
@@ -625,6 +628,10 @@ def get_validation_data(doc): |
625 | 628 | errs.append(error('GL07', |
626 | 629 | correct_sections=', '.join(correct_order))) |
627 | 630 |
|
| 631 | + if (doc.deprecated_with_directive |
| 632 | + and not doc.extended_summary.startswith('.. deprecated:: ')): |
| 633 | + errs.append(error('GL09')) |
| 634 | + |
628 | 635 | if not doc.summary: |
629 | 636 | errs.append(error('SS01')) |
630 | 637 | else: |
|
0 commit comments