From 140f11190b20127944a91149604461fee0a5c5c2 Mon Sep 17 00:00:00 2001 From: Victor Zverovich Date: Sun, 8 May 2016 08:03:01 -0700 Subject: [PATCH] Add a website update script --- doc/build.py | 6 ++++-- support/travis-build.py | 1 + support/update-website.py | 43 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 48 insertions(+), 2 deletions(-) create mode 100755 support/update-website.py diff --git a/doc/build.py b/doc/build.py index 9721e298..c49094be 100755 --- a/doc/build.py +++ b/doc/build.py @@ -18,9 +18,8 @@ def pip_install(package, commit=None, **kwargs): print('Installing {}'.format(package)) check_call(['pip', 'install', '--upgrade', package]) -def build_docs(version='dev'): +def create_build_env(): # Create virtualenv. - doc_dir = os.path.dirname(os.path.realpath(__file__)) virtualenv_dir = 'virtualenv' check_call(['virtualenv', virtualenv_dir]) import sysconfig @@ -51,6 +50,8 @@ def build_docs(version='dev'): check_version='1.4a0.dev-20151013') pip_install('michaeljones/breathe', '1c9d7f80378a92cffa755084823a78bb38ee4acc') + +def build_docs(version='dev', doc_dir=os.path.dirname(os.path.realpath(__file__))): # Build docs. cmd = ['doxygen', '-'] p = Popen(cmd, stdin=PIPE) @@ -96,4 +97,5 @@ def build_docs(version='dev'): return 'html' if __name__ == '__main__': + create_build_env() build_docs(sys.argv[1]) diff --git a/support/travis-build.py b/support/travis-build.py index 6dc09666..a43af2da 100755 --- a/support/travis-build.py +++ b/support/travis-build.py @@ -43,6 +43,7 @@ if build == 'Doc': check_call(['sudo', 'dpkg', '-i', deb_file]) sys.path.insert(0, os.path.join(fmt_dir, 'doc')) import build + build.create_build_env() html_dir = build.build_docs() repo = 'fmtlib.github.io' if travis and 'KEY' not in os.environ: diff --git a/support/update-website.py b/support/update-website.py new file mode 100755 index 00000000..1ad24ed5 --- /dev/null +++ b/support/update-website.py @@ -0,0 +1,43 @@ +#!/usr/bin/env python + +import os, shutil, sys +from subprocess import check_call + +class Git: + def __init__(self, dir): + self.dir = dir + + def call(self, method, args, **kwargs): + return check_call(['git', method] + list(args), **kwargs) + + def clone(self, *args): + return self.call('clone', list(args) + [self.dir]) + + def checkout(self, *args): + return self.call('checkout', args, cwd=self.dir) + +# Create build environment. +fmt_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) +sys.path.insert(0, os.path.join(fmt_dir, 'doc')) +import build +build.create_build_env() + +git = Git('fmt') +git.clone('git@github.com:fmtlib/fmt.git') + +versions = ['1.0.0'] +for version in versions: + git.checkout(version) + target_doc_dir = os.path.join(git.dir, 'doc') + # Remove the old theme. + for entry in os.listdir(target_doc_dir): + path = os.path.join(target_doc_dir, entry) + if os.path.isdir(path): + shutil.rmtree(path) + # Copy the new theme. + for entry in ['_static', '_templates', 'basic-bootstrap', 'bootstrap']: + src = os.path.join(fmt_dir, 'doc', entry) + dst = os.path.join(target_doc_dir, entry) + shutil.copytree(src, dst) + build.build_docs(version, target_doc_dir) + # TODO: copy docs to website