Skip to content

Commit

Permalink
Fix documentation html hacks
Browse files Browse the repository at this point in the history
  • Loading branch information
CensoredUsername committed Jan 30, 2023
1 parent c574c29 commit 25aca61
Show file tree
Hide file tree
Showing 6 changed files with 52 additions and 49 deletions.
3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,15 @@ members = [
"plugin",
"runtime",
"testing",
"doc/insref",
]

[workspace.package]
authors = ["Alexander Stocko <[email protected]>", "CensoredUsername <[email protected]>"]
version = "1.2.3"
edition = "2018"

documentation = "https://censoredusername.github.io/dynasm-rs/plugin/dynasm/index.html"
documentation = "https://censoredusername.github.io/dynasm-rs/language/index.html"
repository = "https://github.com/CensoredUsername/dynasm-rs"

readme = "README.md"
Expand Down
21 changes: 12 additions & 9 deletions build_docs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,15 @@ set -o errexit
shopt -s globstar

echo "build individual documentation"
(cd plugin && cargo doc --no-deps)
(cd runtime && cargo doc --no-deps)
cargo doc -p dynasm --no-deps
cargo doc -p dynasmrt --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 -- x64 > ../instructionref_x64.md && cargo run -- aarch64 > ../instructionref_aarch64.md)
Expand All @@ -24,15 +22,20 @@ 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
cp -r ./target/doc/* ./build_docs/

echo "Do some css linking"
cd build_docs/language
RUSTDOC=$(echo ../static.files/rustdoc*.css)
LIGHT=$(echo ../static.files/light*.css)
cd ../..
RUSTDOC=$RUSTDOC LIGHT=$LIGHT envsubst < ./doc/formatting.css > ./build_docs/language/formatting.css


echo "insert javascript"
cat ./doc/hack.js >> ./build_docs/plugin/search-index.js
cat ./doc/hack.js >> ./build_docs/runtime/search-index.js
cat ./doc/hack.js >> ./build_docs/static.files/main-*.js

echo "copy docs examples to tests"
declare -a examples=("bf-jit" "hello-world" "bf-interpreter")
Expand Down
4 changes: 2 additions & 2 deletions doc/formatting.css
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
@import url('../plugin/rustdoc.css');
@import url('../plugin/light.css');
@import url('${RUSTDOC}');
@import url('${LIGHT}');

code.language-diffnew {
background-color: rgb(203, 255, 203);
Expand Down
43 changes: 23 additions & 20 deletions doc/hack.js
Original file line number Diff line number Diff line change
@@ -1,32 +1,35 @@
// I'm sorry
var path = document.getElementsByClassName("logo-container")[0].childNodes[0].getAttribute("src");
var nest_count = (path.match(/\.\./g)||[]).length + 1;
var nest_count = (path.match(/\.\./g)||[]).length;

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

var sidebar = document.getElementsByClassName("sidebar")[0];
var sidebar = document.getElementsByClassName("sidebar-elems")[0];

var node = document.createElement("div");
node.innerHTML = '\
<p class="location">\
<h2 class="location">\
<a href="' + base_path + 'language/index.html">dynasm-rs</a>\
</p>\
<div class = "block modules">\
<h3>Components</h3>\
<ul>\
<li>\
<a href="' + base_path + 'language/index.html">Syntax</a>\
</li>\
<li>\
<a href="' + base_path + 'plugin/dynasm/index.html">Plugin (dynasm)</a>\
</li>\
<li>\
<a href="' + base_path + 'runtime/dynasmrt/index.html">Runtime (dynasmrt)</a>\
</li>\
</ul>\
</div>';
</h2>\
<h3>Components</h3>\
<ul class = "block crate">\
<li>\
<a href="' + base_path + 'language/index.html">Syntax</a>\
</li>\
<li>\
<a href="' + base_path + 'dynasm/index.html">Plugin (dynasm)</a>\
</li>\
<li>\
<a href="' + base_path + 'dynasmrt/index.html">Runtime (dynasmrt)</a>\
</li>\
</ul>';

while (node.childNodes.length != 0) {
var n = node.childNodes[0];
node.removeChild(n);
sidebar.appendChild(n);
}

sidebar.insertBefore(node, sidebar.childNodes[2]);
6 changes: 3 additions & 3 deletions doc/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ and formats supported by dynasm-rs. Finally, documentation on the

The following list summarizes some of the larger differences between LuaJIT dynasm and dynasm-rs.

## general
### general

- LuaJIT dynasm uses full program analysis, allowing it to compile local and global labels down to
enums. Dynasm-rs however uses HashMaps keyed by static strings, meaning label resolution in dynasm-rs
Expand All @@ -41,14 +41,14 @@ instructions, dynasm-rs uses the `dynasm!` procedural macro with lines starting
- LuaJIT has macros in its invocations, dynasm-rs uses rust macros that expand to `dynasm!` invocations.
- Dynasm-rs doesn't have typed aliases

## x64/x86
### x64/x86

- LuaJIT uses the `mov64` mnemnonic to encode 64-bit displacement mov. Dynasm-rs uses the `movabs`
mnemnonic with a 64-bit immediate parameter to encode this.
- Dynasm-rs is not sensitive to the order of parameters inside a memory reference.
- The syntax used for type maps is significantly different. In LuaJit dynasm it is `Type:reg->attr`
in dynasm-rs it is `reg => Type.attr`.

## aarch64
### aarch64

- Unknown.
24 changes: 10 additions & 14 deletions doc/pre.html
Original file line number Diff line number Diff line change
@@ -1,24 +1,22 @@
<nav class="sidebar">
<p class="location">
<a href="./index.html">dynasm-rs</a>
</p>
<div class = "block modules">
<h2 class="location">
<a href="#">Language dynasm-rs</a>
</h2>
<div class="sidebar-elems">
<h3>Components</h3>
<ul>
<ul class="block crate">
<li>
<a href="../language/index.html">Syntax</a>
</li>
<li>
<a href="../plugin/dynasm/index.html">Plugin (dynasm)</a>
<a href="../dynasm/index.html">Plugin (dynasm)</a>
</li>
<li>
<a href="../runtime/dynasmrt/index.html">Runtime (dynasmrt)</a>
<a href="../dynasmrt/index.html">Runtime (dynasmrt)</a>
</li>
</ul>
</div>
<div class = "block crate">
<h3>Syntax</h3>
<ul>
<ul class="block crate">
<li>
<a href="./index.html">Home</a>
</li>
Expand All @@ -32,11 +30,9 @@ <h3>Syntax</h3>
<a href="./releasenotes.html">Release Notes</a>
</li>
</ul>
</div>
<div class = "block crate">
<h3>Architectures</h3>
<h4>x64/x86</h4>
<ul>
<ul class="block crate">
<li>
<a href="./langref_x64.html">Language dialect</a>
</li>
Expand All @@ -45,7 +41,7 @@ <h4>x64/x86</h4>
</li>
</ul>
<h4>aarch64</h4>
<ul>
<ul class="block crate">
<li>
<a href="./langref_aarch64.html">Language dialect</a>
</li>
Expand Down

0 comments on commit 25aca61

Please sign in to comment.