mirror of
https://github.com/fmtlib/fmt.git
synced 2024-12-24 03:17:53 +00:00
Build docs on travis
This commit is contained in:
parent
abba1477a7
commit
f9936c4859
20
.travis.yml
20
.travis.yml
@ -4,17 +4,15 @@ os:
|
||||
- linux
|
||||
- osx
|
||||
|
||||
before_install:
|
||||
- git submodule update --init
|
||||
|
||||
env:
|
||||
- BUILD_TYPE=Debug
|
||||
- BUILD_TYPE=Release
|
||||
- BUILD=Doc
|
||||
- BUILD=Debug
|
||||
- BUILD=Release
|
||||
|
||||
matrix:
|
||||
exclude:
|
||||
- os: osx
|
||||
- env: BUILD=Doc
|
||||
|
||||
script:
|
||||
- cmake -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DFMT_PEDANTIC=ON .
|
||||
- make -j4
|
||||
- CTEST_OUTPUT_ON_FAILURE=1 make test
|
||||
|
||||
after_failure:
|
||||
- cat Testing/Temporary/LastTest.log
|
||||
- support/travis-build.py
|
||||
|
26
doc/build.py
26
doc/build.py
@ -13,9 +13,10 @@ def pip_install(package, commit=None):
|
||||
package = 'git+git://github.com/{0}.git@{1}'.format(package, commit)
|
||||
check_call(['pip', 'install', '-q', package])
|
||||
|
||||
def build_docs(workdir, travis):
|
||||
def build_docs():
|
||||
# Create virtualenv.
|
||||
virtualenv_dir = os.path.join(workdir, 'virtualenv')
|
||||
doc_dir = os.path.dirname(os.path.realpath(__file__))
|
||||
virtualenv_dir = os.path.join(doc_dir, 'virtualenv')
|
||||
check_call(['virtualenv', virtualenv_dir])
|
||||
activate_this_file = os.path.join(virtualenv_dir, 'bin', 'activate_this.py')
|
||||
execfile(activate_this_file, dict(__file__=activate_this_file))
|
||||
@ -23,8 +24,8 @@ def build_docs(workdir, travis):
|
||||
pip_install('sphinx==1.3.1')
|
||||
pip_install('michaeljones/breathe', '18bd461b4e29dde0adf5df4b3da7e5473e2c2983')
|
||||
# Build docs.
|
||||
doc_dir = os.path.dirname(os.path.realpath(__file__))
|
||||
p = Popen(['doxygen', '-'], stdin=PIPE)
|
||||
cmd = ['doxygen', '-']
|
||||
p = Popen(cmd, stdin=PIPE, cwd=doc_dir)
|
||||
p.communicate(input=r'''
|
||||
PROJECT_NAME = C++ Format
|
||||
GENERATE_LATEX = NO
|
||||
@ -46,13 +47,12 @@ def build_docs(workdir, travis):
|
||||
EXCLUDE_SYMBOLS = fmt::internal::* StringValue write_str
|
||||
'''.format(os.path.dirname(doc_dir)))
|
||||
if p.returncode != 0:
|
||||
return p.returncode
|
||||
check_call(['sphinx-build',
|
||||
'-D', "breathe_projects.format=" + os.path.join(os.getcwd(), "doxyxml"),
|
||||
'-b', 'html', doc_dir, 'html'])
|
||||
return 0
|
||||
raise CalledProcessError(p.returncode, cmd)
|
||||
check_call(['sphinx-build', '-D', 'breathe_projects.format=doxyxml',
|
||||
'-b', 'html', '.', 'html'], cwd=doc_dir)
|
||||
check_call(['lessc', '--clean-css', '--include-path=bootstrap', 'cppformat.less',
|
||||
'html/_static/cppformat.css'], cwd=doc_dir)
|
||||
return os.path.join(doc_dir, 'html')
|
||||
|
||||
returncode = 1
|
||||
travis = 'TRAVIS' in os.environ
|
||||
returncode = build_docs('', travis=travis)
|
||||
exit(returncode)
|
||||
if __name__ == '__main__':
|
||||
build_docs()
|
||||
|
55
support/travis-build.py
Executable file
55
support/travis-build.py
Executable file
@ -0,0 +1,55 @@
|
||||
#!/usr/bin/env python
|
||||
# Build the project on Travis CI.
|
||||
|
||||
from __future__ import print_function
|
||||
import errno, os, re, shutil, sys, tempfile
|
||||
from subprocess import call, check_call, Popen, PIPE, STDOUT
|
||||
|
||||
def rmtree_if_exists(dir):
|
||||
try:
|
||||
shutil.rmtree(dir)
|
||||
except OSError as e:
|
||||
if e.errno == errno.ENOENT:
|
||||
pass
|
||||
|
||||
build = os.environ['BUILD']
|
||||
if build == 'Doc':
|
||||
travis = 'TRAVIS' in os.environ
|
||||
# Install dependencies.
|
||||
if travis:
|
||||
check_call(['sudo', 'apt-get', 'install', 'python-virtualenv', 'doxygen', 'node-less'])
|
||||
cppformat_dir = os.path.dirname(os.path.dirname(os.path.realpath(__file__)))
|
||||
sys.path.insert(0, os.path.join(cppformat_dir, 'doc'))
|
||||
import build
|
||||
html_dir = build.build_docs()
|
||||
# Clone the cppformat.github.io repo.
|
||||
repo = 'cppformat.github.io'
|
||||
rmtree_if_exists(repo)
|
||||
check_call(['git', 'clone', 'https://github.com/cppformat/{}.git'.format(repo)])
|
||||
# Copy docs to the repo.
|
||||
target_dir = os.path.join(repo, 'dev')
|
||||
rmtree_if_exists(target_dir)
|
||||
shutil.copytree(html_dir, target_dir)
|
||||
if travis:
|
||||
check_call(['git', 'config', '--global', 'user.name', 'amplbot'])
|
||||
check_call(['git', 'config', '--global', 'user.email', 'viz@ampl.com'])
|
||||
# Push docs to GitHub pages.
|
||||
check_call(['git', 'add', '--all'], cwd=repo)
|
||||
if call(['git', 'diff-index', '--quiet', 'HEAD'], cwd=repo):
|
||||
check_call(['git', 'commit', '-m', 'Update documentation'], cwd=repo)
|
||||
cmd = 'git push https://$KEY@github.com/cppformat/cppformat.github.io.git master'
|
||||
p = Popen(cmd, shell=True, stdout=PIPE, stderr=STDOUT)
|
||||
# Remove URL from output because it may contain a token.
|
||||
print(re.sub(r'https:.*\.git', '<url>', p.communicate()[0]))
|
||||
if p.returncode != 0:
|
||||
raise CalledProcessError(p.returncode, cmd)
|
||||
exit(0)
|
||||
|
||||
check_call(['git', 'submodule', 'update', '--init'])
|
||||
check_call(['cmake', '-DCMAKE_BUILD_TYPE=' + build, '-DFMT_PEDANTIC=ON', '.'])
|
||||
check_call(['make', '-j4'])
|
||||
env = os.environ.copy()
|
||||
env['CTEST_OUTPUT_ON_FAILURE'] = '1'
|
||||
if call(['make', 'test'], env=env):
|
||||
with open('Testing/Temporary/LastTest.log', 'r') as f:
|
||||
print(f.read())
|
Loading…
Reference in New Issue
Block a user