|
18 | 18 | import jinja2 |
19 | 19 | from sphinx.ext.autosummary import _import_by_name |
20 | 20 | from numpydoc.docscrape import NumpyDocString |
21 | | -from numpydoc.docscrape_sphinx import SphinxDocString |
| 21 | + |
22 | 22 |
|
23 | 23 | logger = logging.getLogger(__name__) |
24 | 24 |
|
|
110 | 110 | else None))) |
111 | 111 | autosummary_generate = True if pattern is None else ['index'] |
112 | 112 |
|
| 113 | +# numpydoc |
| 114 | +numpydoc_attributes_as_param_list = False |
| 115 | + |
113 | 116 | # matplotlib plot directive |
114 | 117 | plot_include_source = True |
115 | 118 | plot_formats = [("png", 90)] |
|
422 | 425 | ] |
423 | 426 |
|
424 | 427 |
|
425 | | -def sphinxdocstring_str(self, indent=0, func_role="obj"): |
426 | | - # Pandas displays Attributes section in style like Methods section |
427 | | - |
428 | | - # Function is copy of `SphinxDocString.__str__` |
429 | | - ns = { |
430 | | - 'signature': self._str_signature(), |
431 | | - 'index': self._str_index(), |
432 | | - 'summary': self._str_summary(), |
433 | | - 'extended_summary': self._str_extended_summary(), |
434 | | - 'parameters': self._str_param_list('Parameters'), |
435 | | - 'returns': self._str_returns('Returns'), |
436 | | - 'yields': self._str_returns('Yields'), |
437 | | - 'other_parameters': self._str_param_list('Other Parameters'), |
438 | | - 'raises': self._str_param_list('Raises'), |
439 | | - 'warns': self._str_param_list('Warns'), |
440 | | - 'warnings': self._str_warnings(), |
441 | | - 'see_also': self._str_see_also(func_role), |
442 | | - 'notes': self._str_section('Notes'), |
443 | | - 'references': self._str_references(), |
444 | | - 'examples': self._str_examples(), |
445 | | - # Replaced `self._str_param_list('Attributes', fake_autosummary=True)` |
446 | | - # with `self._str_member_list('Attributes')` |
447 | | - 'attributes': self._str_member_list('Attributes'), |
448 | | - 'methods': self._str_member_list('Methods'), |
449 | | - } |
450 | | - ns = {k: '\n'.join(v) for k, v in ns.items()} |
451 | | - |
452 | | - rendered = self.template.render(**ns) |
453 | | - return '\n'.join(self._str_indent(rendered.split('\n'), indent)) |
454 | | - |
455 | | - |
456 | | -SphinxDocString.__str__ = sphinxdocstring_str |
457 | | - |
458 | | - |
459 | | -# Fix "WARNING: Inline strong start-string without end-string." |
460 | | -# PR #155 "Escape the * in *args and **kwargs" from numpydoc |
461 | | -# Can be removed after PR merges in v0.9.0 |
462 | | -def decorate_process_param(func): |
463 | | - def _escape_args_and_kwargs(name): |
464 | | - if name[:2] == '**': |
465 | | - return r'\*\*' + name[2:] |
466 | | - elif name[:1] == '*': |
467 | | - return r'\*' + name[1:] |
468 | | - else: |
469 | | - return name |
470 | | - |
471 | | - def func_wrapper(self, param, desc, fake_autosummary): |
472 | | - param = _escape_args_and_kwargs(param.strip()) |
473 | | - return func(self, param, desc, fake_autosummary) |
474 | | - |
475 | | - return func_wrapper |
476 | | - |
477 | | - |
478 | | -func = SphinxDocString._process_param |
479 | | -SphinxDocString._process_param = decorate_process_param(func) |
480 | | - |
481 | 428 | # Add custom Documenter to handle attributes/methods of an AccessorProperty |
482 | 429 | # eg pandas.Series.str and pandas.Series.dt (see GH9322) |
483 | 430 |
|
|
0 commit comments