dpdk/buildtools/call-sphinx-build.py
<<
>>
Prefs
   1#! /usr/bin/env python3
   2# SPDX-License-Identifier: BSD-3-Clause
   3# Copyright(c) 2019 Intel Corporation
   4#
   5
   6import sys
   7import os
   8from os.path import join
   9from subprocess import run, PIPE, STDOUT
  10from packaging.version import Version
  11
  12# assign parameters to variables
  13(sphinx, version, src, dst, *extra_args) = sys.argv[1:]
  14
  15# set the version in environment for sphinx to pick up
  16os.environ['DPDK_VERSION'] = version
  17
  18# for sphinx version >= 1.7 add parallelism using "-j auto"
  19ver = run([sphinx, '--version'], stdout=PIPE,
  20          stderr=STDOUT).stdout.decode().split()[-1]
  21sphinx_cmd = [sphinx] + extra_args
  22if Version(ver) >= Version('1.7'):
  23    sphinx_cmd += ['-j', 'auto']
  24
  25# find all the files sphinx will process so we can write them as dependencies
  26srcfiles = []
  27for root, dirs, files in os.walk(src):
  28    srcfiles.extend([join(root, f) for f in files])
  29
  30# run sphinx, putting the html output in a "html" directory
  31with open(join(dst, 'sphinx_html.out'), 'w') as out:
  32    process = run(sphinx_cmd + ['-b', 'html', src, join(dst, 'html')],
  33                  stdout=out)
  34
  35# create a gcc format .d file giving all the dependencies of this doc build
  36with open(join(dst, '.html.d'), 'w') as d:
  37    d.write('html: ' + ' '.join(srcfiles) + '\n')
  38
  39sys.exit(process.returncode)
  40