From cac8fe28233f64c64ad0f9fd453e63b936be7070 Mon Sep 17 00:00:00 2001 From: Joris Van den Bossche Date: Tue, 14 Nov 2017 11:40:09 +0100 Subject: [PATCH] Add option to use member listing for attributes --- numpydoc/docscrape_sphinx.py | 8 ++++++-- numpydoc/numpydoc.py | 7 +++++-- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/numpydoc/docscrape_sphinx.py b/numpydoc/docscrape_sphinx.py index 640efa7b..4807f72c 100644 --- a/numpydoc/docscrape_sphinx.py +++ b/numpydoc/docscrape_sphinx.py @@ -33,6 +33,8 @@ def load_config(self, config): self.use_plots = config.get('use_plots', False) self.use_blockquotes = config.get('use_blockquotes', False) self.class_members_toctree = config.get('class_members_toctree', True) + self.attributes_as_param_list = config.get('attributes_as_param_list', + True) self.template = config.get('template', None) if self.template is None: template_dirs = [os.path.join(os.path.dirname(__file__), 'templates')] @@ -365,8 +367,10 @@ def __str__(self, indent=0, func_role="obj"): 'notes': self._str_section('Notes'), 'references': self._str_references(), 'examples': self._str_examples(), - 'attributes': self._str_param_list('Attributes', - fake_autosummary=True), + 'attributes': + self._str_param_list('Attributes', fake_autosummary=True) + if self.attributes_as_param_list + else self._str_member_list('Attributes'), 'methods': self._str_member_list('Methods'), } ns = dict((k, '\n'.join(v)) for k, v in ns.items()) diff --git a/numpydoc/numpydoc.py b/numpydoc/numpydoc.py index 26abd66a..ea1cd338 100644 --- a/numpydoc/numpydoc.py +++ b/numpydoc/numpydoc.py @@ -75,8 +75,10 @@ def mangle_docstrings(app, what, name, obj, options, lines): 'use_blockquotes': app.config.numpydoc_use_blockquotes, 'show_class_members': app.config.numpydoc_show_class_members, 'show_inherited_class_members': - app.config.numpydoc_show_inherited_class_members, - 'class_members_toctree': app.config.numpydoc_class_members_toctree} + app.config.numpydoc_show_inherited_class_members, + 'class_members_toctree': app.config.numpydoc_class_members_toctree, + 'attributes_as_param_list': + app.config.numpydoc_attributes_as_param_list} u_NL = sixu('\n') if what == 'module': @@ -146,6 +148,7 @@ def setup(app, get_doc_object_=get_doc_object): app.add_config_value('numpydoc_show_inherited_class_members', True, True) app.add_config_value('numpydoc_class_members_toctree', True, True) app.add_config_value('numpydoc_citation_re', '[a-z0-9_.-]+', True) + app.add_config_value('numpydoc_attributes_as_param_list', True, True) # Extra mangling domains app.add_domain(NumpyPythonDomain)