Skip to content

DOC: update numpydoc to current master (commit 223df02530) #6003

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

Merged
merged 2 commits into from
Jan 24, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions doc/sphinxext/MANIFEST.in

This file was deleted.

1 change: 0 additions & 1 deletion doc/sphinxext/__init__.py

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
-------------------------------------------------------------------------------
The files
- numpydoc.py
- autosummary.py
- autosummary_generate.py
- docscrape.py
- docscrape_sphinx.py
- phantom_import.py
Expand Down Expand Up @@ -71,10 +69,9 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.


-------------------------------------------------------------------------------
The files
- only_directives.py
The file
- plot_directive.py
originate from Matplotlib (http://matplotlib.sf.net/) which has
originates from Matplotlib (http://matplotlib.sf.net/) which has
the following license:

Copyright (c) 2002-2008 John D. Hunter; All Rights Reserved.
Expand Down
15 changes: 7 additions & 8 deletions doc/sphinxext/README.txt → doc/sphinxext/numpydoc/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,10 @@ The following extensions are available:

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

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

- ``numpydoc.only_directives``: (DEPRECATED)

- ``numpydoc.autosummary``: (DEPRECATED) An ``autosummary::`` directive.
Available in Sphinx 0.6.2 and (to-be) 1.0 as ``sphinx.ext.autosummary``,
and it the Sphinx 1.0 version is recommended over that included in
Numpydoc.


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

- 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.

- numpydoc_edit_link: bool (DEPRECATED -- edit your HTML template instead)

Whether to insert an edit link after docstrings.
3 changes: 3 additions & 0 deletions doc/sphinxext/numpydoc/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from __future__ import division, absolute_import, print_function

from .numpydoc import setup
Original file line number Diff line number Diff line change
@@ -1,25 +1,29 @@
from cStringIO import StringIO
from __future__ import division, absolute_import, print_function

import sys
if sys.version_info[0] >= 3:
from io import StringIO
else:
from io import StringIO

import compiler
import inspect
import textwrap
import tokenize

from compiler_unparse import unparse
from .compiler_unparse import unparse


class Comment(object):

""" A comment block.
"""
is_comment = True

def __init__(self, start_lineno, end_lineno, text):
# int : The first line number in the block. 1-indexed.
self.start_lineno = start_lineno
# int : The last line number. Inclusive!
self.end_lineno = end_lineno
# str : The text block including '#' character but not any leading
# spaces.
# str : The text block including '#' character but not any leading spaces.
self.text = text

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

def __repr__(self):
return '%s(%r, %r, %r)' % (self.__class__.__name__, self.start_lineno,
self.end_lineno, self.text)
self.end_lineno, self.text)


class NonComment(object):

""" A non-comment block of code.
"""
is_comment = False

def __init__(self, start_lineno, end_lineno):
self.start_lineno = start_lineno
self.end_lineno = end_lineno
Expand All @@ -54,14 +56,12 @@ def add(self, string, start, end, line):

def __repr__(self):
return '%s(%r, %r)' % (self.__class__.__name__, self.start_lineno,
self.end_lineno)
self.end_lineno)


class CommentBlocker(object):

""" Pull out contiguous comment blocks.
"""

def __init__(self):
# Start with a dummy.
self.current_block = NonComment(0, 0)
Expand All @@ -75,7 +75,11 @@ def __init__(self):
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()

Expand Down Expand Up @@ -160,6 +164,6 @@ def get_class_traits(klass):
if isinstance(node, compiler.ast.Assign):
name = node.nodes[0].name
rhs = unparse(node.expr).strip()
doc = strip_comment_marker(
cb.search_for_comment(node.lineno, default=''))
doc = strip_comment_marker(cb.search_for_comment(node.lineno, default=''))
yield name, rhs, doc

Loading