execute_command('python setup.py build_sphinx') execute_command('sphinxtogithub doc/build/html --verbose') orig_cwd = os.getcwd() clone = GitClone() with clone as clone_dir: execute_command('git clean -fdx') with inbranch('gh-pages'): doc_dir = os.path.join('doc', ver) if os.path.exists(doc_dir): warning("Documentation for version '" + ver + "' already exists.") if not maybe_continue('y'): sys.exit(-1) execute_command('git rm -rf ' + doc_dir) shutil.copytree(os.path.join(orig_cwd, 'doc', 'build', 'html'), doc_dir) p = re.compile('\d*[.]\d*[.]\d*') with open('doc/index.html', 'r') as f: redirect = f.read() redirect = p.sub(ver, redirect) with open('doc/index.html', 'w+') as f: f.write(redirect) execute_command('git add -f ' + os.path.join('doc', ver, '*')) execute_command('git add -f doc/index.html') if has_changes(): execute_command('git commit -m "Uploading documentation for ' 'version {0}"'.format(ver)) execute_command('git clean -fdx') clone.commit() clone.clean_up()