Skip to content

Commit 6ca8433

Browse files
committed
pull changes from numpydoc
1 parent 37e5b19 commit 6ca8433

File tree

11 files changed

+689
-353
lines changed

11 files changed

+689
-353
lines changed

doc/postprocess.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ def process_tex(lines):
4444
"""
4545
new_lines = []
4646
for line in lines:
47-
line = unicode(line, 'utf-8').replace(u"\00a0", u"~").encode('utf-8')
4847
if (line.startswith(r'\section{numpy.')
4948
or line.startswith(r'\subsection{numpy.')
5049
or line.startswith(r'\subsubsection{numpy.')

doc/source/conf.py

Lines changed: 93 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,30 @@
11
# -*- coding: utf-8 -*-
2-
#
3-
# Quantities documentation build configuration file, created by
4-
# sphinx-quickstart on Fri May 2 12:33:25 2008.
5-
#
6-
# This file is execfile()d with the current directory set to its containing dir.
7-
#
8-
# The contents of this file are pickled, so don't put values in the namespace
9-
# that aren't pickleable (module imports are okay, they're removed automatically).
10-
#
11-
# All configuration values have a default value; values that are commented out
12-
# serve to show the default value.
13-
14-
import sys, os
2+
3+
import sys, os, re
154

165
# Check Sphinx version
176
import sphinx
187
if sphinx.__version__ < "0.5":
198
raise RuntimeError("Sphinx 0.5.dev or newer required")
209

21-
# General configuration
22-
# ---------------------
10+
# -----------------------------------------------------------------------------
11+
# General configuration
12+
# -----------------------------------------------------------------------------
2313

2414
# Add any Sphinx extension module names here, as strings. They can be extensions
2515
# coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
2616

27-
sys.path.append(os.path.abspath('../sphinxext'))
17+
sys.path.insert(0, os.path.abspath('../sphinxext'))
2818

29-
extensions = ['sphinx.ext.autodoc', 'sphinx.ext.pngmath', 'numpydoc',
30-
'sphinx.ext.intersphinx', 'sphinx.ext.coverage',
31-
'only_directives']
19+
extensions = ['sphinx.ext.autodoc', 'sphinx.ext.pngmath', 'numpydoc',
20+
'sphinx.ext.intersphinx', 'sphinx.ext.coverage',
21+
'plot_directive']
3222

3323
if sphinx.__version__ >= "0.7":
3424
extensions.append('sphinx.ext.autosummary')
35-
import glob
36-
autosummary_generate = glob.glob("reference/*.rst")
3725
else:
3826
extensions.append('autosummary')
27+
extensions.append('only_directives')
3928

4029
# Add any paths that contain templates here, relative to this directory.
4130
templates_path = ['_templates']
@@ -69,18 +58,18 @@
6958
# Else, today_fmt is used as the format for a strftime call.
7059
today_fmt = '%B %d, %Y'
7160

72-
# List of directories, relative to source directory, that shouldn't be searched
73-
# for source files.
74-
exclude_trees = ['_build']
61+
# List of documents that shouldn't be included in the build.
62+
#unused_docs = []
7563

7664
# The reST default role (used for this markup: `text`) to use for all documents.
77-
#default_role = None
65+
default_role = 'autolink'
7866

79-
# List of documents that shouldn't be included in the build.
80-
#unused_docs = []
67+
# List of directories, relative to source directories, that shouldn't be searched
68+
# for source files.
69+
exclude_dirs = []
8170

8271
# If true, '()' will be appended to :func: etc. cross-reference text.
83-
#add_function_parentheses = True
72+
add_function_parentheses = False
8473

8574
# If true, the current module name will be prepended to all description
8675
# unit titles (such as .. function::).
@@ -93,12 +82,10 @@
9382
# The name of the Pygments (syntax highlighting) style to use.
9483
pygments_style = 'sphinx'
9584

96-
# A list of ignored prefixes for module index sorting.
97-
#modindex_common_prefix = []
98-
9985

100-
# Options for HTML output
101-
# -----------------------
86+
# -----------------------------------------------------------------------------
87+
# HTML output
88+
# -----------------------------------------------------------------------------
10289

10390
# The style sheet to use for HTML and HTML Help pages. A file of that name
10491
# must exist either in Sphinx' static/ path, or in one of the custom paths
@@ -169,8 +156,9 @@
169156
htmlhelp_basename = 'Quantitiesdoc'
170157

171158

172-
# Options for LaTeX output
173-
# ------------------------
159+
# -----------------------------------------------------------------------------
160+
# LaTeX output
161+
# -----------------------------------------------------------------------------
174162

175163
# The paper size ('letter' or 'a4').
176164
latex_paper_size = 'letter'
@@ -199,8 +187,74 @@
199187

200188
latex_use_parts = True
201189

202-
#############################################################
203-
# numpy extensions
204190

205-
# Edit links
206-
numpydoc_edit_link = '`Edit </numpy/docs/%(full_name)s/>`__'
191+
# -----------------------------------------------------------------------------
192+
# Intersphinx configuration
193+
# -----------------------------------------------------------------------------
194+
intersphinx_mapping = {'http://docs.python.org/dev': None}
195+
196+
197+
# -----------------------------------------------------------------------------
198+
# Numpy extensions
199+
# -----------------------------------------------------------------------------
200+
201+
# If we want to do a phantom import from an XML file for all autodocs
202+
phantom_import_file = 'dump.xml'
203+
204+
# Make numpydoc to generate plots for example sections
205+
numpydoc_use_plots = True
206+
207+
# -----------------------------------------------------------------------------
208+
# Autosummary
209+
# -----------------------------------------------------------------------------
210+
211+
if sphinx.__version__ >= "0.7":
212+
import glob
213+
autosummary_generate = glob.glob("reference/*.rst")
214+
215+
# -----------------------------------------------------------------------------
216+
# Coverage checker
217+
# -----------------------------------------------------------------------------
218+
coverage_ignore_modules = r"""
219+
""".split()
220+
coverage_ignore_functions = r"""
221+
test($|_) (some|all)true bitwise_not cumproduct pkgload
222+
generic\.
223+
""".split()
224+
coverage_ignore_classes = r"""
225+
""".split()
226+
227+
coverage_c_path = []
228+
coverage_c_regexes = {}
229+
coverage_ignore_c_items = {}
230+
231+
232+
# -----------------------------------------------------------------------------
233+
# Plots
234+
# -----------------------------------------------------------------------------
235+
plot_pre_code = """
236+
import numpy as np
237+
np.random.seed(0)
238+
"""
239+
plot_include_source = True
240+
plot_formats = [('png', 100), 'pdf']
241+
242+
import math
243+
phi = (math.sqrt(5) + 1)/2
244+
245+
import matplotlib
246+
matplotlib.rcParams.update({
247+
'font.size': 8,
248+
'axes.titlesize': 8,
249+
'axes.labelsize': 8,
250+
'xtick.labelsize': 8,
251+
'ytick.labelsize': 8,
252+
'legend.fontsize': 8,
253+
'figure.figsize': (3*phi, 3),
254+
'figure.subplot.bottom': 0.2,
255+
'figure.subplot.left': 0.2,
256+
'figure.subplot.right': 0.9,
257+
'figure.subplot.top': 0.85,
258+
'figure.subplot.wspace': 0.4,
259+
'text.usetex': False,
260+
})

doc/source/devel/documenting.rst

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -104,19 +104,6 @@ mind:
104104
105105
\int_{-\infty}^{\infty}\frac{e^{i\phi}}{1+x^2\frac{e^{i\phi}}{1+x^2}}
106106
107-
* Interactive IPython sessions can be illustrated in the documentation using
108-
the following directive::
109-
110-
.. sourcecode:: ipython
111-
112-
In [69]: lines = plot([1,2,3])
113-
114-
which would yield:
115-
116-
.. sourcecode:: ipython
117-
118-
In [69]: lines = plot([1,2,3])
119-
120107
* Footnotes [#]_ can be added using ``[#]_``, followed later by::
121108

122109
.. rubric:: Footnotes

doc/source/reference/intro.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,4 @@ Conversion
1414
.. autosummary::
1515
:toctree: generated/
1616

17-
Quantity.astype
17+
.. Quantity.astype

doc/sphinxext/autosummary.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,11 @@ def append_row(*column_texts):
210210
vl = ViewList()
211211
vl.append(text, '<autosummary>')
212212
state.nested_parse(vl, 0, node)
213+
try:
214+
if isinstance(node[0], nodes.paragraph):
215+
node = node[0]
216+
except IndexError:
217+
pass
213218
row.append(nodes.entry('', node))
214219
body.append(row)
215220

doc/sphinxext/docscrape.py

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import pydoc
99
from StringIO import StringIO
1010
from warnings import warn
11-
4
11+
1212
class Reader(object):
1313
"""A line-based string reader.
1414
@@ -386,6 +386,8 @@ def __str__(self, func_role=''):
386386
out += self._str_see_also(func_role)
387387
for s in ('Notes','References','Examples'):
388388
out += self._str_section(s)
389+
for param_list in ('Attributes', 'Methods'):
390+
out += self._str_param_list(param_list)
389391
out += self._str_index()
390392
return '\n'.join(out)
391393

@@ -477,21 +479,19 @@ def __init__(self,cls,modulename='',func_doc=FunctionDoc,doc=None):
477479

478480
NumpyDocString.__init__(self, doc)
479481

482+
if not self['Methods']:
483+
self['Methods'] = [(name, '', '') for name in sorted(self.methods)]
484+
485+
if not self['Attributes']:
486+
self['Attributes'] = [(name, '', '')
487+
for name in sorted(self.properties)]
488+
480489
@property
481490
def methods(self):
482491
return [name for name,func in inspect.getmembers(self._cls)
483492
if not name.startswith('_') and callable(func)]
484493

485-
def __str__(self):
486-
out = ''
487-
out += super(ClassDoc, self).__str__()
488-
out += "\n\n"
489-
490-
#for m in self.methods:
491-
# print "Parsing `%s`" % m
492-
# out += str(self._func_doc(getattr(self._cls,m), 'meth')) + '\n\n'
493-
# out += '.. index::\n single: %s; %s\n\n' % (self._name, m)
494-
495-
return out
496-
497-
494+
@property
495+
def properties(self):
496+
return [name for name,func in inspect.getmembers(self._cls)
497+
if not name.startswith('_') and func is None]

0 commit comments

Comments
 (0)