Skip to content

Commit 753780f

Browse files
committed
Finish move of theme to mdbook-html
This updates everything for the move of theme to mdbook-html. There will be followup commits that will be doing more cleanup here.
1 parent 3087686 commit 753780f

File tree

13 files changed

+77
-56
lines changed

13 files changed

+77
-56
lines changed

Cargo.lock

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ handlebars = "6.0"
6565
hex = "0.4.3"
6666
log.workspace = true
6767
mdbook-core.workspace = true
68+
mdbook-html.workspace = true
6869
mdbook-markdown.workspace = true
6970
mdbook-preprocessor.workspace = true
7071
mdbook-renderer.workspace = true
@@ -109,7 +110,7 @@ walkdir = "2.3.3"
109110
default = ["watch", "serve", "search"]
110111
watch = ["dep:notify", "dep:notify-debouncer-mini", "dep:ignore", "dep:pathdiff", "dep:walkdir"]
111112
serve = ["dep:futures-util", "dep:tokio", "dep:axum", "dep:tower-http"]
112-
search = ["dep:elasticlunr-rs", "dep:ammonia"]
113+
search = ["dep:elasticlunr-rs", "dep:ammonia", "mdbook-html/search"]
113114

114115
[[bin]]
115116
doc = false

crates/mdbook-html/Cargo.toml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,14 @@ repository.workspace = true
88
rust-version.workspace = true
99

1010
[dependencies]
11+
anyhow.workspace = true
12+
log.workspace = true
13+
14+
[dev-dependencies]
15+
tempfile.workspace = true
1116

1217
[lints]
1318
workspace = true
19+
20+
[features]
21+
search = []

crates/mdbook-html/src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
11
//! mdBook HTML renderer.
2+
3+
pub mod theme;

crates/mdbook-html/src/theme/fonts.rs

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,61 +1,61 @@
1-
pub static CSS: &[u8] = include_bytes!("fonts.css");
1+
pub static CSS: &[u8] = include_bytes!("../../front-end/fonts/fonts.css");
22
// An array of (file_name, file_contents) pairs
33
pub static LICENSES: [(&str, &[u8]); 2] = [
44
(
55
"fonts/OPEN-SANS-LICENSE.txt",
6-
include_bytes!("OPEN-SANS-LICENSE.txt"),
6+
include_bytes!("../../front-end/fonts/OPEN-SANS-LICENSE.txt"),
77
),
88
(
99
"fonts/SOURCE-CODE-PRO-LICENSE.txt",
10-
include_bytes!("SOURCE-CODE-PRO-LICENSE.txt"),
10+
include_bytes!("../../front-end/fonts/SOURCE-CODE-PRO-LICENSE.txt"),
1111
),
1212
];
1313
// An array of (file_name, file_contents) pairs
1414
pub static OPEN_SANS: [(&str, &[u8]); 10] = [
1515
(
1616
"fonts/open-sans-v17-all-charsets-300.woff2",
17-
include_bytes!("open-sans-v17-all-charsets-300.woff2"),
17+
include_bytes!("../../front-end/fonts/open-sans-v17-all-charsets-300.woff2"),
1818
),
1919
(
2020
"fonts/open-sans-v17-all-charsets-300italic.woff2",
21-
include_bytes!("open-sans-v17-all-charsets-300italic.woff2"),
21+
include_bytes!("../../front-end/fonts/open-sans-v17-all-charsets-300italic.woff2"),
2222
),
2323
(
2424
"fonts/open-sans-v17-all-charsets-regular.woff2",
25-
include_bytes!("open-sans-v17-all-charsets-regular.woff2"),
25+
include_bytes!("../../front-end/fonts/open-sans-v17-all-charsets-regular.woff2"),
2626
),
2727
(
2828
"fonts/open-sans-v17-all-charsets-italic.woff2",
29-
include_bytes!("open-sans-v17-all-charsets-italic.woff2"),
29+
include_bytes!("../../front-end/fonts/open-sans-v17-all-charsets-italic.woff2"),
3030
),
3131
(
3232
"fonts/open-sans-v17-all-charsets-600.woff2",
33-
include_bytes!("open-sans-v17-all-charsets-600.woff2"),
33+
include_bytes!("../../front-end/fonts/open-sans-v17-all-charsets-600.woff2"),
3434
),
3535
(
3636
"fonts/open-sans-v17-all-charsets-600italic.woff2",
37-
include_bytes!("open-sans-v17-all-charsets-600italic.woff2"),
37+
include_bytes!("../../front-end/fonts/open-sans-v17-all-charsets-600italic.woff2"),
3838
),
3939
(
4040
"fonts/open-sans-v17-all-charsets-700.woff2",
41-
include_bytes!("open-sans-v17-all-charsets-700.woff2"),
41+
include_bytes!("../../front-end/fonts/open-sans-v17-all-charsets-700.woff2"),
4242
),
4343
(
4444
"fonts/open-sans-v17-all-charsets-700italic.woff2",
45-
include_bytes!("open-sans-v17-all-charsets-700italic.woff2"),
45+
include_bytes!("../../front-end/fonts/open-sans-v17-all-charsets-700italic.woff2"),
4646
),
4747
(
4848
"fonts/open-sans-v17-all-charsets-800.woff2",
49-
include_bytes!("open-sans-v17-all-charsets-800.woff2"),
49+
include_bytes!("../../front-end/fonts/open-sans-v17-all-charsets-800.woff2"),
5050
),
5151
(
5252
"fonts/open-sans-v17-all-charsets-800italic.woff2",
53-
include_bytes!("open-sans-v17-all-charsets-800italic.woff2"),
53+
include_bytes!("../../front-end/fonts/open-sans-v17-all-charsets-800italic.woff2"),
5454
),
5555
];
5656

