Skip to content

Commit 79f9dc2

Browse files
chore(docs): vendor the book into docs/book and serve it from the site
Hosting the book as a separate repository made link upkeep, dep versioning, and CI fan-out unnecessarily painful. The book sources, the hello demo, justfile, and README move under docs/book and the demo's nightshade dependency switches from a git URL to a workspace-relative path. The docs directory is excluded from the cargo workspace so the demo stays out of the main build, and the gitignore whitelists the book's markdown files. The site's Book button now resolves to {{ base_url }}/book/, the pages workflow installs mdBook, builds the book and demo into site/static/book, and bamboo bundles them into the deployed site so the book is reachable at /nightshade/book/. The README points there too.
1 parent cfc51c7 commit 79f9dc2

106 files changed

Lines changed: 21984 additions & 9 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/pages.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,23 @@ jobs:
5555
if: steps.cache-bamboo.outputs.cache-hit != 'true'
5656
run: cargo install bamboo-cli --version 0.5.3 --locked
5757

58+
- name: Setup mdBook
59+
uses: peaceiris/actions-mdbook@v2
60+
with:
61+
mdbook-version: '0.4.52'
62+
5863
- name: Build viewer
5964
run: trunk build --release --config apps/viewer/Trunk.toml --dist "$GITHUB_WORKSPACE/site/static/viewer" --public-url /nightshade/viewer/
6065

