Skip to content

Commit 7e41691

Browse files
committed
Merge pull request #450 from grlee77/docfix
MRG: allow building docs with Python 3
2 parents 7b9b83c + d4b31e6 commit 7e41691

File tree

5 files changed

+25
-20
lines changed

5 files changed

+25
-20
lines changed

.travis.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,9 @@ matrix:
7676
- python: 3.5
7777
env:
7878
- STYLE=1
79+
- python: 3.5
80+
env:
81+
- DOC_DOC_TEST=1
7982
before_install:
8083
- source tools/travis_tools.sh
8184
- virtualenv --python=python venv

doc/source/dicom/dicom_niftiheader.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,4 +70,4 @@ Optional Dependency Note: If pydicom is not installed, nibabel uses a generic
7070
7171
.. _`NIfTI Extensions Standard`: http://nifti.nimh.nih.gov/nifti-1/documentation/nifti1fields/nifti1fields_pages/extension.html
7272
73-
.. include:: links_names.txt
73+
.. include:: ../links_names.txt

doc/tools/apigen.py

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ def __init__(self,
4040
rst_extension='.txt',
4141
package_skip_patterns=None,
4242
module_skip_patterns=None,
43-
other_defines = True
43+
other_defines=True
4444
):
4545
''' Initialize package for parsing
4646
@@ -162,7 +162,7 @@ def _uri2path(self, uri):
162162
path = path.replace('.', os.path.sep)
163163
path = os.path.join(self.root_path, path)
164164
# XXX maybe check for extensions as well?
165-
if os.path.exists(path + '.py'): # file
165+
if os.path.exists(path + '.py'): # file
166166
path += '.py'
167167
elif os.path.exists(os.path.join(path, '__init__.py')):
168168
path = os.path.join(path, '__init__.py')
@@ -184,7 +184,7 @@ def _parse_module(self, uri):
184184
if filename is None:
185185
print(filename, 'erk')
186186
# nothing that we could handle here.
187-
return ([],[])
187+
return ([], [])
188188

189189
f = open(filename, 'rt')
190190
functions, classes = self._parse_lines(f)
@@ -207,7 +207,7 @@ def _parse_module_with_import(self, uri):
207207
classes : list of str
208208
A list of (public) class names in the module.
209209
"""
210-
mod = __import__(uri, fromlist=[uri])
210+
mod = __import__(uri, fromlist=[uri.split('.')[-1]])
211211
# find all public objects in the module.
212212
obj_strs = [obj for obj in dir(mod) if not obj.startswith('_')]
213213
functions = []
@@ -276,7 +276,7 @@ def generate_api_doc(self, uri):
276276

277277
# Make a shorter version of the uri that omits the package name for
278278
# titles
279-
uri_short = re.sub(r'^%s\.' % self.package_name,'',uri)
279+
uri_short = re.sub(r'^%s\.' % self.package_name, '', uri)
280280

281281
head = '.. AUTO-GENERATED FILE -- DO NOT EDIT!\n\n'
282282
body = ''
@@ -300,10 +300,10 @@ def generate_api_doc(self, uri):
300300
body += '\n.. autoclass:: ' + c + '\n'
301301
# must NOT exclude from index to keep cross-refs working
302302
body += ' :members:\n' \
303-
' :undoc-members:\n' \
304-
' :show-inheritance:\n' \
305-
'\n' \
306-
' .. automethod:: __init__\n\n'
303+
' :undoc-members:\n' \
304+
' :show-inheritance:\n' \
305+
'\n' \
306+
' .. automethod:: __init__\n\n'
307307
head += '.. autosummary::\n\n'
308308
for f in classes + functions:
309309
head += ' ' + f + '\n'
@@ -402,7 +402,7 @@ def discover_modules(self):
402402
package_uri = '.'.join((root_uri, subpkg_name))
403403
package_path = self._uri2path(package_uri)
404404
if (package_path and
405-
self._survives_exclude(package_uri, 'package')):
405+
self._survives_exclude(package_uri, 'package')):
406406
modules.append(package_uri)
407407

408408
return sorted(modules)
@@ -425,12 +425,12 @@ def write_modules_api(self, modules, outdir):
425425
written_modules = []
426426

427427
for ulm, mods in module_by_ulm.items():
428-
print "Generating docs for %s:" % ulm
428+
print("Generating docs for %s:" % ulm)
429429
document_head = []
430430
document_body = []
431431

432432
for m in mods:
433-
print " -> " + m
433+
print(" -> " + m)
434434
head, body = self.generate_api_doc(m)
435435

436436
document_head.append(head)
@@ -467,7 +467,7 @@ def write_api_docs(self, outdir):
467467
os.mkdir(outdir)
468468
# compose list of modules
469469
modules = self.discover_modules()
470-
self.write_modules_api(modules,outdir)
470+
self.write_modules_api(modules, outdir)
471471

472472
def write_index(self, outdir, froot='gen', relative_to=None):
473473
"""Make a reST API index file from written files
@@ -493,10 +493,11 @@ def write_index(self, outdir, froot='gen', relative_to=None):
493493
path = os.path.join(outdir, froot+self.rst_extension)
494494
# Path written into index is relative to rootpath
495495
if relative_to is not None:
496-
relpath = (outdir + os.path.sep).replace(relative_to + os.path.sep, '')
496+
relpath = (
497+
outdir + os.path.sep).replace(relative_to + os.path.sep, '')
497498
else:
498499
relpath = outdir
499-
idx = open(path,'wt')
500+
idx = open(path, 'wt')
500501
w = idx.write
501502
w('.. AUTO-GENERATED FILE -- DO NOT EDIT!\n\n')
502503

@@ -505,5 +506,5 @@ def write_index(self, outdir, froot='gen', relative_to=None):
505506
w("=" * len(title) + "\n\n")
506507
w('.. toctree::\n\n')
507508
for f in self.written_modules:
508-
w(' %s\n' % os.path.join(relpath,f))
509+
w(' %s\n' % os.path.join(relpath, f))
509510
idx.close()

doc/tools/build_modref_templates.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@
1414
# version comparison
1515
from distutils.version import LooseVersion as V
1616

17-
#*****************************************************************************
17+
# *****************************************************************************
18+
1819

1920
def abort(error):
2021
print('*WARNING* API documentation not generated: %s' % error)
@@ -36,7 +37,7 @@ def abort(error):
3637

3738
try:
3839
__import__(package)
39-
except ImportError, e:
40+
except ImportError as e:
4041
abort("Can not import " + package)
4142

4243
module = sys.modules[package]

nibabel/freesurfer/io.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import time
66

77

8-
from .. externals.six.moves import xrange
8+
from ..externals.six.moves import xrange
99
from ..openers import Opener
1010

1111

0 commit comments

Comments
 (0)