From 67161271db73d9782d7f26f9f51286fee85c71e1 Mon Sep 17 00:00:00 2001 From: CensoredUsername Date: Fri, 23 Aug 2019 03:16:05 +0200 Subject: [PATCH] Fixup docs --- .gitignore | 6 +++--- build_docs.sh | 20 ++++++++++++++++---- doc/hack.js | 21 +++++++++++---------- 3 files changed, 30 insertions(+), 17 deletions(-) diff --git a/.gitignore b/.gitignore index 1066e4e997..6ca8e20e22 100644 --- a/.gitignore +++ b/.gitignore @@ -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__ diff --git a/build_docs.sh b/build_docs.sh index c011e3cacc..c4d08fc5af 100644 --- a/build_docs.sh +++ b/build_docs.sh @@ -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 diff --git a/doc/hack.js b/doc/hack.js index 271ebd43bf..90f7dca713 100644 --- a/doc/hack.js +++ b/doc/hack.js @@ -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 = '\

\ dynasm-rs\

\
\ -

Components

\ +

Components

\ \ -
'); + '; + +sidebar.insertBefore(node, sidebar.childNodes[2]);