Skip to content

Commit c9013b8

Browse files
Merge pull request #6003 from jorisvandenbossche/numpydoc
DOC: update numpydoc to current master (commit 223df02530)
2 parents c44143f + 9a4e932 commit c9013b8

21 files changed

+762
-592
lines changed

doc/sphinxext/MANIFEST.in

-2
This file was deleted.

doc/sphinxext/__init__.py

-1
This file was deleted.

doc/sphinxext/LICENSE.txt renamed to doc/sphinxext/numpydoc/LICENSE.txt

+2-5
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
-------------------------------------------------------------------------------
22
The files
33
- numpydoc.py
4-
- autosummary.py
5-
- autosummary_generate.py
64
- docscrape.py
75
- docscrape_sphinx.py
86
- phantom_import.py
@@ -71,10 +69,9 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
7169

7270

7371
-------------------------------------------------------------------------------
74-
The files
75-
- only_directives.py
72+
The file
7673
- plot_directive.py
77-
originate from Matplotlib (http://matplotlib.sf.net/) which has
74+
originates from Matplotlib (http://matplotlib.sf.net/) which has
7875
the following license:
7976

8077
Copyright (c) 2002-2008 John D. Hunter; All Rights Reserved.

doc/sphinxext/README.txt renamed to doc/sphinxext/numpydoc/README.rst

+7-8
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,10 @@ The following extensions are available:
1414

1515
- ``numpydoc.traitsdoc``: For gathering documentation about Traits attributes.
1616

17-
- ``numpydoc.plot_directives``: Adaptation of Matplotlib's ``plot::``
17+
- ``numpydoc.plot_directive``: Adaptation of Matplotlib's ``plot::``
1818
directive. Note that this implementation may still undergo severe
1919
changes or eventually be deprecated.
2020

21-
- ``numpydoc.only_directives``: (DEPRECATED)
22-
23-
- ``numpydoc.autosummary``: (DEPRECATED) An ``autosummary::`` directive.
24-
Available in Sphinx 0.6.2 and (to-be) 1.0 as ``sphinx.ext.autosummary``,
25-
and it the Sphinx 1.0 version is recommended over that included in
26-
Numpydoc.
27-
2821

2922
numpydoc
3023
========
@@ -47,6 +40,12 @@ The following options can be set in conf.py:
4740
Whether to show all members of a class in the Methods and Attributes
4841
sections automatically.
4942

43+
- numpydoc_class_members_toctree: bool
44+
45+
Whether to create a Sphinx table of contents for the lists of class
46+
methods and attributes. If a table of contents is made, Sphinx expects
47+
each entry to have a separate page.
48+
5049
- numpydoc_edit_link: bool (DEPRECATED -- edit your HTML template instead)
5150

5251
Whether to insert an edit link after docstrings.

doc/sphinxext/numpydoc/__init__.py

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
from __future__ import division, absolute_import, print_function
2+
3+
from .numpydoc import setup

doc/sphinxext/comment_eater.py renamed to doc/sphinxext/numpydoc/comment_eater.py

+19-15
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,29 @@
1-
from cStringIO import StringIO
1+
from __future__ import division, absolute_import, print_function
2+
3+
import sys
4+
if sys.version_info[0] >= 3:
5+
from io import StringIO
6+
else:
7+
from io import StringIO
8+
29
import compiler
310
import inspect
411
import textwrap
512
import tokenize
613

7-
from compiler_unparse import unparse
14+
from .compiler_unparse import unparse
815

916

1017
class Comment(object):
11-
1218
""" A comment block.
1319
"""
1420
is_comment = True
15-
1621
def __init__(self, start_lineno, end_lineno, text):
1722
# int : The first line number in the block. 1-indexed.
1823
self.start_lineno = start_lineno
1924
# int : The last line number. Inclusive!
2025
self.end_lineno = end_lineno
21-
# str : The text block including '#' character but not any leading
22-
# spaces.
26+
# str : The text block including '#' character but not any leading spaces.
2327
self.text = text
2428

2529
def add(self, string, start, end, line):
@@ -31,15 +35,13 @@ def add(self, string, start, end, line):
3135

3236
def __repr__(self):
3337
return '%s(%r, %r, %r)' % (self.__class__.__name__, self.start_lineno,
34-
self.end_lineno, self.text)
38+
self.end_lineno, self.text)
3539

3640

3741
class NonComment(object):
38-
3942
""" A non-comment block of code.
4043
"""
4144
is_comment = False
42-
4345
def __init__(self, start_lineno, end_lineno):
4446
self.start_lineno = start_lineno
4547
self.end_lineno = end_lineno
@@ -54,14 +56,12 @@ def add(self, string, start, end, line):
5456

5557
def __repr__(self):
5658
return '%s(%r, %r)' % (self.__class__.__name__, self.start_lineno,
57-
self.end_lineno)
59+
self.end_lineno)
5860

5961

6062
class CommentBlocker(object):
61-
6263
""" Pull out contiguous comment blocks.
6364
"""
64-
6565
def __init__(self):
6666
# Start with a dummy.
6767
self.current_block = NonComment(0, 0)
@@ -75,7 +75,11 @@ def __init__(self):
7575
def process_file(self, file):
7676
""" Process a file object.
7777
"""
78-
for token in tokenize.generate_tokens(file.next):
78+
if sys.version_info[0] >= 3:
79+
nxt = file.__next__
80+
else:
81+
nxt = file.next
82+
for token in tokenize.generate_tokens(nxt):
7983
self.process_token(*token)
8084
self.make_index()
8185

@@ -160,6 +164,6 @@ def get_class_traits(klass):
160164
if isinstance(node, compiler.ast.Assign):
161165
name = node.nodes[0].name
162166
rhs = unparse(node.expr).strip()
163-
doc = strip_comment_marker(
164-
cb.search_for_comment(node.lineno, default=''))
167+
doc = strip_comment_marker(cb.search_for_comment(node.lineno, default=''))
165168
yield name, rhs, doc
169+

0 commit comments

Comments
 (0)