forked from dimforge/nphysics.org
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfix_rustdoc.sh
executable file
·76 lines (64 loc) · 2.46 KB
/
fix_rustdoc.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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#! /bin/bash
echo "Integrating rust documentation to the website..."
cssfile=./docs/rustdoc/rustdoc.css
tmpcssfile=./docs/rustdoc/rustdoc.css.tmp
echo '@import url("//fonts.googleapis.com/css?family=Lato:400,700,900,400italic");' > $tmpcssfile
echo '@import url("//cdn.rawgit.com/piscis/github-fork-ribbon-css-bem/v0.1.22/dist/gh-fork-ribbon-bem.min.css");' >> $tmpcssfile
cat $cssfile >> $tmpcssfile
cat custom_flatly/css/bootstrap-custom.min2.css >> $tmpcssfile
cat custom_flatly/css/base2.css >> $tmpcssfile
cat custom_flatly/css/font-awesome-4.0.3.css >> $tmpcssfile
sed -i '' -e 's/margin-left:[ ]*230px;//g' $tmpcssfile
mv $tmpcssfile $cssfile
files2d=`find ./docs/rustdoc/nphysics2d ./docs/rustdoc/src/nphysics2d -name \*.html -printf '%p '`
files3d=`find ./docs/rustdoc/nphysics3d ./docs/rustdoc/src/nphysics3d -name \*.html -printf '%p '`
sidebar='<nav class="sidebar">'
sub='<nav class="sub">'
container='<div class="container">'
class3='<div id="hide_medium" class="col-md-3">'
class9='<div class="col-md-9">'
end_div='</div>'
footer='<section class="footer"></section>'
body='<body[^>]*>'
head='<head>'
favicon='<link rel="shortcut icon" href="/img/favicon.ico">'
function patch_file() {
echo "Patching $1."
sed -i '' -e "s#$head#${head}${favicon}#g" $1
sed -i '' -e "s#$sidebar#${container}${class3}${sidebar}#g" $1
sed -i '' -e "s#$sub#${end_div}${class9}${sub}#g" $1
sed -i '' -e "s#$footer#${end_div}${end_div}${footer}#g" $1
sed -i '' -e "s#</body>\|</html>##g" $1
sed -i '' -e "s#</head>#${css}</head>#g" $1
nav='
<div id='"'"'nav_placeholder'"'"'> </div>
<script src="/jquery.js"></script>
<script>
var the_footer;
$.get("/'$2'/index.html", function(data) {
data = data.split("../").join("/");
data = data.split("..").join("/");
var $data = $(data);
$("div#nav_placeholder").prepend($data.find("#common_navbar"));
});
</script>'
escaped_nav=`echo $nav | sed ':a;N;$!ba;s/\n/ /g'`
sed -i '' -e "s%${body}%&${escaped_nav}%g" $1
fileend='
<script>var base_url = "../" + window.rootPath;</script>
<script src="/js/highlight.pack.js"></script>
<script src="/js/bootstrap-3.0.3.min.js"></script>
<script src="/js/base.js"></script>
</body>
</html>'
echo $fileend >> $1
}
for file in `echo $files2d`
do
patch_file $file "rustdoc_nphysics2d"
done
for file in `echo $files3d`
do
patch_file $file "rustdoc_nphysics3d"
done
echo "... integration done!"