-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy path_update_docs.sh
More file actions
executable file
·84 lines (64 loc) · 2.13 KB
/
_update_docs.sh
File metadata and controls
executable file
·84 lines (64 loc) · 2.13 KB
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
#!/bin/bash
# SPDX-License-Identifier: BSD-3-Clause
# Copyright(c) 2022 Intel Corporation
set -euo pipefail
#
# This script builds documentation for this website from CNDP source
#
# Get repo name from command line arguments
[ "$1" ] || { echo "Usage: ${BASH_SOURCE[0]} <repo>"; exit 1; }
set -u
REPO=$1
# Directory containing this script
SCRIPT_DIR=$(realpath $(dirname ${BASH_SOURCE[0]}))
# Where the api documents are output
API_OUTDIR="$SCRIPT_DIR/api"
# Where the guide documents are output
GUIDE_OUTDIR="$SCRIPT_DIR/guide"
if [ -e $API_OUTDIR ]; then
echo "Warning: Moving existing $API_OUTDIR to ${SCRIPT_DIR}/_api.bak"
mv $API_OUTDIR ${SCRIPT_DIR}/_api.bak
fi
if [ -e $GUIDE_OUTDIR ]; then
echo "Warning: Moving existing $GUIDE_OUTDIR to ${SCRIPT_DIR}/_guide.bak"
mv $GUIDE_OUTDIR ${SCRIPT_DIR}/_guide.bak
fi
# Cleanup after ourselves
tmpdir=$(mktemp -d)
trap "{ rm -rf $tmpdir; }" EXIT
# Checkout latest tag
pushd $tmpdir
git clone $REPO cndp
CNDP_DIR="$tmpdir/cndp"
pushd $CNDP_DIR
git checkout $(git describe --abbrev=0)
# Guide requires custom template to insert link to the website
echo "templates_path = ['$SCRIPT_DIR/_guide/templates']" >> $CNDP_DIR/doc/guides/conf.py
# Build docs
make docs
popd
popd
#
# Post process api output
#
# Add custom header for the website navbar
API_DIR="$CNDP_DIR/builddir/doc/api"
echo "HTML_HEADER = ${SCRIPT_DIR}/_api/new_header.html" >> $API_DIR/doxy-api.conf
# Rebuild api reference with updated config
doxygen $API_DIR/doxy-api.conf
#
# Post process guide output
#
GUIDE_DIR="$CNDP_DIR/builddir/doc/guides/html"
# custom.css is only installed with "make install" but this script does not do that
mkdir $GUIDE_DIR/_static/css
cp -n $CNDP_DIR/doc/guides/custom.css $GUIDE_DIR/_static/css
# Replace leading underscores
mv $GUIDE_DIR/_images $GUIDE_DIR/images
mv $GUIDE_DIR/_sources $GUIDE_DIR/sources
mv $GUIDE_DIR/_static $GUIDE_DIR/static
find $GUIDE_DIR -name '*.html' -exec sed -i 's/_images/images/g' {} +
find $GUIDE_DIR -name '*.html' -exec sed -i 's/_sources/sources/g' {} +
find $GUIDE_DIR -name '*.html' -exec sed -i 's/_static/static/g' {} +
mv $GUIDE_DIR $GUIDE_OUTDIR
mv $API_DIR/api $API_OUTDIR