2020-11-08 17:46:27 +00:00
|
|
|
#!/usr/bin/env python3
|
2015-04-10 15:39:09 +00:00
|
|
|
# Build the documentation.
|
|
|
|
|
2020-11-08 17:46:27 +00:00
|
|
|
import errno, os, re, sys
|
|
|
|
from subprocess import check_call, CalledProcessError, Popen, PIPE, STDOUT
|
2015-04-10 15:39:09 +00:00
|
|
|
|
2022-01-06 22:35:15 +00:00
|
|
|
versions = ['1.0.0', '1.1.0', '2.0.0', '3.0.2', '4.0.0', '4.1.0', '5.0.0', '5.1.0', '5.2.0', '5.2.1', '5.3.0', '6.0.0', '6.1.0', '6.1.1', '6.1.2', '6.2.0', '6.2.1', '7.0.0', '7.0.1', '7.0.2', '7.0.3', '7.1.0', '7.1.1', '7.1.2', '7.1.3', '8.0.0', '8.0.1', '8.1.0', '8.1.1']
|
2017-07-01 14:30:51 +00:00
|
|
|
|
2020-11-08 17:46:27 +00:00
|
|
|
class Pip:
|
|
|
|
def __init__(self, venv_dir):
|
|
|
|
self.path = os.path.join(venv_dir, 'bin', 'pip')
|
2015-04-10 15:39:09 +00:00
|
|
|
|
2020-11-08 17:46:27 +00:00
|
|
|
def install(self, package, commit=None):
|
|
|
|
"Install package using pip."
|
|
|
|
if commit:
|
|
|
|
package = 'git+https://github.com/{0}.git@{1}'.format(package, commit)
|
|
|
|
print('Installing {0}'.format(package))
|
|
|
|
check_call([self.path, 'install', package])
|
|
|
|
|
|
|
|
def create_build_env(venv_dir='virtualenv'):
|
2015-04-10 15:39:09 +00:00
|
|
|
# Create virtualenv.
|
2020-11-08 17:46:27 +00:00
|
|
|
if not os.path.exists(venv_dir):
|
|
|
|
check_call(['python3', '-m', 'venv', venv_dir])
|
2020-10-07 15:11:59 +00:00
|
|
|
# Install Sphinx and Breathe. Require the exact version of Sphinx which is
|
|
|
|
# compatible with Breathe.
|
2020-11-08 17:46:27 +00:00
|
|
|
pip = Pip(venv_dir)
|
2021-06-03 16:10:07 +00:00
|
|
|
pip.install('wheel')
|
2020-11-29 17:13:14 +00:00
|
|
|
pip.install('six')
|
2021-10-30 16:12:36 +00:00
|
|
|
# See: https://github.com/sphinx-doc/sphinx/issues/9777
|
|
|
|
pip.install('docutils==0.17.1')
|
2020-11-08 17:46:27 +00:00
|
|
|
pip.install('sphinx-doc/sphinx', 'v3.3.0')
|
2021-06-27 15:10:37 +00:00
|
|
|
pip.install('michaeljones/breathe', 'v4.25.0')
|
2016-05-08 15:03:01 +00:00
|
|
|
|
2020-07-26 16:44:37 +00:00
|
|
|
def build_docs(version='dev', **kwargs):
|
2016-05-09 15:36:16 +00:00
|
|
|
doc_dir = kwargs.get('doc_dir', os.path.dirname(os.path.realpath(__file__)))
|
2016-05-26 14:35:10 +00:00
|
|
|
work_dir = kwargs.get('work_dir', '.')
|
2018-02-11 17:23:17 +00:00
|
|
|
include_dir = kwargs.get(
|
|
|
|
'include_dir', os.path.join(os.path.dirname(doc_dir), 'include', 'fmt'))
|
2015-04-10 15:39:09 +00:00
|
|
|
# Build docs.
|
2015-05-20 15:06:12 +00:00
|
|
|
cmd = ['doxygen', '-']
|
2020-11-08 14:16:49 +00:00
|
|
|
p = Popen(cmd, stdin=PIPE, stdout=PIPE, stderr=STDOUT)
|
2016-05-26 14:35:10 +00:00
|
|
|
doxyxml_dir = os.path.join(work_dir, 'doxyxml')
|
2020-11-08 14:13:56 +00:00
|
|
|
out, _ = p.communicate(input=r'''
|
2016-04-28 14:00:22 +00:00
|
|
|
PROJECT_NAME = fmt
|
2015-04-10 15:39:09 +00:00
|
|
|
GENERATE_LATEX = NO
|
|
|
|
GENERATE_MAN = NO
|
|
|
|
GENERATE_RTF = NO
|
|
|
|
CASE_SENSE_NAMES = NO
|
2020-10-07 15:11:59 +00:00
|
|
|
INPUT = {0}/chrono.h {0}/color.h {0}/core.h {0}/compile.h \
|
2021-06-02 15:19:54 +00:00
|
|
|
{0}/format.h {0}/os.h {0}/ostream.h {0}/printf.h \
|
|
|
|
{0}/xchar.h
|
2015-04-10 15:39:09 +00:00
|
|
|
QUIET = YES
|
|
|
|
JAVADOC_AUTOBRIEF = YES
|
|
|
|
AUTOLINK_SUPPORT = NO
|
|
|
|
GENERATE_HTML = NO
|
|
|
|
GENERATE_XML = YES
|
2016-05-26 14:35:10 +00:00
|
|
|
XML_OUTPUT = {1}
|
2015-04-10 15:39:09 +00:00
|
|
|
ALIASES = "rst=\verbatim embed:rst"
|
|
|
|
ALIASES += "endrst=\endverbatim"
|
2015-12-24 14:54:37 +00:00
|
|
|
MACRO_EXPANSION = YES
|
2015-04-10 15:39:09 +00:00
|
|
|
PREDEFINED = _WIN32=1 \
|
2021-01-09 15:18:56 +00:00
|
|
|
__linux__=1 \
|
2021-10-03 14:05:31 +00:00
|
|
|
FMT_ENABLE_IF(...)= \
|
2015-04-10 15:39:09 +00:00
|
|
|
FMT_USE_VARIADIC_TEMPLATES=1 \
|
2015-10-12 22:35:22 +00:00
|
|
|
FMT_USE_RVALUE_REFERENCES=1 \
|
2015-12-18 15:13:43 +00:00
|
|
|
FMT_USE_USER_DEFINED_LITERALS=1 \
|
2018-10-07 14:48:27 +00:00
|
|
|
FMT_USE_ALIAS_TEMPLATES=1 \
|
2018-05-12 19:57:16 +00:00
|
|
|
FMT_API= \
|
2018-05-12 20:12:04 +00:00
|
|
|
"FMT_BEGIN_NAMESPACE=namespace fmt {{" \
|
2018-09-13 14:20:43 +00:00
|
|
|
"FMT_END_NAMESPACE=}}" \
|
2018-12-13 01:50:50 +00:00
|
|
|
"FMT_STRING_ALIAS=1" \
|
2021-06-27 13:41:54 +00:00
|
|
|
"FMT_VARIADIC(...)=" \
|
|
|
|
"FMT_VARIADIC_W(...)=" \
|
2020-11-08 17:46:27 +00:00
|
|
|
"FMT_DOC=1"
|
2020-10-07 16:07:39 +00:00
|
|
|
EXCLUDE_SYMBOLS = fmt::formatter fmt::printf_formatter fmt::arg_join \
|
|
|
|
fmt::basic_format_arg::handle
|
2016-05-26 14:35:10 +00:00
|
|
|
'''.format(include_dir, doxyxml_dir).encode('UTF-8'))
|
2021-06-03 16:32:12 +00:00
|
|
|
out = out.decode('utf-8')
|
2020-11-08 14:48:34 +00:00
|
|
|
internal_symbols = [
|
|
|
|
'fmt::detail::.*',
|
|
|
|
'basic_data<>',
|
2020-11-08 14:58:41 +00:00
|
|
|
'fmt::type_identity',
|
2020-11-08 14:48:34 +00:00
|
|
|
'fmt::dynamic_formatter'
|
|
|
|
]
|
2020-11-08 14:58:41 +00:00
|
|
|
noisy_warnings = [
|
2020-11-08 15:04:42 +00:00
|
|
|
'warning: (Compound|Member .* of class) (' + '|'.join(internal_symbols) + \
|
|
|
|
') is not documented.',
|
2020-11-08 14:58:41 +00:00
|
|
|
'warning: Internal inconsistency: .* does not belong to any container!'
|
|
|
|
]
|
|
|
|
for w in noisy_warnings:
|
2020-11-08 14:29:50 +00:00
|
|
|
out = re.sub('.*' + w + '\n', '', out)
|
2020-11-08 14:13:56 +00:00
|
|
|
print(out)
|
2015-04-10 15:39:09 +00:00
|
|
|
if p.returncode != 0:
|
2015-05-20 15:06:12 +00:00
|
|
|
raise CalledProcessError(p.returncode, cmd)
|
2020-11-08 14:13:56 +00:00
|
|
|
|
2016-05-26 14:35:10 +00:00
|
|
|
html_dir = os.path.join(work_dir, 'html')
|
2017-07-01 14:30:51 +00:00
|
|
|
main_versions = reversed(versions[-3:])
|
2021-06-19 13:31:19 +00:00
|
|
|
check_call([os.path.join(work_dir, 'virtualenv', 'bin', 'sphinx-build'),
|
2016-06-02 13:52:07 +00:00
|
|
|
'-Dbreathe_projects.format=' + os.path.abspath(doxyxml_dir),
|
2016-05-26 13:52:51 +00:00
|
|
|
'-Dversion=' + version, '-Drelease=' + version,
|
2017-07-01 14:30:51 +00:00
|
|
|
'-Aversion=' + version, '-Aversions=' + ','.join(main_versions),
|
2016-06-02 13:41:25 +00:00
|
|
|
'-b', 'html', doc_dir, html_dir])
|
2015-10-16 15:28:58 +00:00
|
|
|
try:
|
2020-11-07 17:27:06 +00:00
|
|
|
check_call(['lessc', '--verbose', '--clean-css',
|
|
|
|
'--include-path=' + os.path.join(doc_dir, 'bootstrap'),
|
|
|
|
os.path.join(doc_dir, 'fmt.less'),
|
|
|
|
os.path.join(html_dir, '_static', 'fmt.css')])
|
2015-10-17 15:05:58 +00:00
|
|
|
except OSError as e:
|
2015-10-16 15:28:58 +00:00
|
|
|
if e.errno != errno.ENOENT:
|
|
|
|
raise
|
2016-05-26 13:52:51 +00:00
|
|
|
print('lessc not found; make sure that Less (http://lesscss.org/) ' +
|
|
|
|
'is installed')
|
2015-10-16 15:28:58 +00:00
|
|
|
sys.exit(1)
|
2016-05-26 14:35:10 +00:00
|
|
|
return html_dir
|
2015-04-10 15:39:09 +00:00
|
|
|
|
2015-05-20 15:06:12 +00:00
|
|
|
if __name__ == '__main__':
|
2016-05-08 15:03:01 +00:00
|
|
|
create_build_env()
|
2020-07-26 16:44:37 +00:00
|
|
|
build_docs(sys.argv[1])
|