From f16abaf80b38c6d9f98cd1b7144b793ef6a2d9f9 Mon Sep 17 00:00:00 2001 From: "Gregory R. Lee" Date: Sat, 30 Apr 2016 16:22:21 -0400 Subject: [PATCH 1/6] DOC: python 3 compatibility fixes in doc/tools --- doc/tools/apigen.py | 4 ++-- doc/tools/build_modref_templates.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/doc/tools/apigen.py b/doc/tools/apigen.py index 3b95b3b72b..a64cb50277 100644 --- a/doc/tools/apigen.py +++ b/doc/tools/apigen.py @@ -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) diff --git a/doc/tools/build_modref_templates.py b/doc/tools/build_modref_templates.py index c6b5ecaade..2b1d6990d2 100755 --- a/doc/tools/build_modref_templates.py +++ b/doc/tools/build_modref_templates.py @@ -36,7 +36,7 @@ def abort(error): try: __import__(package) - except ImportError, e: + except ImportError as e: abort("Can not import " + package) module = sys.modules[package] From e5b4851ce3c70b126f1fa416f548415085532b91 Mon Sep 17 00:00:00 2001 From: "Gregory R. Lee" Date: Sat, 30 Apr 2016 16:25:26 -0400 Subject: [PATCH 2/6] STY: PEP8 in doc/tools --- doc/tools/apigen.py | 27 ++++++++++++++------------- doc/tools/build_modref_templates.py | 3 ++- 2 files changed, 16 insertions(+), 14 deletions(-) diff --git a/doc/tools/apigen.py b/doc/tools/apigen.py index a64cb50277..0411529415 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) @@ -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) @@ -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 2b1d6990d2..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) From 5127d5472903f80c7d27b136f2dae2ac9724f148 Mon Sep 17 00:00:00 2001 From: "Gregory R. Lee" Date: Sat, 30 Apr 2016 17:07:30 -0400 Subject: [PATCH 3/6] DOC: fix ImportErrors in apigen.py for Python 3 The fix was copied from scikit-image's version of apigen.py --- doc/tools/apigen.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/tools/apigen.py b/doc/tools/apigen.py index 0411529415..f595192acb 100644 --- a/doc/tools/apigen.py +++ b/doc/tools/apigen.py @@ -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 = [] From 726a8c606709189db0306bc6c4ac17514560f1f5 Mon Sep 17 00:00:00 2001 From: "Gregory R. Lee" Date: Mon, 23 May 2016 21:18:48 -0400 Subject: [PATCH 4/6] BLD: add doctest to Travis matrix --- .travis.yml | 3 +++ 1 file changed, 3 insertions(+) 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 From 545ed3508c303be063a418557fe9b1b5f1c181ab Mon Sep 17 00:00:00 2001 From: "Gregory R. Lee" Date: Wed, 25 May 2016 13:08:11 -0400 Subject: [PATCH 5/6] FIX: remove improper space from import in freesurfer/io.py --- nibabel/freesurfer/io.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 From d4b31e6b17a3f3fa3dba8ab39dcd7af58a8425d4 Mon Sep 17 00:00:00 2001 From: "Gregory R. Lee" Date: Wed, 25 May 2016 13:31:32 -0400 Subject: [PATCH 6/6] DOC: fix path to links_names.txt --- doc/source/dicom/dicom_niftiheader.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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