66+
- name: Build book demo
67+
run: trunk build --release --config docs/book/demos/hello/Trunk.toml --dist "$GITHUB_WORKSPACE/docs/book/demos/hello/dist" --public-url /nightshade/book/demos/hello/
68+
69+
- name: Build book
70+
run: mdbook build docs/book --dest-dir "$GITHUB_WORKSPACE/site/static/book"
71+
72+
- name: Copy book demo into book output
73+
run: mkdir -p site/static/book/demos/hello && cp -r docs/book/demos/hello/dist/. site/static/book/demos/hello/
74+
6175
- name: Build site
6276
working-directory: site
6377
run: bamboo build --base-url "https://matthewjberger.github.io/nightshade"

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ logs/
1414
!crates/nightshade/*.md
1515
!template/*.md
1616
!docs/*.md
17+
!docs/book/**/*.md
1718
!site/content/*.md
1819
apps/game/game.json
1920
*.tmp

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[workspace]
22
members = ["apps/*", "crates/*"]
3-
exclude = ["site", "template"]
3+
exclude = ["site", "template", "docs"]
44
resolver = "2"
55

66
[workspace.package]

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<a href="https://github.com/matthewjberger/nightshade"><img alt="github" src="https://img.shields.io/badge/github-matthewjberger/nightshade-8da0cb?style=for-the-badge&labelColor=555555&logo=github" height="20"></a>
77
<a href="https://crates.io/crates/nightshade"><img alt="crates.io" src="https://img.shields.io/crates/v/nightshade.svg?style=for-the-badge&color=fc8d62&logo=rust" height="20"></a>
88
<a href="https://docs.rs/nightshade"><img alt="docs.rs" src="https://img.shields.io/badge/docs.rs-nightshade-66c2a5?style=for-the-badge&labelColor=555555&logo=docs.rs" height="20"></a>
9-
<a href="https://matthewjberger.github.io/nightshade-book"><img alt="book" src="https://img.shields.io/badge/book-nightshade-blue?style=for-the-badge&labelColor=555555&logo=mdbook" height="20"></a>
9+
<a href="https://matthewjberger.github.io/nightshade/book/"><img alt="book" src="https://img.shields.io/badge/book-nightshade-blue?style=for-the-badge&labelColor=555555&logo=mdbook" height="20"></a>
1010
</p>
1111

1212
`Nightshade` is a data-oriented game engine written in rust 🦀
@@ -16,7 +16,7 @@
1616

1717
## Documentation
1818

19-
📖 **[Read the Book](https://matthewjberger.github.io/nightshade-book)** - Comprehensive guide covering all engine systems, from getting started to advanced features like SDF sculpting and audio-reactive effects.
19+
📖 **[Read the Book](https://matthewjberger.github.io/nightshade/book/)** - Comprehensive guide covering all engine systems, from getting started to advanced features like SDF sculpting and audio-reactive effects.
2020

2121
## Gallery
2222

docs/book/README.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# Nightshade Game Engine Documentation
2+
3+
Comprehensive documentation for the [Nightshade](https://github.com/matthewjberger/nightshade) game engine, built with [mdBook](https://rust-lang.github.io/mdBook/).
4+
5+
## Building
6+
7+
Install mdBook:
8+
9+
```bash
10+
cargo install mdbook
11+
```
12+
13+
Build and serve locally:
14+
15+
```bash
16+
mdbook serve --open
17+
```
18+
19+
## License
20+
21+
Nightshade is free, open source and permissively licensed. All code in this repository is dual-licensed under either:
22+
23+
* MIT License ([LICENSE-MIT](LICENSE-MIT) or http://opensource.org/licenses/MIT)
24+
* Apache License, Version 2.0 ([LICENSE-APACHE](LICENSE-APACHE) or http://www.apache.org/licenses/LICENSE-2.0)
25+
26+
at your option.
27+
28+
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in `nightshade` by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

docs/book/book.toml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
[book]
2+
authors = ["Matthew J. Berger"]
3+
language = "en"
4+
src = "src"
5+
title = "Nightshade Game Engine"
6+
7+
[rust]
8+
edition = "2024"
9+
10+
[output.html]
11+
default-theme = "dark"
12+
preferred-dark-theme = "ayu"
13+
mathjax-support = false

docs/book/demos/hello/.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
/target
2+
/dist
3+
Cargo.lock

docs/book/demos/hello/Cargo.toml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
[package]
2+
name = "hello-nightshade"
3+
version = "0.1.0"
4+
edition = "2024"
5+
6+
[dependencies]
7+
nightshade = { path = "../../../../crates/nightshade", features = ["egui"] }
8+
9+
[target.'cfg(target_arch = "wasm32")'.dependencies]
10+
wasm-bindgen = "0.2"
11+
wasm-bindgen-futures = "0.4"
12+
13+
[profile.release]
14+
opt-level = "z"
15+
lto = true

docs/book/demos/hello/Trunk.toml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
[build]
2+
target = "index.html"
3+
dist = "dist"
4+
5+
[serve]
6+
addresses = ["127.0.0.1"]
7+
port = 8080
8+
open = true

docs/book/demos/hello/index.html

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
<!doctype html>
2+
<html>
3+
<head>
4+
<meta charset="utf-8" />
5+
<meta name="viewport" content="width=device-width, initial-scale=1" />
6+
<title>Hello Nightshade</title>
7+
<base data-trunk-public-url />
8+
<style type="text/css">
9+
:focus {
10+
outline: none;
11+
}
12+
13+
body,
14+
html {
15+
margin: 0;
16+
padding: 0;
17+
width: 100%;
18+
height: 100%;
19+
overflow: hidden;
20+
}
21+
22+
.root {
23+
width: 100%;
24+
height: 100%;
25+
display: flex;
26+
justify-content: center;
27+
align-items: center;
28+
}
29+
30+
.main-canvas {
31+
display: block;
32+
width: 100%;
33+
height: 100%;
34+
}
35+
</style>
36+
</head>
37+
38+
<body>
39+
<script>
40+
window.addEventListener('error', function(e) {
41+
if (e.message && e.message.includes('message channel closed')) {
42+
e.preventDefault();
43+
}
44+
});
45+
window.addEventListener('unhandledrejection', function(e) {
46+
if (e.reason && e.reason.message && e.reason.message.includes('message channel closed')) {
47+
e.preventDefault();
48+
}
49+
});
50+
</script>
51+
<link data-trunk rel="rust" href="Cargo.toml" data-target-name="hello-nightshade" />
52+
<div class="root">
53+
<canvas class="main-canvas" id="canvas"></canvas>
54+
</div>
55+
<script>
56+
function resizeCanvas() {
57+
const canvas = document.getElementById("canvas");
58+
const dpr = window.devicePixelRatio || 1;
59+
const width = window.innerWidth;
60+
const height = window.innerHeight;
61+
62+
canvas.width = Math.round(width * dpr);
63+
canvas.height = Math.round(height * dpr);
64+
canvas.style.width = width + "px";
65+
canvas.style.height = height + "px";
66+
}
67+
resizeCanvas();
68+
window.addEventListener("resize", resizeCanvas);
69+
</script>
70+
</body>
71+
</html>

0 commit comments

Comments
 (0)