Hello community, here is the log from the commit of package python-numpydoc for openSUSE:Factory checked in at 2017-01-24 10:38:50 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/python-numpydoc (Old) and /work/SRC/openSUSE:Factory/.python-numpydoc.new (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "python-numpydoc" Changes: -------- --- /work/SRC/openSUSE:Factory/python-numpydoc/python-numpydoc.changes 2015-05-15 07:44:47.000000000 +0200 +++ /work/SRC/openSUSE:Factory/.python-numpydoc.new/python-numpydoc.changes 2017-01-24 10:38:51.279945420 +0100 @@ -1,0 +2,27 @@ +Fri Jan 20 21:04:08 UTC 2017 - [email protected] + +- update to version 0.6.0: + * REL: use the distutils sdist command instead of the setuptools + one. + * numpydoc.docscrape: Restore support for Python 3.4. + * CI: run Travis on Sphinx 1.2.x and latest + * better error messages from NumpyDocString + * MAINT inspect.getfullargspec is deprecated in Py3.5 + * return extension metadata + * CI: fix travis pip install + add caching + * BUG: fix spacing in sphinx class doc attribute listing + * PEP8 fixes for docscrape_sphinx.py + * PEP8 fixes for docscrape.py + * PEP8 fixes for numpydoc.py + * MAINT: More explicit call while building docstrings. + * TST: More unit tests for the Yields section. + * ENH: Raise exception if docstring contains Returns and Yields. + * TST : removed print statement + * ENH : simplify handling of Yield section + * Add support for Yields for sphinx strings as well. + * Add unit test for Yields section. + * ENH : NumpyDocString subclass collections.Mapping + * Support Yields section in traitsdoc too. + * Support Yields section. + +------------------------------------------------------------------- Old: ---- numpydoc-0.5.tar.gz New: ---- numpydoc-0.6.0.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ python-numpydoc.spec ++++++ --- /var/tmp/diff_new_pack.bZsMNx/_old 2017-01-24 10:38:51.767876122 +0100 +++ /var/tmp/diff_new_pack.bZsMNx/_new 2017-01-24 10:38:51.771875554 +0100 @@ -1,7 +1,7 @@ # # spec file for package python-numpydoc # -# Copyright (c) 2015 SUSE LINUX GmbH, Nuernberg, Germany. +# Copyright (c) 2017 SUSE LINUX GmbH, Nuernberg, Germany. # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -17,13 +17,13 @@ Name: python-numpydoc -Version: 0.5 +Version: 0.6.0 Release: 0 Summary: Sphinx extension to support docstrings in Numpy format License: BSD-3-Clause Group: Development/Languages/Python Url: https://github.com/numpy/numpydoc -Source: https://pypi.python.org/packages/source/n/numpydoc/numpydoc-%{version}.tar.gz +Source: https://pypi.io/packages/source/n/numpydoc/numpydoc-%{version}.tar.gz BuildRequires: python-devel BuildRequires: python-setuptools # Test requirements ++++++ numpydoc-0.5.tar.gz -> numpydoc-0.6.0.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/numpydoc-0.5/MANIFEST.in new/numpydoc-0.6.0/MANIFEST.in --- old/numpydoc-0.5/MANIFEST.in 2013-07-24 18:15:41.000000000 +0200 +++ new/numpydoc-0.6.0/MANIFEST.in 2016-02-02 22:47:07.000000000 +0100 @@ -1,2 +1,8 @@ +include MANIFEST.in recursive-include numpydoc/tests *.py include *.txt +include *.rst + +# Exclude what we don't want to include +prune */__pycache__ +global-exclude *.pyc *~ *.bak *.swp *.pyo diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/numpydoc-0.5/PKG-INFO new/numpydoc-0.6.0/PKG-INFO --- old/numpydoc-0.5/PKG-INFO 2014-06-08 22:14:48.000000000 +0200 +++ new/numpydoc-0.6.0/PKG-INFO 2016-02-02 23:05:40.000000000 +0100 @@ -1,6 +1,6 @@ Metadata-Version: 1.1 Name: numpydoc -Version: 0.5 +Version: 0.6.0 Summary: Sphinx extension to support docstrings in Numpy format Home-page: https://github.com/numpy/numpy/blob/master/doc/HOWTO_DOCUMENT.rst.txt Author: Pauli Virtanen and others @@ -9,8 +9,16 @@ Description: UNKNOWN Keywords: sphinx numpy Platform: UNKNOWN -Classifier: Development Status :: 3 - Alpha +Classifier: Development Status :: 4 - Beta Classifier: Environment :: Plugins Classifier: License :: OSI Approved :: BSD License Classifier: Topic :: Documentation +Classifier: Programming Language :: Python +Classifier: Programming Language :: Python :: 2 +Classifier: Programming Language :: Python :: 2.6 +Classifier: Programming Language :: Python :: 2.7 +Classifier: Programming Language :: Python :: 3 +Classifier: Programming Language :: Python :: 3.3 +Classifier: Programming Language :: Python :: 3.4 +Classifier: Programming Language :: Python :: 3.5 Requires: sphinx (>= 1.0.1) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/numpydoc-0.5/README.rst new/numpydoc-0.6.0/README.rst --- old/numpydoc-0.5/README.rst 2014-06-08 22:03:45.000000000 +0200 +++ new/numpydoc-0.6.0/README.rst 2015-04-07 22:56:26.000000000 +0200 @@ -45,12 +45,20 @@ Whether to show all members of a class in the Methods and Attributes sections automatically. + ``True`` by default. + +- numpydoc_show_inherited_class_members: bool + + Whether to show all inherited members of a class in the Methods and Attributes + sections automatically. If it's false, inherited members won't shown. + ``True`` by default. - numpydoc_class_members_toctree: bool Whether to create a Sphinx table of contents for the lists of class methods and attributes. If a table of contents is made, Sphinx expects each entry to have a separate page. + ``True`` by default. - numpydoc_edit_link: bool (DEPRECATED -- edit your HTML template instead) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/numpydoc-0.5/numpydoc/docscrape.py new/numpydoc-0.6.0/numpydoc/docscrape.py --- old/numpydoc-0.5/numpydoc/docscrape.py 2014-06-08 22:03:45.000000000 +0200 +++ new/numpydoc-0.6.0/numpydoc/docscrape.py 2016-01-31 22:52:44.000000000 +0100 @@ -24,10 +24,10 @@ String with lines separated by '\n'. """ - if isinstance(data,list): + if isinstance(data, list): self._str = data else: - self._str = data.split('\n') # store string as list of lines + self._str = data.split('\n') # store string as list of lines self.reset() @@ -35,7 +35,7 @@ return self._str[n] def reset(self): - self._l = 0 # current line nr + self._l = 0 # current line nr def read(self): if not self.eof(): @@ -67,8 +67,10 @@ def read_to_next_empty_line(self): self.seek_next_non_empty_line() + def is_empty(line): return not line.strip() + return self.read_to_condition(is_empty) def read_to_next_unindented_line(self): @@ -76,7 +78,7 @@ return (line.strip() and (len(line.lstrip()) == len(line))) return self.read_to_condition(is_unindented) - def peek(self,n=0): + def peek(self, n=0): if self._l + n < len(self._str): return self[self._l + n] else: @@ -86,8 +88,17 @@ return not ''.join(self._str).strip() -class NumpyDocString(object): +class ParseError(Exception): + def __str__(self): + message = self.message + if hasattr(self, 'docstring'): + message = "%s in %r" % (message, self.docstring) + return message + + +class NumpyDocString(collections.Mapping): def __init__(self, docstring, config={}): + orig_docstring = docstring docstring = textwrap.dedent(docstring).split('\n') self._doc = Reader(docstring) @@ -97,6 +108,7 @@ 'Extended Summary': [], 'Parameters': [], 'Returns': [], + 'Yields': [], 'Raises': [], 'Warns': [], 'Other Parameters': [], @@ -110,17 +122,27 @@ 'index': {} } - self._parse() + try: + self._parse() + except ParseError as e: + e.docstring = orig_docstring + raise - def __getitem__(self,key): + def __getitem__(self, key): return self._parsed_data[key] - def __setitem__(self,key,val): + def __setitem__(self, key, val): if key not in self._parsed_data: warn("Unknown section %s" % key) else: self._parsed_data[key] = val + def __iter__(self): + return iter(self._parsed_data) + + def __len__(self): + return len(self._parsed_data) + def _is_at_section(self): self._doc.seek_next_non_empty_line() @@ -132,17 +154,19 @@ if l1.startswith('.. index::'): return True - l2 = self._doc.peek(1).strip() # ---------- or ========== + l2 = self._doc.peek(1).strip() # ---------- or ========== return l2.startswith('-'*len(l1)) or l2.startswith('='*len(l1)) - def _strip(self,doc): + def _strip(self, doc): i = 0 j = 0 - for i,line in enumerate(doc): - if line.strip(): break + for i, line in enumerate(doc): + if line.strip(): + break - for j,line in enumerate(doc[::-1]): - if line.strip(): break + for j, line in enumerate(doc[::-1]): + if line.strip(): + break return doc[i:len(doc)-j] @@ -150,7 +174,7 @@ section = self._doc.read_to_next_empty_line() while not self._is_at_section() and not self._doc.eof(): - if not self._doc.peek(-1).strip(): # previous line was empty + if not self._doc.peek(-1).strip(): # previous line was empty section += [''] section += self._doc.read_to_next_empty_line() @@ -162,14 +186,14 @@ data = self._read_to_next_section() name = data[0].strip() - if name.startswith('..'): # index section + if name.startswith('..'): # index section yield name, data[1:] elif len(data) < 2: yield StopIteration else: yield name, self._strip(data[2:]) - def _parse_param_list(self,content): + def _parse_param_list(self, content): r = Reader(content) params = [] while not r.eof(): @@ -182,13 +206,13 @@ desc = r.read_to_next_unindented_line() desc = dedent_lines(desc) - params.append((arg_name,arg_type,desc)) + params.append((arg_name, arg_type, desc)) return params - _name_rgx = re.compile(r"^\s*(:(?P<role>\w+):`(?P<name>[a-zA-Z0-9_.-]+)`|" r" (?P<name2>[a-zA-Z0-9_.-]+))\s*", re.X) + def _parse_see_also(self, content): """ func_name : Descriptive text @@ -208,7 +232,7 @@ return g[3], None else: return g[2], g[1] - raise ValueError("%s is not a item name" % text) + raise ParseError("%s is not a item name" % text) def push_item(name, rest): if not name: @@ -221,7 +245,8 @@ rest = [] for line in content: - if not line.strip(): continue + if not line.strip(): + continue m = self._name_rgx.match(line) if m and line[m.end():].strip().startswith(':'): @@ -288,11 +313,23 @@ self._doc.reset() self._parse_summary() - for (section,content) in self._read_sections(): + sections = list(self._read_sections()) + section_names = set([section for section, content in sections]) + + has_returns = 'Returns' in section_names + has_yields = 'Yields' in section_names + # We could do more tests, but we are not. Arbitrarily. + if has_returns and has_yields: + msg = 'Docstring contains both a Returns and Yields section.' + raise ValueError(msg) + + for (section, content) in sections: if not section.startswith('..'): - section = ' '.join([s.capitalize() for s in section.split(' ')]) - if section in ('Parameters', 'Returns', 'Raises', 'Warns', - 'Other Parameters', 'Attributes', 'Methods'): + section = (s.capitalize() for s in section.split(' ')) + section = ' '.join(section) + if section in ('Parameters', 'Returns', 'Yields', 'Raises', + 'Warns', 'Other Parameters', 'Attributes', + 'Methods'): self[section] = self._parse_param_list(content) elif section.startswith('.. index::'): self['index'] = self._parse_index(section, content) @@ -314,7 +351,7 @@ def _str_signature(self): if self['Signature']: - return [self['Signature'].replace('*','\*')] + [''] + return [self['Signature'].replace('*', '\*')] + [''] else: return [''] @@ -334,7 +371,7 @@ out = [] if self[name]: out += self._str_header(name) - for param,param_type,desc in self[name]: + for param, param_type, desc in self[name]: if param_type: out += ['%s : %s' % (param, param_type)] else: @@ -352,7 +389,8 @@ return out def _str_see_also(self, func_role): - if not self['See Also']: return [] + if not self['See Also']: + return [] out = [] out += self._str_header("See Also") last_had_desc = True @@ -379,7 +417,7 @@ def _str_index(self): idx = self['index'] out = [] - out += ['.. index:: %s' % idx.get('default','')] + out += ['.. index:: %s' % idx.get('default', '')] for section, references in idx.items(): if section == 'default': continue @@ -391,12 +429,12 @@ out += self._str_signature() out += self._str_summary() out += self._str_extended_summary() - for param_list in ('Parameters', 'Returns', 'Other Parameters', - 'Raises', 'Warns'): + for param_list in ('Parameters', 'Returns', 'Yields', + 'Other Parameters', 'Raises', 'Warns'): out += self._str_param_list(param_list) out += self._str_section('Warnings') out += self._str_see_also(func_role) - for s in ('Notes','References','Examples'): + for s in ('Notes', 'References', 'Examples'): out += self._str_section(s) for param_list in ('Attributes', 'Methods'): out += self._str_param_list(param_list) @@ -404,17 +442,19 @@ return '\n'.join(out) -def indent(str,indent=4): +def indent(str, indent=4): indent_str = ' '*indent if str is None: return indent_str lines = str.split('\n') return '\n'.join(indent_str + l for l in lines) + def dedent_lines(lines): """Deindent a list of lines maximally""" return textwrap.dedent("\n".join(lines)).split("\n") + def header(text, style='-'): return text + '\n' + style*len(text) + '\n' @@ -422,7 +462,7 @@ class FunctionDoc(NumpyDocString): def __init__(self, func, role='func', doc=None, config={}): self._f = func - self._role = role # e.g. "func" or "meth" + self._role = role # e.g. "func" or "meth" if doc is None: if func is None: @@ -433,15 +473,17 @@ if not self['Signature'] and func is not None: func, func_name = self.get_func() try: - # try to read signature - if sys.version_info[0] >= 3: - argspec = inspect.getfullargspec(func) - else: - argspec = inspect.getargspec(func) - argspec = inspect.formatargspec(*argspec) - argspec = argspec.replace('*','\*') - signature = '%s%s' % (func_name, argspec) - except TypeError as e: + try: + signature = str(inspect.signature(func)) + except (AttributeError, ValueError): + # try to read signature, backward compat for older Python + if sys.version_info[0] >= 3: + argspec = inspect.getfullargspec(func) + else: + argspec = inspect.getargspec(func) + signature = inspect.formatargspec(*argspec) + signature = '%s%s' % (func_name, signature.replace('*', '\*')) + except TypeError: signature = '%s()' % func_name self['Signature'] = signature @@ -465,7 +507,7 @@ if self._role: if self._role not in roles: print("Warning: invalid role %s" % self._role) - out += '.. %s:: %s\n \n\n' % (roles.get(self._role,''), + out += '.. %s:: %s\n \n\n' % (roles.get(self._role, ''), func_name) out += super(FunctionDoc, self).__str__(func_role=self._role) @@ -482,6 +524,9 @@ raise ValueError("Expected a class or None, but got %r" % cls) self._cls = cls + self.show_inherited_members = config.get( + 'show_inherited_class_members', True) + if modulename and not modulename.endswith('.'): modulename += '.' self._mod = modulename @@ -505,27 +550,36 @@ if not self[field]: doc_list = [] for name in sorted(items): - try: + try: doc_item = pydoc.getdoc(getattr(self._cls, name)) doc_list.append((name, '', splitlines_x(doc_item))) - except AttributeError: - pass # method doesn't exist + except AttributeError: + pass # method doesn't exist self[field] = doc_list @property def methods(self): if self._cls is None: return [] - return [name for name,func in inspect.getmembers(self._cls) + return [name for name, func in inspect.getmembers(self._cls) if ((not name.startswith('_') or name in self.extra_public_methods) - and isinstance(func, collections.Callable))] + and isinstance(func, collections.Callable) + and self._is_show_member(name))] @property def properties(self): if self._cls is None: return [] - return [name for name,func in inspect.getmembers(self._cls) - if not name.startswith('_') and - (func is None or isinstance(func, property) or - inspect.isgetsetdescriptor(func))] + return [name for name, func in inspect.getmembers(self._cls) + if (not name.startswith('_') and + (func is None or isinstance(func, property) or + inspect.isgetsetdescriptor(func)) + and self._is_show_member(name))] + + def _is_show_member(self, name): + if self.show_inherited_members: + return True # show all class members + if name not in self._cls.__dict__: + return False # class member is inherited, we do not show it + return True diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/numpydoc-0.5/numpydoc/docscrape_sphinx.py new/numpydoc-0.6.0/numpydoc/docscrape_sphinx.py --- old/numpydoc-0.5/numpydoc/docscrape_sphinx.py 2014-01-25 13:49:54.000000000 +0100 +++ new/numpydoc-0.6.0/numpydoc/docscrape_sphinx.py 2016-01-31 16:14:29.000000000 +0100 @@ -1,8 +1,13 @@ from __future__ import division, absolute_import, print_function -import sys, re, inspect, textwrap, pydoc +import sys +import re +import inspect +import textwrap +import pydoc import sphinx import collections + from .docscrape import NumpyDocString, FunctionDoc, ClassDoc if sys.version_info[0] >= 3: @@ -46,12 +51,12 @@ def _str_extended_summary(self): return self['Extended Summary'] + [''] - def _str_returns(self): + def _str_returns(self, name='Returns'): out = [] - if self['Returns']: - out += self._str_field_list('Returns') + if self[name]: + out += self._str_field_list(name) out += [''] - for param, param_type, desc in self['Returns']: + for param, param_type, desc in self[name]: if param_type: out += self._str_indent(['**%s** : %s' % (param.strip(), param_type)]) @@ -130,7 +135,7 @@ maxlen_0 = max(3, max([len(x[0]) for x in others])) hdr = sixu("=")*maxlen_0 + sixu(" ") + sixu("=")*10 fmt = sixu('%%%ds %%s ') % (maxlen_0,) - out += ['', hdr] + out += ['', '', hdr] for param, param_type, desc in others: desc = sixu(" ").join(x.strip() for x in desc).strip() if param_type: @@ -171,7 +176,7 @@ if len(idx) == 0: return out - out += ['.. index:: %s' % idx.get('default','')] + out += ['.. index:: %s' % idx.get('default', '')] for section, references in idx.items(): if section == 'default': continue @@ -192,9 +197,9 @@ # Latex collects all references to a separate bibliography, # so we need to insert links to it if sphinx.__version__ >= "0.6": - out += ['.. only:: latex',''] + out += ['.. only:: latex', ''] else: - out += ['.. latexonly::',''] + out += ['.. latexonly::', ''] items = [] for line in self['References']: m = re.match(r'.. \[([a-z0-9._-]+)\]', line, re.I) @@ -224,7 +229,8 @@ out += self._str_summary() out += self._str_extended_summary() out += self._str_param_list('Parameters') - out += self._str_returns() + out += self._str_returns('Returns') + out += self._str_returns('Yields') for param_list in ('Other Parameters', 'Raises', 'Warns'): out += self._str_param_list(param_list) out += self._str_warnings() @@ -234,25 +240,29 @@ out += self._str_examples() for param_list in ('Attributes', 'Methods'): out += self._str_member_list(param_list) - out = self._str_indent(out,indent) + out = self._str_indent(out, indent) return '\n'.join(out) + class SphinxFunctionDoc(SphinxDocString, FunctionDoc): def __init__(self, obj, doc=None, config={}): self.load_config(config) FunctionDoc.__init__(self, obj, doc=doc, config=config) + class SphinxClassDoc(SphinxDocString, ClassDoc): def __init__(self, obj, doc=None, func_doc=None, config={}): self.load_config(config) ClassDoc.__init__(self, obj, doc=doc, func_doc=None, config=config) + class SphinxObjDoc(SphinxDocString): def __init__(self, obj, doc=None, config={}): self._f = obj self.load_config(config) SphinxDocString.__init__(self, doc, config=config) + def get_doc_object(obj, what=None, doc=None, config={}): if what is None: if inspect.isclass(obj): diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/numpydoc-0.5/numpydoc/numpydoc.py new/numpydoc-0.6.0/numpydoc/numpydoc.py --- old/numpydoc-0.5/numpydoc/numpydoc.py 2014-01-25 13:49:54.000000000 +0100 +++ new/numpydoc-0.6.0/numpydoc/numpydoc.py 2016-01-31 16:14:29.000000000 +0100 @@ -10,14 +10,17 @@ - Convert Parameters etc. sections to field lists. - Convert See Also section to a See also entry. - Renumber references. -- Extract the signature from the docstring, if it can't be determined otherwise. +- Extract the signature from the docstring, if it can't be determined + otherwise. .. [1] https://github.com/numpy/numpy/blob/master/doc/HOWTO_DOCUMENT.rst.txt """ from __future__ import division, absolute_import, print_function -import os, sys, re, pydoc +import sys +import re +import pydoc import sphinx import inspect import collections @@ -37,26 +40,28 @@ def mangle_docstrings(app, what, name, obj, options, lines, reference_offset=[0]): - cfg = dict(use_plots=app.config.numpydoc_use_plots, - show_class_members=app.config.numpydoc_show_class_members, - class_members_toctree=app.config.numpydoc_class_members_toctree, - ) + cfg = {'use_plots': app.config.numpydoc_use_plots, + '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} + u_NL = sixu('\n') if what == 'module': # Strip top title - title_re = re.compile(sixu('^\\s*[#*=]{4,}\\n[a-z0-9 -]+\\n[#*=]{4,}\\s*'), - re.I|re.S) - lines[:] = title_re.sub(sixu(''), sixu("\n").join(lines)).split(sixu("\n")) + pattern = '^\\s*[#*=]{4,}\\n[a-z0-9 -]+\\n[#*=]{4,}\\s*' + title_re = re.compile(sixu(pattern), re.I | re.S) + lines[:] = title_re.sub(sixu(''), u_NL.join(lines)).split(u_NL) else: - doc = get_doc_object(obj, what, sixu("\n").join(lines), config=cfg) + doc = get_doc_object(obj, what, u_NL.join(lines), config=cfg) if sys.version_info[0] >= 3: doc = str(doc) else: doc = unicode(doc) - lines[:] = doc.split(sixu("\n")) + lines[:] = doc.split(u_NL) - if app.config.numpydoc_edit_link and hasattr(obj, '__name__') and \ - obj.__name__: + if (app.config.numpydoc_edit_link and hasattr(obj, '__name__') and + obj.__name__): if hasattr(obj, '__module__'): v = dict(full_name=sixu("%s.%s") % (obj.__module__, obj.__name__)) else: @@ -89,24 +94,30 @@ reference_offset[0] += len(references) + def mangle_signature(app, what, name, obj, options, sig, retann): # Do not try to inspect classes that don't define `__init__` if (inspect.isclass(obj) and (not hasattr(obj, '__init__') or - 'initializes x; see ' in pydoc.getdoc(obj.__init__))): + 'initializes x; see ' in pydoc.getdoc(obj.__init__))): return '', '' - if not (isinstance(obj, collections.Callable) or hasattr(obj, '__argspec_is_invalid_')): return - if not hasattr(obj, '__doc__'): return + if not (isinstance(obj, collections.Callable) or + hasattr(obj, '__argspec_is_invalid_')): + return + + if not hasattr(obj, '__doc__'): + return doc = SphinxDocString(pydoc.getdoc(obj)) if doc['Signature']: sig = re.sub(sixu("^[^(]*"), sixu(""), doc['Signature']) return sig, sixu('') + def setup(app, get_doc_object_=get_doc_object): if not hasattr(app, 'add_config_value'): - return # probably called by nose, better bail out + return # probably called by nose, better bail out global get_doc_object get_doc_object = get_doc_object_ @@ -116,20 +127,25 @@ app.add_config_value('numpydoc_edit_link', None, False) app.add_config_value('numpydoc_use_plots', None, False) app.add_config_value('numpydoc_show_class_members', True, True) + app.add_config_value('numpydoc_show_inherited_class_members', True, True) app.add_config_value('numpydoc_class_members_toctree', True, True) # Extra mangling domains app.add_domain(NumpyPythonDomain) app.add_domain(NumpyCDomain) + + metadata = {'parallel_read_safe': True} + return metadata -#------------------------------------------------------------------------------ +# ------------------------------------------------------------------------------ # Docstring-mangling domains -#------------------------------------------------------------------------------ +# ------------------------------------------------------------------------------ from docutils.statemachine import ViewList from sphinx.domains.c import CDomain from sphinx.domains.python import PythonDomain + class ManglingDomainBase(object): directive_mangling_map = {} @@ -142,6 +158,7 @@ self.directives[name] = wrap_mangling_directive( self.directives[name], objtype) + class NumpyPythonDomain(ManglingDomainBase, PythonDomain): name = 'np' directive_mangling_map = { @@ -155,6 +172,7 @@ } indices = [] + class NumpyCDomain(ManglingDomainBase, CDomain): name = 'np-c' directive_mangling_map = { @@ -165,6 +183,7 @@ 'var': 'object', } + def wrap_mangling_directive(base_directive, objtype): class directive(base_directive): def run(self): diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/numpydoc-0.5/numpydoc/tests/test_docscrape.py new/numpydoc-0.6.0/numpydoc/tests/test_docscrape.py --- old/numpydoc-0.5/numpydoc/tests/test_docscrape.py 2013-07-24 18:15:41.000000000 +0200 +++ new/numpydoc-0.6.0/numpydoc/tests/test_docscrape.py 2016-01-31 16:14:29.000000000 +0100 @@ -122,6 +122,20 @@ ''' doc = NumpyDocString(doc_txt) +doc_yields_txt = """ +Test generator + +Yields +------ +a : int + The number of apples. +b : int + The number of bananas. +int + The number of unknowns. +""" +doc_yields = NumpyDocString(doc_yields_txt) + def test_signature(): assert doc['Signature'].startswith('numpy.multivariate_normal(') @@ -164,6 +178,37 @@ assert desc[0].startswith('This is not a real') assert desc[-1].endswith('anonymous return values.') +def test_yields(): + section = doc_yields['Yields'] + assert_equal(len(section), 3) + truth = [('a', 'int', 'apples.'), + ('b', 'int', 'bananas.'), + ('int', '', 'unknowns.')] + for (arg, arg_type, desc), (arg_, arg_type_, end) in zip(section, truth): + assert_equal(arg, arg_) + assert_equal(arg_type, arg_type_) + assert desc[0].startswith('The number of') + assert desc[0].endswith(end) + +def test_returnyield(): + doc_text = """ +Test having returns and yields. + +Returns +------- +int + The number of apples. + +Yields +------ +a : int + The number of apples. +b : int + The number of bananas. + +""" + assert_raises(ValueError, NumpyDocString, doc_text) + def test_notes(): assert doc['Notes'][0].startswith('Instead') assert doc['Notes'][-1].endswith('definite.') @@ -193,6 +238,9 @@ "\n>>> %s\n<<< %s\n" % (n,line,b[n])) def test_str(): + # doc_txt has the order of Notes and See Also sections flipped. + # This should be handled automatically, and so, one thing this test does + # is to make sure that See Also precedes Notes in the output. non_blank_line_by_line_compare(str(doc), """numpy.multivariate_normal(mean, cov, shape=None, spam=None) @@ -302,6 +350,22 @@ :refguide: random;distributions, random;gauss""") +def test_yield_str(): + non_blank_line_by_line_compare(str(doc_yields), +"""Test generator + +Yields +------ +a : int + The number of apples. +b : int + The number of bananas. +int + The number of unknowns. + +.. index:: """) + + def test_sphinx_str(): sphinx_doc = SphinxDocString(doc_txt) non_blank_line_by_line_compare(str(sphinx_doc), @@ -427,6 +491,27 @@ """) +def test_sphinx_yields_str(): + sphinx_doc = SphinxDocString(doc_yields_txt) + non_blank_line_by_line_compare(str(sphinx_doc), +"""Test generator + +:Yields: + + **a** : int + + The number of apples. + + **b** : int + + The number of bananas. + + int + + The number of unknowns. +""") + + doc2 = NumpyDocString(""" Returns array of indices of the maximum values of along the given axis. @@ -451,6 +536,12 @@ signature = str(doc3).split('\n')[0] assert_equal(signature, 'my_signature(\*params, \*\*kwds)') + def my_func(a, b, **kwargs): + pass + + fdoc = FunctionDoc(func=my_func) + assert_equal(fdoc['Signature'], 'my_func(a, b, \*\*kwargs)') + doc4 = NumpyDocString( """a.conj() @@ -646,6 +737,46 @@ else: assert 'Spammity index' in str(doc), str(doc) + class SubDummy(Dummy): + """ + Subclass of Dummy class. + + """ + def ham(self, c, d): + """Cheese\n\nNo cheese.\nOverloaded Dummy.ham""" + pass + + def bar(self, a, b): + """Bar\n\nNo bar""" + pass + + for cls in (ClassDoc, SphinxClassDoc): + doc = cls(SubDummy, config=dict(show_class_members=True, + show_inherited_class_members=False)) + assert 'Methods' in str(doc), (cls, str(doc)) + assert 'spam' not in str(doc), (cls, str(doc)) + assert 'ham' in str(doc), (cls, str(doc)) + assert 'bar' in str(doc), (cls, str(doc)) + assert 'spammity' not in str(doc), (cls, str(doc)) + + if cls is SphinxClassDoc: + assert '.. autosummary::' in str(doc), str(doc) + else: + assert 'Spammity index' not in str(doc), str(doc) + + doc = cls(SubDummy, config=dict(show_class_members=True, + show_inherited_class_members=True)) + assert 'Methods' in str(doc), (cls, str(doc)) + assert 'spam' in str(doc), (cls, str(doc)) + assert 'ham' in str(doc), (cls, str(doc)) + assert 'bar' in str(doc), (cls, str(doc)) + assert 'spammity' in str(doc), (cls, str(doc)) + + if cls is SphinxClassDoc: + assert '.. autosummary::' in str(doc), str(doc) + else: + assert 'Spammity index' in str(doc), str(doc) + def test_duplicate_signature(): # Duplicate function signatures occur e.g. in ufuncs, when the # automatic mechanism adds one, and a more detailed comes from the @@ -677,6 +808,8 @@ Current time. y : ndarray Current variable values. + x : float + Some parameter Methods ------- @@ -712,6 +845,8 @@ Current time. y : ndarray Current variable values. + x : float + Some parameter Methods ------- @@ -726,7 +861,13 @@ """) def test_class_members_doc_sphinx(): - doc = SphinxClassDoc(None, class_doc_txt) + class Foo: + @property + def x(self): + """Test attribute""" + return None + + doc = SphinxClassDoc(Foo, class_doc_txt) non_blank_line_by_line_compare(str(doc), """ Foo @@ -747,6 +888,11 @@ .. rubric:: Attributes + .. autosummary:: + :toctree: + + x + === ========== t (float) Current time. y (ndarray) Current variable values. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/numpydoc-0.5/numpydoc/traitsdoc.py new/numpydoc-0.6.0/numpydoc/traitsdoc.py --- old/numpydoc-0.5/numpydoc/traitsdoc.py 2013-07-24 18:15:41.000000000 +0200 +++ new/numpydoc-0.6.0/numpydoc/traitsdoc.py 2015-04-07 22:56:26.000000000 +0200 @@ -61,6 +61,7 @@ 'Extended Summary': [], 'Parameters': [], 'Returns': [], + 'Yields': [], 'Raises': [], 'Warns': [], 'Other Parameters': [], @@ -89,7 +90,7 @@ out += self._str_summary() out += self._str_extended_summary() for param_list in ('Parameters', 'Traits', 'Methods', - 'Returns','Raises'): + 'Returns', 'Yields', 'Raises'): out += self._str_param_list(param_list) out += self._str_see_also("obj") out += self._str_section('Notes') diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/numpydoc-0.5/numpydoc.egg-info/PKG-INFO new/numpydoc-0.6.0/numpydoc.egg-info/PKG-INFO --- old/numpydoc-0.5/numpydoc.egg-info/PKG-INFO 2014-06-08 22:14:48.000000000 +0200 +++ new/numpydoc-0.6.0/numpydoc.egg-info/PKG-INFO 1970-01-01 01:00:00.000000000 +0100 @@ -1,16 +0,0 @@ -Metadata-Version: 1.1 -Name: numpydoc -Version: 0.5 -Summary: Sphinx extension to support docstrings in Numpy format -Home-page: https://github.com/numpy/numpy/blob/master/doc/HOWTO_DOCUMENT.rst.txt -Author: Pauli Virtanen and others -Author-email: [email protected] -License: BSD -Description: UNKNOWN -Keywords: sphinx numpy -Platform: UNKNOWN -Classifier: Development Status :: 3 - Alpha -Classifier: Environment :: Plugins -Classifier: License :: OSI Approved :: BSD License -Classifier: Topic :: Documentation -Requires: sphinx (>= 1.0.1) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/numpydoc-0.5/numpydoc.egg-info/SOURCES.txt new/numpydoc-0.6.0/numpydoc.egg-info/SOURCES.txt --- old/numpydoc-0.5/numpydoc.egg-info/SOURCES.txt 2014-06-08 22:14:48.000000000 +0200 +++ new/numpydoc-0.6.0/numpydoc.egg-info/SOURCES.txt 1970-01-01 01:00:00.000000000 +0100 @@ -1,23 +0,0 @@ -LICENSE.txt -MANIFEST.in -README.rst -setup.py -numpydoc/__init__.py -numpydoc/comment_eater.py -numpydoc/compiler_unparse.py -numpydoc/docscrape.py -numpydoc/docscrape_sphinx.py -numpydoc/linkcode.py -numpydoc/numpydoc.py -numpydoc/phantom_import.py -numpydoc/plot_directive.py -numpydoc/traitsdoc.py -numpydoc.egg-info/PKG-INFO -numpydoc.egg-info/SOURCES.txt -numpydoc.egg-info/dependency_links.txt -numpydoc.egg-info/top_level.txt -numpydoc/tests/test_docscrape.py -numpydoc/tests/test_linkcode.py -numpydoc/tests/test_phantom_import.py -numpydoc/tests/test_plot_directive.py -numpydoc/tests/test_traitsdoc.py \ No newline at end of file diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/numpydoc-0.5/numpydoc.egg-info/dependency_links.txt new/numpydoc-0.6.0/numpydoc.egg-info/dependency_links.txt --- old/numpydoc-0.5/numpydoc.egg-info/dependency_links.txt 2014-06-08 22:14:48.000000000 +0200 +++ new/numpydoc-0.6.0/numpydoc.egg-info/dependency_links.txt 1970-01-01 01:00:00.000000000 +0100 @@ -1 +0,0 @@ - diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/numpydoc-0.5/numpydoc.egg-info/top_level.txt new/numpydoc-0.6.0/numpydoc.egg-info/top_level.txt --- old/numpydoc-0.5/numpydoc.egg-info/top_level.txt 2014-06-08 22:14:48.000000000 +0200 +++ new/numpydoc-0.6.0/numpydoc.egg-info/top_level.txt 1970-01-01 01:00:00.000000000 +0100 @@ -1 +0,0 @@ -numpydoc diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/numpydoc-0.5/setup.cfg new/numpydoc-0.6.0/setup.cfg --- old/numpydoc-0.5/setup.cfg 2014-06-08 22:14:48.000000000 +0200 +++ new/numpydoc-0.6.0/setup.cfg 1970-01-01 01:00:00.000000000 +0100 @@ -1,5 +0,0 @@ -[egg_info] -tag_build = -tag_date = 0 -tag_svn_revision = 0 - diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/numpydoc-0.5/setup.py new/numpydoc-0.6.0/setup.py --- old/numpydoc-0.5/setup.py 2014-06-08 22:04:13.000000000 +0200 +++ new/numpydoc-0.6.0/setup.py 2016-02-02 22:53:17.000000000 +0100 @@ -1,13 +1,15 @@ from __future__ import division, print_function import sys + +from distutils.command.sdist import sdist import setuptools from distutils.core import setup if sys.version_info[:2] < (2, 6) or (3, 0) <= sys.version_info[0:2] < (3, 3): raise RuntimeError("Python version 2.6, 2.7 or >= 3.3 required.") -version = "0.5" +version = "0.6.0" setup( name="numpydoc", @@ -15,10 +17,18 @@ version=version, description="Sphinx extension to support docstrings in Numpy format", # classifiers from http://pypi.python.org/pypi?%3Aaction=list_classifiers - classifiers=["Development Status :: 3 - Alpha", + classifiers=["Development Status :: 4 - Beta", "Environment :: Plugins", "License :: OSI Approved :: BSD License", - "Topic :: Documentation"], + "Topic :: Documentation", + "Programming Language :: Python", + "Programming Language :: Python :: 2", + "Programming Language :: Python :: 2.6", + "Programming Language :: Python :: 2.7", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.3", + "Programming Language :: Python :: 3.4", + "Programming Language :: Python :: 3.5"], keywords="sphinx numpy", author="Pauli Virtanen and others", author_email="[email protected]", @@ -27,4 +37,5 @@ requires=["sphinx (>= 1.0.1)"], package_data={'numpydoc': ['tests/test_*.py']}, test_suite = 'nose.collector', + cmdclass={"sdist": sdist}, )
