-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathbuild-docs.sh
42 lines (32 loc) · 1.26 KB
/
build-docs.sh
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
#!/bin/bash
set -e
rm -rf build/
# This build script is only used for local docs build.
# The docs build for the website uses a different script.
# Move theming elements into the docs folder
cp -R pytket-docs-theming/quantinuum-sphinx .
cp pytket-docs-theming/conf.py .
cp -R pytket-docs-theming/_static . # Currently unused
# Get the name of the project
PACKAGE="$(basename "$(dirname `pwd`)")"
# Get pytket extension version
VERSION="$(pip show $PACKAGE | grep Version | awk '{print $2}')"
# Output package version
echo extension version $VERSION
# Combine to set title
PACKAGE+=" $VERSION"
# Build the docs setting the html_title
sphinx-build -b html . build -D html_title="$PACKAGE API documentation" -W
# Find and replace all generated links that use _tket in the built html.
# Note that MACOS and linux have differing sed syntax.
if [[ "$OSTYPE" == "darwin"* ]]; then
find build/ -type f -name "*.html" | xargs sed -e 's/pytket._tket/pytket/g' -i ""
sed -i '' 's/pytket._tket/pytket/g' build/searchindex.js
else
find build/ -type f -name "*.html" | xargs sed -i 's/pytket._tket/pytket/g'
sed -i 's/pytket._tket/pytket/g' build/searchindex.js
fi
# Remove copied files after build is done. This ensures reusability.
rm -r quantinuum-sphinx
rm conf.py
set +e