-
Notifications
You must be signed in to change notification settings - Fork 98
MAINT: Get docs to build again #384
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 3 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,16 +1,12 @@ | ||
| """Extract reference documentation from the NumPy source tree. | ||
|
|
||
| """ | ||
| from __future__ import print_function | ||
|
|
||
| import inspect | ||
| import textwrap | ||
| import re | ||
|
|
||
| import six | ||
| import six.moves as sm | ||
|
|
||
| import pydoc | ||
| from StringIO import StringIO | ||
| from warnings import warn | ||
|
|
||
| class Reader(object): | ||
|
|
@@ -126,7 +122,7 @@ def __getitem__(self,key): | |
| return self._parsed_data[key] | ||
|
|
||
| def __setitem__(self,key,val): | ||
| if key not in self._parsed_data: | ||
| if not self._parsed_data.has_key(key): | ||
| warn("Unknown section %s" % key) | ||
| else: | ||
| self._parsed_data[key] = val | ||
|
|
@@ -366,7 +362,7 @@ def _str_index(self): | |
| idx = self['index'] | ||
| out = [] | ||
| out += ['.. index:: %s' % idx.get('default','')] | ||
| for section, references in six.iteritems(idx): | ||
| for section, references in idx.iteritems(): | ||
| if section == 'default': | ||
| continue | ||
| out += [' :%s: %s' % (section, ', '.join(references))] | ||
|
|
@@ -403,13 +399,13 @@ def __init__(self, func, role='func'): | |
| self._role = role # e.g. "func" or "meth" | ||
| try: | ||
| NumpyDocString.__init__(self,inspect.getdoc(func) or '') | ||
| except ValueError as e: | ||
| print('*'*78) | ||
| print("ERROR: '%s' while parsing `%s`" % (e, self._f)) | ||
| print('*'*78) | ||
| #print("Docstring follows:") | ||
| #print(doclines) | ||
| #print('='*78) | ||
| except ValueError, e: | ||
| print '*'*78 | ||
| print "ERROR: '%s' while parsing `%s`" % (e, self._f) | ||
| print '*'*78 | ||
| #print "Docstring follows:" | ||
| #print doclines | ||
| #print '='*78 | ||
|
|
||
| if not self['Signature']: | ||
| func, func_name = self.get_func() | ||
|
|
@@ -419,7 +415,7 @@ def __init__(self, func, role='func'): | |
| argspec = inspect.formatargspec(*argspec) | ||
| argspec = argspec.replace('*','\*') | ||
| signature = '%s%s' % (func_name, argspec) | ||
| except TypeError as e: | ||
| except TypeError, e: | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Don't revert this line! |
||
| signature = '%s()' % func_name | ||
| self['Signature'] = signature | ||
|
|
||
|
|
@@ -441,8 +437,8 @@ def __str__(self): | |
| 'meth': 'method'} | ||
|
|
||
| if self._role: | ||
| if self._role not in roles: | ||
| print("Warning: invalid role %s" % self._role) | ||
| if not roles.has_key(self._role): | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This seems an unnecessary change. |
||
| print "Warning: invalid role %s" % self._role | ||
| out += '.. %s:: %s\n \n\n' % (roles.get(self._role,''), | ||
| func_name) | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,14 +1,7 @@ | ||
| from __future__ import print_function | ||
|
|
||
| import os, re, pydoc | ||
|
|
||
| import six | ||
| import six.moves as sm | ||
|
|
||
| from .docscrape_sphinx import SphinxDocString, SphinxClassDoc, SphinxFunctionDoc | ||
| from docscrape_sphinx import SphinxDocString, SphinxClassDoc, SphinxFunctionDoc | ||
| import inspect | ||
|
|
||
|
|
||
| def mangle_docstrings(app, what, name, obj, options, lines, | ||
| reference_offset=[0]): | ||
| if what == 'module': | ||
|
|
@@ -33,7 +26,7 @@ def mangle_docstrings(app, what, name, obj, options, lines, | |
| try: | ||
| references.append(int(l[len('.. ['):l.index(']')])) | ||
| except ValueError: | ||
| print("WARNING: invalid reference in %s docstring" % name) | ||
| print "WARNING: invalid reference in %s docstring" % name | ||
|
|
||
| # Start renaming from the biggest number, otherwise we may | ||
| # overwrite references. | ||
|
|
@@ -88,7 +81,7 @@ def initialize(app): | |
|
|
||
| fn = app.config.numpydoc_phantom_import_file | ||
| if (fn and os.path.isfile(fn)): | ||
| print("[numpydoc] Phantom importing modules from", fn, "...") | ||
| print "[numpydoc] Phantom importing modules from", fn, "..." | ||
| import_phantom_module(fn) | ||
|
|
||
| def setup(app): | ||
|
|
@@ -265,7 +258,7 @@ def _import_by_name(name): | |
| name_parts = name.split('.') | ||
| last_j = 0 | ||
| modname = None | ||
| for j in reversed(sm.xrange(1, len(name_parts)+1)): | ||
| for j in reversed(range(1, len(name_parts)+1)): | ||
| last_j = j | ||
| modname = '.'.join(name_parts[:j]) | ||
| try: | ||
|
|
@@ -282,7 +275,7 @@ def _import_by_name(name): | |
| return obj | ||
| else: | ||
| return sys.modules[modname] | ||
| except (ValueError, ImportError, AttributeError, KeyError) as e: | ||
| except (ValueError, ImportError, AttributeError, KeyError), e: | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Again, keep the 'as' |
||
| raise ImportError(e) | ||
|
|
||
| #------------------------------------------------------------------------------ | ||
|
|
@@ -322,7 +315,7 @@ def monkeypatch_sphinx_ext_autodoc(): | |
| if sphinx.ext.autodoc.format_signature is our_format_signature: | ||
| return | ||
|
|
||
| print("[numpydoc] Monkeypatching sphinx.ext.autodoc ...") | ||
| print "[numpydoc] Monkeypatching sphinx.ext.autodoc ..." | ||
| _original_format_signature = sphinx.ext.autodoc.format_signature | ||
| sphinx.ext.autodoc.format_signature = our_format_signature | ||
|
|
||
|
|
@@ -438,7 +431,6 @@ def base_cmp(a, b): | |
| doc = "%s%s\n\n%s" % (funcname, argspec, doc) | ||
| obj = lambda: 0 | ||
| obj.__argspec_is_invalid_ = True | ||
|
|
||
| obj.func_name = funcname | ||
| obj.__name__ = name | ||
| obj.__doc__ = doc | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or this line!