Skip to content

Commit 5549388

Browse files
committed
Merge pull request nipy#444 from satra/enh/travis
Enh/travis
2 parents e8a9d85 + af0fb10 commit 5549388

File tree

2 files changed

+60
-66
lines changed

2 files changed

+60
-66
lines changed

Makefile

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,8 @@
55
PYTHON ?= python
66
NOSETESTS ?= nosetests
77

8-
zipdoc:
9-
@echo "Clean documentation directory."
10-
python setup.py clean
11-
@echo "Build documentation.zip..."
12-
python setup.py build_sphinx
13-
@echo "Clean documentation directory."
14-
python setup.py clean
8+
zipdoc: html
9+
zip documentation.zip doc/_build/html
1510

1611
sdist: zipdoc
1712
@echo "Building source distribution..."
@@ -75,6 +70,3 @@ check-before-commit: trailing-spaces html test
7570
@echo "removed spaces"
7671
@echo "built docs"
7772
@echo "ran test"
78-
79-
80-

build_docs.py

Lines changed: 58 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,6 @@
1818
from distutils.cmd import Command
1919
from distutils.command.clean import clean
2020

21-
# Sphinx import.
22-
from sphinx.setup_command import BuildDoc
23-
2421
_info_fname = pjoin(os.path.dirname(__file__), 'nipype', 'info.py')
2522
INFO_VARS = {}
2623
exec(open(_info_fname, 'rt').read(), {}, INFO_VARS)
@@ -104,61 +101,66 @@ def relative_path(filename):
104101

105102
################################################################################
106103
# Distutils Command class build the docs
107-
class MyBuildDoc(BuildDoc):
108-
""" Sub-class the standard sphinx documentation building system, to
109-
add logics for API generation and matplotlib's plot directive.
110-
"""
111-
112-
def run(self):
113-
self.run_command('api_docs')
114-
# We need to be in the doc directory for to plot_directive
115-
# and API generation to work
116-
"""
117-
os.chdir('doc')
118-
try:
119-
BuildDoc.run(self)
120-
finally:
121-
os.chdir('..')
122-
"""
123-
# It put's the build in a doc/doc/_build directory with the
124-
# above?!?! I'm leaving the code above here but commented out
125-
# in case I'm missing something?
126-
BuildDoc.run(self)
127-
self.zip_docs()
128-
129-
def zip_docs(self):
130-
if not os.path.exists(DOC_BUILD_DIR):
131-
raise OSError, 'Doc directory does not exist.'
132-
target_file = os.path.join('doc', 'documentation.zip')
133-
# ZIP_DEFLATED actually compresses the archive. However, there
134-
# will be a RuntimeError if zlib is not installed, so we check
135-
# for it. ZIP_STORED produces an uncompressed zip, but does not
136-
# require zlib.
137-
try:
138-
zf = zipfile.ZipFile(target_file, 'w',
139-
compression=zipfile.ZIP_DEFLATED)
140-
except RuntimeError:
141-
warnings.warn('zlib not installed, storing the docs '
142-
'without compression')
143-
zf = zipfile.ZipFile(target_file, 'w',
144-
compression=zipfile.ZIP_STORED)
145-
146-
for root, dirs, files in os.walk(DOC_BUILD_DIR):
147-
relative = relative_path(root)
148-
if not relative.startswith('.doctrees'):
149-
for f in files:
150-
zf.write(os.path.join(root, f),
151-
os.path.join(relative, 'html_docs', f))
152-
zf.close()
153-
154-
155-
def finalize_options(self):
156-
""" Override the default for the documentation build
157-
directory.
104+
# Sphinx import.
105+
try:
106+
from sphinx.setup_command import BuildDoc
107+
except:
108+
MyBuildDoc = None
109+
else:
110+
class MyBuildDoc(BuildDoc):
111+
""" Sub-class the standard sphinx documentation building system, to
112+
add logics for API generation and matplotlib's plot directive.
158113
"""
159-
self.build_dir = os.path.join(*DOC_BUILD_DIR.split(os.sep)[:-1])
160-
BuildDoc.finalize_options(self)
161114

115+
def run(self):
116+
self.run_command('api_docs')
117+
# We need to be in the doc directory for to plot_directive
118+
# and API generation to work
119+
"""
120+
os.chdir('doc')
121+
try:
122+
BuildDoc.run(self)
123+
finally:
124+
os.chdir('..')
125+
"""
126+
# It put's the build in a doc/doc/_build directory with the
127+
# above?!?! I'm leaving the code above here but commented out
128+
# in case I'm missing something?
129+
BuildDoc.run(self)
130+
self.zip_docs()
131+
132+
def zip_docs(self):
133+
if not os.path.exists(DOC_BUILD_DIR):
134+
raise OSError, 'Doc directory does not exist.'
135+
target_file = os.path.join('doc', 'documentation.zip')
136+
# ZIP_DEFLATED actually compresses the archive. However, there
137+
# will be a RuntimeError if zlib is not installed, so we check
138+
# for it. ZIP_STORED produces an uncompressed zip, but does not
139+
# require zlib.
140+
try:
141+
zf = zipfile.ZipFile(target_file, 'w',
142+
compression=zipfile.ZIP_DEFLATED)
143+
except RuntimeError:
144+
warnings.warn('zlib not installed, storing the docs '
145+
'without compression')
146+
zf = zipfile.ZipFile(target_file, 'w',
147+
compression=zipfile.ZIP_STORED)
148+
149+
for root, dirs, files in os.walk(DOC_BUILD_DIR):
150+
relative = relative_path(root)
151+
if not relative.startswith('.doctrees'):
152+
for f in files:
153+
zf.write(os.path.join(root, f),
154+
os.path.join(relative, 'html_docs', f))
155+
zf.close()
156+
157+
158+
def finalize_options(self):
159+
""" Override the default for the documentation build
160+
directory.
161+
"""
162+
self.build_dir = os.path.join(*DOC_BUILD_DIR.split(os.sep)[:-1])
163+
BuildDoc.finalize_options(self)
162164

163165
################################################################################
164166
# Distutils Command class to clean

0 commit comments

Comments
 (0)