]> git.proxmox.com Git - ceph.git/blobdiff - ceph/src/fmt/doc/build.py
import quincy beta 17.1.0
[ceph.git] / ceph / src / fmt / doc / build.py
index e5bcbf3be746b6092992089911972f6b1d04156d..7b1a413938aa310926bc65fc8b13f38e675bb062 100755 (executable)
@@ -1,63 +1,33 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 # Build the documentation.
 
-from __future__ import print_function
-import errno, os, shutil, sys, tempfile
-from subprocess import check_call, check_output, CalledProcessError, Popen, PIPE
-from distutils.version import LooseVersion
+import errno, os, re, sys
+from subprocess import check_call, CalledProcessError, Popen, PIPE, STDOUT
 
-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']
+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']
 
-def pip_install(package, commit=None, **kwargs):
-  "Install package using pip."
-  min_version = kwargs.get('min_version')
-  if min_version:
-    from pkg_resources import get_distribution, DistributionNotFound
-    try:
-      installed_version = get_distribution(os.path.basename(package)).version
-      if LooseVersion(installed_version) >= min_version:
-        print('{} {} already installed'.format(package, min_version))
-        return
-    except DistributionNotFound:
-      pass
-  if commit:
-    package = 'git+https://github.com/{0}.git@{1}'.format(package, commit)
-  print('Installing {0}'.format(package))
-  check_call(['pip', 'install', package])
+class Pip:
+  def __init__(self, venv_dir):
+    self.path = os.path.join(venv_dir, 'bin', 'pip')
 
-def create_build_env(dirname='virtualenv'):
+  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'):
   # Create virtualenv.
-  if not os.path.exists(dirname):
-    check_call(['virtualenv', dirname])
-  import sysconfig
-  scripts_dir = os.path.basename(sysconfig.get_path('scripts'))
-  activate_this_file = os.path.join(dirname, scripts_dir, 'activate_this.py')
-  with open(activate_this_file) as f:
-    exec(f.read(), dict(__file__=activate_this_file))
-  # Import get_distribution after activating virtualenv to get info about
-  # the correct packages.
-  from pkg_resources import get_distribution, DistributionNotFound
-  # 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.
-  pip_version = get_distribution('pip').version
-  if LooseVersion(pip_version) < LooseVersion('1.5.4'):
-    print("Updating pip")
-    check_call(['pip', 'install', '--upgrade', 'pip'])
-  # Upgrade distribute because installation of sphinx with distribute 0.6.24
-  # available on Travis is broken (see #207).
-  try:
-    distribute_version = get_distribution('distribute').version
-    if LooseVersion(distribute_version) <= LooseVersion('0.6.24'):
-      print("Updating distribute")
-      check_call(['pip', 'install', '--upgrade', 'distribute'])
-  except DistributionNotFound:
-    pass
-  # Install Sphinx and Breathe.
-  pip_install('sphinx-doc/sphinx', '12b83372ac9316e8cbe86e7fed889296a4cc29ee',
-              min_version='1.4.1.dev20160531')
-  pip_install('michaeljones/breathe',
-              '129222318f7c8f865d2631e7da7b033567e7f56a',
-              min_version='4.2.0')
+  if not os.path.exists(venv_dir):
+    check_call(['python3', '-m', 'venv', venv_dir])
+  # Install Sphinx and Breathe. Require the exact version of Sphinx which is
+  # compatible with Breathe.
+  pip = Pip(venv_dir)
+  pip.install('wheel')
+  pip.install('six')
+  pip.install('sphinx-doc/sphinx', 'v3.3.0')
+  pip.install('michaeljones/breathe', 'v4.23.0')
 
 def build_docs(version='dev', **kwargs):
   doc_dir = kwargs.get('doc_dir', os.path.dirname(os.path.realpath(__file__)))
@@ -66,16 +36,17 @@ def build_docs(version='dev', **kwargs):
       'include_dir', os.path.join(os.path.dirname(doc_dir), 'include', 'fmt'))
   # Build docs.
   cmd = ['doxygen', '-']
-  p = Popen(cmd, stdin=PIPE)
+  p = Popen(cmd, stdin=PIPE, stdout=PIPE, stderr=STDOUT)
   doxyxml_dir = os.path.join(work_dir, 'doxyxml')
-  p.communicate(input=r'''
+  out, _ = p.communicate(input=r'''
       PROJECT_NAME      = fmt
       GENERATE_LATEX    = NO
       GENERATE_MAN      = NO
       GENERATE_RTF      = NO
       CASE_SENSE_NAMES  = NO
-      INPUT             = {0}/core.h {0}/format.h {0}/os.h {0}/ostream.h \
-                          {0}/printf.h {0}/time.h
+      INPUT             = {0}/chrono.h {0}/color.h {0}/core.h {0}/compile.h \
+                          {0}/format.h {0}/os.h {0}/ostream.h {0}/printf.h \
+                          {0}/xchar.h
       QUIET             = YES
       JAVADOC_AUTOBRIEF = YES
       AUTOLINK_SUPPORT  = NO
@@ -86,6 +57,7 @@ def build_docs(version='dev', **kwargs):
       ALIASES          += "endrst=\endverbatim"
       MACRO_EXPANSION   = YES
       PREDEFINED        = _WIN32=1 \
+                          __linux__=1 \
                           FMT_USE_VARIADIC_TEMPLATES=1 \
                           FMT_USE_RVALUE_REFERENCES=1 \
                           FMT_USE_USER_DEFINED_LITERALS=1 \
@@ -94,20 +66,37 @@ def build_docs(version='dev', **kwargs):
                           "FMT_BEGIN_NAMESPACE=namespace fmt {{" \
                           "FMT_END_NAMESPACE=}}" \
                           "FMT_STRING_ALIAS=1" \
-                          "FMT_ENABLE_IF(B)="
-      EXCLUDE_SYMBOLS   = fmt::internal::* StringValue write_str
+                          "FMT_DOC=1"
+      EXCLUDE_SYMBOLS   = fmt::formatter fmt::printf_formatter fmt::arg_join \
+                          fmt::basic_format_arg::handle
     '''.format(include_dir, doxyxml_dir).encode('UTF-8'))
+  out = out.decode('utf-8')
+  internal_symbols = [
+    'fmt::detail::.*',
+    'basic_data<>',
+    'fmt::type_identity',
+    'fmt::dynamic_formatter'
+  ]
+  noisy_warnings = [
+    'warning: (Compound|Member .* of class) (' + '|'.join(internal_symbols) + \
+      ') is not documented.',
+    'warning: Internal inconsistency: .* does not belong to any container!'
+  ]
+  for w in noisy_warnings:
+      out = re.sub('.*' + w + '\n', '', out)
+  print(out)
   if p.returncode != 0:
     raise CalledProcessError(p.returncode, cmd)
+
   html_dir = os.path.join(work_dir, 'html')
   main_versions = reversed(versions[-3:])
-  check_call(['sphinx-build',
+  check_call([os.path.join('virtualenv', 'bin', 'sphinx-build'),
               '-Dbreathe_projects.format=' + os.path.abspath(doxyxml_dir),
               '-Dversion=' + version, '-Drelease=' + version,
               '-Aversion=' + version, '-Aversions=' + ','.join(main_versions),
               '-b', 'html', doc_dir, html_dir])
   try:
-    check_call(['lessc', '--clean-css',
+    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')])