5757
// A (file_name, file_contents) pair
5858
pub static SOURCE_CODE_PRO: (&str, &[u8]) = (
5959
"fonts/source-code-pro-v11-all-charsets-500.woff2",
60-
include_bytes!("source-code-pro-v11-all-charsets-500.woff2"),
60+
include_bytes!("../../front-end/fonts/source-code-pro-v11-all-charsets-500.woff2"),
6161
);

crates/mdbook-html/src/theme/mod.rs

Lines changed: 30 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -11,31 +11,36 @@ pub mod playground_editor;
1111
#[cfg(feature = "search")]
1212
pub mod searcher;
1313

14-
pub static INDEX: &[u8] = include_bytes!("templates/index.hbs");
15-
pub static HEAD: &[u8] = include_bytes!("templates/head.hbs");
16-
pub static REDIRECT: &[u8] = include_bytes!("templates/redirect.hbs");
17-
pub static HEADER: &[u8] = include_bytes!("templates/header.hbs");
18-
pub static TOC_JS: &[u8] = include_bytes!("templates/toc.js.hbs");
19-
pub static TOC_HTML: &[u8] = include_bytes!("templates/toc.html.hbs");
20-
pub static CHROME_CSS: &[u8] = include_bytes!("css/chrome.css");
21-
pub static GENERAL_CSS: &[u8] = include_bytes!("css/general.css");
22-
pub static PRINT_CSS: &[u8] = include_bytes!("css/print.css");
23-
pub static VARIABLES_CSS: &[u8] = include_bytes!("css/variables.css");
24-
pub static FAVICON_PNG: &[u8] = include_bytes!("images/favicon.png");
25-
pub static FAVICON_SVG: &[u8] = include_bytes!("images/favicon.svg");
26-
pub static JS: &[u8] = include_bytes!("js/book.js");
27-
pub static HIGHLIGHT_JS: &[u8] = include_bytes!("js/highlight.js");
28-
pub static TOMORROW_NIGHT_CSS: &[u8] = include_bytes!("css/tomorrow-night.css");
29-
pub static HIGHLIGHT_CSS: &[u8] = include_bytes!("css/highlight.css");
30-
pub static AYU_HIGHLIGHT_CSS: &[u8] = include_bytes!("css/ayu-highlight.css");
31-
pub static CLIPBOARD_JS: &[u8] = include_bytes!("js/clipboard.min.js");
32-
pub static FONT_AWESOME: &[u8] = include_bytes!("css/font-awesome.min.css");
33-
pub static FONT_AWESOME_EOT: &[u8] = include_bytes!("fonts/fontawesome-webfont.eot");
34-
pub static FONT_AWESOME_SVG: &[u8] = include_bytes!("fonts/fontawesome-webfont.svg");
35-
pub static FONT_AWESOME_TTF: &[u8] = include_bytes!("fonts/fontawesome-webfont.ttf");
36-
pub static FONT_AWESOME_WOFF: &[u8] = include_bytes!("fonts/fontawesome-webfont.woff");
37-
pub static FONT_AWESOME_WOFF2: &[u8] = include_bytes!("fonts/fontawesome-webfont.woff2");
38-
pub static FONT_AWESOME_OTF: &[u8] = include_bytes!("fonts/FontAwesome.otf");
14+
pub static INDEX: &[u8] = include_bytes!("../../front-end/templates/index.hbs");
15+
pub static HEAD: &[u8] = include_bytes!("../../front-end/templates/head.hbs");
16+
pub static REDIRECT: &[u8] = include_bytes!("../../front-end/templates/redirect.hbs");
17+
pub static HEADER: &[u8] = include_bytes!("../../front-end/templates/header.hbs");
18+
pub static TOC_JS: &[u8] = include_bytes!("../../front-end/templates/toc.js.hbs");
19+
pub static TOC_HTML: &[u8] = include_bytes!("../../front-end/templates/toc.html.hbs");
20+
pub static CHROME_CSS: &[u8] = include_bytes!("../../front-end/css/chrome.css");
21+
pub static GENERAL_CSS: &[u8] = include_bytes!("../../front-end/css/general.css");
22+
pub static PRINT_CSS: &[u8] = include_bytes!("../../front-end/css/print.css");
23+
pub static VARIABLES_CSS: &[u8] = include_bytes!("../../front-end/css/variables.css");
24+
pub static FAVICON_PNG: &[u8] = include_bytes!("../../front-end/images/favicon.png");
25+
pub static FAVICON_SVG: &[u8] = include_bytes!("../../front-end/images/favicon.svg");
26+
pub static JS: &[u8] = include_bytes!("../../front-end/js/book.js");
27+
pub static HIGHLIGHT_JS: &[u8] = include_bytes!("../../front-end/js/highlight.js");
28+
pub static TOMORROW_NIGHT_CSS: &[u8] = include_bytes!("../../front-end/css/tomorrow-night.css");
29+
pub static HIGHLIGHT_CSS: &[u8] = include_bytes!("../../front-end/css/highlight.css");
30+
pub static AYU_HIGHLIGHT_CSS: &[u8] = include_bytes!("../../front-end/css/ayu-highlight.css");
31+
pub static CLIPBOARD_JS: &[u8] = include_bytes!("../../front-end/js/clipboard.min.js");
32+
pub static FONT_AWESOME: &[u8] = include_bytes!("../../front-end/css/font-awesome.min.css");
33+
pub static FONT_AWESOME_EOT: &[u8] =
34+
include_bytes!("../../front-end/fonts/fontawesome-webfont.eot");
35+
pub static FONT_AWESOME_SVG: &[u8] =
36+
include_bytes!("../../front-end/fonts/fontawesome-webfont.svg");
37+
pub static FONT_AWESOME_TTF: &[u8] =
38+
include_bytes!("../../front-end/fonts/fontawesome-webfont.ttf");
39+
pub static FONT_AWESOME_WOFF: &[u8] =
40+
include_bytes!("../../front-end/fonts/fontawesome-webfont.woff");
41+
pub static FONT_AWESOME_WOFF2: &[u8] =
42+
include_bytes!("../../front-end/fonts/fontawesome-webfont.woff2");
43+
pub static FONT_AWESOME_OTF: &[u8] = include_bytes!("../../front-end/fonts/FontAwesome.otf");
3944

