summaryrefslogtreecommitdiffstats
path: root/src/spdk/dpdk/buildtools/call-sphinx-build.py
blob: b9a3994e1799e8df2a28ecd092a9d8f3f80e464c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#! /usr/bin/env python3
# SPDX-License-Identifier: BSD-3-Clause
# Copyright(c) 2019 Intel Corporation
#

import sys
import os
from os.path import join
from subprocess import run, PIPE
from distutils.version import StrictVersion

(sphinx, src, dst) = sys.argv[1:]  # assign parameters to variables

# for sphinx version >= 1.7 add parallelism using "-j auto"
ver = run([sphinx, '--version'], stdout=PIPE).stdout.decode().split()[-1]
sphinx_cmd = [sphinx]
if StrictVersion(ver) >= StrictVersion('1.7'):
    sphinx_cmd += ['-j', 'auto']

# find all the files sphinx will process so we can write them as dependencies
srcfiles = []
for root, dirs, files in os.walk(src):
    srcfiles.extend([join(root, f) for f in files])

# run sphinx, putting the html output in a "html" directory
process = run(sphinx_cmd + ['-b', 'html', src, join(dst, 'html')], check=True)
print(str(process.args) + ' Done OK')

# create a gcc format .d file giving all the dependencies of this doc build
with open(join(dst, '.html.d'), 'w') as d:
    d.write('html: ' + ' '.join(srcfiles) + '\n')