-
Notifications
You must be signed in to change notification settings - Fork 56
/
Copy pathbuild_docs.sh
62 lines (50 loc) · 1.78 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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#!/bin/bash
set -o errexit
shopt -s globstar
echo "build individual documentation"
(cd plugin && cargo doc --no-deps)
(cd runtime && cargo doc --no-deps)
echo "remove old docs build"
rm -rf build_docs
echo "build directory structure"
mkdir ./build_docs
mkdir ./build_docs/language
mkdir ./build_docs/plugin
mkdir ./build_docs/runtime
echo "create instruction reference markdown file"
(cd doc/insref && cargo update && cargo run > ../instructionref.md)
echo "build plugin docs"
for f in ./doc/*.md; do
rustdoc $f -o ./build_docs/language --markdown-no-toc --html-before-content=./doc/pre.html --html-after-content=./doc/post.html --markdown-css=./formatting.css
done
cp ./doc/formatting.css ./build_docs/language/formatting.css
echo "copy over the docs folders"
cp -r ./plugin/target/doc/* ./build_docs/plugin
cp -r ./runtime/target/doc/* ./build_docs/runtime
echo "insert javascript"
cat ./doc/hack.js >> ./build_docs/plugin/search-index.js
cat ./doc/hack.js >> ./build_docs/runtime/search-index.js
echo "copy docs examples to tests"
declare -a examples=("bf-interpreter" "bf-jit" "hello-world")
for EX in "${examples[@]}"
do
TARGET=$(echo $EX | tr - _)
cp "./doc/examples/${EX}/src/main.rs" "./testing/tests/${TARGET}.rs"
echo -n -e "#[test]\nfn ex_${TARGET}()\n{\n main();\n}\n" >> \
"./testing/tests/${TARGET}.rs"
done
if [ "$1" == "commit" ]; then
echo "cloning gh-pages into a temporary directory"
git clone --branch gh-pages --depth 1 "[email protected]:CensoredUsername/dynasm-rs.git" deploy_docs
git gc
cd deploy_docs
git config user.name "CensoredUsername"
git config user.email "[email protected]"
cp ../build_docs/* ./ -r
git add .
git commit -m "Rebuild docs"
git push origin gh-pages
cd ..
rm deploy_docs -rf
fi
exit