4045
/// The `Theme` struct should be used instead of the static variables because
4146
/// the `new()` method will look if the user has a theme directory in their
Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
//! Theme dependencies for the playground editor.
22
3-
pub static JS: &[u8] = include_bytes!("editor.js");
4-
pub static ACE_JS: &[u8] = include_bytes!("ace.js");
5-
pub static MODE_RUST_JS: &[u8] = include_bytes!("mode-rust.js");
6-
pub static THEME_DAWN_JS: &[u8] = include_bytes!("theme-dawn.js");
7-
pub static THEME_TOMORROW_NIGHT_JS: &[u8] = include_bytes!("theme-tomorrow_night.js");
3+
pub static JS: &[u8] = include_bytes!("../../front-end/playground_editor/editor.js");
4+
pub static ACE_JS: &[u8] = include_bytes!("../../front-end/playground_editor/ace.js");
5+
pub static MODE_RUST_JS: &[u8] = include_bytes!("../../front-end/playground_editor/mode-rust.js");
6+
pub static THEME_DAWN_JS: &[u8] = include_bytes!("../../front-end/playground_editor/theme-dawn.js");
7+
pub static THEME_TOMORROW_NIGHT_JS: &[u8] =
8+
include_bytes!("../../front-end/playground_editor/theme-tomorrow_night.js");
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//! Theme dependencies for in-browser search. Not included in mdbook when
22
//! the "search" cargo feature is disabled.
33
4-
pub static JS: &[u8] = include_bytes!("searcher.js");
5-
pub static MARK_JS: &[u8] = include_bytes!("mark.min.js");
6-
pub static ELASTICLUNR_JS: &[u8] = include_bytes!("elasticlunr.min.js");
4+
pub static JS: &[u8] = include_bytes!("../../front-end/searcher/searcher.js");
5+
pub static MARK_JS: &[u8] = include_bytes!("../../front-end/searcher/mark.min.js");
6+
pub static ELASTICLUNR_JS: &[u8] = include_bytes!("../../front-end/searcher/elasticlunr.min.js");

src/book/init.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@ use std::io::Write;
33
use std::path::PathBuf;
44

55
use super::MDBook;
6-
use crate::theme;
76
use anyhow::{Context, Result};
87
use log::{debug, error, info, trace};
98
use mdbook_core::config::Config;
109
use mdbook_core::utils::fs::write_file;
10+
use mdbook_html::theme;
1111

1212
/// A helper for setting up a new book and its directory structure.
1313
#[derive(Debug, Clone, PartialEq)]

src/lib.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,6 @@
8383
pub mod book;
8484
pub mod preprocess;
8585
pub mod renderer;
86-
#[path = "front-end/mod.rs"]
87-
pub mod theme;
8886

8987
pub use crate::book::BookItem;
9088
pub use crate::book::MDBook;

0 commit comments

Comments
 (0)