Skip to content

Commit

Permalink
Fixup docs
Browse files Browse the repository at this point in the history
  • Loading branch information
CensoredUsername committed Aug 23, 2019
1 parent e9e2ab2 commit 6716127
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 17 deletions.
6 changes: 3 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ target/
build_docs/
Cargo.lock

testing/tests/bf_interpreter.rs
testing/tests/bf_jit.rs
testing/tests/hello_world.rs
testing/tests/bf_interpreter*.rs
testing/tests/bf_jit*.rs
testing/tests/hello_world*.rs

__pycache__
20 changes: 16 additions & 4 deletions build_docs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,25 @@ 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-jit" "hello-world")
declare -a examples=("bf-jit" "hello-world" "bf-interpreter")
for EX in "${examples[@]}"
do
TARGET=$(echo $EX | tr - _)
cp "./doc/examples/${EX}/src/x64.rs" "./testing/tests/${TARGET}.rs"
echo -n -e "#[test]\nfn ex_${TARGET}()\n{\n main();\n}\n" >> \
"./testing/tests/${TARGET}.rs"
if [ -f "./doc/examples/${EX}/src/main.rs" ]; then
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"
fi
if [ -f "./doc/examples/${EX}/src/x64.rs" ]; then
cp "./doc/examples/${EX}/src/x64.rs" "./testing/tests/${TARGET}_x64.rs"
echo -n -e "#[cfg(target_arch=\"x64\")]\n#[test]\nfn ex_${TARGET}()\n{\n main();\n}\n" >> \
"./testing/tests/${TARGET}_x64.rs"
fi
if [ -f "./doc/examples/${EX}/src/aarch64.rs" ]; then
cp "./doc/examples/${EX}/src/aarch64.rs" "./testing/tests/${TARGET}_aarch64.rs"
echo -n -e "#[cfg(target_arch=\"aarch64\")]\n#[test]\nfn ex_${TARGET}()\n{\n main();\n}\n" >> \
"./testing/tests/${TARGET}_aarch64.rs"
fi
done

if [ "$1" == "commit" ]; then
Expand Down
21 changes: 11 additions & 10 deletions doc/hack.js
Original file line number Diff line number Diff line change
@@ -1,22 +1,21 @@
var path = $(".location").text();
var nest_count;
if (path) {
nest_count = path.split("::").length + 1;
} else {
nest_count = 1;
}
// I'm sorry
var path = document.getElementsByClassName("logo-container")[0].childNodes[0].getAttribute("src");
var nest_count = (path.match(/\.\./g)||[]).length + 1;

var base_path = "";
for (i = 0; i < nest_count; i++) {
base_path += "../";
}

$(".sidebar").prepend('\
var sidebar = document.getElementsByClassName("sidebar")[0];

var node = document.createElement("div");
node.innerHTML = '\
<p class="location">\
<a href="' + base_path + 'language/index.html">dynasm-rs</a>\
</p>\
<div class = "block modules">\
<h3>Components</h3>\
<h3>Components</h3>\
<ul>\
<li>\
<a href="' + base_path + 'language/index.html">Syntax</a>\
Expand All @@ -28,4 +27,6 @@ $(".sidebar").prepend('\
<a href="' + base_path + 'runtime/dynasmrt/index.html">Runtime (dynasmrt)</a>\
</li>\
</ul>\
</div>');
</div>';

sidebar.insertBefore(node, sidebar.childNodes[2]);

0 comments on commit 6716127

Please sign in to comment.