2015-07-26 18:48:26 +03:00
|
|
|
#!/usr/bin/env python2
|
2015-04-10 18:39:09 +03:00
|
|
|
# Build the documentation.
|
|
|
|
|
|
|
|
from __future__ import print_function
|
2015-10-15 18:13:32 +03:00
|
|
|
import os, shutil, tempfile
|
2015-10-13 18:45:49 +03:00
|
|
|
from subprocess import check_call, check_output, CalledProcessError, Popen, PIPE
|
2015-10-14 18:17:39 +03:00
|
|
|
from distutils.version import LooseVersion
|
2015-04-10 18:39:09 +03:00
|
|
|
|
2015-10-13 18:24:16 +03:00
|
|
|
def pip_install(package, commit=None, **kwargs):
|
2015-04-10 18:39:09 +03:00
|
|
|
"Install package using pip."
|
|
|
|
if commit:
|
2015-10-13 18:24:16 +03:00
|
|
|
check_version = kwargs.get('check_version', '')
|
2015-10-14 18:31:54 +03:00
|
|
|
#output = check_output(['pip', 'show', package.split('/')[1]])
|
|
|
|
#if check_version in output:
|
|
|
|
# print('{} already installed'.format(package))
|
|
|
|
# return
|
2015-04-10 18:39:09 +03:00
|
|
|
package = 'git+git://github.com/{0}.git@{1}'.format(package, commit)
|
2015-10-13 18:45:49 +03:00
|
|
|
print('Installing {}'.format(package))
|
2015-10-14 16:52:07 +03:00
|
|
|
check_call(['pip', 'install', '--upgrade', package])
|
2015-04-10 18:39:09 +03:00
|
|
|
|
2015-05-20 18:06:12 +03:00
|
|
|
def build_docs():
|
2015-04-10 18:39:09 +03:00
|
|
|
# Create virtualenv.
|
2015-05-20 18:06:12 +03:00
|
|
|
doc_dir = os.path.dirname(os.path.realpath(__file__))
|
2015-06-22 16:40:21 +03:00
|
|
|
virtualenv_dir = 'virtualenv'
|
2015-04-10 18:39:09 +03:00
|
|
|
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))
|
2015-10-14 18:31:54 +03:00
|
|
|
# Upgrade pip because installation of sphinx with pip 1.1 available on Travis
|
|
|
|
# is broken (see #207) and it doesn't support the show command.
|
2015-10-15 18:13:32 +03:00
|
|
|
import pkg_resources
|
2015-10-15 18:09:19 +03:00
|
|
|
pip_version = pkg_resources.get_distribution('pip').version
|
|
|
|
print('pip version: ' + pip_version)
|
|
|
|
if LooseVersion(pip_version) < LooseVersion('1.5.4'):
|
2015-10-15 16:41:16 +03:00
|
|
|
print("Updating pip")
|
2015-10-15 17:40:34 +03:00
|
|
|
check_call(['pip', 'install', '--upgrade', 'pip'])
|
2015-05-19 18:13:13 +03:00
|
|
|
# Install Sphinx and Breathe.
|
2015-10-15 18:26:44 +03:00
|
|
|
check_call(['pip', 'install', 'sphinx-rtd-theme==0.1.8'])
|
2015-10-13 01:35:22 +03:00
|
|
|
pip_install('sphinx-doc/sphinx',
|
2015-10-13 18:24:16 +03:00
|
|
|
'4d2c17e043d9e8197fa5cd0db34212af3bb17069',
|
|
|
|
check_version='1.4a0.dev-20151013')
|
2015-06-25 16:56:54 +03:00
|
|
|
pip_install('michaeljones/breathe',
|
|
|
|
'511b0887293e7c6b12310bb61b3659068f48f0f4')
|
2015-10-14 17:13:23 +03:00
|
|
|
print(check_output(['pip', '--version']))
|
2015-10-15 17:54:41 +03:00
|
|
|
print(check_output(['pip', 'show', 'sphinx-rtd-theme']))
|
2015-10-13 18:45:49 +03:00
|
|
|
print(check_output(['sphinx-build', '--version']))
|
2015-10-13 18:55:05 +03:00
|
|
|
print('PATH:', os.environ['PATH'])
|
2015-10-14 16:39:07 +03:00
|
|
|
print(check_output(['which', 'sphinx-build']))
|
2015-10-14 16:52:07 +03:00
|
|
|
import sphinx
|
|
|
|
print(sphinx.__version__)
|
2015-04-10 18:39:09 +03:00
|
|
|
# Build docs.
|
2015-05-20 18:06:12 +03:00
|
|
|
cmd = ['doxygen', '-']
|
2015-06-22 16:40:21 +03:00
|
|
|
p = Popen(cmd, stdin=PIPE)
|
2015-04-10 18:39:09 +03:00
|
|
|
p.communicate(input=r'''
|
|
|
|
PROJECT_NAME = C++ Format
|
|
|
|
GENERATE_LATEX = NO
|
|
|
|
GENERATE_MAN = NO
|
|
|
|
GENERATE_RTF = NO
|
|
|
|
CASE_SENSE_NAMES = NO
|
|
|
|
INPUT = {0}/format.h
|
|
|
|
QUIET = YES
|
|
|
|
JAVADOC_AUTOBRIEF = YES
|
|
|
|
AUTOLINK_SUPPORT = NO
|
|
|
|
GENERATE_HTML = NO
|
|
|
|
GENERATE_XML = YES
|
|
|
|
XML_OUTPUT = doxyxml
|
|
|
|
ALIASES = "rst=\verbatim embed:rst"
|
|
|
|
ALIASES += "endrst=\endverbatim"
|
|
|
|
PREDEFINED = _WIN32=1 \
|
|
|
|
FMT_USE_VARIADIC_TEMPLATES=1 \
|
2015-10-13 01:35:22 +03:00
|
|
|
FMT_USE_RVALUE_REFERENCES=1 \
|
|
|
|
FMT_USE_USER_DEFINED_LITERALS=1
|
2015-04-10 18:39:09 +03:00
|
|
|
EXCLUDE_SYMBOLS = fmt::internal::* StringValue write_str
|
|
|
|
'''.format(os.path.dirname(doc_dir)))
|
|
|
|
if p.returncode != 0:
|
2015-05-20 18:06:12 +03:00
|
|
|
raise CalledProcessError(p.returncode, cmd)
|
2015-06-25 16:56:54 +03:00
|
|
|
check_call(['sphinx-build', '-D',
|
|
|
|
'breathe_projects.format=' + os.path.join(os.getcwd(), 'doxyxml'),
|
2015-06-22 16:40:21 +03:00
|
|
|
'-b', 'html', doc_dir, 'html'])
|
2015-06-25 16:56:54 +03:00
|
|
|
check_call(['lessc', '--clean-css',
|
|
|
|
'--include-path=' + os.path.join(doc_dir, 'bootstrap'),
|
|
|
|
os.path.join(doc_dir, 'cppformat.less'),
|
|
|
|
'html/_static/cppformat.css'])
|
2015-06-22 16:40:21 +03:00
|
|
|
return 'html'
|
2015-04-10 18:39:09 +03:00
|
|
|
|
2015-05-20 18:06:12 +03:00
|
|
|
if __name__ == '__main__':
|
|
|
|
build_docs()
|