From 16bdd8424f14cc1f02841f73a5d243ec6307351b Mon Sep 17 00:00:00 2001 From: Victor Zverovich Date: Sat, 1 Jul 2017 07:30:51 -0700 Subject: [PATCH] Update scripts --- doc/build.py | 6 ++++-- support/manage.py | 19 ++++++++++++------- 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/doc/build.py b/doc/build.py index 55992b9f..22e734ca 100755 --- a/doc/build.py +++ b/doc/build.py @@ -6,6 +6,8 @@ import errno, os, shutil, sys, tempfile from subprocess import check_call, check_output, CalledProcessError, Popen, PIPE from distutils.version import LooseVersion +versions = ['1.0.0', '1.1.0', '2.0.0', '3.0.2', '4.0.0'] + def pip_install(package, commit=None, **kwargs): "Install package using pip." min_version = kwargs.get('min_version') @@ -93,11 +95,11 @@ def build_docs(version='dev', **kwargs): if p.returncode != 0: raise CalledProcessError(p.returncode, cmd) html_dir = os.path.join(work_dir, 'html') - versions = ['3.0.0', '2.0.0', '1.1.0'] + main_versions = reversed(versions[-3:]) check_call(['sphinx-build', '-Dbreathe_projects.format=' + os.path.abspath(doxyxml_dir), '-Dversion=' + version, '-Drelease=' + version, - '-Aversion=' + version, '-Aversions=' + ','.join(versions), + '-Aversion=' + version, '-Aversions=' + ','.join(main_versions), '-b', 'html', doc_dir, html_dir]) try: check_call(['lessc', '--clean-css', diff --git a/support/manage.py b/support/manage.py index 037d4878..8414c369 100755 --- a/support/manage.py +++ b/support/manage.py @@ -8,7 +8,7 @@ Usage: """ from __future__ import print_function -import datetime, docopt, fileinput, json, os +import datetime, docopt, errno, fileinput, json, os import re, requests, shutil, sys, tempfile from contextlib import contextmanager from distutils.version import LooseVersion @@ -80,6 +80,7 @@ def create_build_env(): import build env.build_dir = 'build' + env.versions = build.versions # Virtualenv and repos are cached to speed up builds. build.create_build_env(os.path.join(env.build_dir, 'virtualenv')) @@ -113,7 +114,7 @@ def update_site(env): doc_repo = Git(os.path.join(env.build_dir, 'fmtlib.github.io')) doc_repo.update('git@github.com:fmtlib/fmtlib.github.io') - for version in ['1.0.0', '1.1.0', '2.0.0', '3.0.2', '4.0.0']: + for version in env.versions: clean_checkout(env.fmt_repo, version) target_doc_dir = os.path.join(env.fmt_repo.dir, 'doc') # Remove the old theme. @@ -165,7 +166,11 @@ def update_site(env): os.symlink(target, link) # Copy docs to the website. version_doc_dir = os.path.join(doc_repo.dir, version) - shutil.rmtree(version_doc_dir) + try: + shutil.rmtree(version_doc_dir) + except OSError as e: + if e.errno != errno.ENOENT: + raise shutil.move(html_dir, version_doc_dir) @@ -205,13 +210,13 @@ def release(args): title_len = 0 sys.stdout.write(line) - # Add the version to the script. - script = os.path.join('support', 'manage.py') + # Add the version to the build script. + script = os.path.join('doc', 'build.py') script_path = os.path.join(fmt_repo.dir, script) for line in fileinput.input(script_path, inplace=True): - m = re.match(r'( *for version in )\[(.+)\]:', line) + m = re.match(r'( *versions = )\[(.+)\]', line) if m: - line = '{}[{}, \'{}\']:\n'.format(m.group(1), m.group(2), version) + line = '{}[{}, \'{}\']\n'.format(m.group(1), m.group(2), version) sys.stdout.write(line) fmt_repo.checkout('-B', 'release')