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