def run(self):
if self.test:
path = "docs/_build/doctest"
mode = "doctest"
else:
path = "docs/_build/%s" % __version__
mode = "html"
try:
os.makedirs(path)
except:
pass
if has_subprocess:
# Prevent run with in-place extensions because cython-generated objects do not carry docstrings
# http://docs.cython.org/src/userguide/special_methods.html#docstrings
import glob
for f in glob.glob("cassandra/*.so"):
print("Removing '%s' to allow docs to run on pure python modules." %(f,))
os.unlink(f)
# Build io extension to make import and docstrings work
try:
output = subprocess.check_output(
["python", "setup.py", "build_ext", "--inplace", "--force", "--no-murmur3", "--no-cython"],
stderr=subprocess.STDOUT)
except subprocess.CalledProcessError as exc:
raise RuntimeError("Documentation step '%s' failed: %s: %s" % ("build_ext", exc, exc.output))
else:
print(output)
try:
output = subprocess.check_output(
["sphinx-build", "-b", mode, "docs", path],
stderr=subprocess.STDOUT)
except subprocess.CalledProcessError as exc:
raise RuntimeError("Documentation step '%s' failed: %s: %s" % (mode, exc, exc.output))
else:
print(output)
print("")
print("Documentation step '%s' performed, results here:" % mode)
print(" file://%s/%s/index.html" % (os.path.dirname(os.path.realpath(__file__)), path))
评论列表
文章目录