File: build.sh

package info (click to toggle)
tango 10.0.2%2Bdfsg1-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 89,936 kB
  • sloc: cpp: 201,786; sh: 1,645; python: 953; java: 800; perl: 467; javascript: 447; xml: 325; makefile: 272; sql: 72; ruby: 24
file content (71 lines) | stat: -rwxr-xr-x 2,418 bytes parent folder | download | duplicates (3)
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
#! /usr/bin/env bash

# Adapted from https://oleksandrkvl.github.io/2024/06/05/multi-version-doxygen.html#multi-version-docs

# This script will generate the cppTango documentation website from all the
# versioned docs tarballs in the cppTango package registry and, optionally, from
# build/doc_html.
#
# It is expecting to be run from the cppTango git root directory.
#
# To view the site run the following:
#
#   ci/docs-site/build.sh
#   python -m http.server
#
# Then navigate to 0.0.0.0:8000/site in your browser.
#
# Note, you must run `python -m http.server` from the cppTango
# root directory as the web site is expecting to be hosted at
# <hostname>/<some_dir> to match the gitlab pages address.

set -e

CI_API_V4_URL="${CI_API_V4_URL:-https://gitlab.com/api/v4}"
CI_PROJECT_ID="${CI_PROJECT_ID:-24006041}"

docs_packages=$(curl -s "${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages?package_name=docs&order_by=version&sort=desc")

rm -rf site
rm -rf build/doc-site

mkdir -p build/doc-site
mkdir site

cp ci/docs-site/version_selector_handler.js site

echo '&nbsp;<select id="versionSelector">' > site/version_selector.html

if [ -e build/doc_html ]; then
    git_tag=$(git describe --tags --abbrev=0 --exclude=*test* --always HEAD)
    git_desc=$(git describe --tags --exclude=*test* --always HEAD)
    echo "Preparing documentation for HEAD (${git_desc})"
    cp -r build/doc_html site/${git_tag}
    ci/docs-site/patch-in-version-selector.sh site/${git_tag}
    echo "  <option value=\"${git_tag}\">${git_desc}</option>" >> site/version_selector.html
fi

echo $docs_packages | jq -r '.[].version' | while read -r version; do
  echo "Preparing documentation for tag $version"
  curl -o build/doc-site/${version}.tar.bz2 ${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/generic/docs/${version}/docs.tar.bz2
  tar xjf build/doc-site/${version}.tar.bz2 -C site
  echo "  <option value=\"${version}\">${version}</option>" >> site/version_selector.html
done

echo '</select>' >> site/version_selector.html

latest=$(echo ${docs_packages} | jq '.[0].version' | tr -d '"')

cat << EOF > site/index.html
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="refresh" content="0; url=${latest}/index.html">
    <title>Redirecting...</title>
</head>
<body>
    <p>If you are not redirected automatically, <a href="${latest}/index.html">click here</a>.</p>
</body>
</html>
EOF