(self)
| 1147 | |
| 1148 | |
| 1149 | def _parse_numpydoc_patch(self): |
| 1150 | self._doc.reset() |
| 1151 | self._parse_summary() |
| 1152 | |
| 1153 | sections = list(self._read_sections()) |
| 1154 | section_names = {section for section, content in sections} |
| 1155 | |
| 1156 | has_returns = 'Returns' in section_names |
| 1157 | has_yields = 'Yields' in section_names |
| 1158 | # We could do more tests, but we are not. Arbitrarily. |
| 1159 | if has_returns and has_yields: |
| 1160 | msg = 'Docstring contains both a Returns and Yields section.' |
| 1161 | raise ValueError(msg) |
| 1162 | if not has_yields and 'Receives' in section_names: |
| 1163 | msg = 'Docstring contains a Receives section but not Yields.' |
| 1164 | raise ValueError(msg) |
| 1165 | |
| 1166 | for section, content in sections: |
| 1167 | if not section.startswith('..'): |
| 1168 | section = (s.capitalize() for s in section.split(' ')) |
| 1169 | section = ' '.join(section) |
| 1170 | if self.get(section): |
| 1171 | self._error_location( |
| 1172 | 'The section %s appears twice in %s' # noqa |
| 1173 | % (section, '\n'.join(self._doc._str)) # noqa |
| 1174 | ) |
| 1175 | |
| 1176 | # Patch is here, extending the sections with these other options |
| 1177 | if section in ('Parameters', 'Other Parameters', 'Attributes', 'Methods') + tuple( |
| 1178 | _numpydoc_extra_sections() |
| 1179 | ): |
| 1180 | self[section] = self._parse_param_list(content) |
| 1181 | elif section in ('Returns', 'Yields', 'Raises', 'Warns', 'Receives'): |
| 1182 | self[section] = self._parse_param_list(content, single_element_is_type=True) |
| 1183 | elif section.startswith('.. index::'): |
| 1184 | self['index'] = self._parse_index(section, content) |
| 1185 | elif section == 'See Also': |
| 1186 | self['See Also'] = self._parse_see_also(content) |
| 1187 | else: |
| 1188 | self[section] = content |
| 1189 | |
| 1190 | |
| 1191 | @contextmanager |
nothing calls this directly
no test coverage detected
searching dependent graphs…