summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--doc/source/conf.py29
-rw-r--r--doc/sphinxext/MANIFEST.in2
-rw-r--r--doc/sphinxext/__init__.py1
-rw-r--r--doc/sphinxext/numpydoc/__init__.py1
-rw-r--r--doc/sphinxext/numpydoc/comment_eater.py (renamed from doc/sphinxext/comment_eater.py)15
-rw-r--r--doc/sphinxext/numpydoc/compiler_unparse.py (renamed from doc/sphinxext/compiler_unparse.py)8
-rw-r--r--doc/sphinxext/numpydoc/docscrape.py (renamed from doc/sphinxext/docscrape.py)56
-rw-r--r--doc/sphinxext/numpydoc/docscrape_sphinx.py (renamed from doc/sphinxext/docscrape_sphinx.py)31
-rw-r--r--doc/sphinxext/numpydoc/linkcode.py (renamed from doc/sphinxext/linkcode.py)7
-rw-r--r--doc/sphinxext/numpydoc/numpydoc.py (renamed from doc/sphinxext/numpydoc.py)23
-rw-r--r--doc/sphinxext/numpydoc/phantom_import.py (renamed from doc/sphinxext/phantom_import.py)7
-rw-r--r--doc/sphinxext/numpydoc/plot_directive.py (renamed from doc/sphinxext/plot_directive.py)13
-rw-r--r--doc/sphinxext/numpydoc/tests/test_docscrape.py (renamed from doc/sphinxext/tests/test_docscrape.py)145
-rw-r--r--doc/sphinxext/numpydoc/tests/test_linkcode.py3
-rw-r--r--doc/sphinxext/numpydoc/tests/test_phantom_import.py3
-rw-r--r--doc/sphinxext/numpydoc/tests/test_plot_directive.py3
-rw-r--r--doc/sphinxext/numpydoc/tests/test_traitsdoc.py3
-rw-r--r--doc/sphinxext/numpydoc/traitsdoc.py (renamed from doc/sphinxext/traitsdoc.py)11
-rw-r--r--doc/sphinxext/setup.py10
19 files changed, 279 insertions, 92 deletions
diff --git a/doc/source/conf.py b/doc/source/conf.py
index de9f6adf3..7848bb6bc 100644
--- a/doc/source/conf.py
+++ b/doc/source/conf.py
@@ -20,24 +20,8 @@ sys.path.insert(0, os.path.abspath('../sphinxext'))
extensions = ['sphinx.ext.autodoc', 'sphinx.ext.pngmath', 'numpydoc',
'sphinx.ext.intersphinx', 'sphinx.ext.coverage',
- 'sphinx.ext.doctest', 'sphinx.ext.autosummary']
-
-# Determine if the matplotlib has a recent enough version of the
-# plot_directive, otherwise use the local fork.
-try:
- from matplotlib.sphinxext import plot_directive
-except ImportError:
- use_matplotlib_plot_directive = False
-else:
- try:
- use_matplotlib_plot_directive = (plot_directive.__version__ >= 2)
- except AttributeError:
- use_matplotlib_plot_directive = False
-
-if use_matplotlib_plot_directive:
- extensions.append('matplotlib.sphinxext.plot_directive')
-else:
- extensions.append('plot_directive')
+ 'sphinx.ext.doctest', 'sphinx.ext.autosummary',
+ 'matplotlib.sphinxext.plot_directive']
# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']
@@ -61,7 +45,7 @@ version = re.sub(r'(\d+\.\d+)\.\d+(.*)', r'\1\2', numpy.__version__)
version = re.sub(r'(\.dev\d+).*?$', r'\1', version)
# The full version, including alpha/beta/rc tags.
release = numpy.__version__
-print version, release
+print("%s %s" % (version, release))
# There are two options for replacing |today|: either, you set today to some
# non-false value, then it is used:
@@ -283,9 +267,6 @@ plot_rcparams = {
'text.usetex': False,
}
-if not use_matplotlib_plot_directive:
- import matplotlib
- matplotlib.rcParams.update(plot_rcparams)
# -----------------------------------------------------------------------------
# Source code links
@@ -294,7 +275,7 @@ if not use_matplotlib_plot_directive:
import inspect
from os.path import relpath, dirname
-for name in ['sphinx.ext.linkcode', 'linkcode', 'numpydoc.linkcode']:
+for name in ['sphinx.ext.linkcode', 'numpydoc.linkcode']:
try:
__import__(name)
extensions.append(name)
@@ -302,7 +283,7 @@ for name in ['sphinx.ext.linkcode', 'linkcode', 'numpydoc.linkcode']:
except ImportError:
pass
else:
- print "NOTE: linkcode extension not found -- no links to source generated"
+ print("NOTE: linkcode extension not found -- no links to source generated")
def linkcode_resolve(domain, info):
"""
diff --git a/doc/sphinxext/MANIFEST.in b/doc/sphinxext/MANIFEST.in
index f88ed785c..5176d485b 100644
--- a/doc/sphinxext/MANIFEST.in
+++ b/doc/sphinxext/MANIFEST.in
@@ -1,2 +1,2 @@
-recursive-include tests *.py
+recursive-include numpydoc/tests *.py
include *.txt
diff --git a/doc/sphinxext/__init__.py b/doc/sphinxext/__init__.py
deleted file mode 100644
index ae9073bc4..000000000
--- a/doc/sphinxext/__init__.py
+++ /dev/null
@@ -1 +0,0 @@
-from numpydoc import setup
diff --git a/doc/sphinxext/numpydoc/__init__.py b/doc/sphinxext/numpydoc/__init__.py
new file mode 100644
index 000000000..68dbbb00a
--- /dev/null
+++ b/doc/sphinxext/numpydoc/__init__.py
@@ -0,0 +1 @@
+from .numpydoc import setup
diff --git a/doc/sphinxext/comment_eater.py b/doc/sphinxext/numpydoc/comment_eater.py
index e11eea902..f84ca6934 100644
--- a/doc/sphinxext/comment_eater.py
+++ b/doc/sphinxext/numpydoc/comment_eater.py
@@ -1,10 +1,15 @@
-from cStringIO import StringIO
+import sys
+if sys.version_info[0] >= 3:
+ from io import StringIO
+else:
+ from cStringIO import StringIO
+
import compiler
import inspect
import textwrap
import tokenize
-from compiler_unparse import unparse
+from .compiler_unparse import unparse
class Comment(object):
@@ -68,7 +73,11 @@ class CommentBlocker(object):
def process_file(self, file):
""" Process a file object.
"""
- for token in tokenize.generate_tokens(file.next):
+ if sys.version_info[0] >= 3:
+ nxt = file.__next__
+ else:
+ nxt = file.next
+ for token in tokenize.generate_tokens(nxt):
self.process_token(*token)
self.make_index()
diff --git a/doc/sphinxext/compiler_unparse.py b/doc/sphinxext/numpydoc/compiler_unparse.py
index ffcf51b35..385f61c58 100644
--- a/doc/sphinxext/compiler_unparse.py
+++ b/doc/sphinxext/numpydoc/compiler_unparse.py
@@ -12,11 +12,15 @@
"""
import sys
-import cStringIO
from compiler.ast import Const, Name, Tuple, Div, Mul, Sub, Add
+if sys.version_info[0] >= 3:
+ from io import StringIO
+else:
+ from cStringIO import StringIO
+
def unparse(ast, single_line_functions=False):
- s = cStringIO.StringIO()
+ s = StringIO()
UnparseCompilerAst(ast, s, single_line_functions)
return s.getvalue().lstrip()
diff --git a/doc/sphinxext/docscrape.py b/doc/sphinxext/numpydoc/docscrape.py
index 2348149ac..6a157a917 100644
--- a/doc/sphinxext/docscrape.py
+++ b/doc/sphinxext/numpydoc/docscrape.py
@@ -2,14 +2,19 @@
"""
+import sys
import inspect
import textwrap
import re
import pydoc
-from StringIO import StringIO
from warnings import warn
import collections
+if sys.version_info[0] >= 3:
+ from io import StringIO
+else:
+ from cStringIO import StringIO
+
class Reader(object):
"""A line-based string reader.
@@ -114,7 +119,7 @@ class NumpyDocString(object):
return self._parsed_data[key]
def __setitem__(self,key,val):
- if not key in self._parsed_data:
+ if key not in self._parsed_data:
warn("Unknown section %s" % key)
else:
self._parsed_data[key] = val
@@ -266,13 +271,17 @@ class NumpyDocString(object):
if self._is_at_section():
return
- summary = self._doc.read_to_next_empty_line()
- summary_str = " ".join([s.strip() for s in summary]).strip()
- if re.compile('^([\w., ]+=)?\s*[\w\.]+\(.*\)$').match(summary_str):
- self['Signature'] = summary_str
- if not self._is_at_section():
- self['Summary'] = self._doc.read_to_next_empty_line()
- else:
+ # If several signatures present, take the last one
+ while True:
+ summary = self._doc.read_to_next_empty_line()
+ summary_str = " ".join([s.strip() for s in summary]).strip()
+ if re.compile('^([\w., ]+=)?\s*[\w\.]+\(.*\)$').match(summary_str):
+ self['Signature'] = summary_str
+ if not self._is_at_section():
+ continue
+ break
+
+ if summary is not None:
self['Summary'] = summary
if not self._is_at_section():
@@ -371,7 +380,7 @@ class NumpyDocString(object):
idx = self['index']
out = []
out += ['.. index:: %s' % idx.get('default','')]
- for section, references in idx.iteritems():
+ for section, references in idx.items():
if section == 'default':
continue
out += [' :%s: %s' % (section, ', '.join(references))]
@@ -451,8 +460,8 @@ class FunctionDoc(NumpyDocString):
'meth': 'method'}
if self._role:
- if not self._role in roles:
- print "Warning: invalid role %s" % 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,''),
func_name)
@@ -482,12 +491,19 @@ class ClassDoc(NumpyDocString):
NumpyDocString.__init__(self, doc)
if config.get('show_class_members', True):
- if not self['Methods']:
- self['Methods'] = [(name, '', '')
- for name in sorted(self.methods)]
- if not self['Attributes']:
- self['Attributes'] = [(name, '', '')
- for name in sorted(self.properties)]
+ def splitlines_x(s):
+ if not s:
+ return []
+ else:
+ return s.splitlines()
+
+ for field, items in [('Methods', self.methods),
+ ('Attributes', self.properties)]:
+ if not self[field]:
+ self[field] = [
+ (name, '',
+ splitlines_x(pydoc.getdoc(getattr(self._cls, name))))
+ for name in sorted(items)]
@property
def methods(self):
@@ -503,4 +519,6 @@ class ClassDoc(NumpyDocString):
if self._cls is None:
return []
return [name for name,func in inspect.getmembers(self._cls)
- if not name.startswith('_') and func is None]
+ if not name.startswith('_') and
+ (func is None or isinstance(func, property) or
+ inspect.isgetsetdescriptor(func))]
diff --git a/doc/sphinxext/docscrape_sphinx.py b/doc/sphinxext/numpydoc/docscrape_sphinx.py
index 273385475..ec0f9482e 100644
--- a/doc/sphinxext/docscrape_sphinx.py
+++ b/doc/sphinxext/numpydoc/docscrape_sphinx.py
@@ -1,7 +1,7 @@
import re, inspect, textwrap, pydoc
import sphinx
-from docscrape import NumpyDocString, FunctionDoc, ClassDoc
import collections
+from .docscrape import NumpyDocString, FunctionDoc, ClassDoc
class SphinxDocString(NumpyDocString):
def __init__(self, docstring, config={}):
@@ -73,7 +73,16 @@ class SphinxDocString(NumpyDocString):
others = []
for param, param_type, desc in self[name]:
param = param.strip()
- if not self._obj or hasattr(self._obj, param):
+
+ # Check if the referenced member can have a docstring or not
+ param_obj = getattr(self._obj, param, None)
+ if not (callable(param_obj)
+ or isinstance(param_obj, property)
+ or inspect.isgetsetdescriptor(param_obj)):
+ param_obj = None
+
+ if param_obj and (pydoc.getdoc(param_obj) or not desc):
+ # Referenced object has a docstring
autosum += [" %s%s" % (prefix, param)]
else:
others.append((param, param_type, desc))
@@ -83,15 +92,15 @@ class SphinxDocString(NumpyDocString):
out += autosum
if others:
- maxlen_0 = max([len(x[0]) for x in others])
- maxlen_1 = max([len(x[1]) for x in others])
- hdr = "="*maxlen_0 + " " + "="*maxlen_1 + " " + "="*10
- fmt = '%%%ds %%%ds ' % (maxlen_0, maxlen_1)
- n_indent = maxlen_0 + maxlen_1 + 4
- out += [hdr]
+ maxlen_0 = max(3, max([len(x[0]) for x in others]))
+ hdr = u"="*maxlen_0 + u" " + u"="*10
+ fmt = u'%%%ds %%s ' % (maxlen_0,)
+ out += ['', hdr]
for param, param_type, desc in others:
- out += [fmt % (param.strip(), param_type)]
- out += self._str_indent(desc, n_indent)
+ desc = u" ".join(x.strip() for x in desc).strip()
+ if param_type:
+ desc = "(%s) %s" % (param_type, desc)
+ out += [fmt % (param.strip(), desc)]
out += [hdr]
out += ['']
return out
@@ -128,7 +137,7 @@ class SphinxDocString(NumpyDocString):
return out
out += ['.. index:: %s' % idx.get('default','')]
- for section, references in idx.iteritems():
+ for section, references in idx.items():
if section == 'default':
continue
elif section == 'refguide':
diff --git a/doc/sphinxext/linkcode.py b/doc/sphinxext/numpydoc/linkcode.py
index f1dffd337..4d3f8d03e 100644
--- a/doc/sphinxext/linkcode.py
+++ b/doc/sphinxext/numpydoc/linkcode.py
@@ -11,8 +11,9 @@
import warnings
import collections
-warnings.warn("This extension has been submitted to Sphinx upstream. "
- "Use the version from there if it is accepted "
+
+warnings.warn("This extension has been accepted to Sphinx upstream. "
+ "Use the version from there (Sphinx >= 1.2) "
"https://bitbucket.org/birkenfeld/sphinx/pull-request/47/sphinxextlinkcode",
FutureWarning, stacklevel=1)
@@ -77,4 +78,4 @@ def doctree_read(app, doctree):
def setup(app):
app.connect('doctree-read', doctree_read)
- app.add_config_value('linkcode_resolve', None, 'env')
+ app.add_config_value('linkcode_resolve', None, '')
diff --git a/doc/sphinxext/numpydoc.py b/doc/sphinxext/numpydoc/numpydoc.py
index dd0c59b8d..cf4172de4 100644
--- a/doc/sphinxext/numpydoc.py
+++ b/doc/sphinxext/numpydoc/numpydoc.py
@@ -22,8 +22,8 @@ import collections
if sphinx.__version__ < '1.0.1':
raise RuntimeError("Sphinx 1.0.1 or newer is required")
-import os, re, pydoc
-from docscrape_sphinx import get_doc_object, SphinxDocString
+import os, sys, re, pydoc
+from .docscrape_sphinx import get_doc_object, SphinxDocString
from sphinx.util.compat import Directive
import inspect
@@ -35,12 +35,16 @@ def mangle_docstrings(app, what, name, obj, options, lines,
if what == 'module':
# Strip top title
- title_re = re.compile(ur'^\s*[#*=]{4,}\n[a-z0-9 -]+\n[#*=]{4,}\s*',
+ title_re = re.compile(u'^\\s*[#*=]{4,}\\n[a-z0-9 -]+\\n[#*=]{4,}\\s*',
re.I|re.S)
lines[:] = title_re.sub(u'', u"\n".join(lines)).split(u"\n")
else:
doc = get_doc_object(obj, what, u"\n".join(lines), config=cfg)
- lines[:] = unicode(doc).split(u"\n")
+ if sys.version_info[0] >= 3:
+ doc = str(doc)
+ else:
+ doc = str(doc).decode('utf-8')
+ lines[:] = doc.split(u"\n")
if app.config.numpydoc_edit_link and hasattr(obj, '__name__') and \
obj.__name__:
@@ -48,7 +52,7 @@ def mangle_docstrings(app, what, name, obj, options, lines,
v = dict(full_name=u"%s.%s" % (obj.__module__, obj.__name__))
else:
v = dict(full_name=obj.__name__)
- lines += [u'', u'.. htmlonly::', '']
+ lines += [u'', u'.. htmlonly::', u'']
lines += [u' %s' % x for x in
(app.config.numpydoc_edit_link % v).split("\n")]
@@ -56,7 +60,7 @@ def mangle_docstrings(app, what, name, obj, options, lines,
references = []
for line in lines:
line = line.strip()
- m = re.match(ur'^.. \[([a-z0-9_.-])\]', line, re.I)
+ m = re.match(u'^.. \\[([a-z0-9_.-])\\]', line, re.I)
if m:
references.append(m.group(1))
@@ -65,7 +69,7 @@ def mangle_docstrings(app, what, name, obj, options, lines,
if references:
for i, line in enumerate(lines):
for r in references:
- if re.match(ur'^\d+$', r):
+ if re.match(u'^\\d+$', r):
new_r = u"R%d" % (reference_offset[0] + int(r))
else:
new_r = u"%s%d" % (r, reference_offset[0])
@@ -92,6 +96,9 @@ def mangle_signature(app, what, name, obj, options, sig, retann):
return sig, u''
def setup(app, get_doc_object_=get_doc_object):
+ if not hasattr(app, 'add_config_value'):
+ return # probably called by nose, better bail out
+
global get_doc_object
get_doc_object = get_doc_object_
@@ -121,7 +128,7 @@ class ManglingDomainBase(object):
self.wrap_mangling_directives()
def wrap_mangling_directives(self):
- for name, objtype in self.directive_mangling_map.items():
+ for name, objtype in list(self.directive_mangling_map.items()):
self.directives[name] = wrap_mangling_directive(
self.directives[name], objtype)
diff --git a/doc/sphinxext/phantom_import.py b/doc/sphinxext/numpydoc/phantom_import.py
index b6cd3af87..c1e1ce1d8 100644
--- a/doc/sphinxext/phantom_import.py
+++ b/doc/sphinxext/numpydoc/phantom_import.py
@@ -23,7 +23,7 @@ def setup(app):
def initialize(app):
fn = app.config.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)
#------------------------------------------------------------------------------
@@ -129,7 +129,10 @@ def import_phantom_module(xml_file):
doc = "%s%s\n\n%s" % (funcname, argspec, doc)
obj = lambda: 0
obj.__argspec_is_invalid_ = True
- obj.__name__ = funcname
+ if sys.version_info[0] >= 3:
+ obj.__name__ = funcname
+ else:
+ obj.func_name = funcname
obj.__name__ = name
obj.__doc__ = doc
if inspect.isclass(object_cache[parent]):
diff --git a/doc/sphinxext/plot_directive.py b/doc/sphinxext/numpydoc/plot_directive.py
index 7fa827664..954fea391 100644
--- a/doc/sphinxext/plot_directive.py
+++ b/doc/sphinxext/numpydoc/plot_directive.py
@@ -75,9 +75,14 @@ TODO
"""
-import sys, os, glob, shutil, imp, warnings, cStringIO, re, textwrap, traceback
+import sys, os, glob, shutil, imp, warnings, re, textwrap, traceback
import sphinx
+if sys.version_info[0] >= 3:
+ from io import StringIO
+else:
+ from cStringIO import StringIO
+
import warnings
warnings.warn("A plot_directive module is also available under "
"matplotlib.sphinxext; expect this numpydoc.plot_directive "
@@ -314,7 +319,7 @@ def run(arguments, content, options, state_machine, state, lineno):
else:
source_code = ""
- opts = [':%s: %s' % (key, val) for key, val in options.items()
+ opts = [':%s: %s' % (key, val) for key, val in list(options.items())
if key in ('alt', 'height', 'width', 'scale', 'align', 'class')]
only_html = ".. only:: html"
@@ -444,7 +449,7 @@ def run_code(code, code_path, ns=None):
# Redirect stdout
stdout = sys.stdout
- sys.stdout = cStringIO.StringIO()
+ sys.stdout = StringIO()
# Reset sys.argv
old_sys_argv = sys.argv
@@ -520,7 +525,7 @@ def makefig(code, code_path, output_dir, output_base, config):
all_exists = True
for i, code_piece in enumerate(code_pieces):
images = []
- for j in xrange(1000):
+ for j in range(1000):
img = ImageFile('%s_%02d_%02d' % (output_base, i, j), output_dir)
for format, dpi in formats:
if out_of_date(code_path, img.filename(format)):
diff --git a/doc/sphinxext/tests/test_docscrape.py b/doc/sphinxext/numpydoc/tests/test_docscrape.py
index 6fab79832..27b0fb60a 100644
--- a/doc/sphinxext/tests/test_docscrape.py
+++ b/doc/sphinxext/numpydoc/tests/test_docscrape.py
@@ -1,10 +1,9 @@
# -*- encoding:utf-8 -*-
-import sys, os
-sys.path.append(os.path.join(os.path.dirname(__file__), '..'))
+import sys, textwrap
-from docscrape import NumpyDocString, FunctionDoc, ClassDoc
-from docscrape_sphinx import SphinxDocString, SphinxClassDoc
+from numpydoc.docscrape import NumpyDocString, FunctionDoc, ClassDoc
+from numpydoc.docscrape_sphinx import SphinxDocString, SphinxClassDoc
from nose.tools import *
doc_txt = '''\
@@ -165,11 +164,12 @@ def test_examples():
def test_index():
assert_equal(doc['index']['default'], 'random')
- print doc['index']
assert_equal(len(doc['index']), 2)
assert_equal(len(doc['index']['refguide']), 2)
def non_blank_line_by_line_compare(a,b):
+ a = textwrap.dedent(a)
+ b = textwrap.dedent(b)
a = [l for l in a.split('\n') if l.strip()]
b = [l for l in b.split('\n') if l.strip()]
for n,line in enumerate(a):
@@ -556,7 +556,11 @@ def test_unicode():
äää
""")
- assert doc['Summary'][0] == u'öäöäöäöäöåååå'.encode('utf-8')
+ assert isinstance(doc['Summary'][0], str)
+ if sys.version_info[0] >= 3:
+ assert doc['Summary'][0] == u'öäöäöäöäöåååå'
+ else:
+ assert doc['Summary'][0] == u'öäöäöäöäöåååå'.encode('utf-8')
def test_plot_examples():
cfg = dict(use_plots=True)
@@ -594,20 +598,149 @@ def test_class_members():
def ham(self, c, d):
"""Cheese\n\nNo cheese."""
pass
+ @property
+ def spammity(self):
+ """Spammity index"""
+ return 0.95
+
+ class Ignorable(object):
+ """local class, to be ignored"""
+ pass
for cls in (ClassDoc, SphinxClassDoc):
doc = cls(Dummy, config=dict(show_class_members=False))
assert 'Methods' not in str(doc), (cls, str(doc))
assert 'spam' not in str(doc), (cls, str(doc))
assert 'ham' not in str(doc), (cls, str(doc))
+ assert 'spammity' not in str(doc), (cls, str(doc))
+ assert 'Spammity index' not in str(doc), (cls, str(doc))
doc = cls(Dummy, config=dict(show_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 '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
+ # docstring itself.
+
+ doc = NumpyDocString(
+ """
+ z(x1, x2)
+
+ z(a, theta)
+ """)
+
+ assert doc['Signature'].strip() == 'z(a, theta)'
+
+
+class_doc_txt = """
+ Foo
+
+ Parameters
+ ----------
+ f : callable ``f(t, y, *f_args)``
+ Aaa.
+ jac : callable ``jac(t, y, *jac_args)``
+ Bbb.
+
+ Attributes
+ ----------
+ t : float
+ Current time.
+ y : ndarray
+ Current variable values.
+
+ Methods
+ -------
+ a
+ b
+ c
+
+ Examples
+ --------
+ For usage examples, see `ode`.
+"""
+
+def test_class_members_doc():
+ doc = ClassDoc(None, class_doc_txt)
+ non_blank_line_by_line_compare(str(doc),
+ """
+ Foo
+
+ Parameters
+ ----------
+ f : callable ``f(t, y, *f_args)``
+ Aaa.
+ jac : callable ``jac(t, y, *jac_args)``
+ Bbb.
+
+ Examples
+ --------
+ For usage examples, see `ode`.
+
+ Attributes
+ ----------
+ t : float
+ Current time.
+ y : ndarray
+ Current variable values.
+
+ Methods
+ -------
+ a :
+
+ b :
+
+ c :
+
+ .. index::
+
+ """)
+
+def test_class_members_doc_sphinx():
+ doc = SphinxClassDoc(None, class_doc_txt)
+ non_blank_line_by_line_compare(str(doc),
+ """
+ Foo
+
+ :Parameters:
+
+ **f** : callable ``f(t, y, *f_args)``
+
+ Aaa.
+
+ **jac** : callable ``jac(t, y, *jac_args)``
+
+ Bbb.
+
+ .. rubric:: Examples
+
+ For usage examples, see `ode`.
+
+ .. rubric:: Attributes
+
+ === ==========
+ t (float) Current time.
+ y (ndarray) Current variable values.
+ === ==========
+
+ .. rubric:: Methods
+
+ === ==========
+ a
+ b
+ c
+ === ==========
+
+ """)
if __name__ == "__main__":
import nose
diff --git a/doc/sphinxext/numpydoc/tests/test_linkcode.py b/doc/sphinxext/numpydoc/tests/test_linkcode.py
new file mode 100644
index 000000000..45de6b70d
--- /dev/null
+++ b/doc/sphinxext/numpydoc/tests/test_linkcode.py
@@ -0,0 +1,3 @@
+import numpydoc.linkcode
+
+# No tests at the moment...
diff --git a/doc/sphinxext/numpydoc/tests/test_phantom_import.py b/doc/sphinxext/numpydoc/tests/test_phantom_import.py
new file mode 100644
index 000000000..b9ee76fc6
--- /dev/null
+++ b/doc/sphinxext/numpydoc/tests/test_phantom_import.py
@@ -0,0 +1,3 @@
+import numpydoc.phantom_import
+
+# No tests at the moment...
diff --git a/doc/sphinxext/numpydoc/tests/test_plot_directive.py b/doc/sphinxext/numpydoc/tests/test_plot_directive.py
new file mode 100644
index 000000000..3496d2c29
--- /dev/null
+++ b/doc/sphinxext/numpydoc/tests/test_plot_directive.py
@@ -0,0 +1,3 @@
+import numpydoc.plot_directive
+
+# No tests at the moment...
diff --git a/doc/sphinxext/numpydoc/tests/test_traitsdoc.py b/doc/sphinxext/numpydoc/tests/test_traitsdoc.py
new file mode 100644
index 000000000..99b1600fb
--- /dev/null
+++ b/doc/sphinxext/numpydoc/tests/test_traitsdoc.py
@@ -0,0 +1,3 @@
+import numpydoc.traitsdoc
+
+# No tests at the moment...
diff --git a/doc/sphinxext/traitsdoc.py b/doc/sphinxext/numpydoc/traitsdoc.py
index 84753b4e5..e63789436 100644
--- a/doc/sphinxext/traitsdoc.py
+++ b/doc/sphinxext/numpydoc/traitsdoc.py
@@ -18,14 +18,13 @@ import inspect
import os
import pydoc
-import docscrape
-import docscrape_sphinx
-from docscrape_sphinx import SphinxClassDoc, SphinxFunctionDoc, SphinxDocString
+from . import docscrape
+from . import docscrape_sphinx
+from .docscrape_sphinx import SphinxClassDoc, SphinxFunctionDoc, SphinxDocString
-import numpydoc
+from . import numpydoc
-import comment_eater
-import collections
+from . import comment_eater
class SphinxTraitsDoc(SphinxClassDoc):
def __init__(self, cls, modulename='', func_doc=SphinxFunctionDoc):
diff --git a/doc/sphinxext/setup.py b/doc/sphinxext/setup.py
index ec6aa3840..3dbcee5c8 100644
--- a/doc/sphinxext/setup.py
+++ b/doc/sphinxext/setup.py
@@ -1,11 +1,16 @@
+import setuptools
from distutils.core import setup
-version = "0.4"
+import sys
+if sys.version_info[0] >= 3 and sys.version_info[1] < 3 or \
+ sys.version_info[0] <= 2 and sys.version_info[1] < 6:
+ raise RuntimeError("Python version 2.6, 2.7 or >= 3.3 required.")
+
+version = "0.4.dev"
setup(
name="numpydoc",
packages=["numpydoc"],
- package_dir={"numpydoc": "."},
version=version,
description="Sphinx extension to support docstrings in Numpy format",
# classifiers from http://pypi.python.org/pypi?%3Aaction=list_classifiers
@@ -20,4 +25,5 @@ setup(
license="BSD",
requires=["sphinx (>= 1.0.1)"],
package_data={'numpydoc': ['tests/test_*.py']},
+ test_suite = 'nose.collector',
)