diff --git a/.travis.yml b/.travis.yml index 08f976869e..5e4fc0389e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -76,6 +76,9 @@ matrix: - python: 3.5 env: - STYLE=1 + - python: 3.5 + env: + - DOC_DOC_TEST=1 before_install: - source tools/travis_tools.sh - virtualenv --python=python venv diff --git a/doc/source/dicom/dicom_niftiheader.rst b/doc/source/dicom/dicom_niftiheader.rst index 8e973937ff..a16ead7f20 100644 --- a/doc/source/dicom/dicom_niftiheader.rst +++ b/doc/source/dicom/dicom_niftiheader.rst @@ -70,4 +70,4 @@ Optional Dependency Note: If pydicom is not installed, nibabel uses a generic .. _`NIfTI Extensions Standard`: http://nifti.nimh.nih.gov/nifti-1/documentation/nifti1fields/nifti1fields_pages/extension.html -.. include:: links_names.txt +.. include:: ../links_names.txt diff --git a/doc/tools/apigen.py b/doc/tools/apigen.py index 3b95b3b72b..f595192acb 100644 --- a/doc/tools/apigen.py +++ b/doc/tools/apigen.py @@ -40,7 +40,7 @@ def __init__(self, rst_extension='.txt', package_skip_patterns=None, module_skip_patterns=None, - other_defines = True + other_defines=True ): ''' Initialize package for parsing @@ -162,7 +162,7 @@ def _uri2path(self, uri): path = path.replace('.', os.path.sep) path = os.path.join(self.root_path, path) # XXX maybe check for extensions as well? - if os.path.exists(path + '.py'): # file + if os.path.exists(path + '.py'): # file path += '.py' elif os.path.exists(os.path.join(path, '__init__.py')): path = os.path.join(path, '__init__.py') @@ -184,7 +184,7 @@ def _parse_module(self, uri): if filename is None: print(filename, 'erk') # nothing that we could handle here. - return ([],[]) + return ([], []) f = open(filename, 'rt') functions, classes = self._parse_lines(f) @@ -207,7 +207,7 @@ def _parse_module_with_import(self, uri): classes : list of str A list of (public) class names in the module. """ - mod = __import__(uri, fromlist=[uri]) + mod = __import__(uri, fromlist=[uri.split('.')[-1]]) # find all public objects in the module. obj_strs = [obj for obj in dir(mod) if not obj.startswith('_')] functions = [] @@ -276,7 +276,7 @@ def generate_api_doc(self, uri): # Make a shorter version of the uri that omits the package name for # titles - uri_short = re.sub(r'^%s\.' % self.package_name,'',uri) + uri_short = re.sub(r'^%s\.' % self.package_name, '', uri) head = '.. AUTO-GENERATED FILE -- DO NOT EDIT!\n\n' body = '' @@ -300,10 +300,10 @@ def generate_api_doc(self, uri): body += '\n.. autoclass:: ' + c + '\n' # must NOT exclude from index to keep cross-refs working body += ' :members:\n' \ - ' :undoc-members:\n' \ - ' :show-inheritance:\n' \ - '\n' \ - ' .. automethod:: __init__\n\n' + ' :undoc-members:\n' \ + ' :show-inheritance:\n' \ + '\n' \ + ' .. automethod:: __init__\n\n' head += '.. autosummary::\n\n' for f in classes + functions: head += ' ' + f + '\n' @@ -402,7 +402,7 @@ def discover_modules(self): package_uri = '.'.join((root_uri, subpkg_name)) package_path = self._uri2path(package_uri) if (package_path and - self._survives_exclude(package_uri, 'package')): + self._survives_exclude(package_uri, 'package')): modules.append(package_uri) return sorted(modules) @@ -425,12 +425,12 @@ def write_modules_api(self, modules, outdir): written_modules = [] for ulm, mods in module_by_ulm.items(): - print "Generating docs for %s:" % ulm + print("Generating docs for %s:" % ulm) document_head = [] document_body = [] for m in mods: - print " -> " + m + print(" -> " + m) head, body = self.generate_api_doc(m) document_head.append(head) @@ -467,7 +467,7 @@ def write_api_docs(self, outdir): os.mkdir(outdir) # compose list of modules modules = self.discover_modules() - self.write_modules_api(modules,outdir) + self.write_modules_api(modules, outdir) def write_index(self, outdir, froot='gen', relative_to=None): """Make a reST API index file from written files @@ -493,10 +493,11 @@ def write_index(self, outdir, froot='gen', relative_to=None): path = os.path.join(outdir, froot+self.rst_extension) # Path written into index is relative to rootpath if relative_to is not None: - relpath = (outdir + os.path.sep).replace(relative_to + os.path.sep, '') + relpath = ( + outdir + os.path.sep).replace(relative_to + os.path.sep, '') else: relpath = outdir - idx = open(path,'wt') + idx = open(path, 'wt') w = idx.write w('.. AUTO-GENERATED FILE -- DO NOT EDIT!\n\n') @@ -505,5 +506,5 @@ def write_index(self, outdir, froot='gen', relative_to=None): w("=" * len(title) + "\n\n") w('.. toctree::\n\n') for f in self.written_modules: - w(' %s\n' % os.path.join(relpath,f)) + w(' %s\n' % os.path.join(relpath, f)) idx.close() diff --git a/doc/tools/build_modref_templates.py b/doc/tools/build_modref_templates.py index c6b5ecaade..7d1c5a7487 100755 --- a/doc/tools/build_modref_templates.py +++ b/doc/tools/build_modref_templates.py @@ -14,7 +14,8 @@ # version comparison from distutils.version import LooseVersion as V -#***************************************************************************** +# ***************************************************************************** + def abort(error): print('*WARNING* API documentation not generated: %s' % error) @@ -36,7 +37,7 @@ def abort(error): try: __import__(package) - except ImportError, e: + except ImportError as e: abort("Can not import " + package) module = sys.modules[package] diff --git a/nibabel/freesurfer/io.py b/nibabel/freesurfer/io.py index 6ccdef5f12..2ac5592090 100644 --- a/nibabel/freesurfer/io.py +++ b/nibabel/freesurfer/io.py @@ -5,7 +5,7 @@ import time -from .. externals.six.moves import xrange +from ..externals.six.moves import xrange from ..openers import Opener