From d95207a9c5ac9dc3edc9f5156ffc81791d401f28 Mon Sep 17 00:00:00 2001 From: Evan Almloff Date: Fri, 8 May 2026 15:32:16 -0500 Subject: [PATCH 1/7] switch to dioxus code --- .claude/settings.local.json | 7 + Cargo.lock | 632 ++++--- Cargo.toml | 3 +- packages/docs-blog/Cargo.toml | 1 - packages/docs-router/Cargo.toml | 3 +- packages/docs-router/src/lib.rs | 16 +- packages/docsite/Cargo.toml | 2 +- packages/docsite/assets/main.css | 21 + .../src/components/homepage/snippets.rs | 25 +- .../packages/mdbook-gen-example/src/lib.rs | 2 +- .../packages/mdbook-gen-example/src/router.rs | 1479 ++++++----------- .../packages/mdbook-gen/Cargo.toml | 19 +- .../packages/mdbook-gen/src/rsx.rs | 190 ++- .../packages/mdbook-gen/themes/Base16.thTheme | 401 ----- .../mdbook-gen/themes/MonokaiDark.thTheme | 410 ----- .../packages/mdbook-macro/Cargo.toml | 1 - .../packages/syntect-html/Cargo.toml | 15 - .../packages/syntect-html/src/lib.rs | 163 -- .../packages/use-mdbook/Cargo.toml | 1 + .../packages/use-mdbook/src/lib.rs | 4 + 20 files changed, 1048 insertions(+), 2347 deletions(-) create mode 100644 .claude/settings.local.json delete mode 100644 packages/include_mdbook/packages/mdbook-gen/themes/Base16.thTheme delete mode 100644 packages/include_mdbook/packages/mdbook-gen/themes/MonokaiDark.thTheme delete mode 100644 packages/include_mdbook/packages/syntect-html/Cargo.toml delete mode 100644 packages/include_mdbook/packages/syntect-html/src/lib.rs diff --git a/.claude/settings.local.json b/.claude/settings.local.json new file mode 100644 index 0000000000..6676ac5002 --- /dev/null +++ b/.claude/settings.local.json @@ -0,0 +1,7 @@ +{ + "permissions": { + "allow": [ + "Bash(gh pr list:*)" + ] + } +} diff --git a/Cargo.lock b/Cargo.lock index ee614965ff..256d322600 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -125,19 +125,222 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a23eb6b1614318a8071c9b2521f36b424b2c83db5eb3a0fead4a6c0809af6e61" [[package]] -name = "approx" -version = "0.5.1" +name = "arbitrary" +version = "1.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cab112f0a86d568ea0e627cc1d6be74a1e9cd55214684db5561995f6dad897c6" +checksum = "c3d036a3c4ab069c7b410a2ce876bd74808d2d0888a82667669f8e783a898bf1" + +[[package]] +name = "arborium" +version = "2.16.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "db65328fda517795f476b9d1b0794199cce180077e204629946a0705f0093093" dependencies = [ - "num-traits", + "arborium-bash", + "arborium-batch", + "arborium-css", + "arborium-dockerfile", + "arborium-highlight", + "arborium-html", + "arborium-javascript", + "arborium-json", + "arborium-lua", + "arborium-powershell", + "arborium-rust", + "arborium-theme", + "arborium-toml", + "arborium-tree-sitter", + "arborium-tsx", + "arborium-yaml", + "dlmalloc", ] [[package]] -name = "arbitrary" -version = "1.4.2" +name = "arborium-bash" +version = "2.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3d036a3c4ab069c7b410a2ce876bd74808d2d0888a82667669f8e783a898bf1" +checksum = "5b29627168ad951fccf683bac9b66674455b279eee7c03b61584207c9165aa6f" +dependencies = [ + "arborium-sysroot", + "cc", + "tree-sitter-language", +] + +[[package]] +name = "arborium-batch" +version = "2.16.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87e857cf7124cc81245ea39c4a4406d22aa4652689e0e53f1cc40b2d727a2117" +dependencies = [ + "arborium-sysroot", + "cc", + "tree-sitter-language", +] + +[[package]] +name = "arborium-css" +version = "2.16.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "356459e8f05e0d34f11130105a8b41b9ca8d50026d8491de9f8943e46fe4f4d8" +dependencies = [ + "arborium-sysroot", + "cc", + "tree-sitter-language", +] + +[[package]] +name = "arborium-dockerfile" +version = "2.16.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f2196d25a5ef3e2ff99e2e31fca2c4a3912e0242cc2696298a7f922b2d4c9d99" +dependencies = [ + "arborium-sysroot", + "cc", + "tree-sitter-language", +] + +[[package]] +name = "arborium-highlight" +version = "2.16.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "517a6778e29dc5d73d3c9993836bad9bc6fdd8bd8037fe7fd3f295e866d5cdab" +dependencies = [ + "arborium-theme", + "arborium-tree-sitter", + "streaming-iterator", +] + +[[package]] +name = "arborium-html" +version = "2.16.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "10dc4b68331e73185be5ecefa85f14ddbc4cf708c387650046826b04811b7596" +dependencies = [ + "arborium-css", + "arborium-javascript", + "arborium-sysroot", + "cc", + "tree-sitter-language", +] + +[[package]] +name = "arborium-javascript" +version = "2.16.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d2bc4cd42b968c2ba2dbac049ce7e9c94611cad1ff13c0b1dc8c84b0f314f1ce" +dependencies = [ + "arborium-sysroot", + "cc", + "tree-sitter-language", +] + +[[package]] +name = "arborium-json" +version = "2.16.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e97a71fbd9dcbe232f6b71fd5f526d6a20178920bc277298037f1dd80dfa8983" +dependencies = [ + "arborium-sysroot", + "cc", + "tree-sitter-language", +] + +[[package]] +name = "arborium-lua" +version = "2.16.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dbe5948a7e0fb3e9401e5384e2e05099d2b79891fb9c32b8eef4c48b488fab83" +dependencies = [ + "arborium-sysroot", + "cc", + "tree-sitter-language", +] + +[[package]] +name = "arborium-powershell" +version = "2.16.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cd686774f76ea4bdd43df840d69d2a165eb517d0e61b5cfcf09d66b254f93b47" +dependencies = [ + "arborium-sysroot", + "cc", + "tree-sitter-language", +] + +[[package]] +name = "arborium-rust" +version = "2.16.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fdac14e869cffb0378a3f6535f814f1105dd9cbe223f29751589c07f81a6d4a5" +dependencies = [ + "arborium-sysroot", + "cc", + "tree-sitter-language", +] + +[[package]] +name = "arborium-sysroot" +version = "2.16.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "43374e79fbeaedc2bf27eed475c26686c8ed8eef2180854eef22340b9e25b64a" +dependencies = [ + "cc", + "dlmalloc", +] + +[[package]] +name = "arborium-theme" +version = "2.16.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4b6dc64ecabaad99640e27c351008b1fd6df46bcfaefab6c0e315aac3247d1d9" + +[[package]] +name = "arborium-toml" +version = "2.16.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "069ccfccf82bc3698431d3845b0398249c331898c04f6bb2c01a465d92821780" +dependencies = [ + "arborium-sysroot", + "cc", + "tree-sitter-language", +] + +[[package]] +name = "arborium-tree-sitter" +version = "2.16.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f5a9280a27a2fd42ffbf3b72b99d60122f2c28c55c16c39da8ba2d126d1856c4" +dependencies = [ + "arborium-sysroot", + "cc", + "regex", + "regex-syntax", + "streaming-iterator", + "tree-sitter-language", +] + +[[package]] +name = "arborium-tsx" +version = "2.16.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85a69221bfca865125eafdb291ce708795f6984ca5ab7172381276c098a8e543" +dependencies = [ + "arborium-javascript", + "arborium-sysroot", + "cc", + "tree-sitter-language", +] + +[[package]] +name = "arborium-yaml" +version = "2.16.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6271e0c1be230902a18bc00ffc334bd6266c984e46a88a66ea9a13f0fea2b75c" +dependencies = [ + "arborium-sysroot", + "cc", + "tree-sitter-language", +] [[package]] name = "arg_enum_proc_macro" @@ -147,7 +350,7 @@ checksum = "0ae92a5119aa49cdbcf6b9f893fe4e1d98b04ccbf82ee0584ad948a44a734dea" dependencies = [ "proc-macro2", "quote", - "syn 2.0.107", + "syn 2.0.117", ] [[package]] @@ -222,7 +425,7 @@ checksum = "3b43422f69d8ff38f95f1b2bb76517c91589a924d1559a0e935d7c8ce0274c11" dependencies = [ "proc-macro2", "quote", - "syn 2.0.107", + "syn 2.0.117", ] [[package]] @@ -244,7 +447,7 @@ checksum = "c7c24de15d275a1ecfd47a380fb4d5ec9bfe0933f309ed5e705b775596a3574d" dependencies = [ "proc-macro2", "quote", - "syn 2.0.107", + "syn 2.0.117", ] [[package]] @@ -255,7 +458,7 @@ checksum = "9035ad2d096bed7955a320ee7e2230574d28fd3c3a0f186cbea1ff3c7eed5dbb" dependencies = [ "proc-macro2", "quote", - "syn 2.0.107", + "syn 2.0.117", ] [[package]] @@ -326,7 +529,7 @@ checksum = "ebb4bd301db2e2ca1f5be131c24eb8ebf2d9559bc3744419e93baf8ddea7e670" dependencies = [ "proc-macro2", "quote", - "syn 2.0.107", + "syn 2.0.117", ] [[package]] @@ -451,7 +654,7 @@ checksum = "604fde5e028fea851ce1d8570bbdc034bec850d157f7569d10f347d06808c05c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.107", + "syn 2.0.117", ] [[package]] @@ -466,15 +669,6 @@ version = "0.22.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6" -[[package]] -name = "bincode" -version = "1.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b1f45e9417d87227c7a56d22e471c6206462cba514c7590c09aff4cf6d1ddcad" -dependencies = [ - "serde", -] - [[package]] name = "bit_field" version = "0.10.3" @@ -559,12 +753,6 @@ version = "3.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "46c5e41b57b8bba42a04676d81cb89e9ee8e859a1a66f80a5a72e1cb76b34d43" -[[package]] -name = "by_address" -version = "1.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "64fa3c856b712db6612c019f14756e64e4bcea13337a6b33b696333a9eaa2d06" - [[package]] name = "bytemuck" version = "1.24.0" @@ -782,7 +970,7 @@ dependencies = [ "heck 0.5.0", "proc-macro2", "quote", - "syn 2.0.107", + "syn 2.0.117", ] [[package]] @@ -916,7 +1104,7 @@ checksum = "797d158acb331e2a89d696343a27cd39bf7e36aaef33ba4799a5ef1526e24861" dependencies = [ "proc-macro2", "quote", - "syn 2.0.107", + "syn 2.0.117", ] [[package]] @@ -1185,7 +1373,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "13b588ba4ac1a99f7f2964d24b3d896ddc6bf847ee3855dbd4366f058cfcd331" dependencies = [ "quote", - "syn 2.0.107", + "syn 2.0.117", ] [[package]] @@ -1208,7 +1396,7 @@ dependencies = [ "ident_case", "proc-macro2", "quote", - "syn 2.0.107", + "syn 2.0.117", ] [[package]] @@ -1219,7 +1407,7 @@ checksum = "d38308df82d1080de0afee5d069fa14b0326a88c14f15c5ccda35b4a6c414c81" dependencies = [ "darling_core", "quote", - "syn 2.0.107", + "syn 2.0.117", ] [[package]] @@ -1272,7 +1460,7 @@ dependencies = [ "proc-macro2", "quote", "rustc_version", - "syn 2.0.107", + "syn 2.0.117", ] [[package]] @@ -1292,7 +1480,7 @@ checksum = "bda628edc44c4bb645fbe0f758797143e4e07926f7ebf4e9bdfbd3d2ce621df3" dependencies = [ "proc-macro2", "quote", - "syn 2.0.107", + "syn 2.0.117", "unicode-xid", ] @@ -1378,7 +1566,7 @@ dependencies = [ "quote", "regex", "serde", - "syn 2.0.107", + "syn 2.0.117", ] [[package]] @@ -1390,6 +1578,33 @@ dependencies = [ "wasm-bindgen", ] +[[package]] +name = "dioxus-code" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "28fcba1b18d2caec11fe1ff2db089c75353c5dd011fe8fc06913d58cd7fba7f1" +dependencies = [ + "arborium", + "arborium-theme", + "dioxus", + "dioxus-code-macro", +] + +[[package]] +name = "dioxus-code-macro" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fa8a99cabf9a5b47d492f6d6c9c7291ec1bb739af67a06895a1dd7c5a044dfa2" +dependencies = [ + "arborium", + "arborium-theme", + "macro-string", + "proc-macro-crate 3.5.0", + "proc-macro2", + "quote", + "syn 2.0.117", +] + [[package]] name = "dioxus-config-macro" version = "0.7.1" @@ -1439,7 +1654,7 @@ dependencies = [ "dioxus-rsx", "proc-macro2", "quote", - "syn 2.0.107", + "syn 2.0.117", ] [[package]] @@ -1604,7 +1819,6 @@ dependencies = [ "mdbook-gen", "mdbook-shared", "serde", - "syntect-html", "use-mdbook", ] @@ -1619,6 +1833,7 @@ dependencies = [ "chrono", "dioxus", "dioxus-cli-config", + "dioxus-code", "dioxus-desktop", "dioxus-liveview", "dioxus-ssr", @@ -1640,7 +1855,6 @@ dependencies = [ "serde_json", "slab", "stork-lib", - "syntect-html", "tokio", "tower-http 0.5.2", "tracing", @@ -1784,7 +1998,7 @@ dependencies = [ "convert_case 0.8.0", "proc-macro2", "quote", - "syn 2.0.107", + "syn 2.0.117", "xxhash-rust", ] @@ -1852,7 +2066,7 @@ dependencies = [ "convert_case 0.8.0", "proc-macro2", "quote", - "syn 2.0.107", + "syn 2.0.117", ] [[package]] @@ -1940,7 +2154,7 @@ dependencies = [ "serde", "serde-wasm-bindgen", "serde_json", - "syn 2.0.107", + "syn 2.0.117", "thiserror 2.0.17", "uuid", "wasm-bindgen", @@ -1979,7 +2193,7 @@ dependencies = [ "quote", "sha2", "slab", - "syn 2.0.107", + "syn 2.0.117", ] [[package]] @@ -1991,7 +2205,7 @@ dependencies = [ "proc-macro2", "proc-macro2-diagnostics", "quote", - "syn 2.0.107", + "syn 2.0.117", ] [[package]] @@ -2007,7 +2221,7 @@ dependencies = [ "proc-macro2", "proc-macro2-diagnostics", "quote", - "syn 2.0.107", + "syn 2.0.117", "tracing", ] @@ -2025,7 +2239,7 @@ dependencies = [ "htmlentity", "proc-macro2", "quote", - "syn 2.0.107", + "syn 2.0.117", ] [[package]] @@ -2051,7 +2265,7 @@ name = "dioxus-search-macro" version = "0.1.0" dependencies = [ "quote", - "syn 2.0.107", + "syn 2.0.117", ] [[package]] @@ -2177,7 +2391,7 @@ dependencies = [ "convert_case 0.8.0", "proc-macro2", "quote", - "syn 2.0.107", + "syn 2.0.117", ] [[package]] @@ -2224,6 +2438,7 @@ dependencies = [ "axum", "chrono", "dioxus", + "dioxus-code", "dioxus-docs-03", "dioxus-docs-04", "dioxus-docs-05", @@ -2249,7 +2464,6 @@ dependencies = [ "serde_json", "slab", "stork-lib", - "syntect-html", "tokio", "use-mdbook", "wasm-bindgen", @@ -2303,7 +2517,7 @@ checksum = "97369cbbc041bc366949bc74d34658d6cda5621039731c6310521892a3a20ae0" dependencies = [ "proc-macro2", "quote", - "syn 2.0.107", + "syn 2.0.117", ] [[package]] @@ -2315,6 +2529,17 @@ dependencies = [ "libloading 0.8.9", ] +[[package]] +name = "dlmalloc" +version = "0.2.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9f5b01c17f85ee988d832c40e549a64bd89ab2c9f8d8a613bdf5122ae507e294" +dependencies = [ + "cfg-if", + "libc", + "windows-sys 0.61.2", +] + [[package]] name = "dlopen2" version = "0.8.0" @@ -2335,7 +2560,7 @@ checksum = "788160fb30de9cdd857af31c6a2675904b16ece8fc2737b2c7127ba368c9d0f4" dependencies = [ "proc-macro2", "quote", - "syn 2.0.107", + "syn 2.0.117", ] [[package]] @@ -2449,7 +2674,7 @@ checksum = "67c78a4d8fdf9953a5c9d458f9efe940fd97a0cab0941c075a813ac594733827" dependencies = [ "proc-macro2", "quote", - "syn 2.0.107", + "syn 2.0.117", ] [[package]] @@ -2470,7 +2695,7 @@ dependencies = [ "darling", "proc-macro2", "quote", - "syn 2.0.107", + "syn 2.0.117", ] [[package]] @@ -2490,7 +2715,7 @@ checksum = "44f23cf4b44bfce11a86ace86f8a73ffdec849c9fd00a386a53d278bd9e81fb3" dependencies = [ "proc-macro2", "quote", - "syn 2.0.107", + "syn 2.0.117", ] [[package]] @@ -2578,12 +2803,6 @@ version = "0.1.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7360491ce676a36bf9bb3c56c1aa791658183a54d2744120f27285738d90465a" -[[package]] -name = "fast-srgb8" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dd2e7510819d6fbf51a5545c8f922716ecfb14df168a3242f7d33e0239efe6a1" - [[package]] name = "fastrand" version = "2.3.0" @@ -2607,7 +2826,7 @@ checksum = "a0aca10fb742cb43f9e7bb8467c91aa9bcb8e3ffbc6a6f7389bb93ffc920577d" dependencies = [ "proc-macro2", "quote", - "syn 2.0.107", + "syn 2.0.117", ] [[package]] @@ -2690,7 +2909,7 @@ checksum = "1a5c6c585bc94aaf2c7b51dd4c2ba22680844aba4c687be581871a6f518c5742" dependencies = [ "proc-macro2", "quote", - "syn 2.0.107", + "syn 2.0.117", ] [[package]] @@ -2808,7 +3027,7 @@ checksum = "162ee34ebcb7c64a8abebc059ce0fee27c2262618d7b60ed8faf72fef13c3650" dependencies = [ "proc-macro2", "quote", - "syn 2.0.107", + "syn 2.0.117", ] [[package]] @@ -3088,7 +3307,7 @@ dependencies = [ "proc-macro-error", "proc-macro2", "quote", - "syn 2.0.107", + "syn 2.0.117", ] [[package]] @@ -3239,7 +3458,7 @@ dependencies = [ "proc-macro-error", "proc-macro2", "quote", - "syn 2.0.107", + "syn 2.0.117", ] [[package]] @@ -3312,6 +3531,12 @@ dependencies = [ "foldhash 0.2.0", ] +[[package]] +name = "hashbrown" +version = "0.17.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4f467dd6dccf739c208452f8014c75c18bb8301b050ad1cfb27153803edb0f51" + [[package]] name = "hashlink" version = "0.9.1" @@ -3761,12 +3986,12 @@ dependencies = [ [[package]] name = "indexmap" -version = "2.12.0" +version = "2.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6717a8d2a5a929a1a2eb43a12812498ed141a0bcfb7e8f7844fbdbe4303bba9f" +checksum = "d466e9454f08e4a911e14806c24e16fba1b4c121d1ea474396f396069cf949d9" dependencies = [ "equivalent", - "hashbrown 0.16.0", + "hashbrown 0.17.0", ] [[package]] @@ -3808,7 +4033,7 @@ checksum = "c34819042dc3d3971c46c2190835914dfbe0c3c13f61449b2997f4e9722dfa60" dependencies = [ "proc-macro2", "quote", - "syn 2.0.107", + "syn 2.0.117", ] [[package]] @@ -3928,15 +4153,6 @@ dependencies = [ "wasm-bindgen", ] -[[package]] -name = "jsonc-parser" -version = "0.26.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d6d80e6d70e7911a29f3cf3f44f452df85d06f73572b494ca99a2cad3fcf8f4" -dependencies = [ - "serde_json", -] - [[package]] name = "keyboard-types" version = "0.7.0" @@ -4172,7 +4388,7 @@ checksum = "1b27834086c65ec3f9387b096d66e99f221cf081c2b738042aa252bcd41204e3" dependencies = [ "proc-macro2", "quote", - "syn 2.0.107", + "syn 2.0.117", ] [[package]] @@ -4240,7 +4456,7 @@ dependencies = [ "manganis-core", "proc-macro2", "quote", - "syn 2.0.107", + "syn 2.0.117", ] [[package]] @@ -4279,7 +4495,7 @@ checksum = "88a9689d8d44bf9964484516275f5cd4c9b59457a6940c1d5d0ecbb94510a36b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.107", + "syn 2.0.117", ] [[package]] @@ -4328,12 +4544,13 @@ name = "mdbook-gen" version = "0.0.0" dependencies = [ "anyhow", + "arborium", + "arborium-theme", "convert_case 0.6.0", "dioxus-autofmt", "dioxus-rsx", "macro_state", "mdbook-shared", - "once_cell", "postcard", "pretty_assertions", "prettyplease", @@ -4343,9 +4560,7 @@ dependencies = [ "quote", "serde", "serde_json", - "sublime-color-scheme", - "syn 2.0.107", - "syntect", + "syn 2.0.117", ] [[package]] @@ -4358,7 +4573,7 @@ dependencies = [ "mdbook-shared", "prettyplease", "serde", - "syn 2.0.107", + "syn 2.0.117", "use-mdbook", ] @@ -4378,8 +4593,7 @@ dependencies = [ "quote", "serde", "serde_json", - "syn 2.0.107", - "syntect", + "syn 2.0.117", ] [[package]] @@ -4664,7 +4878,7 @@ checksum = "ed3955f1a9c7c0c15e092f9c887db08b1fc683305fdf6eb6684f22555355e202" dependencies = [ "proc-macro2", "quote", - "syn 2.0.107", + "syn 2.0.117", ] [[package]] @@ -4722,10 +4936,10 @@ version = "0.7.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ff32365de1b6743cb203b710788263c44a03de03802daf96092f2da4fe6ba4d7" dependencies = [ - "proc-macro-crate 3.4.0", + "proc-macro-crate 2.0.0", "proc-macro2", "quote", - "syn 2.0.107", + "syn 2.0.117", ] [[package]] @@ -4855,28 +5069,6 @@ version = "1.70.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "384b8ab6d37215f3c5301a95a4accb5d64aa607f1fcb26a11b5303878451b4fe" -[[package]] -name = "onig" -version = "6.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "336b9c63443aceef14bea841b899035ae3abe89b7c486aaf4c5bd8aafedac3f0" -dependencies = [ - "bitflags 2.10.0", - "libc", - "once_cell", - "onig_sys", -] - -[[package]] -name = "onig_sys" -version = "69.9.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c7f86c6eef3d6df15f23bcfb6af487cbd2fed4e5581d58d5bf1f5f8b7f6727dc" -dependencies = [ - "cc", - "pkg-config", -] - [[package]] name = "openssl" version = "0.10.74" @@ -4900,7 +5092,7 @@ checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.107", + "syn 2.0.117", ] [[package]] @@ -4937,30 +5129,6 @@ dependencies = [ "pin-project-lite", ] -[[package]] -name = "palette" -version = "0.7.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4cbf71184cc5ecc2e4e1baccdb21026c20e5fc3dcf63028a086131b3ab00b6e6" -dependencies = [ - "approx", - "fast-srgb8", - "palette_derive", - "phf 0.11.3", -] - -[[package]] -name = "palette_derive" -version = "0.7.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f5030daf005bface118c096f510ffb781fc28f9ab6a32ab224d8631be6851d30" -dependencies = [ - "by_address", - "proc-macro2", - "quote", - "syn 2.0.107", -] - [[package]] name = "pango" version = "0.18.3" @@ -5057,7 +5225,7 @@ dependencies = [ "pest_meta", "proc-macro2", "quote", - "syn 2.0.107", + "syn 2.0.117", ] [[package]] @@ -5190,7 +5358,7 @@ dependencies = [ "phf_shared 0.11.3", "proc-macro2", "quote", - "syn 2.0.107", + "syn 2.0.117", ] [[package]] @@ -5237,7 +5405,7 @@ checksum = "6e918e4ff8c4549eb882f14b3a4bc8c8bc93de829416eacf579f1207a8fbf861" dependencies = [ "proc-macro2", "quote", - "syn 2.0.107", + "syn 2.0.117", ] [[package]] @@ -5258,19 +5426,6 @@ version = "0.3.32" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7edddbd0b52d732b21ad9a5fab5c704c14cd949e5e9a1ec5929a24fded1b904c" -[[package]] -name = "plist" -version = "1.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "740ebea15c5d1428f910cd1a5f52cebf8d25006245ed8ade92702f4943d91e07" -dependencies = [ - "base64", - "indexmap", - "quick-xml 0.38.3", - "serde", - "time", -] - [[package]] name = "png" version = "0.17.16" @@ -5369,7 +5524,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "479ca8adacdd7ce8f1fb39ce9ecccbfe93a3f1344b3d0d97f20bc0196208f62b" dependencies = [ "proc-macro2", - "syn 2.0.107", + "syn 2.0.117", ] [[package]] @@ -5393,11 +5548,11 @@ dependencies = [ [[package]] name = "proc-macro-crate" -version = "3.4.0" +version = "3.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "219cb19e96be00ab2e37d6e299658a0cfa83e52429179969b0f0121b4ac46983" +checksum = "e67ba7e9b2b56446f1d419b1d807906278ffa1a658a8a5d8a39dcb1f5a78614f" dependencies = [ - "toml_edit 0.23.7", + "toml_edit 0.25.11+spec-1.1.0", ] [[package]] @@ -5432,9 +5587,9 @@ checksum = "dc375e1527247fe1a97d8b7156678dfe7c1af2fc075c9a4db3690ecd2a148068" [[package]] name = "proc-macro2" -version = "1.0.101" +version = "1.0.106" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "89ae43fd86e4158d6db51ad8e2b80f313af9cc74f5c0e03ccb87de09998732de" +checksum = "8fd00f0bb2e90d81d1044c2b32617f68fcb9fa3bb7640c23e9c748e53fb30934" dependencies = [ "unicode-ident", ] @@ -5447,7 +5602,7 @@ checksum = "af066a9c399a26e020ada66a034357a868728e72cd426f3adcd35f80d88d88c8" dependencies = [ "proc-macro2", "quote", - "syn 2.0.107", + "syn 2.0.117", "version_check", ] @@ -5467,7 +5622,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "52717f9a02b6965224f95ca2a81e2e0c5c43baacd28ca057577988930b6c3d5b" dependencies = [ "quote", - "syn 2.0.107", + "syn 2.0.117", ] [[package]] @@ -5559,15 +5714,6 @@ dependencies = [ "memchr", ] -[[package]] -name = "quick-xml" -version = "0.38.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "42a232e7487fc2ef313d96dde7948e7a3c05101870d8985e4fd8d26aedd27b89" -dependencies = [ - "memchr", -] - [[package]] name = "quinn" version = "0.11.9" @@ -5625,9 +5771,9 @@ dependencies = [ [[package]] name = "quote" -version = "1.0.41" +version = "1.0.45" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ce25767e7b499d1b604768e7cde645d14cc8584231ea6b295e9c9eb22c02e1d1" +checksum = "41f2619966050689382d2b44f664f4bc593e129785a36d6ee376ddf37259b924" dependencies = [ "proc-macro2", ] @@ -6292,7 +6438,7 @@ checksum = "d540f220d3187173da220f885ab66608367b6574e925011a9353e4badda91d79" dependencies = [ "proc-macro2", "quote", - "syn 2.0.107", + "syn 2.0.117", ] [[package]] @@ -6338,7 +6484,7 @@ checksum = "175ee3e80ae9982737ca543e96133087cbd9a485eecc3bc4de9c1a37b47ea59c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.107", + "syn 2.0.117", ] [[package]] @@ -6521,7 +6667,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f62f06db0370222f7f498ef478fce9f8df5828848d1d3517e3331936d7074f55" dependencies = [ "quote", - "syn 2.0.107", + "syn 2.0.117", ] [[package]] @@ -6647,6 +6793,12 @@ dependencies = [ "unicode-segmentation", ] +[[package]] +name = "streaming-iterator" +version = "0.1.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2b2231b7c3057d5e4ad0156fb3dc807d900806020c5ffa3ee6ff2c8c76fb8520" + [[package]] name = "string_cache" version = "0.8.9" @@ -6678,21 +6830,6 @@ version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f" -[[package]] -name = "sublime-color-scheme" -version = "0.1.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1ac192237c56081594f5a429c3d770ab1e8a6c768bd442c2095137c793a4db1a" -dependencies = [ - "jsonc-parser", - "log", - "palette", - "serde", - "serde_json", - "syntect", - "thiserror 2.0.17", -] - [[package]] name = "subsecond" version = "0.7.1" @@ -6740,9 +6877,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.107" +version = "2.0.117" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2a26dbd934e5451d21ef060c018dae56fc073894c5a7896f882928a76e6d081b" +checksum = "e665b8803e7b1d2a727f4023456bbbbe74da67099c585258af0ad9c5013b9b99" dependencies = [ "proc-macro2", "quote", @@ -6766,38 +6903,7 @@ checksum = "728a70f3dbaf5bab7f0c4b1ac8d7ae5ea60a4b5549c8a5914361c99147a709d2" dependencies = [ "proc-macro2", "quote", - "syn 2.0.107", -] - -[[package]] -name = "syntect" -version = "5.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "656b45c05d95a5704399aeef6bd0ddec7b2b3531b7c9e900abbf7c4d2190c925" -dependencies = [ - "bincode", - "flate2", - "fnv", - "once_cell", - "onig", - "plist", - "regex-syntax", - "serde", - "serde_derive", - "serde_json", - "thiserror 2.0.17", - "walkdir", - "yaml-rust", -] - -[[package]] -name = "syntect-html" -version = "0.1.0" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.107", - "syntect", + "syn 2.0.117", ] [[package]] @@ -6883,7 +6989,7 @@ checksum = "f4e16beb8b2ac17db28eab8bca40e62dbfbb34c0fcdc6d9826b11b7b5d047dfd" dependencies = [ "proc-macro2", "quote", - "syn 2.0.107", + "syn 2.0.117", ] [[package]] @@ -6948,7 +7054,7 @@ checksum = "4fee6c4efc90059e10f81e6d42c60a18f76588c3d74cb83a0b242a2b6c7504c1" dependencies = [ "proc-macro2", "quote", - "syn 2.0.107", + "syn 2.0.117", ] [[package]] @@ -6959,7 +7065,7 @@ checksum = "3ff15c8ecd7de3849db632e14d18d2571fa09dfc5ed93479bc4485c7a517c913" dependencies = [ "proc-macro2", "quote", - "syn 2.0.107", + "syn 2.0.117", ] [[package]] @@ -7067,7 +7173,7 @@ checksum = "af407857209536a95c8e56f8231ef2c2e2aff839b22e07a1ffcbc617e9db9fa5" dependencies = [ "proc-macro2", "quote", - "syn 2.0.107", + "syn 2.0.117", ] [[package]] @@ -7185,9 +7291,9 @@ dependencies = [ [[package]] name = "toml_datetime" -version = "0.7.3" +version = "1.1.1+spec-1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f2cdb639ebbc97961c51720f858597f7f24c4fc295327923af55b74c3c724533" +checksum = "3165f65f62e28e0115a00b2ebdd37eb6f3b641855f9d636d3cd4103767159ad7" dependencies = [ "serde_core", ] @@ -7232,23 +7338,23 @@ dependencies = [ [[package]] name = "toml_edit" -version = "0.23.7" +version = "0.25.11+spec-1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6485ef6d0d9b5d0ec17244ff7eb05310113c3f316f2d14200d4de56b3cb98f8d" +checksum = "0b59c4d22ed448339746c59b905d24568fcbb3ab65a500494f7b8c3e97739f2b" dependencies = [ "indexmap", - "toml_datetime 0.7.3", + "toml_datetime 1.1.1+spec-1.1.0", "toml_parser", - "winnow 0.7.13", + "winnow 1.0.2", ] [[package]] name = "toml_parser" -version = "1.0.4" +version = "1.1.2+spec-1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c0cbe268d35bdb4bb5a56a2de88d0ad0eb70af5384a99d648cd4b3d04039800e" +checksum = "a2abe9b86193656635d2411dc43050282ca48aa31c2451210f4202550afb7526" dependencies = [ - "winnow 0.7.13", + "winnow 1.0.2", ] [[package]] @@ -7375,7 +7481,7 @@ checksum = "81383ab64e72a7a8b8e13130c49e3dab29def6d0c7d76a03087b3cf71c5c6903" dependencies = [ "proc-macro2", "quote", - "syn 2.0.107", + "syn 2.0.117", ] [[package]] @@ -7444,6 +7550,12 @@ dependencies = [ "windows-sys 0.60.2", ] +[[package]] +name = "tree-sitter-language" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "009994f150cc0cd50ff54917d5bc8bffe8cad10ca10d81c34da2ec421ae61782" + [[package]] name = "try-lock" version = "0.2.5" @@ -7574,6 +7686,7 @@ name = "use-mdbook" version = "0.1.0" dependencies = [ "dioxus", + "dioxus-code", "dioxus-router", "lazy_static", "mdbook-macro", @@ -7684,7 +7797,7 @@ checksum = "59195a1db0e95b920366d949ba5e0d3fc0e70b67c09be15ce5abb790106b0571" dependencies = [ "proc-macro2", "quote", - "syn 2.0.107", + "syn 2.0.117", ] [[package]] @@ -7733,7 +7846,7 @@ dependencies = [ "log", "proc-macro2", "quote", - "syn 2.0.107", + "syn 2.0.117", "wasm-bindgen-shared", ] @@ -7768,7 +7881,7 @@ checksum = "9f07d2f20d4da7b26400c9f4a0511e6e0345b040694e8a75bd41d578fa4421d7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.107", + "syn 2.0.117", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -7840,7 +7953,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "54cb1e9dc49da91950bdfd8b848c49330536d9d1fb03d4bfec8cae50caa50ae3" dependencies = [ "proc-macro2", - "quick-xml 0.37.5", + "quick-xml", "quote", ] @@ -7966,7 +8079,7 @@ checksum = "1d228f15bba3b9d56dde8bddbee66fa24545bd17b48d5128ccf4a8742b18e431" dependencies = [ "proc-macro2", "quote", - "syn 2.0.107", + "syn 2.0.117", ] [[package]] @@ -8084,7 +8197,7 @@ checksum = "053e2e040ab57b9dc951b72c264860db7eb3b0200ba345b4e4c3b14f67855ddf" dependencies = [ "proc-macro2", "quote", - "syn 2.0.107", + "syn 2.0.117", ] [[package]] @@ -8095,7 +8208,7 @@ checksum = "3f316c4a2570ba26bbec722032c4099d8c8bc095efccdc15688708623367e358" dependencies = [ "proc-macro2", "quote", - "syn 2.0.107", + "syn 2.0.117", ] [[package]] @@ -8434,6 +8547,15 @@ dependencies = [ "memchr", ] +[[package]] +name = "winnow" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2ee1708bef14716a11bae175f579062d4554d95be2c6829f518df847b7b3fdd0" +dependencies = [ + "memchr", +] + [[package]] name = "wit-bindgen" version = "0.46.0" @@ -8580,7 +8702,7 @@ checksum = "38da3c9736e16c5d3c8c597a9aaa5d1fa565d0532ae05e27c24aa62fb32c0ab6" dependencies = [ "proc-macro2", "quote", - "syn 2.0.107", + "syn 2.0.117", "synstructure", ] @@ -8619,10 +8741,10 @@ version = "5.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1cdb94821ca8a87ca9c298b5d1cbd80e2a8b67115d99f6e4551ac49e42b6a314" dependencies = [ - "proc-macro-crate 3.4.0", + "proc-macro-crate 3.5.0", "proc-macro2", "quote", - "syn 2.0.107", + "syn 2.0.117", "zbus_names", "zvariant", "zvariant_utils", @@ -8657,7 +8779,7 @@ checksum = "88d2b8d9c68ad2b9e4340d7832716a4d21a22a1154777ad56ea55c51a9cf3831" dependencies = [ "proc-macro2", "quote", - "syn 2.0.107", + "syn 2.0.117", ] [[package]] @@ -8677,7 +8799,7 @@ checksum = "d71e5d6e06ab090c67b5e44993ec16b72dcbaabc526db883a360057678b48502" dependencies = [ "proc-macro2", "quote", - "syn 2.0.107", + "syn 2.0.117", "synstructure", ] @@ -8717,7 +8839,7 @@ checksum = "5b96237efa0c878c64bd89c436f661be4e46b2f3eff1ebb976f7ef2321d2f58f" dependencies = [ "proc-macro2", "quote", - "syn 2.0.107", + "syn 2.0.117", ] [[package]] @@ -8765,10 +8887,10 @@ version = "5.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "da58575a1b2b20766513b1ec59d8e2e68db2745379f961f86650655e862d2006" dependencies = [ - "proc-macro-crate 3.4.0", + "proc-macro-crate 3.5.0", "proc-macro2", "quote", - "syn 2.0.107", + "syn 2.0.117", "zvariant_utils", ] @@ -8781,6 +8903,6 @@ dependencies = [ "proc-macro2", "quote", "serde", - "syn 2.0.107", + "syn 2.0.117", "winnow 0.7.13", ] diff --git a/Cargo.toml b/Cargo.toml index 1b2adeccfe..30c64b609a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -22,7 +22,6 @@ members = [ "packages/include_mdbook/packages/mdbook-macro", "packages/include_mdbook/packages/use-mdbook", "packages/include_mdbook/packages/mdbook-shared", - "packages/include_mdbook/packages/syntect-html", "packages/include_mdbook/packages/mdbook-gen", "packages/include_mdbook/packages/mdbook-gen-example", @@ -50,7 +49,6 @@ stork-lib = { git = "https://github.com/dioxuslabs/stork", default-features = fa mdbook-gen = { path = "packages/include_mdbook/packages/mdbook-gen" } use-mdbook = { path = "packages/include_mdbook/packages/use-mdbook" } mdbook-shared = { path = "packages/include_mdbook/packages/mdbook-shared" } -syntect-html = { path = "packages/include_mdbook/packages/syntect-html" } # playground model = { path = "packages/playground/model" } @@ -81,6 +79,7 @@ dioxus-rsx-rosetta = "0.7.0" dioxus-autofmt = "0.7.0" dioxus-dx-wire-format = "0.7.0" dioxus-logger = "0.7.0" +dioxus-code = { version = "0.1.1", default-features = false } # 3rd-party dioxus # dioxus-sdk = { version = "0.6", default-features = false } diff --git a/packages/docs-blog/Cargo.toml b/packages/docs-blog/Cargo.toml index 5ac90aa690..ec2de8f216 100644 --- a/packages/docs-blog/Cargo.toml +++ b/packages/docs-blog/Cargo.toml @@ -8,7 +8,6 @@ publish = false [dependencies] dioxus = { workspace = true, features = ["router"] } -syntect-html = { workspace = true } mdbook-shared = { workspace = true } use-mdbook = { workspace = true } dioxus-docs-examples = { workspace = true } diff --git a/packages/docs-router/Cargo.toml b/packages/docs-router/Cargo.toml index ed0782e7d5..7d8d8b3864 100644 --- a/packages/docs-router/Cargo.toml +++ b/packages/docs-router/Cargo.toml @@ -10,9 +10,9 @@ dioxus-ssr = { workspace = true, optional = true } dioxus-desktop = { workspace = true, optional = true } dioxus-cli-config = { workspace = true, optional = true } dioxus-liveview = { workspace = true, features = ["axum"], optional = true } +dioxus-code = { workspace = true } # dioxus-material-icons = { version = "3.0.0" } -syntect-html = { workspace = true } mdbook-shared = { workspace = true } use-mdbook = { workspace = true } @@ -84,4 +84,3 @@ doc_test = [ "dep:rusqlite" ] production = [] - diff --git a/packages/docs-router/src/lib.rs b/packages/docs-router/src/lib.rs index 8b0f616856..e489feed54 100644 --- a/packages/docs-router/src/lib.rs +++ b/packages/docs-router/src/lib.rs @@ -1,6 +1,7 @@ #![allow(unused)] use dioxus::prelude::*; +use dioxus_code::{advanced::HighlightedSource, Code, CodeTheme, Theme}; pub mod doc_examples; pub use doc_examples::*; @@ -128,11 +129,15 @@ pub enum Route {{\n\t" } #[component] -pub fn CodeBlock(contents: String, light_contents: String, name: Option) -> Element { +pub fn CodeBlock(source: HighlightedSource, name: Option) -> Element { let mut copied = use_signal(|| false); + let theme = CodeTheme::system(Theme::GITHUB_LIGHT, Theme::GITHUB_DARK); + let theme_classes = theme.classes(); rsx! { - div { class: "border overflow-hidden rounded-md border-stone-200 dark:border-gray-700 my-4", + div { + class: "border overflow-hidden rounded-md border-stone-200 dark:border-gray-700 my-4", + "data-codeblock": "true", div { class: "w-full bg-red flex-row justify-between border-b border-stone-200 dark:border-gray-700 py-1 px-2 text-xs items-center bg-gray-100 dark:bg-ideblack", display: if name.is_some() { "flex" } else { "none" }, div { class: "font-mono", @@ -143,7 +148,7 @@ pub fn CodeBlock(contents: String, light_contents: String, name: Option) button { class: "hover:text-blue-600 flex flex-row items-center gap-1", class: if copied() { "text-green-600" }, - "onclick": "navigator.clipboard.writeText(this.parentNode.parentNode.lastChild.innerText);", + "onclick": "navigator.clipboard.writeText(this.closest('[data-codeblock]').querySelector('pre').innerText);", onclick: move |_| copied.set(true), if copied() { "Copied!" @@ -161,8 +166,9 @@ pub fn CodeBlock(contents: String, light_contents: String, name: Option) } } } - div { class: "codeblock hidden dark:block", dangerous_inner_html: contents } - div { class: "codeblock dark:hidden", dangerous_inner_html: light_contents } + div { class: "codeblock {theme_classes}", + Code { src: source, theme } + } } } } diff --git a/packages/docsite/Cargo.toml b/packages/docsite/Cargo.toml index cbcb9037ac..44a7b54d49 100644 --- a/packages/docsite/Cargo.toml +++ b/packages/docsite/Cargo.toml @@ -20,7 +20,7 @@ dioxus-docs-blog = { workspace = true } dioxus-docs-examples = { workspace = true } # dioxus-material-icons = { version = "3.0.0" } -syntect-html = { workspace = true } +dioxus-code = { workspace = true, features = ["macro"] } mdbook-shared = { workspace = true } use-mdbook = { workspace = true } dioxus-search = { workspace = true } diff --git a/packages/docsite/assets/main.css b/packages/docsite/assets/main.css index 652ac47b5a..62fb9a993a 100644 --- a/packages/docsite/assets/main.css +++ b/packages/docsite/assets/main.css @@ -68,6 +68,22 @@ html { font-weight: 400; } +.codeblock.dxc-system, +.homepage-codeblock.dxc-system { + --docsite-codeblock-bg: var(--dxc-light-on, var(--dxc-light-background, #ffffff)) var(--dxc-dark-on, var(--dxc-dark-background, #0d1117)); + background: var(--docsite-codeblock-bg); +} + +html[data-theme="light"] .dxc-system { + --dxc-light-on: initial; + --dxc-dark-on: ; +} + +html[data-theme="dark"] .dxc-system { + --dxc-light-on: ; + --dxc-dark-on: initial; +} + .codeblock > pre { /* &:where([data-theme="light"], [data-theme="light"] *) { background-color: rgb(37, 36, 36) !important; @@ -79,6 +95,11 @@ html { margin-bottom: 0px !important; } +.codeblock > pre.dxc, +.homepage-codeblock > pre.dxc { + background: var(--docsite-codeblock-bg) !important; +} + .markdown-body { box-sizing: border-box; min-width: 200px; diff --git a/packages/docsite/src/components/homepage/snippets.rs b/packages/docsite/src/components/homepage/snippets.rs index 61b9696ca0..d8c290a6fb 100644 --- a/packages/docsite/src/components/homepage/snippets.rs +++ b/packages/docsite/src/components/homepage/snippets.rs @@ -1,43 +1,44 @@ use dioxus::prelude::*; -use syntect_html::syntect_html_fs; +use dioxus_code::{advanced::HighlightedSource, code, Code, CodeTheme, Theme}; -#[derive(PartialEq, Eq, Debug)] pub(crate) struct Snippet { pub(crate) title: &'static str, pub(crate) filename: &'static str, - pub(crate) html: &'static str, + pub(crate) source: fn() -> HighlightedSource, } pub(crate) static SNIPPETS: &[Snippet] = &[ Snippet { title: "Hello world", filename: "readme.rs", - html: syntect_html_fs!("./src/snippets/readme.rs"), + source: || code!("/src/snippets/readme.rs"), }, Snippet { title: "Components", filename: "components.rs", - html: syntect_html_fs!("./src/snippets/components.rs"), + source: || code!("/src/snippets/components.rs"), }, Snippet { title: "Async", filename: "async.rs", - html: syntect_html_fs!("./src/snippets/async_.rs"), + source: || code!("/src/snippets/async_.rs"), }, Snippet { title: "Server", filename: "server.rs", - html: syntect_html_fs!("./src/snippets/server.rs"), + source: || code!("/src/snippets/server.rs"), }, Snippet { title: "Global State", filename: "global.rs", - html: syntect_html_fs!("./src/snippets/global.rs"), + source: || code!("/src/snippets/global.rs"), }, ]; pub(crate) fn Snippets() -> Element { let mut selected_snippet = use_signal(|| 0); + let theme = CodeTheme::system(Theme::GITHUB_LIGHT, Theme::GITHUB_DARK); + let theme_classes = theme.classes(); rsx! { section { class: "dark:text-white mt-4 -mx-4 sm:mx-0 lg:mt-0 lg:col-span-7 xl:col-span-6", @@ -66,11 +67,13 @@ pub(crate) fn Snippets() -> Element { for (id , snippet) in SNIPPETS.iter().enumerate() { div { key: "{snippet.title}", - class: "w-full min-h-0 p-4", + class: "homepage-codeblock {theme_classes} w-full min-h-0 p-4", // Instead of hiding/showing, we just render all the code blocks at once and hide them with css instead class: if selected_snippet() == id { "block" } else { "hidden" }, - background_color: "#000000", - dangerous_inner_html: "{snippet.html}", + Code { + src: (snippet.source)(), + theme, + } } } } diff --git a/packages/include_mdbook/packages/mdbook-gen-example/src/lib.rs b/packages/include_mdbook/packages/mdbook-gen-example/src/lib.rs index 021a088e7e..b18f742e21 100644 --- a/packages/include_mdbook/packages/mdbook-gen-example/src/lib.rs +++ b/packages/include_mdbook/packages/mdbook-gen-example/src/lib.rs @@ -3,6 +3,6 @@ use dioxus::prelude::*; mod router; #[component] -pub fn CodeBlock(contents: String, name: Option) -> Element { +pub fn CodeBlock(source: use_mdbook::HighlightedSource, name: Option) -> Element { todo!() } diff --git a/packages/include_mdbook/packages/mdbook-gen-example/src/router.rs b/packages/include_mdbook/packages/mdbook-gen-example/src/router.rs index 64779a1acf..67f3773b18 100644 --- a/packages/include_mdbook/packages/mdbook-gen-example/src/router.rs +++ b/packages/include_mdbook/packages/mdbook-gen-example/src/router.rs @@ -1,4 +1,3 @@ -use dioxus::prelude::*; #[derive( Clone, Copy, @@ -22,14 +21,14 @@ impl BookRoute { /// Get the markdown for a page by its ID pub const fn page_markdown(id: use_mdbook::mdbook_shared::PageId) -> &'static str { match id.0 { - 1usize => { - "# Roadmap & Feature-set\n\nThis feature set and roadmap can help you decide if what Dioxus can do today works for you.\n\nIf a feature that you need doesn't exist or you want to contribute to projects on the roadmap, feel free to get involved by [joining the discord](https://discord.gg/XgGxMSkvUM).\n\nGenerally, here's the status of each platform:\n\n* **Web**: Dioxus is a great choice for pure web-apps – especially for CRUD/complex apps. However, it does lack the ecosystem of React, so you might be missing a component library or some useful hook.\n\n* **SSR**: Dioxus is a great choice for pre-rendering, hydration, and rendering HTML on a web endpoint. Be warned – the VirtualDom is not (currently) `Send + Sync`.\n\n* **Desktop**: You can build very competent single-window desktop apps right now. However, multi-window apps require support from Dioxus core and are not ready.\n\n* **Mobile**: Mobile support is very young. You'll be figuring things out as you go and there are not many support crates for peripherals.\n\n* **LiveView**: LiveView support is very young. You'll be figuring things out as you go. Thankfully, none of it is too hard and any work can be upstreamed into Dioxus.\n\n````rust\nfn main() {\n dioxus_rocks;\n}\n````\n\n## Features\n\n---\n\n|Feature|Status|Description|\n|-------|------|-----------|\n|Conditional Rendering|✅|if/then to hide/show component|\n|Map, Iterator|✅|map/filter/reduce to produce rsx!|\n|Keyed Components|✅|advanced diffing with keys|\n|Web|✅|renderer for web browser|\n|Desktop (webview)|✅|renderer for desktop|\n|Shared State (Context)|✅|share state through the tree|\n|Hooks|✅|memory cells in components|\n|SSR|✅|render directly to string|\n|Component Children|✅|cx.children() as a list of nodes|\n|Headless components|✅|components that don't return real elements|\n|Fragments|✅|multiple elements without a real root|\n|Manual Props|✅|Manually pass in props with spread syntax|\n|Controlled Inputs|✅|stateful wrappers around inputs|\n|CSS/Inline Styles|✅|syntax for inline styles/attribute groups|\n|Custom elements|✅|Define new element primitives|\n|Suspense|✅|schedule future render from future/promise|\n|Integrated error handling|✅|Gracefully handle errors with ? syntax|\n|NodeRef|✅|gain direct access to nodes|\n|Re-hydration|✅|Pre-render to HTML to speed up first contentful paint|\n|Jank-Free Rendering|✅|Large diffs are segmented across frames for silky-smooth transitions|\n|Effects|✅|Run effects after a component has been committed to render|\n|Portals|🛠|Render nodes outside of the traditional tree structure|\n|Cooperative Scheduling|🛠|Prioritize important events over non-important events|\n|Server Components|🛠|Hybrid components for SPA and Server|\n|Bundle Splitting|👀|Efficiently and asynchronously load the app|\n|Lazy Components|👀|Dynamically load the new components as the page is loaded|\n|1st class global state|✅|redux/recoil/mobx on top of context|\n|Runs natively|✅|runs as a portable binary w/o a runtime (Node)|\n|Subtree Memoization|✅|skip diffing static element subtrees|\n|High-efficiency templates|✅|rsx! calls are translated to templates on the DOM's side|\n|Compile-time correct|✅|Throw errors on invalid template layouts|\n|Heuristic Engine|✅|track component memory usage to minimize future allocations|\n|Fine-grained reactivity|👀|Skip diffing for fine-grain updates|\n\n* ✅ = implemented and working\n* 🛠 = actively being worked on\n* 👀 = not yet implemented or being worked on\n\n## Roadmap\n\nThese Features are planned for the future of Dioxus:\n\n### Core\n\n* [x] Release of Dioxus Core\n* [x] Upgrade documentation to include more theory and be more comprehensive\n* [x] Support for HTML-side templates for lightning-fast dom manipulation\n* [ ] Support for multiple renderers for same virtualdom (subtrees)\n* [ ] Support for ThreadSafe (Send + Sync)\n* [ ] Support for Portals\n\n### SSR\n\n* [x] SSR Support + Hydration\n* [ ] Integrated suspense support for SSR\n\n### Desktop\n\n* [ ] Declarative window management\n* [ ] Templates for building/bundling\n* [ ] Access to Canvas/WebGL context natively\n\n### Mobile\n\n* [ ] Mobile standard library\n * [ ] GPS\n * [ ] Camera\n * [ ] filesystem\n * [ ] Biometrics\n * [ ] WiFi\n * [ ] Bluetooth\n * [ ] Notifications\n * [ ] Clipboard\n* [ ] Animations\n\n### Bundling (CLI)\n\n* [x] Translation from HTML into RSX\n* [x] Dev server\n* [x] Live reload\n* [x] Translation from JSX into RSX\n* [ ] Hot module replacement\n* [ ] Code splitting\n* [ ] Asset macros\n* [ ] Css pipeline\n* [ ] Image pipeline\n\n### Essential hooks\n\n* [x] Router\n* [x] Global state management\n* [ ] Resize observer\n\n## Work in Progress\n\n### Build Tool\n\nWe are currently working on our own build tool called [Dioxus CLI](https://github.com/DioxusLabs/dioxus/tree/master/packages/cli) which will support:\n\n* an interactive TUI\n* on-the-fly reconfiguration\n* hot CSS reloading\n* two-way data binding between browser and source code\n* an interpreter for `rsx!`\n* ability to publish to github/netlify/vercel\n* bundling for iOS/Desktop/etc\n\n### Server Component Support\n\nWhile not currently fully implemented, the expectation is that LiveView apps can be a hybrid between Wasm and server-rendered where only portions of a page are \"live\" and the rest of the page is either server-rendered, statically generated, or handled by the host SPA.\n\n### Native rendering\n\nWe are currently working on a native renderer for Dioxus using WGPU called [Blitz](https://github.com/DioxusLabs/blitz/). This will allow you to build apps that are rendered natively for iOS, Android, and Desktop.\n\n## Internal Links\n\nInternal links like [this](./chapter_1.md) are typechecked and will fail to compile if the file is not found." - } 2usize => { "# Assets\n\nSome assets:\n![some_external](https://avatars.githubusercontent.com/u/79236386?s=200&v=4)\n![some_local](/example-book/assets/logo.png)\n![some_local1](/example-book/assets/logo1.png)\n![some_local2](/example-book/assets/logo2.png)" } + 1usize => { + "# Roadmap & Feature-set\n\nThis feature set and roadmap can help you decide if what Dioxus can do today works for you.\n\nIf a feature that you need doesn't exist or you want to contribute to projects on the roadmap, feel free to get involved by [joining the discord](https://discord.gg/XgGxMSkvUM).\n\nGenerally, here's the status of each platform:\n\n* **Web**: Dioxus is a great choice for pure web-apps – especially for CRUD/complex apps. However, it does lack the ecosystem of React, so you might be missing a component library or some useful hook.\n\n* **SSR**: Dioxus is a great choice for pre-rendering, hydration, and rendering HTML on a web endpoint. Be warned – the VirtualDom is not (currently) `Send + Sync`.\n\n* **Desktop**: You can build very competent single-window desktop apps right now. However, multi-window apps require support from Dioxus core and are not ready.\n\n* **Mobile**: Mobile support is very young. You'll be figuring things out as you go and there are not many support crates for peripherals.\n\n* **LiveView**: LiveView support is very young. You'll be figuring things out as you go. Thankfully, none of it is too hard and any work can be upstreamed into Dioxus.\n\n````rust\nfn main() {\n dioxus_rocks;\n}\n````\n\n## Features\n\n---\n\n|Feature|Status|Description|\n|-------|------|-----------|\n|Conditional Rendering|✅|if/then to hide/show component|\n|Map, Iterator|✅|map/filter/reduce to produce rsx!|\n|Keyed Components|✅|advanced diffing with keys|\n|Web|✅|renderer for web browser|\n|Desktop (webview)|✅|renderer for desktop|\n|Shared State (Context)|✅|share state through the tree|\n|Hooks|✅|memory cells in components|\n|SSR|✅|render directly to string|\n|Component Children|✅|cx.children() as a list of nodes|\n|Headless components|✅|components that don't return real elements|\n|Fragments|✅|multiple elements without a real root|\n|Manual Props|✅|Manually pass in props with spread syntax|\n|Controlled Inputs|✅|stateful wrappers around inputs|\n|CSS/Inline Styles|✅|syntax for inline styles/attribute groups|\n|Custom elements|✅|Define new element primitives|\n|Suspense|✅|schedule future render from future/promise|\n|Integrated error handling|✅|Gracefully handle errors with ? syntax|\n|NodeRef|✅|gain direct access to nodes|\n|Re-hydration|✅|Pre-render to HTML to speed up first contentful paint|\n|Jank-Free Rendering|✅|Large diffs are segmented across frames for silky-smooth transitions|\n|Effects|✅|Run effects after a component has been committed to render|\n|Portals|🛠|Render nodes outside of the traditional tree structure|\n|Cooperative Scheduling|🛠|Prioritize important events over non-important events|\n|Server Components|🛠|Hybrid components for SPA and Server|\n|Bundle Splitting|👀|Efficiently and asynchronously load the app|\n|Lazy Components|👀|Dynamically load the new components as the page is loaded|\n|1st class global state|✅|redux/recoil/mobx on top of context|\n|Runs natively|✅|runs as a portable binary w/o a runtime (Node)|\n|Subtree Memoization|✅|skip diffing static element subtrees|\n|High-efficiency templates|✅|rsx! calls are translated to templates on the DOM's side|\n|Compile-time correct|✅|Throw errors on invalid template layouts|\n|Heuristic Engine|✅|track component memory usage to minimize future allocations|\n|Fine-grained reactivity|👀|Skip diffing for fine-grain updates|\n\n* ✅ = implemented and working\n* 🛠 = actively being worked on\n* 👀 = not yet implemented or being worked on\n\n## Roadmap\n\nThese Features are planned for the future of Dioxus:\n\n### Core\n\n* [x] Release of Dioxus Core\n* [x] Upgrade documentation to include more theory and be more comprehensive\n* [x] Support for HTML-side templates for lightning-fast dom manipulation\n* [ ] Support for multiple renderers for same virtualdom (subtrees)\n* [ ] Support for ThreadSafe (Send + Sync)\n* [ ] Support for Portals\n\n### SSR\n\n* [x] SSR Support + Hydration\n* [ ] Integrated suspense support for SSR\n\n### Desktop\n\n* [ ] Declarative window management\n* [ ] Templates for building/bundling\n* [ ] Access to Canvas/WebGL context natively\n\n### Mobile\n\n* [ ] Mobile standard library\n * [ ] GPS\n * [ ] Camera\n * [ ] filesystem\n * [ ] Biometrics\n * [ ] WiFi\n * [ ] Bluetooth\n * [ ] Notifications\n * [ ] Clipboard\n* [ ] Animations\n\n### Bundling (CLI)\n\n* [x] Translation from HTML into RSX\n* [x] Dev server\n* [x] Live reload\n* [x] Translation from JSX into RSX\n* [ ] Hot module replacement\n* [ ] Code splitting\n* [ ] Asset macros\n* [ ] Css pipeline\n* [ ] Image pipeline\n\n### Essential hooks\n\n* [x] Router\n* [x] Global state management\n* [ ] Resize observer\n\n## Work in Progress\n\n### Build Tool\n\nWe are currently working on our own build tool called [Dioxus CLI](https://github.com/DioxusLabs/dioxus/tree/master/packages/cli) which will support:\n\n* an interactive TUI\n* on-the-fly reconfiguration\n* hot CSS reloading\n* two-way data binding between browser and source code\n* an interpreter for `rsx!`\n* ability to publish to github/netlify/vercel\n* bundling for iOS/Desktop/etc\n\n### Server Component Support\n\nWhile not currently fully implemented, the expectation is that LiveView apps can be a hybrid between Wasm and server-rendered where only portions of a page are \"live\" and the rest of the page is either server-rendered, statically generated, or handled by the host SPA.\n\n### Native rendering\n\nWe are currently working on a native renderer for Dioxus using WGPU called [Blitz](https://github.com/DioxusLabs/blitz/). This will allow you to build apps that are rendered natively for iOS, Android, and Desktop.\n\n## Internal Links\n\nInternal links like [this](./chapter_1.md) are typechecked and will fail to compile if the file is not found." + } 0usize => { - "# Liveview\n\nLiveview allows apps to *run* on the server and *render* in the browser. It uses WebSockets to communicate between the server and the browser.\n\nExamples:\n\n* [Axum Example](https://github.com/DioxusLabs/dioxus/tree/master/packages/liveview/examples/axum.rs)\n* [Salvo Example](https://github.com/DioxusLabs/dioxus/tree/master/packages/liveview/examples/salvo.rs)\n* [Warp Example](https://github.com/DioxusLabs/dioxus/tree/master/packages/liveview/examples/warp.rs)\n\n## Support\n\nLiveview is currently limited in capability when compared to the Web platform. Liveview apps run on the server in a native thread. This means that browser APIs are not available, so rendering WebGL, Canvas, etc is not as easy as the Web. However, native system APIs are accessible, so streaming, WebSockets, filesystem, etc are all viable APIs.\n\n## Setup\n\nFor this guide, we're going to show how to use Dioxus Liveview with [Axum](https://docs.rs/axum/latest/axum/).\n\nMake sure you have Rust and Cargo installed, and then create a new project:\n\n````shell\ncargo new --bin demo\ncd app\n````\n\nAdd Dioxus and the liveview renderer with the Axum feature as dependencies:\n\n````shell\ncargo add dioxus\ncargo add dioxus-liveview --features axum\n````\n\nNext, add all the Axum dependencies. This will be different if you're using a different Web Framework\n\n````\ncargo add tokio --features full\ncargo add axum\n````\n\nYour dependencies should look roughly like this:\n\n````toml\n[dependencies]\naxum = \"0.4.5\"\ndioxus = { version = \"*\" }\ndioxus-liveview = { version = \"*\", features = [\"axum\"] }\ntokio = { version = \"1.15.0\", features = [\"full\"] }\n````\n\n````rust@included_example.rs\nfn it_works() {}\n\n````\n\n````sh\n{\"timestamp\":\" 9.927s\",\"level\":\"INFO\",\"message\":\"Bundled app successfully!\",\"target\":\"dx::cli::bundle\"}\n{\"timestamp\":\" 9.927s\",\"level\":\"INFO\",\"message\":\"App produced 2 outputs:\",\"target\":\"dx::cli::bundle\"}\n{\"timestamp\":\" 9.927s\",\"level\":\"INFO\",\"message\":\"app - [target/dx/hot_dog/bundle/macos/bundle/macos/HotDog.app]\",\"target\":\"dx::cli::bundle\"}\n{\"timestamp\":\" 9.927s\",\"level\":\"INFO\",\"message\":\"dmg - [target/dx/hot_dog/bundle/macos/bundle/dmg/HotDog_0.1.0_aarch64.dmg]\",\"target\":\"dx::cli::bundle\"}\n{\"timestamp\":\" 9.927s\",\"level\":\"DEBUG\",\"json\":\"{\\\"BundleOutput\\\":{\\\"bundles\\\":[\\\"target/dx/hot_dog/bundle/macos/bundle/macos/HotDog.app\\\"]}}\"}\n````" + "# Liveview\n\nLiveview allows apps to *run* on the server and *render* in the browser. It uses WebSockets to communicate between the server and the browser.\n\nExamples:\n\n* [Axum Example](https://github.com/DioxusLabs/dioxus/tree/master/packages/liveview/examples/axum.rs)\n* [Salvo Example](https://github.com/DioxusLabs/dioxus/tree/master/packages/liveview/examples/salvo.rs)\n* [Warp Example](https://github.com/DioxusLabs/dioxus/tree/master/packages/liveview/examples/warp.rs)\n\n## Support\n\nLiveview is currently limited in capability when compared to the Web platform. Liveview apps run on the server in a native thread. This means that browser APIs are not available, so rendering WebGL, Canvas, etc is not as easy as the Web. However, native system APIs are accessible, so streaming, WebSockets, filesystem, etc are all viable APIs.\n\n## Setup\n\nFor this guide, we're going to show how to use Dioxus Liveview with [Axum](https://docs.rs/axum/latest/axum/).\n\nMake sure you have Rust and Cargo installed, and then create a new project:\n\n````shell\ncargo new --bin demo\ncd app\n````\n\nAdd Dioxus and the liveview renderer with the Axum feature as dependencies:\n\n````shell\ncargo add dioxus\ncargo add dioxus-liveview --features axum\n````\n\nNext, add all the Axum dependencies. This will be different if you're using a different Web Framework\n\n````\ncargo add tokio --features full\ncargo add axum\n````\n\nYour dependencies should look roughly like this:\n\n````toml\n[dependencies]\naxum = \"0.4.5\"\ndioxus = { version = \"*\" }\ndioxus-liveview = { version = \"*\", features = [\"axum\"] }\ntokio = { version = \"1.15.0\", features = [\"full\"] }\n````\n\n````rs@included_example.rs\nfn it_works() {}\n\n````\n\n````sh\n{\"timestamp\":\" 9.927s\",\"level\":\"INFO\",\"message\":\"Bundled app successfully!\",\"target\":\"dx::cli::bundle\"}\n{\"timestamp\":\" 9.927s\",\"level\":\"INFO\",\"message\":\"App produced 2 outputs:\",\"target\":\"dx::cli::bundle\"}\n{\"timestamp\":\" 9.927s\",\"level\":\"INFO\",\"message\":\"app - [target/dx/hot_dog/bundle/macos/bundle/macos/HotDog.app]\",\"target\":\"dx::cli::bundle\"}\n{\"timestamp\":\" 9.927s\",\"level\":\"INFO\",\"message\":\"dmg - [target/dx/hot_dog/bundle/macos/bundle/dmg/HotDog_0.1.0_aarch64.dmg]\",\"target\":\"dx::cli::bundle\"}\n{\"timestamp\":\" 9.927s\",\"level\":\"DEBUG\",\"json\":\"{\\\"BundleOutput\\\":{\\\"bundles\\\":[\\\"target/dx/hot_dog/bundle/macos/bundle/macos/HotDog.app\\\"]}}\"}\n````" } _ => panic!("Invalid page ID:"), } @@ -59,151 +58,163 @@ pub static LAZY_BOOK: use_mdbook::Lazy, _page_id_mapping: &mut std::collections::HashMap<_, _>| { + _pages.push((0usize, { + ::use_mdbook::mdbook_shared::Page { + title: "Chapter 1".to_string(), + url: BookRoute::Chapter1 { + section: Chapter1Section::Empty, + }, + segments: vec![], + sections: vec![ + ::use_mdbook::mdbook_shared::Section { + title: "Liveview".to_string(), + id: "liveview".to_string(), + level: 1usize, + }, + ::use_mdbook::mdbook_shared::Section { + title: "Support".to_string(), + id: "support".to_string(), + level: 2usize, + }, + ::use_mdbook::mdbook_shared::Section { + title: "Setup".to_string(), + id: "setup".to_string(), + level: 2usize, + }, + ], + raw: String::new(), + id: ::use_mdbook::mdbook_shared::PageId(0usize), + } + })); + _page_id_mapping.insert( + BookRoute::Chapter1 { + section: Chapter1Section::Empty, }, - ::use_mdbook::mdbook_shared::Section { - title: "Native rendering".to_string(), - id: "native-rendering".to_string(), - level: 3usize, + ::use_mdbook::mdbook_shared::PageId(0usize), + ); + }; + __push_page_0(&mut pages, &mut page_id_mapping); + let __push_page_1: fn(_, _) = + |_pages: &mut Vec<_>, _page_id_mapping: &mut std::collections::HashMap<_, _>| { + _pages.push((1usize, { + ::use_mdbook::mdbook_shared::Page { + title: "Chapter 2".to_string(), + url: BookRoute::Chapter2 { + section: Chapter2Section::Empty, + }, + segments: vec![], + sections: vec![ + ::use_mdbook::mdbook_shared::Section { + title: "Roadmap & Feature-set".to_string(), + id: "roadmap--feature-set".to_string(), + level: 1usize, + }, + ::use_mdbook::mdbook_shared::Section { + title: "Features".to_string(), + id: "features".to_string(), + level: 2usize, + }, + ::use_mdbook::mdbook_shared::Section { + title: "Roadmap".to_string(), + id: "roadmap".to_string(), + level: 2usize, + }, + ::use_mdbook::mdbook_shared::Section { + title: "Core".to_string(), + id: "core".to_string(), + level: 3usize, + }, + ::use_mdbook::mdbook_shared::Section { + title: "SSR".to_string(), + id: "ssr".to_string(), + level: 3usize, + }, + ::use_mdbook::mdbook_shared::Section { + title: "Desktop".to_string(), + id: "desktop".to_string(), + level: 3usize, + }, + ::use_mdbook::mdbook_shared::Section { + title: "Mobile".to_string(), + id: "mobile".to_string(), + level: 3usize, + }, + ::use_mdbook::mdbook_shared::Section { + title: "Bundling (CLI)".to_string(), + id: "bundling-cli".to_string(), + level: 3usize, + }, + ::use_mdbook::mdbook_shared::Section { + title: "Essential hooks".to_string(), + id: "essential-hooks".to_string(), + level: 3usize, + }, + ::use_mdbook::mdbook_shared::Section { + title: "Work in Progress".to_string(), + id: "work-in-progress".to_string(), + level: 2usize, + }, + ::use_mdbook::mdbook_shared::Section { + title: "Build Tool".to_string(), + id: "build-tool".to_string(), + level: 3usize, + }, + ::use_mdbook::mdbook_shared::Section { + title: "Server Component Support".to_string(), + id: "server-component-support".to_string(), + level: 3usize, + }, + ::use_mdbook::mdbook_shared::Section { + title: "Native rendering".to_string(), + id: "native-rendering".to_string(), + level: 3usize, + }, + ::use_mdbook::mdbook_shared::Section { + title: "Internal Links".to_string(), + id: "internal-links".to_string(), + level: 2usize, + }, + ], + raw: String::new(), + id: ::use_mdbook::mdbook_shared::PageId(1usize), + } + })); + _page_id_mapping.insert( + BookRoute::Chapter2 { + section: Chapter2Section::Empty, }, - ::use_mdbook::mdbook_shared::Section { - title: "Internal Links".to_string(), - id: "internal-links".to_string(), - level: 2usize, + ::use_mdbook::mdbook_shared::PageId(1usize), + ); + }; + __push_page_1(&mut pages, &mut page_id_mapping); + let __push_page_2: fn(_, _) = + |_pages: &mut Vec<_>, _page_id_mapping: &mut std::collections::HashMap<_, _>| { + _pages.push((2usize, { + ::use_mdbook::mdbook_shared::Page { + title: "Chapter 3".to_string(), + url: BookRoute::Chapter3 { + section: Chapter3Section::Empty, + }, + segments: vec![], + sections: vec![::use_mdbook::mdbook_shared::Section { + title: "Assets".to_string(), + id: "assets".to_string(), + level: 1usize, + }], + raw: String::new(), + id: ::use_mdbook::mdbook_shared::PageId(2usize), + } + })); + _page_id_mapping.insert( + BookRoute::Chapter3 { + section: Chapter3Section::Empty, }, - ], - raw: String::new(), - id: ::use_mdbook::mdbook_shared::PageId(1usize), - } - })); - page_id_mapping.insert( - BookRoute::Chapter2 { - section: Chapter2Section::Empty, - }, - ::use_mdbook::mdbook_shared::PageId(1usize), - ); - pages.push((2usize, { - ::use_mdbook::mdbook_shared::Page { - title: "Chapter 3".to_string(), - url: BookRoute::Chapter3 { - section: Chapter3Section::Empty, - }, - segments: vec![], - sections: vec![::use_mdbook::mdbook_shared::Section { - title: "Assets".to_string(), - id: "assets".to_string(), - level: 1usize, - }], - raw: String::new(), - id: ::use_mdbook::mdbook_shared::PageId(2usize), - } - })); - page_id_mapping.insert( - BookRoute::Chapter3 { - section: Chapter3Section::Empty, - }, - ::use_mdbook::mdbook_shared::PageId(2usize), - ); + ::use_mdbook::mdbook_shared::PageId(2usize), + ); + }; + __push_page_2(&mut pages, &mut page_id_mapping); ::use_mdbook::mdbook_shared::MdBook { summary: ::use_mdbook::mdbook_shared::Summary { title: Some("Summary".to_string()), @@ -257,14 +268,16 @@ pub enum Chapter1Section { Setup, } impl std::str::FromStr for Chapter1Section { - type Err = Chapter1SectionParseError; + type Err = &'static str; fn from_str(s: &str) -> Result { match s { "" => Ok(Self::Empty), "liveview" => Ok(Self::Liveview), "support" => Ok(Self::Support), "setup" => Ok(Self::Setup), - _ => Err(Chapter1SectionParseError), + _ => { + Err("Invalid section name. Expected one of Chapter1Sectionliveview, support, setup") + } } } } @@ -278,100 +291,139 @@ impl std::fmt::Display for Chapter1Section { } } } -#[derive(Debug)] -pub struct Chapter1SectionParseError; -impl std::fmt::Display for Chapter1SectionParseError { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - f.write_str( - "Invalid section name. Expected one of Chapter1Sectionliveview, support, setup", - )?; - Ok(()) - } -} -impl std::error::Error for Chapter1SectionParseError {} #[component(no_case_check)] -pub fn Chapter1(section: Chapter1Section) -> dioxus::prelude::Element { - use dioxus::prelude::*; +pub fn Chapter1(section: Chapter1Section) -> Element { rsx! { - h1 { id: "liveview", - Link { - to: BookRoute::Chapter1 { - section: Chapter1Section::Liveview, - }, - class: "header", - "Liveview" - } - } - p { - "Liveview allows apps to " - em { "run" } - " on the server and " - em { "render" } - " in the browser. It uses WebSockets to communicate between the server and the browser." - } - p { "Examples:" } - ul { - li { - Link { to: "https://github.com/DioxusLabs/dioxus/tree/master/packages/liveview/examples/axum.rs", - "Axum Example" - } - } - li { - Link { to: "https://github.com/DioxusLabs/dioxus/tree/master/packages/liveview/examples/salvo.rs", - "Salvo Example" - } - } - li { - Link { to: "https://github.com/DioxusLabs/dioxus/tree/master/packages/liveview/examples/warp.rs", - "Warp Example" - } - } - } - h2 { id: "support", - Link { - to: BookRoute::Chapter1 { - section: Chapter1Section::Support, - }, - class: "header", - "Support" - } - } - p { - "Liveview is currently limited in capability when compared to the Web platform. Liveview apps run on the server in a native thread. This means that browser APIs are not available, so rendering WebGL, Canvas, etc is not as easy as the Web. However, native system APIs are accessible, so streaming, WebSockets, filesystem, etc are all viable APIs." - } - h2 { id: "setup", - Link { - to: BookRoute::Chapter1 { - section: Chapter1Section::Setup, - }, - class: "header", - "Setup" - } - } - p { - "For this guide, we're going to show how to use Dioxus Liveview with " - Link { to: "https://docs.rs/axum/latest/axum/", "Axum" } - "." - } - p { "Make sure you have Rust and Cargo installed, and then create a new project:" } - CodeBlock { contents: "
\ncargo new --bin demo\ncd app
\n" } - p { "Add Dioxus and the liveview renderer with the Axum feature as dependencies:" } - CodeBlock { contents: "
\ncargo add dioxus\ncargo add dioxus-liveview --features axum
\n" } - p { - "Next, add all the Axum dependencies. This will be different if you're using a different Web Framework" - } - CodeBlock { contents: "
\ncargo add tokio --features full\ncargo add axum
\n" } - p { "Your dependencies should look roughly like this:" } - CodeBlock { - contents: "
\n[dependencies]\naxum = "0.4.5"\ndioxus = {{ version = "*" }}\ndioxus-liveview = {{ version = "*", features = ["axum"] }}\ntokio = {{ version = "1.15.0", features = ["full"] }}
\n", - } - CodeBlock { - contents: "
\nfn it_works() {{}}
\n", - name: "included_example.rs".to_string(), - } - CodeBlock { - contents: "
\n{{"timestamp":"   9.927s","level":"INFO","message":"Bundled app successfully!","target":"dx::cli::bundle"}}\n{{"timestamp":"   9.927s","level":"INFO","message":"App produced 2 outputs:","target":"dx::cli::bundle"}}\n{{"timestamp":"   9.927s","level":"INFO","message":"app - [target/dx/hot_dog/bundle/macos/bundle/macos/HotDog.app]","target":"dx::cli::bundle"}}\n{{"timestamp":"   9.927s","level":"INFO","message":"dmg - [target/dx/hot_dog/bundle/macos/bundle/dmg/HotDog_0.1.0_aarch64.dmg]","target":"dx::cli::bundle"}}\n{{"timestamp":"   9.927s","level":"DEBUG","json":"{{\\"BundleOutput\\":{{\\"bundles\\":[\\"target/dx/hot_dog/bundle/macos/bundle/macos/HotDog.app\\"]}}}}"}}
\n", - } + h1 { id : "liveview", Link { to : BookRoute::Chapter1 { section : + Chapter1Section::Liveview, }, class : "header", "Liveview" } } p { + "Liveview allows apps to " em { "run" } " on the server and " em { "render" } + " in the browser. It uses WebSockets to communicate between the server and the browser." + } p { "Examples:" } ul { li { Link { to : + "https://github.com/DioxusLabs/dioxus/tree/master/packages/liveview/examples/axum.rs", + "Axum Example" } } li { Link { to : + "https://github.com/DioxusLabs/dioxus/tree/master/packages/liveview/examples/salvo.rs", + "Salvo Example" } } li { Link { to : + "https://github.com/DioxusLabs/dioxus/tree/master/packages/liveview/examples/warp.rs", + "Warp Example" } } } h2 { id : "support", Link { to : BookRoute::Chapter1 { + section : Chapter1Section::Support, }, class : "header", "Support" } } p { + "Liveview is currently limited in capability when compared to the Web platform. Liveview apps run on the server in a native thread. This means that browser APIs are not available, so rendering WebGL, Canvas, etc is not as easy as the Web. However, native system APIs are accessible, so streaming, WebSockets, filesystem, etc are all viable APIs." + } h2 { id : "setup", Link { to : BookRoute::Chapter1 { section : + Chapter1Section::Setup, }, class : "header", "Setup" } } p { + "For this guide, we're going to show how to use Dioxus Liveview with " Link { to + : "https://docs.rs/axum/latest/axum/", "Axum" } "." } p { + "Make sure you have Rust and Cargo installed, and then create a new project:" } + CodeBlock { source : { static SPANS : & [use_mdbook::HighlightSpan] = & + [use_mdbook::HighlightSpan::new(0u32..5u32, "f"), + use_mdbook::HighlightSpan::new(10u32..15u32, "co"), + use_mdbook::HighlightSpan::new(21u32..23u32, "f"),]; + use_mdbook::HighlightedSource::from_static_parts("cargo new --bin demo\ncd app", + use_mdbook::Language::Rust, SPANS,) }, } p { + "Add Dioxus and the liveview renderer with the Axum feature as dependencies:" } + CodeBlock { source : { static SPANS : & [use_mdbook::HighlightSpan] = & + [use_mdbook::HighlightSpan::new(0u32..5u32, "f"), + use_mdbook::HighlightSpan::new(17u32..22u32, "f"), + use_mdbook::HighlightSpan::new(43u32..53u32, "co"),]; + use_mdbook::HighlightedSource::from_static_parts("cargo add dioxus\ncargo add dioxus-liveview --features axum", + use_mdbook::Language::Rust, SPANS,) }, } p { + "Next, add all the Axum dependencies. This will be different if you're using a different Web Framework" + } CodeBlock { source : { static SPANS : & [use_mdbook::HighlightSpan] = & []; + use_mdbook::HighlightedSource::from_static_parts("cargo add tokio --features full\ncargo add axum", + use_mdbook::Language::Rust, SPANS,) }, } p { + "Your dependencies should look roughly like this:" } CodeBlock { source : { + static SPANS : & [use_mdbook::HighlightSpan] = & + [use_mdbook::HighlightSpan::new(0u32..1u32, "p"), + use_mdbook::HighlightSpan::new(1u32..13u32, "pr"), + use_mdbook::HighlightSpan::new(13u32..14u32, "p"), + use_mdbook::HighlightSpan::new(15u32..19u32, "pr"), + use_mdbook::HighlightSpan::new(20u32..21u32, "o"), + use_mdbook::HighlightSpan::new(22u32..29u32, "s"), + use_mdbook::HighlightSpan::new(30u32..36u32, "pr"), + use_mdbook::HighlightSpan::new(37u32..38u32, "o"), + use_mdbook::HighlightSpan::new(39u32..40u32, "p"), + use_mdbook::HighlightSpan::new(41u32..48u32, "pr"), + use_mdbook::HighlightSpan::new(49u32..50u32, "o"), + use_mdbook::HighlightSpan::new(51u32..54u32, "s"), + use_mdbook::HighlightSpan::new(55u32..56u32, "p"), + use_mdbook::HighlightSpan::new(57u32..72u32, "pr"), + use_mdbook::HighlightSpan::new(73u32..74u32, "o"), + use_mdbook::HighlightSpan::new(75u32..76u32, "p"), + use_mdbook::HighlightSpan::new(77u32..84u32, "pr"), + use_mdbook::HighlightSpan::new(85u32..86u32, "o"), + use_mdbook::HighlightSpan::new(87u32..90u32, "s"), + use_mdbook::HighlightSpan::new(90u32..91u32, "p"), + use_mdbook::HighlightSpan::new(92u32..100u32, "pr"), + use_mdbook::HighlightSpan::new(101u32..102u32, "o"), + use_mdbook::HighlightSpan::new(103u32..104u32, "p"), + use_mdbook::HighlightSpan::new(104u32..110u32, "s"), + use_mdbook::HighlightSpan::new(110u32..111u32, "p"), + use_mdbook::HighlightSpan::new(112u32..113u32, "p"), + use_mdbook::HighlightSpan::new(114u32..119u32, "pr"), + use_mdbook::HighlightSpan::new(120u32..121u32, "o"), + use_mdbook::HighlightSpan::new(122u32..123u32, "p"), + use_mdbook::HighlightSpan::new(124u32..131u32, "pr"), + use_mdbook::HighlightSpan::new(132u32..133u32, "o"), + use_mdbook::HighlightSpan::new(134u32..142u32, "s"), + use_mdbook::HighlightSpan::new(142u32..143u32, "p"), + use_mdbook::HighlightSpan::new(144u32..152u32, "pr"), + use_mdbook::HighlightSpan::new(153u32..154u32, "o"), + use_mdbook::HighlightSpan::new(155u32..156u32, "p"), + use_mdbook::HighlightSpan::new(156u32..162u32, "s"), + use_mdbook::HighlightSpan::new(162u32..163u32, "p"), + use_mdbook::HighlightSpan::new(164u32..165u32, "p"),]; + use_mdbook::HighlightedSource::from_static_parts("[dependencies]\naxum = \"0.4.5\"\ndioxus = { version = \"*\" }\ndioxus-liveview = { version = \"*\", features = [\"axum\"] }\ntokio = { version = \"1.15.0\", features = [\"full\"] }", + use_mdbook::Language::Rust, SPANS,) }, } CodeBlock { source : { static SPANS : & + [use_mdbook::HighlightSpan] = & [use_mdbook::HighlightSpan::new(0u32..2u32, "k"), + use_mdbook::HighlightSpan::new(3u32..11u32, "f"), + use_mdbook::HighlightSpan::new(11u32..13u32, "p"), + use_mdbook::HighlightSpan::new(14u32..16u32, "p"),]; + use_mdbook::HighlightedSource::from_static_parts("fn it_works() {}", + use_mdbook::Language::Rust, SPANS,) }, name : "included_example.rs".to_string(), + } CodeBlock { source : { static SPANS : & [use_mdbook::HighlightSpan] = & + [use_mdbook::HighlightSpan::new(1u32..12u32, "s"), + use_mdbook::HighlightSpan::new(1u32..105u32, "f"), + use_mdbook::HighlightSpan::new(13u32..24u32, "s"), + use_mdbook::HighlightSpan::new(25u32..32u32, "s"), + use_mdbook::HighlightSpan::new(33u32..39u32, "s"), + use_mdbook::HighlightSpan::new(40u32..49u32, "s"), + use_mdbook::HighlightSpan::new(50u32..77u32, "s"), + use_mdbook::HighlightSpan::new(78u32..86u32, "s"), + use_mdbook::HighlightSpan::new(87u32..104u32, "s"), + use_mdbook::HighlightSpan::new(107u32..118u32, "s"), + use_mdbook::HighlightSpan::new(107u32..209u32, "f"), + use_mdbook::HighlightSpan::new(119u32..130u32, "s"), + use_mdbook::HighlightSpan::new(131u32..138u32, "s"), + use_mdbook::HighlightSpan::new(139u32..145u32, "s"), + use_mdbook::HighlightSpan::new(146u32..155u32, "s"), + use_mdbook::HighlightSpan::new(156u32..181u32, "s"), + use_mdbook::HighlightSpan::new(182u32..190u32, "s"), + use_mdbook::HighlightSpan::new(191u32..208u32, "s"), + use_mdbook::HighlightSpan::new(211u32..222u32, "s"), + use_mdbook::HighlightSpan::new(211u32..352u32, "f"), + use_mdbook::HighlightSpan::new(223u32..234u32, "s"), + use_mdbook::HighlightSpan::new(235u32..242u32, "s"), + use_mdbook::HighlightSpan::new(243u32..249u32, "s"), + use_mdbook::HighlightSpan::new(250u32..259u32, "s"), + use_mdbook::HighlightSpan::new(260u32..324u32, "s"), + use_mdbook::HighlightSpan::new(325u32..333u32, "s"), + use_mdbook::HighlightSpan::new(334u32..351u32, "s"), + use_mdbook::HighlightSpan::new(354u32..365u32, "s"), + use_mdbook::HighlightSpan::new(354u32..507u32, "f"), + use_mdbook::HighlightSpan::new(366u32..377u32, "s"), + use_mdbook::HighlightSpan::new(378u32..385u32, "s"), + use_mdbook::HighlightSpan::new(386u32..392u32, "s"), + use_mdbook::HighlightSpan::new(393u32..402u32, "s"), + use_mdbook::HighlightSpan::new(403u32..479u32, "s"), + use_mdbook::HighlightSpan::new(480u32..488u32, "s"), + use_mdbook::HighlightSpan::new(489u32..506u32, "s"), + use_mdbook::HighlightSpan::new(509u32..520u32, "s"), + use_mdbook::HighlightSpan::new(509u32..652u32, "f"), + use_mdbook::HighlightSpan::new(521u32..532u32, "s"), + use_mdbook::HighlightSpan::new(533u32..540u32, "s"), + use_mdbook::HighlightSpan::new(541u32..548u32, "s"), + use_mdbook::HighlightSpan::new(549u32..555u32, "s"), + use_mdbook::HighlightSpan::new(556u32..651u32, "s"),]; + use_mdbook::HighlightedSource::from_static_parts("{\"timestamp\":\" 9.927s\",\"level\":\"INFO\",\"message\":\"Bundled app successfully!\",\"target\":\"dx::cli::bundle\"}\n{\"timestamp\":\" 9.927s\",\"level\":\"INFO\",\"message\":\"App produced 2 outputs:\",\"target\":\"dx::cli::bundle\"}\n{\"timestamp\":\" 9.927s\",\"level\":\"INFO\",\"message\":\"app - [target/dx/hot_dog/bundle/macos/bundle/macos/HotDog.app]\",\"target\":\"dx::cli::bundle\"}\n{\"timestamp\":\" 9.927s\",\"level\":\"INFO\",\"message\":\"dmg - [target/dx/hot_dog/bundle/macos/bundle/dmg/HotDog_0.1.0_aarch64.dmg]\",\"target\":\"dx::cli::bundle\"}\n{\"timestamp\":\" 9.927s\",\"level\":\"DEBUG\",\"json\":\"{\\\"BundleOutput\\\":{\\\"bundles\\\":[\\\"target/dx/hot_dog/bundle/macos/bundle/macos/HotDog.app\\\"]}}\"}", + use_mdbook::Language::Rust, SPANS,) }, } } } #[derive( @@ -396,7 +448,7 @@ pub enum Chapter2Section { InternalLinks, } impl std::str::FromStr for Chapter2Section { - type Err = Chapter2SectionParseError; + type Err = &'static str; fn from_str(s: &str) -> Result { match s { "" => Ok(Self::Empty), @@ -414,7 +466,11 @@ impl std::str::FromStr for Chapter2Section { "server-component-support" => Ok(Self::ServerComponentSupport), "native-rendering" => Ok(Self::NativeRendering), "internal-links" => Ok(Self::InternalLinks), - _ => Err(Chapter2SectionParseError), + _ => { + Err( + "Invalid section name. Expected one of Chapter2Sectionroadmap--feature-set, features, roadmap, core, ssr, desktop, mobile, bundling-cli, essential-hooks, work-in-progress, build-tool, server-component-support, native-rendering, internal-links", + ) + } } } } @@ -439,718 +495,177 @@ impl std::fmt::Display for Chapter2Section { } } } -#[derive(Debug)] -pub struct Chapter2SectionParseError; -impl std::fmt::Display for Chapter2SectionParseError { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - f.write_str( - "Invalid section name. Expected one of Chapter2Sectionroadmap--feature-set, features, roadmap, core, ssr, desktop, mobile, bundling-cli, essential-hooks, work-in-progress, build-tool, server-component-support, native-rendering, internal-links", - )?; - Ok(()) - } -} -impl std::error::Error for Chapter2SectionParseError {} #[component(no_case_check)] -pub fn Chapter2(section: Chapter2Section) -> dioxus::prelude::Element { - use dioxus::prelude::*; +pub fn Chapter2(section: Chapter2Section) -> Element { rsx! { - h1 { id: "roadmap--feature-set", - Link { - to: BookRoute::Chapter2 { - section: Chapter2Section::RoadmapFeatureSet, - }, - class: "header", - "Roadmap & Feature-set" - } - } - p { - "This feature set and roadmap can help you decide if what Dioxus can do today works for you." - } - p { - "If a feature that you need doesn't exist or you want to contribute to projects on the roadmap, feel free to get involved by " - Link { to: "https://discord.gg/XgGxMSkvUM", "joining the discord" } - "." - } - p { "Generally, here's the status of each platform:" } - ul { - li { - p { - strong { "Web" } - ": Dioxus is a great choice for pure web-apps – especially for CRUD/complex apps. However, it does lack the ecosystem of React, so you might be missing a component library or some useful hook." - } - } - li { - p { - strong { "SSR" } - ": Dioxus is a great choice for pre-rendering, hydration, and rendering HTML on a web endpoint. Be warned – the VirtualDom is not (currently) " - code { "Send + Sync" } - "." - } - } - li { - p { - strong { "Desktop" } - ": You can build very competent single-window desktop apps right now. However, multi-window apps require support from Dioxus core and are not ready." - } - } - li { - p { - strong { "Mobile" } - ": Mobile support is very young. You'll be figuring things out as you go and there are not many support crates for peripherals." - } - } - li { - p { - strong { "LiveView" } - ": LiveView support is very young. You'll be figuring things out as you go. Thankfully, none of it is too hard and any work can be upstreamed into Dioxus." - } - } - } - CodeBlock { contents: "
\nfn main() {{\n  dioxus_rocks;\n}}
\n" } - h2 { id: "features", - Link { - to: BookRoute::Chapter2 { - section: Chapter2Section::Features, - }, - class: "header", - "Features" - } - } - hr {} - table { - thead { - th { "Feature" } - th { "Status" } - th { "Description" } - } - tr { - th { "Conditional Rendering" } - th { "✅" } - th { "if/then to hide/show component" } - } - tr { - th { "Map, Iterator" } - th { "✅" } - th { "map/filter/reduce to produce rsx!" } - } - tr { - th { "Keyed Components" } - th { "✅" } - th { "advanced diffing with keys" } - } - tr { - th { "Web" } - th { "✅" } - th { "renderer for web browser" } - } - tr { - th { "Desktop (webview)" } - th { "✅" } - th { "renderer for desktop" } - } - tr { - th { "Shared State (Context)" } - th { "✅" } - th { "share state through the tree" } - } - tr { - th { "Hooks" } - th { "✅" } - th { "memory cells in components" } - } - tr { - th { "SSR" } - th { "✅" } - th { "render directly to string" } - } - tr { - th { "Component Children" } - th { "✅" } - th { "cx.children() as a list of nodes" } - } - tr { - th { "Headless components" } - th { "✅" } - th { "components that don't return real elements" } - } - tr { - th { "Fragments" } - th { "✅" } - th { "multiple elements without a real root" } - } - tr { - th { "Manual Props" } - th { "✅" } - th { "Manually pass in props with spread syntax" } - } - tr { - th { "Controlled Inputs" } - th { "✅" } - th { "stateful wrappers around inputs" } - } - tr { - th { "CSS/Inline Styles" } - th { "✅" } - th { "syntax for inline styles/attribute groups" } - } - tr { - th { "Custom elements" } - th { "✅" } - th { "Define new element primitives" } - } - tr { - th { "Suspense" } - th { "✅" } - th { "schedule future render from future/promise" } - } - tr { - th { "Integrated error handling" } - th { "✅" } - th { "Gracefully handle errors with ? syntax" } - } - tr { - th { "NodeRef" } - th { "✅" } - th { "gain direct access to nodes" } - } - tr { - th { "Re-hydration" } - th { "✅" } - th { "Pre-render to HTML to speed up first contentful paint" } - } - tr { - th { "Jank-Free Rendering" } - th { "✅" } - th { "Large diffs are segmented across frames for silky-smooth transitions" } - } - tr { - th { "Effects" } - th { "✅" } - th { "Run effects after a component has been committed to render" } - } - tr { - th { "Portals" } - th { "🛠" } - th { "Render nodes outside of the traditional tree structure" } - } - tr { - th { "Cooperative Scheduling" } - th { "🛠" } - th { "Prioritize important events over non-important events" } - } - tr { - th { "Server Components" } - th { "🛠" } - th { "Hybrid components for SPA and Server" } - } - tr { - th { "Bundle Splitting" } - th { "👀" } - th { "Efficiently and asynchronously load the app" } - } - tr { - th { "Lazy Components" } - th { "👀" } - th { "Dynamically load the new components as the page is loaded" } - } - tr { - th { "1st class global state" } - th { "✅" } - th { "redux/recoil/mobx on top of context" } - } - tr { - th { "Runs natively" } - th { "✅" } - th { "runs as a portable binary w/o a runtime (Node)" } - } - tr { - th { "Subtree Memoization" } - th { "✅" } - th { "skip diffing static element subtrees" } - } - tr { - th { "High-efficiency templates" } - th { "✅" } - th { "rsx! calls are translated to templates on the DOM's side" } - } - tr { - th { "Compile-time correct" } - th { "✅" } - th { "Throw errors on invalid template layouts" } - } - tr { - th { "Heuristic Engine" } - th { "✅" } - th { "track component memory usage to minimize future allocations" } - } - tr { - th { "Fine-grained reactivity" } - th { "👀" } - th { "Skip diffing for fine-grain updates" } - } - } - ul { - li { "✅ = implemented and working" } - li { "🛠 = actively being worked on" } - li { "👀 = not yet implemented or being worked on" } - } - h2 { id: "roadmap", - Link { - to: BookRoute::Chapter2 { - section: Chapter2Section::Roadmap, - }, - class: "header", - "Roadmap" - } - } - p { "These Features are planned for the future of Dioxus:" } - h3 { id: "core", - Link { - to: BookRoute::Chapter2 { - section: Chapter2Section::Core, - }, - class: "header", - "Core" - } - } - ul { - li { - input { - r#type: "checkbox", - readonly: true, - class: "mdbook-checkbox", - value: "true", - } - "Release of Dioxus Core" - } - li { - input { - r#type: "checkbox", - readonly: true, - class: "mdbook-checkbox", - value: "true", - } - "Upgrade documentation to include more theory and be more comprehensive" - } - li { - input { - r#type: "checkbox", - readonly: true, - class: "mdbook-checkbox", - value: "true", - } - "Support for HTML-side templates for lightning-fast dom manipulation" - } - li { - input { - r#type: "checkbox", - readonly: true, - class: "mdbook-checkbox", - value: "false", - } - "Support for multiple renderers for same virtualdom (subtrees)" - } - li { - input { - r#type: "checkbox", - readonly: true, - class: "mdbook-checkbox", - value: "false", - } - "Support for ThreadSafe (Send + Sync)" - } - li { - input { - r#type: "checkbox", - readonly: true, - class: "mdbook-checkbox", - value: "false", - } - "Support for Portals" - } - } - h3 { id: "ssr", - Link { - to: BookRoute::Chapter2 { - section: Chapter2Section::Ssr, - }, - class: "header", - "SSR" - } - } - ul { - li { - input { - r#type: "checkbox", - readonly: true, - class: "mdbook-checkbox", - value: "true", - } - "SSR Support + Hydration" - } - li { - input { - r#type: "checkbox", - readonly: true, - class: "mdbook-checkbox", - value: "false", - } - "Integrated suspense support for SSR" - } - } - h3 { id: "desktop", - Link { - to: BookRoute::Chapter2 { - section: Chapter2Section::Desktop, - }, - class: "header", - "Desktop" - } - } - ul { - li { - input { - r#type: "checkbox", - readonly: true, - class: "mdbook-checkbox", - value: "false", - } - "Declarative window management" - } - li { - input { - r#type: "checkbox", - readonly: true, - class: "mdbook-checkbox", - value: "false", - } - "Templates for building/bundling" - } - li { - input { - r#type: "checkbox", - readonly: true, - class: "mdbook-checkbox", - value: "false", - } - "Access to Canvas/WebGL context natively" - } - } - h3 { id: "mobile", - Link { - to: BookRoute::Chapter2 { - section: Chapter2Section::Mobile, - }, - class: "header", - "Mobile" - } - } - ul { - li { - input { - r#type: "checkbox", - readonly: true, - class: "mdbook-checkbox", - value: "false", - } - "Mobile standard library" - ul { - li { - input { - r#type: "checkbox", - readonly: true, - class: "mdbook-checkbox", - value: "false", - } - "GPS" - } - li { - input { - r#type: "checkbox", - readonly: true, - class: "mdbook-checkbox", - value: "false", - } - "Camera" - } - li { - input { - r#type: "checkbox", - readonly: true, - class: "mdbook-checkbox", - value: "false", - } - "filesystem" - } - li { - input { - r#type: "checkbox", - readonly: true, - class: "mdbook-checkbox", - value: "false", - } - "Biometrics" - } - li { - input { - r#type: "checkbox", - readonly: true, - class: "mdbook-checkbox", - value: "false", - } - "WiFi" - } - li { - input { - r#type: "checkbox", - readonly: true, - class: "mdbook-checkbox", - value: "false", - } - "Bluetooth" - } - li { - input { - r#type: "checkbox", - readonly: true, - class: "mdbook-checkbox", - value: "false", - } - "Notifications" - } - li { - input { - r#type: "checkbox", - readonly: true, - class: "mdbook-checkbox", - value: "false", - } - "Clipboard" - } - } - } - li { - input { - r#type: "checkbox", - readonly: true, - class: "mdbook-checkbox", - value: "false", - } - "Animations" - } - } - h3 { id: "bundling-cli", - Link { - to: BookRoute::Chapter2 { - section: Chapter2Section::BundlingCli, - }, - class: "header", - "Bundling (CLI)" - } - } - ul { - li { - input { - r#type: "checkbox", - readonly: true, - class: "mdbook-checkbox", - value: "true", - } - "Translation from HTML into RSX" - } - li { - input { - r#type: "checkbox", - readonly: true, - class: "mdbook-checkbox", - value: "true", - } - "Dev server" - } - li { - input { - r#type: "checkbox", - readonly: true, - class: "mdbook-checkbox", - value: "true", - } - "Live reload" - } - li { - input { - r#type: "checkbox", - readonly: true, - class: "mdbook-checkbox", - value: "true", - } - "Translation from JSX into RSX" - } - li { - input { - r#type: "checkbox", - readonly: true, - class: "mdbook-checkbox", - value: "false", - } - "Hot module replacement" - } - li { - input { - r#type: "checkbox", - readonly: true, - class: "mdbook-checkbox", - value: "false", - } - "Code splitting" - } - li { - input { - r#type: "checkbox", - readonly: true, - class: "mdbook-checkbox", - value: "false", - } - "Asset macros" - } - li { - input { - r#type: "checkbox", - readonly: true, - class: "mdbook-checkbox", - value: "false", - } - "Css pipeline" - } - li { - input { - r#type: "checkbox", - readonly: true, - class: "mdbook-checkbox", - value: "false", - } - "Image pipeline" - } - } - h3 { id: "essential-hooks", - Link { - to: BookRoute::Chapter2 { - section: Chapter2Section::EssentialHooks, - }, - class: "header", - "Essential hooks" - } - } - ul { - li { - input { - r#type: "checkbox", - readonly: true, - class: "mdbook-checkbox", - value: "true", - } - "Router" - } - li { - input { - r#type: "checkbox", - readonly: true, - class: "mdbook-checkbox", - value: "true", - } - "Global state management" - } - li { - input { - r#type: "checkbox", - readonly: true, - class: "mdbook-checkbox", - value: "false", - } - "Resize observer" - } - } - h2 { id: "work-in-progress", - Link { - to: BookRoute::Chapter2 { - section: Chapter2Section::WorkInProgress, - }, - class: "header", - "Work in Progress" - } - } - h3 { id: "build-tool", - Link { - to: BookRoute::Chapter2 { - section: Chapter2Section::BuildTool, - }, - class: "header", - "Build Tool" - } - } - p { - "We are currently working on our own build tool called " - Link { to: "https://github.com/DioxusLabs/dioxus/tree/master/packages/cli", - "Dioxus CLI" - } - " which will support:" - } - ul { - li { "an interactive TUI" } - li { "on-the-fly reconfiguration" } - li { "hot CSS reloading" } - li { "two-way data binding between browser and source code" } - li { - "an interpreter for " - code { "rsx!" } - } - li { "ability to publish to github/netlify/vercel" } - li { "bundling for iOS/Desktop/etc" } - } - h3 { id: "server-component-support", - Link { - to: BookRoute::Chapter2 { - section: Chapter2Section::ServerComponentSupport, - }, - class: "header", - "Server Component Support" - } - } - p { - "While not currently fully implemented, the expectation is that LiveView apps can be a hybrid between Wasm and server-rendered where only portions of a page are \"live\" and the rest of the page is either server-rendered, statically generated, or handled by the host SPA." - } - h3 { id: "native-rendering", - Link { - to: BookRoute::Chapter2 { - section: Chapter2Section::NativeRendering, - }, - class: "header", - "Native rendering" - } - } - p { - "We are currently working on a native renderer for Dioxus using WGPU called " - Link { to: "https://github.com/DioxusLabs/blitz/", "Blitz" } - ". This will allow you to build apps that are rendered natively for iOS, Android, and Desktop." - } - h2 { id: "internal-links", - Link { - to: BookRoute::Chapter2 { - section: Chapter2Section::InternalLinks, - }, - class: "header", - "Internal Links" - } - } - p { - "Internal links like " - Link { - to: BookRoute::Chapter1 { - section: Chapter1Section::Empty, - }, - "this" - } - " are typechecked and will fail to compile if the file is not found." - } + h1 { id : "roadmap--feature-set", Link { to : BookRoute::Chapter2 { section : + Chapter2Section::RoadmapFeatureSet, }, class : "header", "Roadmap & Feature-set" + } } p { + "This feature set and roadmap can help you decide if what Dioxus can do today works for you." + } p { + "If a feature that you need doesn't exist or you want to contribute to projects on the roadmap, feel free to get involved by " + Link { to : "https://discord.gg/XgGxMSkvUM", "joining the discord" } "." } p { + "Generally, here's the status of each platform:" } ul { li { p { strong { "Web" } + ": Dioxus is a great choice for pure web-apps – especially for CRUD/complex apps. However, it does lack the ecosystem of React, so you might be missing a component library or some useful hook." + } } li { p { strong { "SSR" } + ": Dioxus is a great choice for pre-rendering, hydration, and rendering HTML on a web endpoint. Be warned – the VirtualDom is not (currently) " + code { "Send + Sync" } "." } } li { p { strong { "Desktop" } + ": You can build very competent single-window desktop apps right now. However, multi-window apps require support from Dioxus core and are not ready." + } } li { p { strong { "Mobile" } + ": Mobile support is very young. You'll be figuring things out as you go and there are not many support crates for peripherals." + } } li { p { strong { "LiveView" } + ": LiveView support is very young. You'll be figuring things out as you go. Thankfully, none of it is too hard and any work can be upstreamed into Dioxus." + } } } CodeBlock { source : { static SPANS : & [use_mdbook::HighlightSpan] = & + [use_mdbook::HighlightSpan::new(0u32..2u32, "k"), + use_mdbook::HighlightSpan::new(3u32..7u32, "f"), + use_mdbook::HighlightSpan::new(7u32..9u32, "p"), + use_mdbook::HighlightSpan::new(10u32..11u32, "p"), + use_mdbook::HighlightSpan::new(26u32..27u32, "p"), + use_mdbook::HighlightSpan::new(28u32..29u32, "p"),]; + use_mdbook::HighlightedSource::from_static_parts("fn main() {\n dioxus_rocks;\n}", + use_mdbook::Language::Rust, SPANS,) }, } h2 { id : "features", Link { to : + BookRoute::Chapter2 { section : Chapter2Section::Features, }, class : "header", + "Features" } } hr {} table { thead { th { "Feature" } th { "Status" } th { + "Description" } } tr { th { "Conditional Rendering" } th { "✅" } th { + "if/then to hide/show component" } } tr { th { "Map, Iterator" } th { "✅" } th + { "map/filter/reduce to produce rsx!" } } tr { th { "Keyed Components" } th { + "✅" } th { "advanced diffing with keys" } } tr { th { "Web" } th { "✅" } th { + "renderer for web browser" } } tr { th { "Desktop (webview)" } th { "✅" } th { + "renderer for desktop" } } tr { th { "Shared State (Context)" } th { "✅" } th { + "share state through the tree" } } tr { th { "Hooks" } th { "✅" } th { + "memory cells in components" } } tr { th { "SSR" } th { "✅" } th { + "render directly to string" } } tr { th { "Component Children" } th { "✅" } th + { "cx.children() as a list of nodes" } } tr { th { "Headless components" } th { + "✅" } th { "components that don't return real elements" } } tr { th { + "Fragments" } th { "✅" } th { "multiple elements without a real root" } } tr { + th { "Manual Props" } th { "✅" } th { + "Manually pass in props with spread syntax" } } tr { th { "Controlled Inputs" } + th { "✅" } th { "stateful wrappers around inputs" } } tr { th { + "CSS/Inline Styles" } th { "✅" } th { + "syntax for inline styles/attribute groups" } } tr { th { "Custom elements" } th + { "✅" } th { "Define new element primitives" } } tr { th { "Suspense" } th { + "✅" } th { "schedule future render from future/promise" } } tr { th { + "Integrated error handling" } th { "✅" } th { + "Gracefully handle errors with ? syntax" } } tr { th { "NodeRef" } th { "✅" } + th { "gain direct access to nodes" } } tr { th { "Re-hydration" } th { "✅" } th + { "Pre-render to HTML to speed up first contentful paint" } } tr { th { + "Jank-Free Rendering" } th { "✅" } th { + "Large diffs are segmented across frames for silky-smooth transitions" } } tr { + th { "Effects" } th { "✅" } th { + "Run effects after a component has been committed to render" } } tr { th { + "Portals" } th { "🛠" } th { + "Render nodes outside of the traditional tree structure" } } tr { th { + "Cooperative Scheduling" } th { "🛠" } th { + "Prioritize important events over non-important events" } } tr { th { + "Server Components" } th { "🛠" } th { "Hybrid components for SPA and Server" } + } tr { th { "Bundle Splitting" } th { "👀" } th { + "Efficiently and asynchronously load the app" } } tr { th { "Lazy Components" } + th { "👀" } th { "Dynamically load the new components as the page is loaded" } + } tr { th { "1st class global state" } th { "✅" } th { + "redux/recoil/mobx on top of context" } } tr { th { "Runs natively" } th { "✅" + } th { "runs as a portable binary w/o a runtime (Node)" } } tr { th { + "Subtree Memoization" } th { "✅" } th { "skip diffing static element subtrees" + } } tr { th { "High-efficiency templates" } th { "✅" } th { + "rsx! calls are translated to templates on the DOM's side" } } tr { th { + "Compile-time correct" } th { "✅" } th { + "Throw errors on invalid template layouts" } } tr { th { "Heuristic Engine" } th + { "✅" } th { "track component memory usage to minimize future allocations" } } + tr { th { "Fine-grained reactivity" } th { "👀" } th { + "Skip diffing for fine-grain updates" } } } ul { li { + "✅ = implemented and working" } li { "🛠 = actively being worked on" } li { + "👀 = not yet implemented or being worked on" } } h2 { id : "roadmap", Link { + to : BookRoute::Chapter2 { section : Chapter2Section::Roadmap, }, class : + "header", "Roadmap" } } p { + "These Features are planned for the future of Dioxus:" } h3 { id : "core", Link { + to : BookRoute::Chapter2 { section : Chapter2Section::Core, }, class : "header", + "Core" } } ul { li { input { r#type : "checkbox", readonly : true, class : + "mdbook-checkbox", value : "true", } "Release of Dioxus Core" } li { input { + r#type : "checkbox", readonly : true, class : "mdbook-checkbox", value : "true", + } "Upgrade documentation to include more theory and be more comprehensive" } li { + input { r#type : "checkbox", readonly : true, class : "mdbook-checkbox", value : + "true", } "Support for HTML-side templates for lightning-fast dom manipulation" } + li { input { r#type : "checkbox", readonly : true, class : "mdbook-checkbox", + value : "false", } + "Support for multiple renderers for same virtualdom (subtrees)" } li { input { + r#type : "checkbox", readonly : true, class : "mdbook-checkbox", value : "false", + } "Support for ThreadSafe (Send + Sync)" } li { input { r#type : "checkbox", + readonly : true, class : "mdbook-checkbox", value : "false", } + "Support for Portals" } } h3 { id : "ssr", Link { to : BookRoute::Chapter2 { + section : Chapter2Section::Ssr, }, class : "header", "SSR" } } ul { li { input { + r#type : "checkbox", readonly : true, class : "mdbook-checkbox", value : "true", + } "SSR Support + Hydration" } li { input { r#type : "checkbox", readonly : true, + class : "mdbook-checkbox", value : "false", } + "Integrated suspense support for SSR" } } h3 { id : "desktop", Link { to : + BookRoute::Chapter2 { section : Chapter2Section::Desktop, }, class : "header", + "Desktop" } } ul { li { input { r#type : "checkbox", readonly : true, class : + "mdbook-checkbox", value : "false", } "Declarative window management" } li { + input { r#type : "checkbox", readonly : true, class : "mdbook-checkbox", value : + "false", } "Templates for building/bundling" } li { input { r#type : "checkbox", + readonly : true, class : "mdbook-checkbox", value : "false", } + "Access to Canvas/WebGL context natively" } } h3 { id : "mobile", Link { to : + BookRoute::Chapter2 { section : Chapter2Section::Mobile, }, class : "header", + "Mobile" } } ul { li { input { r#type : "checkbox", readonly : true, class : + "mdbook-checkbox", value : "false", } "Mobile standard library" ul { li { input { + r#type : "checkbox", readonly : true, class : "mdbook-checkbox", value : "false", + } "GPS" } li { input { r#type : "checkbox", readonly : true, class : + "mdbook-checkbox", value : "false", } "Camera" } li { input { r#type : + "checkbox", readonly : true, class : "mdbook-checkbox", value : "false", } + "filesystem" } li { input { r#type : "checkbox", readonly : true, class : + "mdbook-checkbox", value : "false", } "Biometrics" } li { input { r#type : + "checkbox", readonly : true, class : "mdbook-checkbox", value : "false", } "WiFi" + } li { input { r#type : "checkbox", readonly : true, class : "mdbook-checkbox", + value : "false", } "Bluetooth" } li { input { r#type : "checkbox", readonly : + true, class : "mdbook-checkbox", value : "false", } "Notifications" } li { input + { r#type : "checkbox", readonly : true, class : "mdbook-checkbox", value : + "false", } "Clipboard" } } } li { input { r#type : "checkbox", readonly : true, + class : "mdbook-checkbox", value : "false", } "Animations" } } h3 { id : + "bundling-cli", Link { to : BookRoute::Chapter2 { section : + Chapter2Section::BundlingCli, }, class : "header", "Bundling (CLI)" } } ul { li { + input { r#type : "checkbox", readonly : true, class : "mdbook-checkbox", value : + "true", } "Translation from HTML into RSX" } li { input { r#type : "checkbox", + readonly : true, class : "mdbook-checkbox", value : "true", } "Dev server" } li { + input { r#type : "checkbox", readonly : true, class : "mdbook-checkbox", value : + "true", } "Live reload" } li { input { r#type : "checkbox", readonly : true, + class : "mdbook-checkbox", value : "true", } "Translation from JSX into RSX" } li + { input { r#type : "checkbox", readonly : true, class : "mdbook-checkbox", value + : "false", } "Hot module replacement" } li { input { r#type : "checkbox", + readonly : true, class : "mdbook-checkbox", value : "false", } "Code splitting" } + li { input { r#type : "checkbox", readonly : true, class : "mdbook-checkbox", + value : "false", } "Asset macros" } li { input { r#type : "checkbox", readonly : + true, class : "mdbook-checkbox", value : "false", } "Css pipeline" } li { input { + r#type : "checkbox", readonly : true, class : "mdbook-checkbox", value : "false", + } "Image pipeline" } } h3 { id : "essential-hooks", Link { to : + BookRoute::Chapter2 { section : Chapter2Section::EssentialHooks, }, class : + "header", "Essential hooks" } } ul { li { input { r#type : "checkbox", readonly : + true, class : "mdbook-checkbox", value : "true", } "Router" } li { input { r#type + : "checkbox", readonly : true, class : "mdbook-checkbox", value : "true", } + "Global state management" } li { input { r#type : "checkbox", readonly : true, + class : "mdbook-checkbox", value : "false", } "Resize observer" } } h2 { id : + "work-in-progress", Link { to : BookRoute::Chapter2 { section : + Chapter2Section::WorkInProgress, }, class : "header", "Work in Progress" } } h3 { + id : "build-tool", Link { to : BookRoute::Chapter2 { section : + Chapter2Section::BuildTool, }, class : "header", "Build Tool" } } p { + "We are currently working on our own build tool called " Link { to : + "https://github.com/DioxusLabs/dioxus/tree/master/packages/cli", "Dioxus CLI" } + " which will support:" } ul { li { "an interactive TUI" } li { + "on-the-fly reconfiguration" } li { "hot CSS reloading" } li { + "two-way data binding between browser and source code" } li { + "an interpreter for " code { "rsx!" } } li { + "ability to publish to github/netlify/vercel" } li { + "bundling for iOS/Desktop/etc" } } h3 { id : "server-component-support", Link { + to : BookRoute::Chapter2 { section : Chapter2Section::ServerComponentSupport, }, + class : "header", "Server Component Support" } } p { + "While not currently fully implemented, the expectation is that LiveView apps can be a hybrid between Wasm and server-rendered where only portions of a page are \"live\" and the rest of the page is either server-rendered, statically generated, or handled by the host SPA." + } h3 { id : "native-rendering", Link { to : BookRoute::Chapter2 { section : + Chapter2Section::NativeRendering, }, class : "header", "Native rendering" } } p { + "We are currently working on a native renderer for Dioxus using WGPU called " + Link { to : "https://github.com/DioxusLabs/blitz/", "Blitz" } + ". This will allow you to build apps that are rendered natively for iOS, Android, and Desktop." + } h2 { id : "internal-links", Link { to : BookRoute::Chapter2 { section : + Chapter2Section::InternalLinks, }, class : "header", "Internal Links" } } p { + "Internal links like " Link { to : BookRoute::Chapter1 { section : + Chapter1Section::Empty, }, "this" } + " are typechecked and will fail to compile if the file is not found." } } } #[derive( @@ -1162,12 +677,12 @@ pub enum Chapter3Section { Assets, } impl std::str::FromStr for Chapter3Section { - type Err = Chapter3SectionParseError; + type Err = &'static str; fn from_str(s: &str) -> Result { match s { "" => Ok(Self::Empty), "assets" => Ok(Self::Assets), - _ => Err(Chapter3SectionParseError), + _ => Err("Invalid section name. Expected one of Chapter3Sectionassets"), } } } @@ -1179,51 +694,19 @@ impl std::fmt::Display for Chapter3Section { } } } -#[derive(Debug)] -pub struct Chapter3SectionParseError; -impl std::fmt::Display for Chapter3SectionParseError { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - f.write_str("Invalid section name. Expected one of Chapter3Sectionassets")?; - Ok(()) - } -} -impl std::error::Error for Chapter3SectionParseError {} #[component(no_case_check)] -pub fn Chapter3(section: Chapter3Section) -> dioxus::prelude::Element { - use dioxus::prelude::*; +pub fn Chapter3(section: Chapter3Section) -> Element { rsx! { - h1 { id: "assets", - Link { - to: BookRoute::Chapter3 { - section: Chapter3Section::Assets, - }, - class: "header", - "Assets" - } - } - p { - "Some assets:" - img { - src: "https://avatars.githubusercontent.com/u/79236386?s=200&v=4", - alt: "some_external", - title: "", - } - img { - src: asset!("/example-book/assets/logo.png", ImageAssetOptions::new().with_webp()), - alt: "some_local", - title: "", - } - img { - src: asset!("/example-book/assets/logo1.png", ImageAssetOptions::new().with_webp()), - alt: "some_local1", - title: "", - } - img { - src: asset!("/example-book/assets/logo2.png", ImageAssetOptions::new().with_webp()), - alt: "some_local2", - title: "", - } - } + h1 { id : "assets", Link { to : BookRoute::Chapter3 { section : + Chapter3Section::Assets, }, class : "header", "Assets" } } p { "Some assets:" img + { src : "https://avatars.githubusercontent.com/u/79236386?s=200&v=4", alt : + "some_external", title : "", } img { src : + asset!("/example-book/assets/logo.png", ImageAssetOptions::new().with_webp()), + alt : "some_local", title : "", } img { src : + asset!("/example-book/assets/logo1.png", ImageAssetOptions::new().with_webp()), + alt : "some_local1", title : "", } img { src : + asset!("/example-book/assets/logo2.png", ImageAssetOptions::new().with_webp()), + alt : "some_local2", title : "", } } } } diff --git a/packages/include_mdbook/packages/mdbook-gen/Cargo.toml b/packages/include_mdbook/packages/mdbook-gen/Cargo.toml index 1348560f16..36a4442b83 100644 --- a/packages/include_mdbook/packages/mdbook-gen/Cargo.toml +++ b/packages/include_mdbook/packages/mdbook-gen/Cargo.toml @@ -4,6 +4,22 @@ version = "0.0.0" edition = "2021" [dependencies] +arborium = { version = "2.16.0", default-features = false, features = [ + "lang-bash", + "lang-batch", + "lang-css", + "lang-dockerfile", + "lang-html", + "lang-javascript", + "lang-json", + "lang-lua", + "lang-powershell", + "lang-rust", + "lang-toml", + "lang-tsx", + "lang-yaml", +] } +arborium-theme = "2.16.0" proc-macro2 = { version = "1.0" } quote = "1.0" syn = { workspace = true } @@ -16,13 +32,10 @@ convert_case = "0.6.0" postcard = { version = "1.0.4", features = ["use-std"] } pulldown-cmark = "0.13.0" pulldown-cmark-to-cmark = "21.0.0" -syntect = { version = "5.2.0", features = ["plist-load"] } prettyplease = "0.2.20" -once_cell = "1.20.2" dioxus-rsx = { workspace = true } dioxus-autofmt = { workspace = true } -sublime-color-scheme = "0.1.4" [dev-dependencies] pretty_assertions = "1.3.0" diff --git a/packages/include_mdbook/packages/mdbook-gen/src/rsx.rs b/packages/include_mdbook/packages/mdbook-gen/src/rsx.rs index 916fba72db..63f43960c3 100644 --- a/packages/include_mdbook/packages/mdbook-gen/src/rsx.rs +++ b/packages/include_mdbook/packages/mdbook-gen/src/rsx.rs @@ -12,9 +12,6 @@ use dioxus_rsx::{BodyNode, CallBody, TemplateBody}; use pulldown_cmark::{Alignment, CodeBlockKind, Event, Options, Parser, Tag}; use syn::{parse_quote, parse_str, Ident}; -use syntect::highlighting::ThemeSet; -use syntect::parsing::SyntaxSet; - use crate::{ path_to_route_enum, path_to_route_enum_with_section, to_upper_camel_case_for_ident, EmptyIdentError, @@ -364,17 +361,8 @@ impl<'a, I: Iterator>> RsxMarkdownParser<'a, I> { if lang.as_deref() == Some("inject-dioxus") { self.start_node(parse_str::(&raw_code).unwrap()); } else { - // syntect doesn't seem to detect by name properly, so we transform some common names - // to their extension - let lang = match lang.as_deref() { - Some("shell") => "sh", - Some("javascript") => "js", - Some(res) => res, - None => "txt", - }; - - let dark_html = build_codeblock(&raw_code, lang, true); - let light_html = build_codeblock(&raw_code, lang, false); + let language = normalize_code_language(lang.as_deref()); + let source = highlighted_source_tokens(raw_code.trim_end(), &language); let fname = if let Some(fname) = fname { quote! { name: #fname.to_string() } @@ -384,8 +372,7 @@ impl<'a, I: Iterator>> RsxMarkdownParser<'a, I> { self.start_node(parse_quote! { CodeBlock { - contents: #dark_html, - light_contents: #light_html, + source: #source, #fname } }); @@ -763,77 +750,124 @@ impl<'a, I: Iterator>> Iterator for ResolveCodeBlock<'a, I> { } } -fn build_codeblock(code: &str, lang: &str, is_dark: bool) -> String { - static DARK_THEME: once_cell::sync::Lazy = - once_cell::sync::Lazy::new(|| { - let raw = include_str!("../themes/MonokaiDark.thTheme").to_string(); - let mut reader = std::io::Cursor::new(raw.clone()); - ThemeSet::load_from_reader(&mut reader).unwrap() - }); - - static LIGHT_THEME: once_cell::sync::Lazy = - once_cell::sync::Lazy::new(|| { - let raw = include_str!("../themes/Base16.thTheme").to_string(); - let mut reader = std::io::Cursor::new(raw.clone()); - ThemeSet::load_from_reader(&mut reader).unwrap() - }); - // once_cell::sync::Lazy::new(|| ThemeSet::load_defaults().themes["InspiredGitHub"].clone()); - // once_cell::sync::Lazy::new(|| ThemeSet::load_defaults().themes["InspiredGitHub"].clone()); - - let lang = if lang.to_ascii_lowercase() == "rust" { - "rs" +fn normalize_code_language(lang: Option<&str>) -> String { + let lang = lang + .unwrap_or_default() + .trim() + .split(|ch: char| ch.is_whitespace() || ch == ',') + .next() + .unwrap_or_default() + .to_ascii_lowercase(); + + match lang.as_str() { + "bash" | "sh" | "shell" => "bash", + "cmd" => "batch", + "js" => "javascript", + "jsx" => "tsx", + "plain" | "text" | "txt" => "", + "rs" => "rust", + "yml" => "yaml", + language => language, + } + .to_string() +} + +fn highlighted_source_tokens(code: &str, language: &str) -> TokenStream2 { + let code = code.to_string(); + let spans = if language.is_empty() { + Vec::new() } else { - lang + let mut highlighter = arborium::Highlighter::new(); + highlighter + .highlight_spans(language, &code) + .map(normalize_highlight_spans) + .unwrap_or_default() }; - let ss = modern_syntax_set(); - let syntax = ss.find_syntax_by_name(lang).unwrap_or_else(|| { - ss.find_syntax_by_extension(lang).unwrap_or_else(|| { - ss.find_syntax_by_extension("txt").unwrap_or_else(|| { - panic!("Failed to find syntax for {lang} from {:#?}", ss.syntaxes()) - }) - }) + let spans = spans.into_iter().map(|span| { + let start = span.start; + let end = span.end; + let tag = span.tag; + quote! { + use_mdbook::HighlightSpan::new(#start..#end, #tag) + } }); - let html = syntect::html::highlighted_html_for_string( - code.trim_end(), - &ss, - syntax, - if is_dark { &DARK_THEME } else { &LIGHT_THEME }, - ) - .unwrap(); + quote! {{ + static SPANS: &[use_mdbook::HighlightSpan] = &[#(#spans),*]; + use_mdbook::HighlightedSource::from_static_parts( + #code, + use_mdbook::Language::Rust, + SPANS, + ) + }} +} - escape_text(&html) +struct NormalizedHighlightSpan { + start: u32, + end: u32, + tag: &'static str, } -// This is an updated set of syntaxes with support for toml -fn modern_syntax_set() -> SyntaxSet { - static SYNTAX_SET: once_cell::sync::Lazy = once_cell::sync::Lazy::new(|| { - use syntect::parsing::SyntaxSetBuilder; - let mut builder = SyntaxSetBuilder::new(); - builder - .add_from_folder( - PathBuf::from(env!("CARGO_MANIFEST_DIR")).join("sublime_toml_highlighting"), - true, - ) - .unwrap(); - builder - .add_from_folder( - PathBuf::from(env!("CARGO_MANIFEST_DIR")).join("Packages"), - true, - ) - .unwrap(); - builder - .add_from_folder( - PathBuf::from(env!("CARGO_MANIFEST_DIR")).join("rust-enhanced"), - true, - ) - .unwrap(); - builder.add_plain_text_syntax(); - builder.build() - }); +struct RawHighlightSpan { + start: u32, + end: u32, + tag: Option<&'static str>, + pattern_index: u32, +} + +fn normalize_highlight_spans(spans: Vec) -> Vec { + use std::collections::HashMap; + + let mut deduped: HashMap<(u32, u32), RawHighlightSpan> = HashMap::new(); + for span in spans { + let span = RawHighlightSpan { + start: span.start, + end: span.end, + tag: arborium_theme::tag_for_capture(&span.capture), + pattern_index: span.pattern_index, + }; + let key = (span.start, span.end); + + if let Some(existing) = deduped.get(&key) { + let should_replace = match (span.tag.is_some(), existing.tag.is_some()) { + (true, false) => true, + (false, true) => false, + _ => span.pattern_index >= existing.pattern_index, + }; + if should_replace { + deduped.insert(key, span); + } + } else { + deduped.insert(key, span); + } + } + + let mut spans: Vec<_> = deduped + .into_values() + .filter_map(|span| { + Some(NormalizedHighlightSpan { + start: span.start, + end: span.end, + tag: span.tag?, + }) + }) + .collect(); + + spans.sort_by_key(|span| (span.start, span.end)); + + let mut coalesced: Vec = Vec::with_capacity(spans.len()); + for span in spans { + if let Some(last) = coalesced.last_mut() { + if span.tag == last.tag && span.start <= last.end { + last.end = last.end.max(span.end); + continue; + } + } + coalesced.push(span); + } - SYNTAX_SET.clone() + coalesced } fn transform_code_block( diff --git a/packages/include_mdbook/packages/mdbook-gen/themes/Base16.thTheme b/packages/include_mdbook/packages/mdbook-gen/themes/Base16.thTheme deleted file mode 100644 index ec11bb07b7..0000000000 --- a/packages/include_mdbook/packages/mdbook-gen/themes/Base16.thTheme +++ /dev/null @@ -1,401 +0,0 @@ - - - - - - - - - name - Art School - settings - - - settings - - background - #FFFFFF - caret - #4e342e - foreground - #0D0D0D - invisibles - #3B3A32 - lineHighlight - #FFF700 - selection - #FFF04C - selectionBorder - #FFFFFF00 - - - - name - Comment - scope - comment - settings - - foreground - #999999 - background - #FFFFFF00 - - - - name - String - scope - string - settings - - foreground - #1794FAF0 - background - #FFFFFF3B - - - - name - Number - scope - constant.numeric - settings - - foreground - #0025F5 - - - - name - Built-in constant - scope - constant.language - settings - - foreground - #DE5CFF - - - - name - User-defined constant - scope - constant.character, constant.other - settings - - foreground - #AE81FF - - - - name - Variable - scope - variable - settings - - - - - - - name - entity.other.attribute-name.class.sass - scope - source.sass, meta.selector.sass, entity.other.attribute-name.class.sass - settings - - foreground - #1794FAF0 - - - - name - entity.other.attribute-name.id.sass - scope - source.sass, meta.selector.sass, entity.other.attribute-name.id.sass - settings - - foreground - #1794FAF0 - - - - name - support.type.property-name.sass - scope - source.sass meta.property-list.sass meta.property-name.sass support.type.property-name.sass - settings - - foreground - #FF6708F0 - - - - name - entity.name.tag.sass - scope - source.sass, meta.selector.sass, entity.name.tag.sass - settings - - foreground - #FF0000 - - - - name - constant.other.color.rgb-value.sass - scope - source.sass meta.property-list.sass meta.property-value.sass constant.other.color.rgb-value.sass - settings - - foreground - #D4D4D4 - - - - - - name - Keyword - scope - keyword - settings - - foreground - #FF3333 - - - - name - Storage - scope - storage - settings - - fontStyle - - foreground - #EB5086 - - - - name - Storage type - scope - storage.type - settings - - foreground - #0088FF - - - - name - Class name - scope - entity.name.class - settings - - foreground - #85C70C - - - - name - Inherited class - scope - entity.other.inherited-class - settings - - foreground - #507806 - - - - name - Function name - scope - entity.name.function - settings - - foreground - #1DA11D - - - - name - Function argument - scope - variable.parameter - settings - - foreground - #FF960D - - - - name - Tag name - scope - entity.name.tag - settings - - fontStyle - - foreground - #F92672 - - - - name - Tag attribute - scope - entity.other.attribute-name - settings - - fontStyle - - - - - - name - Library function - scope - support.function - settings - - fontStyle - - foreground - #FFCD03 - - - - name - Library constant - scope - support.constant - settings - - fontStyle - - foreground - #57C8ED - - - - name - Library class/type - scope - support.type, support.class - settings - - foreground - #124CFA - - - - name - Library variable - scope - support.other.variable - settings - - fontStyle - - foreground - #1C1C1C - - - - name - Invalid - scope - invalid - settings - - background - #F92672 - fontStyle - - foreground - #F8F8F0 - - - - name - Invalid deprecated - scope - invalid.deprecated - settings - - background - #AE81FF - foreground - #F8F8F0 - - - - name - entity.other.attribute-name.html - scope - entity.other.attribute-name.html - settings - - foreground - #F77C00 - - - - name - keyword.operator.js - scope - keyword.operator.js - settings - - foreground - #5ECFFF - - - - - name - source.js - scope - source.js - settings - - foreground - #050505 - background - #FFFFFF - - - - name - comment.js - scope - comment.js - settings - - foreground - #C2C2C2 - background - #FFF04C00 - - - - uuid - D8D5E82E-3D5B-46B5-B38E-8C841C21347D - colorSpaceName - sRGB - semanticClass - theme.light.mfa - author - irstacks - - diff --git a/packages/include_mdbook/packages/mdbook-gen/themes/MonokaiDark.thTheme b/packages/include_mdbook/packages/mdbook-gen/themes/MonokaiDark.thTheme deleted file mode 100644 index b25506b679..0000000000 --- a/packages/include_mdbook/packages/mdbook-gen/themes/MonokaiDark.thTheme +++ /dev/null @@ -1,410 +0,0 @@ - - - - - name - Monokai Dark - settings - - - settings - - background - #0D0D0D - caret - #F8F8F0 - foreground - #F8F8F2 - invisibles - #3B3A32 - lineHighlight - #3D3D3D55 - selection - #A63A62 - - - - name - Comment - scope - comment - settings - - foreground - #8C8C8C - - - - name - String - scope - string - settings - - foreground - #FFEE99 - - - - name - Number - scope - constant.numeric - settings - - foreground - #FF80F4 - - - - name - Built-in constant - scope - constant.language - settings - - foreground - #FF80F4 - - - - name - User-defined constant - scope - constant.character, constant.other - settings - - foreground - #FF80F4 - - - - name - Variable - scope - variable - settings - - fontStyle - - - - - name - Keyword - scope - keyword - settings - - foreground - #F92672 - - - - name - Storage - scope - storage - settings - - fontStyle - - foreground - #F92672 - - - - name - Storage type - scope - storage.type - settings - - fontStyle - - foreground - #66D9EF - - - - name - Class name - scope - entity.name.class - settings - - fontStyle - underline - foreground - #A6E22E - - - - name - Inherited class - scope - entity.other.inherited-class - settings - - fontStyle - - foreground - #A6E22E - - - - name - Function name - scope - entity.name.function - settings - - fontStyle - - foreground - #A6E22E - - - - name - Function argument - scope - variable.parameter - settings - - fontStyle - - foreground - #FD971F - - - - name - Tag name - scope - entity.name.tag - settings - - fontStyle - - foreground - #F92672 - - - - name - Tag attribute - scope - entity.other.attribute-name - settings - - fontStyle - - foreground - #A6E22E - - - - name - Library function - scope - support.function - settings - - fontStyle - - foreground - #66D9EF - - - - name - Library constant - scope - support.constant - settings - - fontStyle - - foreground - #66D9EF - - - - name - Library class/type - scope - support.type, support.class - settings - - fontStyle - - foreground - #66D9EF - - - - name - Library variable - scope - support.other.variable - settings - - fontStyle - - - - - name - PHP Namespaces - scope - support.other.namespace, entity.name.type.namespace - settings - - foreground - #FFB2F9 - - - - name - PHP Namespace Alias - scope - support.other.namespace.use-as.php - settings - - foreground - #66D9EF - - - - name - PHP Namespace Keyword - scope - variable.language.namespace.php - settings - - foreground - #D66990 - - - - name - PHP Namespace Separator - scope - punctuation.separator.inheritance.php - settings - - foreground - #F92672 - - - - name - CSS Functions / Property Values - scope - support.function.misc.css, support.constant.property-value.css, support.constant.font-name.css - settings - - foreground - #FFEE99 - - - - name - Twig Tagbraces - scope - entity.other.tagbraces.twig - settings - - foreground - #A6E22E - - - - name - Twig Tag - scope - keyword.control.twig - settings - - foreground - #FD971F - - - - name - Twig Variable - scope - variable.other.twig - settings - - foreground - #FF80F4 - - - - name - Twig Variable Filter - scope - support.function.filter.variable.twig - settings - - foreground - #FFCCFB - - - - name - Twig Function - scope - entity.name.function.twig - settings - - foreground - #F92672 - - - - name - Twig Function Argument - scope - entity.other.argument.twig - settings - - foreground - #E5DB7E - - - - name - Invalid - scope - invalid - settings - - background - #F92672 - fontStyle - - foreground - #F8F8F0 - - - - name - Invalid deprecated - scope - invalid.deprecated - settings - - background - #FF80F4 - foreground - #F8F8F0 - - - - uuid - 233F0694-0B9C-43E3-A44A-ECECF7DF6C73 - - diff --git a/packages/include_mdbook/packages/mdbook-macro/Cargo.toml b/packages/include_mdbook/packages/mdbook-macro/Cargo.toml index 01c588c827..017efad8a1 100644 --- a/packages/include_mdbook/packages/mdbook-macro/Cargo.toml +++ b/packages/include_mdbook/packages/mdbook-macro/Cargo.toml @@ -20,7 +20,6 @@ macro_state = "0.2.0" convert_case = "0.6.0" postcard = { version = "1.0.4", features = ["use-std"] } pulldown-cmark = "0.9.3" -syntect = "5.0" mdbook-gen = { workspace = true } dioxus-rsx = { workspace = true } diff --git a/packages/include_mdbook/packages/syntect-html/Cargo.toml b/packages/include_mdbook/packages/syntect-html/Cargo.toml deleted file mode 100644 index e51d7d3cd8..0000000000 --- a/packages/include_mdbook/packages/syntect-html/Cargo.toml +++ /dev/null @@ -1,15 +0,0 @@ -[package] -name = "syntect-html" -version = "0.1.0" -edition = "2021" - -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html - -[lib] -proc-macro = true - -[dependencies] -proc-macro2 = { version = "1.0" } -quote = "1.0" -syn = { workspace = true } -syntect = "5.0" diff --git a/packages/include_mdbook/packages/syntect-html/src/lib.rs b/packages/include_mdbook/packages/syntect-html/src/lib.rs deleted file mode 100644 index a203e9b6c1..0000000000 --- a/packages/include_mdbook/packages/syntect-html/src/lib.rs +++ /dev/null @@ -1,163 +0,0 @@ -use std::path::PathBuf; - -use proc_macro::TokenStream; -use proc_macro2::Span; -use quote::quote; -use quote::ToTokens; -use syn::parse::Parse; -use syn::parse::ParseStream; -use syn::LitStr; -use syn::Token; -use syntect::highlighting::ThemeSet; -use syntect::parsing::SyntaxSet; - -struct CodeBlock { - dark_html: String, -} - -impl Parse for CodeBlock { - fn parse(input: ParseStream) -> syn::Result { - let code = input.parse::()?; - let _ = input.parse::(); - let extension = input - .parse::() - .unwrap_or_else(|_| LitStr::new("rs", Span::call_site())); - let _ = input.parse::(); - - let theme = input - .parse::() - .unwrap_or_else(|_| LitStr::new("base16-ocean.dark", Span::call_site())); - - Self::new(code.value(), extension.value(), theme.value()) - } -} - -impl CodeBlock { - fn new(code: String, extension: String, theme: String) -> syn::Result { - let ss = SyntaxSet::load_defaults_newlines(); - let ts = ThemeSet::load_defaults(); - - let maybe_theme = ts.themes.get(&theme); - - let theme = maybe_theme.ok_or_else(|| { - syn::Error::new(Span::call_site(), format!("No theme found for {}", theme)) - })?; - - let syntax = ss.find_syntax_by_extension(&extension).ok_or_else(|| { - syn::Error::new( - Span::call_site(), - format!("No syntax found for extension {}", extension), - ) - })?; - - let dark_html = syntect::html::highlighted_html_for_string(&code, &ss, syntax, theme) - .map_err(|err| { - syn::Error::new( - Span::call_site(), - format!("Error while generating HTML: {}", err), - ) - })?; - - Ok(CodeBlock { dark_html }) - } -} - -impl ToTokens for CodeBlock { - fn to_tokens(&self, tokens: &mut proc_macro2::TokenStream) { - let html = &self.dark_html; - - tokens.extend(quote! { - #html - }) - } -} - -struct CodeBlockFs { - html: String, -} - -impl Parse for CodeBlockFs { - fn parse(input: ParseStream) -> syn::Result { - let code_path = input.parse::()?; - let code_path = code_path.value(); - let _ = input.parse::(); - let theme = input - .parse::() - .unwrap_or_else(|_| LitStr::new("base16-ocean.dark", Span::call_site())); - let theme = theme.value(); - - let path = PathBuf::from( - std::env::var("CARGO_MANIFEST_DIR") - .map_err(|_| syn::Error::new(Span::call_site(), "CARGO_MANIFEST_DIR not found"))?, - ); - let path = path.join(code_path); - let code = std::fs::read_to_string(&path).map_err(|err| { - syn::Error::new( - Span::call_site(), - format!( - "Error while reading file: {} while reading {}", - err, - path.display() - ), - ) - })?; - let extension = path.extension(); - let extension = &*extension.unwrap().to_string_lossy(); - let html = syntect::html::highlighted_html_for_string( - &code, - &syntect::parsing::SyntaxSet::load_defaults_newlines(), - syntect::parsing::SyntaxSet::load_defaults_newlines() - .find_syntax_by_extension(extension) - .unwrap(), - syntect::highlighting::ThemeSet::load_defaults() - .themes - .get(&theme) - .unwrap(), - ) - .unwrap(); - - Ok(CodeBlockFs { html }) - } -} - -/// Generate a HTML string from a code block path. -#[proc_macro] -pub fn syntect_html_fs(input: TokenStream) -> TokenStream { - match syn::parse::(input) { - Ok(block) => { - let html = &block.html; - quote! { - #html - } - .into() - } - Err(err) => err.to_compile_error().into(), - } -} - -/// Generate a HTML string from a code block. -/// -/// # Example -/// -/// ```rust -/// use syntect_html::syntect_html; -/// -/// let html = syntect_html! { -/// r#" -/// fn main() { -/// println!("Hello, world!"); -/// } -/// "#, -/// "rs", -/// "base16-ocean.dark" -/// }; -#[proc_macro] -pub fn syntect_html(input: TokenStream) -> TokenStream { - match syn::parse::(input) { - Ok(block) => quote! { - #block - } - .into(), - Err(err) => err.to_compile_error().into(), - } -} diff --git a/packages/include_mdbook/packages/use-mdbook/Cargo.toml b/packages/include_mdbook/packages/use-mdbook/Cargo.toml index 978a60e2ed..e5d2744d1a 100644 --- a/packages/include_mdbook/packages/use-mdbook/Cargo.toml +++ b/packages/include_mdbook/packages/use-mdbook/Cargo.toml @@ -6,6 +6,7 @@ edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] +dioxus-code = { workspace = true } lazy_static = "1.4.0" mdbook-macro = { path = "../mdbook-macro" } mdbook-shared = { path = "../mdbook-shared" } diff --git a/packages/include_mdbook/packages/use-mdbook/src/lib.rs b/packages/include_mdbook/packages/use-mdbook/src/lib.rs index 653bab377e..c87983f317 100644 --- a/packages/include_mdbook/packages/use-mdbook/src/lib.rs +++ b/packages/include_mdbook/packages/use-mdbook/src/lib.rs @@ -1,5 +1,9 @@ pub use mdbook_shared; +pub use dioxus_code::{ + advanced::{HighlightSpan, HighlightedSource}, + Language, +}; pub use mdbook_macro::*; pub use once_cell::sync::Lazy; pub use yazi; From 0de68f117642889258a0cc62e8a05a826d176e96 Mon Sep 17 00:00:00 2001 From: Evan Almloff Date: Fri, 8 May 2026 15:46:39 -0500 Subject: [PATCH 2/7] rebuild tailwind --- .claude/settings.local.json | 7 ------- packages/docsite/assets/tailwind.css | 28 ---------------------------- 2 files changed, 35 deletions(-) delete mode 100644 .claude/settings.local.json diff --git a/.claude/settings.local.json b/.claude/settings.local.json deleted file mode 100644 index 6676ac5002..0000000000 --- a/.claude/settings.local.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "permissions": { - "allow": [ - "Bash(gh pr list:*)" - ] - } -} diff --git a/packages/docsite/assets/tailwind.css b/packages/docsite/assets/tailwind.css index 319bb54905..44eaafeece 100644 --- a/packages/docsite/assets/tailwind.css +++ b/packages/docsite/assets/tailwind.css @@ -316,12 +316,6 @@ .row-span-3 { grid-row: span 3 / span 3; } - .float-left { - float: left; - } - .float-right { - float: right; - } .container { width: 100%; @media (width >= 40rem) { @@ -454,9 +448,6 @@ .inline-flex { display: inline-flex; } - .table { - display: table; - } .h-2 { height: calc(var(--spacing) * 2); } @@ -631,9 +622,6 @@ .basis-0 { flex-basis: calc(var(--spacing) * 0); } - .border-collapse { - border-collapse: collapse; - } .translate-x-px { --tw-translate-x: 1px; translate: var(--tw-translate-x) var(--tw-translate-y); @@ -1300,9 +1288,6 @@ .uppercase { text-transform: uppercase; } - .underline { - text-decoration-line: underline; - } .placeholder-gray-400 { &::placeholder { color: var(--color-gray-400); @@ -1326,17 +1311,10 @@ --tw-shadow: 0 20px 25px -5px var(--tw-shadow-color, rgb(0 0 0 / 0.1)), 0 8px 10px -6px var(--tw-shadow-color, rgb(0 0 0 / 0.1)); box-shadow: var(--tw-inset-shadow), var(--tw-inset-ring-shadow), var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow); } - .outline { - outline-style: var(--tw-outline-style); - outline-width: 1px; - } .invert { --tw-invert: invert(100%); filter: var(--tw-blur,) var(--tw-brightness,) var(--tw-contrast,) var(--tw-grayscale,) var(--tw-hue-rotate,) var(--tw-invert,) var(--tw-saturate,) var(--tw-sepia,) var(--tw-drop-shadow,); } - .filter { - filter: var(--tw-blur,) var(--tw-brightness,) var(--tw-contrast,) var(--tw-grayscale,) var(--tw-hue-rotate,) var(--tw-invert,) var(--tw-saturate,) var(--tw-sepia,) var(--tw-drop-shadow,); - } .backdrop-blur-sm { --tw-backdrop-blur: blur(var(--blur-sm)); -webkit-backdrop-filter: var(--tw-backdrop-blur,) var(--tw-backdrop-brightness,) var(--tw-backdrop-contrast,) var(--tw-backdrop-grayscale,) var(--tw-backdrop-hue-rotate,) var(--tw-backdrop-invert,) var(--tw-backdrop-opacity,) var(--tw-backdrop-saturate,) var(--tw-backdrop-sepia,); @@ -2331,11 +2309,6 @@ inherits: false; initial-value: 0 0 #0000; } -@property --tw-outline-style { - syntax: "*"; - inherits: false; - initial-value: solid; -} @property --tw-blur { syntax: "*"; inherits: false; @@ -2473,7 +2446,6 @@ --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-offset-shadow: 0 0 #0000; - --tw-outline-style: solid; --tw-blur: initial; --tw-brightness: initial; --tw-contrast: initial; From e46db3d6110009f0e76078a5b71b4ae4cd798a43 Mon Sep 17 00:00:00 2001 From: Evan Almloff Date: Mon, 11 May 2026 08:34:05 -0500 Subject: [PATCH 3/7] use dioxus_code::code_str! --- .claude/settings.local.json | 7 + Cargo.lock | 21 +- Cargo.toml | 16 +- packages/docs-03/Cargo.toml | 2 +- packages/docs-04/Cargo.toml | 1 + packages/docs-05/Cargo.toml | 1 + packages/docs-06/Cargo.toml | 1 + packages/docs-07/Cargo.toml | 1 + packages/docs-blog/Cargo.toml | 1 + .../packages/mdbook-gen-example/Cargo.toml | 1 + .../packages/mdbook-gen-example/src/lib.rs | 5 +- .../packages/mdbook-gen-example/src/router.rs | 246 +++++++++--------- .../packages/mdbook-gen/Cargo.toml | 16 -- .../packages/mdbook-gen/src/rsx.rs | 117 +++------ .../packages/use-mdbook/Cargo.toml | 1 - .../packages/use-mdbook/src/lib.rs | 4 - 16 files changed, 200 insertions(+), 241 deletions(-) create mode 100644 .claude/settings.local.json diff --git a/.claude/settings.local.json b/.claude/settings.local.json new file mode 100644 index 0000000000..6676ac5002 --- /dev/null +++ b/.claude/settings.local.json @@ -0,0 +1,7 @@ +{ + "permissions": { + "allow": [ + "Bash(gh pr list:*)" + ] + } +} diff --git a/Cargo.lock b/Cargo.lock index 256d322600..4e2eb738db 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1580,21 +1580,22 @@ dependencies = [ [[package]] name = "dioxus-code" -version = "0.1.1" +version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "28fcba1b18d2caec11fe1ff2db089c75353c5dd011fe8fc06913d58cd7fba7f1" +checksum = "859cbf40e5da690df269d4d1ab01b4ec9921b408cec4cabce2dd1620cc15670e" dependencies = [ "arborium", "arborium-theme", + "arborium-tree-sitter", "dioxus", "dioxus-code-macro", ] [[package]] name = "dioxus-code-macro" -version = "0.1.0" +version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa8a99cabf9a5b47d492f6d6c9c7291ec1bb739af67a06895a1dd7c5a044dfa2" +checksum = "8654ef9b81bb051546b772cfd709401055a1460b3e8fb26d7847b040498354d0" dependencies = [ "arborium", "arborium-theme", @@ -1755,6 +1756,7 @@ name = "dioxus-docs-03" version = "0.0.0" dependencies = [ "dioxus", + "dioxus-code", "dioxus-docs-examples", "mdbook-gen", "mdbook-shared", @@ -1767,6 +1769,7 @@ name = "dioxus-docs-04" version = "0.0.0" dependencies = [ "dioxus", + "dioxus-code", "dioxus-docs-examples", "mdbook-gen", "mdbook-shared", @@ -1779,6 +1782,7 @@ name = "dioxus-docs-05" version = "0.0.0" dependencies = [ "dioxus", + "dioxus-code", "dioxus-docs-examples", "mdbook-gen", "mdbook-shared", @@ -1791,6 +1795,7 @@ name = "dioxus-docs-06" version = "0.0.0" dependencies = [ "dioxus", + "dioxus-code", "dioxus-docs-examples", "mdbook-gen", "mdbook-shared", @@ -1803,6 +1808,7 @@ name = "dioxus-docs-07" version = "0.0.0" dependencies = [ "dioxus", + "dioxus-code", "dioxus-docs-examples", "mdbook-gen", "mdbook-shared", @@ -1815,6 +1821,7 @@ name = "dioxus-docs-blog" version = "0.0.0" dependencies = [ "dioxus", + "dioxus-code", "dioxus-docs-examples", "mdbook-gen", "mdbook-shared", @@ -4544,8 +4551,6 @@ name = "mdbook-gen" version = "0.0.0" dependencies = [ "anyhow", - "arborium", - "arborium-theme", "convert_case 0.6.0", "dioxus-autofmt", "dioxus-rsx", @@ -4569,6 +4574,7 @@ version = "0.0.0" dependencies = [ "dioxus", "dioxus-autofmt", + "dioxus-code", "mdbook-gen", "mdbook-shared", "prettyplease", @@ -4936,7 +4942,7 @@ version = "0.7.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ff32365de1b6743cb203b710788263c44a03de03802daf96092f2da4fe6ba4d7" dependencies = [ - "proc-macro-crate 2.0.0", + "proc-macro-crate 3.5.0", "proc-macro2", "quote", "syn 2.0.117", @@ -7686,7 +7692,6 @@ name = "use-mdbook" version = "0.1.0" dependencies = [ "dioxus", - "dioxus-code", "dioxus-router", "lazy_static", "mdbook-macro", diff --git a/Cargo.toml b/Cargo.toml index 30c64b609a..22cc15ddcb 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -79,7 +79,21 @@ dioxus-rsx-rosetta = "0.7.0" dioxus-autofmt = "0.7.0" dioxus-dx-wire-format = "0.7.0" dioxus-logger = "0.7.0" -dioxus-code = { version = "0.1.1", default-features = false } +dioxus-code = { version = "0.1.2", default-features = false, features = [ + "macro", + "lang-bash", + "lang-batch", + "lang-css", + "lang-dockerfile", + "lang-html", + "lang-javascript", + "lang-json", + "lang-lua", + "lang-powershell", + "lang-toml", + "lang-tsx", + "lang-yaml", +] } # 3rd-party dioxus # dioxus-sdk = { version = "0.6", default-features = false } diff --git a/packages/docs-03/Cargo.toml b/packages/docs-03/Cargo.toml index b72b4af99f..7e3b81eb3e 100644 --- a/packages/docs-03/Cargo.toml +++ b/packages/docs-03/Cargo.toml @@ -8,6 +8,7 @@ publish = false [dependencies] dioxus = { workspace = true, features = ["router"] } +dioxus-code = { workspace = true } dioxus-docs-examples = { workspace = true } mdbook-shared = { workspace = true } use-mdbook = { workspace = true } @@ -17,4 +18,3 @@ serde = { workspace = true, features = ["derive"] } mdbook-gen = { workspace = true, features = ["manganis"]} mdbook-shared = { workspace = true } - diff --git a/packages/docs-04/Cargo.toml b/packages/docs-04/Cargo.toml index 3e8ecac595..2573dccc4f 100644 --- a/packages/docs-04/Cargo.toml +++ b/packages/docs-04/Cargo.toml @@ -8,6 +8,7 @@ publish = false [dependencies] dioxus = { workspace = true, features = ["router"] } +dioxus-code = { workspace = true } mdbook-shared = { workspace = true } use-mdbook = { workspace = true } dioxus-docs-examples = { workspace = true } diff --git a/packages/docs-05/Cargo.toml b/packages/docs-05/Cargo.toml index 5b6379c9a6..4e5192281a 100644 --- a/packages/docs-05/Cargo.toml +++ b/packages/docs-05/Cargo.toml @@ -8,6 +8,7 @@ publish = false [dependencies] dioxus = { workspace = true, features = ["router"] } +dioxus-code = { workspace = true } mdbook-shared = { workspace = true } use-mdbook = { workspace = true } dioxus-docs-examples = { workspace = true } diff --git a/packages/docs-06/Cargo.toml b/packages/docs-06/Cargo.toml index a2ad6c2125..32da5c65d3 100644 --- a/packages/docs-06/Cargo.toml +++ b/packages/docs-06/Cargo.toml @@ -8,6 +8,7 @@ publish = false [dependencies] dioxus = { workspace = true, features = ["router"] } +dioxus-code = { workspace = true } mdbook-shared = { workspace = true } use-mdbook = { workspace = true } dioxus-docs-examples = { workspace = true } diff --git a/packages/docs-07/Cargo.toml b/packages/docs-07/Cargo.toml index 4456efddd2..8f6720ac6e 100644 --- a/packages/docs-07/Cargo.toml +++ b/packages/docs-07/Cargo.toml @@ -8,6 +8,7 @@ publish = false [dependencies] dioxus = { workspace = true, features = ["router"] } +dioxus-code = { workspace = true } mdbook-shared = { workspace = true } use-mdbook = { workspace = true } dioxus-docs-examples = { workspace = true } diff --git a/packages/docs-blog/Cargo.toml b/packages/docs-blog/Cargo.toml index ec2de8f216..dc7f8bd807 100644 --- a/packages/docs-blog/Cargo.toml +++ b/packages/docs-blog/Cargo.toml @@ -8,6 +8,7 @@ publish = false [dependencies] dioxus = { workspace = true, features = ["router"] } +dioxus-code = { workspace = true } mdbook-shared = { workspace = true } use-mdbook = { workspace = true } dioxus-docs-examples = { workspace = true } diff --git a/packages/include_mdbook/packages/mdbook-gen-example/Cargo.toml b/packages/include_mdbook/packages/mdbook-gen-example/Cargo.toml index 38cb2ff5c0..71419ce83d 100644 --- a/packages/include_mdbook/packages/mdbook-gen-example/Cargo.toml +++ b/packages/include_mdbook/packages/mdbook-gen-example/Cargo.toml @@ -4,6 +4,7 @@ version = "0.0.0" edition = "2021" [dependencies] +dioxus-code = { workspace = true } serde = {version = "1.0.163", features = ["derive"]} use-mdbook = { workspace = true } dioxus = { workspace = true, features = ["router"] } diff --git a/packages/include_mdbook/packages/mdbook-gen-example/src/lib.rs b/packages/include_mdbook/packages/mdbook-gen-example/src/lib.rs index b18f742e21..326b373621 100644 --- a/packages/include_mdbook/packages/mdbook-gen-example/src/lib.rs +++ b/packages/include_mdbook/packages/mdbook-gen-example/src/lib.rs @@ -3,6 +3,9 @@ use dioxus::prelude::*; mod router; #[component] -pub fn CodeBlock(source: use_mdbook::HighlightedSource, name: Option) -> Element { +pub fn CodeBlock( + source: dioxus_code::advanced::HighlightedSource, + name: Option, +) -> Element { todo!() } diff --git a/packages/include_mdbook/packages/mdbook-gen-example/src/router.rs b/packages/include_mdbook/packages/mdbook-gen-example/src/router.rs index 67f3773b18..873e5078a1 100644 --- a/packages/include_mdbook/packages/mdbook-gen-example/src/router.rs +++ b/packages/include_mdbook/packages/mdbook-gen-example/src/router.rs @@ -21,15 +21,15 @@ impl BookRoute { /// Get the markdown for a page by its ID pub const fn page_markdown(id: use_mdbook::mdbook_shared::PageId) -> &'static str { match id.0 { + 0usize => { + "# Liveview\n\nLiveview allows apps to *run* on the server and *render* in the browser. It uses WebSockets to communicate between the server and the browser.\n\nExamples:\n\n* [Axum Example](https://github.com/DioxusLabs/dioxus/tree/master/packages/liveview/examples/axum.rs)\n* [Salvo Example](https://github.com/DioxusLabs/dioxus/tree/master/packages/liveview/examples/salvo.rs)\n* [Warp Example](https://github.com/DioxusLabs/dioxus/tree/master/packages/liveview/examples/warp.rs)\n\n## Support\n\nLiveview is currently limited in capability when compared to the Web platform. Liveview apps run on the server in a native thread. This means that browser APIs are not available, so rendering WebGL, Canvas, etc is not as easy as the Web. However, native system APIs are accessible, so streaming, WebSockets, filesystem, etc are all viable APIs.\n\n## Setup\n\nFor this guide, we're going to show how to use Dioxus Liveview with [Axum](https://docs.rs/axum/latest/axum/).\n\nMake sure you have Rust and Cargo installed, and then create a new project:\n\n````shell\ncargo new --bin demo\ncd app\n````\n\nAdd Dioxus and the liveview renderer with the Axum feature as dependencies:\n\n````shell\ncargo add dioxus\ncargo add dioxus-liveview --features axum\n````\n\nNext, add all the Axum dependencies. This will be different if you're using a different Web Framework\n\n````\ncargo add tokio --features full\ncargo add axum\n````\n\nYour dependencies should look roughly like this:\n\n````toml\n[dependencies]\naxum = \"0.4.5\"\ndioxus = { version = \"*\" }\ndioxus-liveview = { version = \"*\", features = [\"axum\"] }\ntokio = { version = \"1.15.0\", features = [\"full\"] }\n````\n\n````rs@included_example.rs\nfn it_works() {}\n\n````\n\n````sh\n{\"timestamp\":\" 9.927s\",\"level\":\"INFO\",\"message\":\"Bundled app successfully!\",\"target\":\"dx::cli::bundle\"}\n{\"timestamp\":\" 9.927s\",\"level\":\"INFO\",\"message\":\"App produced 2 outputs:\",\"target\":\"dx::cli::bundle\"}\n{\"timestamp\":\" 9.927s\",\"level\":\"INFO\",\"message\":\"app - [target/dx/hot_dog/bundle/macos/bundle/macos/HotDog.app]\",\"target\":\"dx::cli::bundle\"}\n{\"timestamp\":\" 9.927s\",\"level\":\"INFO\",\"message\":\"dmg - [target/dx/hot_dog/bundle/macos/bundle/dmg/HotDog_0.1.0_aarch64.dmg]\",\"target\":\"dx::cli::bundle\"}\n{\"timestamp\":\" 9.927s\",\"level\":\"DEBUG\",\"json\":\"{\\\"BundleOutput\\\":{\\\"bundles\\\":[\\\"target/dx/hot_dog/bundle/macos/bundle/macos/HotDog.app\\\"]}}\"}\n````" + } 2usize => { "# Assets\n\nSome assets:\n![some_external](https://avatars.githubusercontent.com/u/79236386?s=200&v=4)\n![some_local](/example-book/assets/logo.png)\n![some_local1](/example-book/assets/logo1.png)\n![some_local2](/example-book/assets/logo2.png)" } 1usize => { "# Roadmap & Feature-set\n\nThis feature set and roadmap can help you decide if what Dioxus can do today works for you.\n\nIf a feature that you need doesn't exist or you want to contribute to projects on the roadmap, feel free to get involved by [joining the discord](https://discord.gg/XgGxMSkvUM).\n\nGenerally, here's the status of each platform:\n\n* **Web**: Dioxus is a great choice for pure web-apps – especially for CRUD/complex apps. However, it does lack the ecosystem of React, so you might be missing a component library or some useful hook.\n\n* **SSR**: Dioxus is a great choice for pre-rendering, hydration, and rendering HTML on a web endpoint. Be warned – the VirtualDom is not (currently) `Send + Sync`.\n\n* **Desktop**: You can build very competent single-window desktop apps right now. However, multi-window apps require support from Dioxus core and are not ready.\n\n* **Mobile**: Mobile support is very young. You'll be figuring things out as you go and there are not many support crates for peripherals.\n\n* **LiveView**: LiveView support is very young. You'll be figuring things out as you go. Thankfully, none of it is too hard and any work can be upstreamed into Dioxus.\n\n````rust\nfn main() {\n dioxus_rocks;\n}\n````\n\n## Features\n\n---\n\n|Feature|Status|Description|\n|-------|------|-----------|\n|Conditional Rendering|✅|if/then to hide/show component|\n|Map, Iterator|✅|map/filter/reduce to produce rsx!|\n|Keyed Components|✅|advanced diffing with keys|\n|Web|✅|renderer for web browser|\n|Desktop (webview)|✅|renderer for desktop|\n|Shared State (Context)|✅|share state through the tree|\n|Hooks|✅|memory cells in components|\n|SSR|✅|render directly to string|\n|Component Children|✅|cx.children() as a list of nodes|\n|Headless components|✅|components that don't return real elements|\n|Fragments|✅|multiple elements without a real root|\n|Manual Props|✅|Manually pass in props with spread syntax|\n|Controlled Inputs|✅|stateful wrappers around inputs|\n|CSS/Inline Styles|✅|syntax for inline styles/attribute groups|\n|Custom elements|✅|Define new element primitives|\n|Suspense|✅|schedule future render from future/promise|\n|Integrated error handling|✅|Gracefully handle errors with ? syntax|\n|NodeRef|✅|gain direct access to nodes|\n|Re-hydration|✅|Pre-render to HTML to speed up first contentful paint|\n|Jank-Free Rendering|✅|Large diffs are segmented across frames for silky-smooth transitions|\n|Effects|✅|Run effects after a component has been committed to render|\n|Portals|🛠|Render nodes outside of the traditional tree structure|\n|Cooperative Scheduling|🛠|Prioritize important events over non-important events|\n|Server Components|🛠|Hybrid components for SPA and Server|\n|Bundle Splitting|👀|Efficiently and asynchronously load the app|\n|Lazy Components|👀|Dynamically load the new components as the page is loaded|\n|1st class global state|✅|redux/recoil/mobx on top of context|\n|Runs natively|✅|runs as a portable binary w/o a runtime (Node)|\n|Subtree Memoization|✅|skip diffing static element subtrees|\n|High-efficiency templates|✅|rsx! calls are translated to templates on the DOM's side|\n|Compile-time correct|✅|Throw errors on invalid template layouts|\n|Heuristic Engine|✅|track component memory usage to minimize future allocations|\n|Fine-grained reactivity|👀|Skip diffing for fine-grain updates|\n\n* ✅ = implemented and working\n* 🛠 = actively being worked on\n* 👀 = not yet implemented or being worked on\n\n## Roadmap\n\nThese Features are planned for the future of Dioxus:\n\n### Core\n\n* [x] Release of Dioxus Core\n* [x] Upgrade documentation to include more theory and be more comprehensive\n* [x] Support for HTML-side templates for lightning-fast dom manipulation\n* [ ] Support for multiple renderers for same virtualdom (subtrees)\n* [ ] Support for ThreadSafe (Send + Sync)\n* [ ] Support for Portals\n\n### SSR\n\n* [x] SSR Support + Hydration\n* [ ] Integrated suspense support for SSR\n\n### Desktop\n\n* [ ] Declarative window management\n* [ ] Templates for building/bundling\n* [ ] Access to Canvas/WebGL context natively\n\n### Mobile\n\n* [ ] Mobile standard library\n * [ ] GPS\n * [ ] Camera\n * [ ] filesystem\n * [ ] Biometrics\n * [ ] WiFi\n * [ ] Bluetooth\n * [ ] Notifications\n * [ ] Clipboard\n* [ ] Animations\n\n### Bundling (CLI)\n\n* [x] Translation from HTML into RSX\n* [x] Dev server\n* [x] Live reload\n* [x] Translation from JSX into RSX\n* [ ] Hot module replacement\n* [ ] Code splitting\n* [ ] Asset macros\n* [ ] Css pipeline\n* [ ] Image pipeline\n\n### Essential hooks\n\n* [x] Router\n* [x] Global state management\n* [ ] Resize observer\n\n## Work in Progress\n\n### Build Tool\n\nWe are currently working on our own build tool called [Dioxus CLI](https://github.com/DioxusLabs/dioxus/tree/master/packages/cli) which will support:\n\n* an interactive TUI\n* on-the-fly reconfiguration\n* hot CSS reloading\n* two-way data binding between browser and source code\n* an interpreter for `rsx!`\n* ability to publish to github/netlify/vercel\n* bundling for iOS/Desktop/etc\n\n### Server Component Support\n\nWhile not currently fully implemented, the expectation is that LiveView apps can be a hybrid between Wasm and server-rendered where only portions of a page are \"live\" and the rest of the page is either server-rendered, statically generated, or handled by the host SPA.\n\n### Native rendering\n\nWe are currently working on a native renderer for Dioxus using WGPU called [Blitz](https://github.com/DioxusLabs/blitz/). This will allow you to build apps that are rendered natively for iOS, Android, and Desktop.\n\n## Internal Links\n\nInternal links like [this](./chapter_1.md) are typechecked and will fail to compile if the file is not found." } - 0usize => { - "# Liveview\n\nLiveview allows apps to *run* on the server and *render* in the browser. It uses WebSockets to communicate between the server and the browser.\n\nExamples:\n\n* [Axum Example](https://github.com/DioxusLabs/dioxus/tree/master/packages/liveview/examples/axum.rs)\n* [Salvo Example](https://github.com/DioxusLabs/dioxus/tree/master/packages/liveview/examples/salvo.rs)\n* [Warp Example](https://github.com/DioxusLabs/dioxus/tree/master/packages/liveview/examples/warp.rs)\n\n## Support\n\nLiveview is currently limited in capability when compared to the Web platform. Liveview apps run on the server in a native thread. This means that browser APIs are not available, so rendering WebGL, Canvas, etc is not as easy as the Web. However, native system APIs are accessible, so streaming, WebSockets, filesystem, etc are all viable APIs.\n\n## Setup\n\nFor this guide, we're going to show how to use Dioxus Liveview with [Axum](https://docs.rs/axum/latest/axum/).\n\nMake sure you have Rust and Cargo installed, and then create a new project:\n\n````shell\ncargo new --bin demo\ncd app\n````\n\nAdd Dioxus and the liveview renderer with the Axum feature as dependencies:\n\n````shell\ncargo add dioxus\ncargo add dioxus-liveview --features axum\n````\n\nNext, add all the Axum dependencies. This will be different if you're using a different Web Framework\n\n````\ncargo add tokio --features full\ncargo add axum\n````\n\nYour dependencies should look roughly like this:\n\n````toml\n[dependencies]\naxum = \"0.4.5\"\ndioxus = { version = \"*\" }\ndioxus-liveview = { version = \"*\", features = [\"axum\"] }\ntokio = { version = \"1.15.0\", features = [\"full\"] }\n````\n\n````rs@included_example.rs\nfn it_works() {}\n\n````\n\n````sh\n{\"timestamp\":\" 9.927s\",\"level\":\"INFO\",\"message\":\"Bundled app successfully!\",\"target\":\"dx::cli::bundle\"}\n{\"timestamp\":\" 9.927s\",\"level\":\"INFO\",\"message\":\"App produced 2 outputs:\",\"target\":\"dx::cli::bundle\"}\n{\"timestamp\":\" 9.927s\",\"level\":\"INFO\",\"message\":\"app - [target/dx/hot_dog/bundle/macos/bundle/macos/HotDog.app]\",\"target\":\"dx::cli::bundle\"}\n{\"timestamp\":\" 9.927s\",\"level\":\"INFO\",\"message\":\"dmg - [target/dx/hot_dog/bundle/macos/bundle/dmg/HotDog_0.1.0_aarch64.dmg]\",\"target\":\"dx::cli::bundle\"}\n{\"timestamp\":\" 9.927s\",\"level\":\"DEBUG\",\"json\":\"{\\\"BundleOutput\\\":{\\\"bundles\\\":[\\\"target/dx/hot_dog/bundle/macos/bundle/macos/HotDog.app\\\"]}}\"}\n````" - } _ => panic!("Invalid page ID:"), } } @@ -312,118 +312,121 @@ pub fn Chapter1(section: Chapter1Section) -> Element { "For this guide, we're going to show how to use Dioxus Liveview with " Link { to : "https://docs.rs/axum/latest/axum/", "Axum" } "." } p { "Make sure you have Rust and Cargo installed, and then create a new project:" } - CodeBlock { source : { static SPANS : & [use_mdbook::HighlightSpan] = & - [use_mdbook::HighlightSpan::new(0u32..5u32, "f"), - use_mdbook::HighlightSpan::new(10u32..15u32, "co"), - use_mdbook::HighlightSpan::new(21u32..23u32, "f"),]; - use_mdbook::HighlightedSource::from_static_parts("cargo new --bin demo\ncd app", - use_mdbook::Language::Rust, SPANS,) }, } p { + CodeBlock { source : { static SPANS : & [::dioxus_code::advanced::HighlightSpan] + = & [::dioxus_code::advanced::HighlightSpan::new(0u32..5u32, "f"), + ::dioxus_code::advanced::HighlightSpan::new(10u32..15u32, "co"), + ::dioxus_code::advanced::HighlightSpan::new(21u32..23u32, "f"),]; + ::dioxus_code::advanced::HighlightedSource::from_static_parts("cargo new --bin demo\ncd app", + ::dioxus_code::Language::Rust, SPANS,) }, } p { "Add Dioxus and the liveview renderer with the Axum feature as dependencies:" } - CodeBlock { source : { static SPANS : & [use_mdbook::HighlightSpan] = & - [use_mdbook::HighlightSpan::new(0u32..5u32, "f"), - use_mdbook::HighlightSpan::new(17u32..22u32, "f"), - use_mdbook::HighlightSpan::new(43u32..53u32, "co"),]; - use_mdbook::HighlightedSource::from_static_parts("cargo add dioxus\ncargo add dioxus-liveview --features axum", - use_mdbook::Language::Rust, SPANS,) }, } p { + CodeBlock { source : { static SPANS : & [::dioxus_code::advanced::HighlightSpan] + = & [::dioxus_code::advanced::HighlightSpan::new(0u32..5u32, "f"), + ::dioxus_code::advanced::HighlightSpan::new(17u32..22u32, "f"), + ::dioxus_code::advanced::HighlightSpan::new(43u32..53u32, "co"),]; + ::dioxus_code::advanced::HighlightedSource::from_static_parts("cargo add dioxus\ncargo add dioxus-liveview --features axum", + ::dioxus_code::Language::Rust, SPANS,) }, } p { "Next, add all the Axum dependencies. This will be different if you're using a different Web Framework" - } CodeBlock { source : { static SPANS : & [use_mdbook::HighlightSpan] = & []; - use_mdbook::HighlightedSource::from_static_parts("cargo add tokio --features full\ncargo add axum", - use_mdbook::Language::Rust, SPANS,) }, } p { + } CodeBlock { source : { static SPANS : & + [::dioxus_code::advanced::HighlightSpan] = & []; + ::dioxus_code::advanced::HighlightedSource::from_static_parts("cargo add tokio --features full\ncargo add axum", + ::dioxus_code::Language::Rust, SPANS,) }, } p { "Your dependencies should look roughly like this:" } CodeBlock { source : { - static SPANS : & [use_mdbook::HighlightSpan] = & - [use_mdbook::HighlightSpan::new(0u32..1u32, "p"), - use_mdbook::HighlightSpan::new(1u32..13u32, "pr"), - use_mdbook::HighlightSpan::new(13u32..14u32, "p"), - use_mdbook::HighlightSpan::new(15u32..19u32, "pr"), - use_mdbook::HighlightSpan::new(20u32..21u32, "o"), - use_mdbook::HighlightSpan::new(22u32..29u32, "s"), - use_mdbook::HighlightSpan::new(30u32..36u32, "pr"), - use_mdbook::HighlightSpan::new(37u32..38u32, "o"), - use_mdbook::HighlightSpan::new(39u32..40u32, "p"), - use_mdbook::HighlightSpan::new(41u32..48u32, "pr"), - use_mdbook::HighlightSpan::new(49u32..50u32, "o"), - use_mdbook::HighlightSpan::new(51u32..54u32, "s"), - use_mdbook::HighlightSpan::new(55u32..56u32, "p"), - use_mdbook::HighlightSpan::new(57u32..72u32, "pr"), - use_mdbook::HighlightSpan::new(73u32..74u32, "o"), - use_mdbook::HighlightSpan::new(75u32..76u32, "p"), - use_mdbook::HighlightSpan::new(77u32..84u32, "pr"), - use_mdbook::HighlightSpan::new(85u32..86u32, "o"), - use_mdbook::HighlightSpan::new(87u32..90u32, "s"), - use_mdbook::HighlightSpan::new(90u32..91u32, "p"), - use_mdbook::HighlightSpan::new(92u32..100u32, "pr"), - use_mdbook::HighlightSpan::new(101u32..102u32, "o"), - use_mdbook::HighlightSpan::new(103u32..104u32, "p"), - use_mdbook::HighlightSpan::new(104u32..110u32, "s"), - use_mdbook::HighlightSpan::new(110u32..111u32, "p"), - use_mdbook::HighlightSpan::new(112u32..113u32, "p"), - use_mdbook::HighlightSpan::new(114u32..119u32, "pr"), - use_mdbook::HighlightSpan::new(120u32..121u32, "o"), - use_mdbook::HighlightSpan::new(122u32..123u32, "p"), - use_mdbook::HighlightSpan::new(124u32..131u32, "pr"), - use_mdbook::HighlightSpan::new(132u32..133u32, "o"), - use_mdbook::HighlightSpan::new(134u32..142u32, "s"), - use_mdbook::HighlightSpan::new(142u32..143u32, "p"), - use_mdbook::HighlightSpan::new(144u32..152u32, "pr"), - use_mdbook::HighlightSpan::new(153u32..154u32, "o"), - use_mdbook::HighlightSpan::new(155u32..156u32, "p"), - use_mdbook::HighlightSpan::new(156u32..162u32, "s"), - use_mdbook::HighlightSpan::new(162u32..163u32, "p"), - use_mdbook::HighlightSpan::new(164u32..165u32, "p"),]; - use_mdbook::HighlightedSource::from_static_parts("[dependencies]\naxum = \"0.4.5\"\ndioxus = { version = \"*\" }\ndioxus-liveview = { version = \"*\", features = [\"axum\"] }\ntokio = { version = \"1.15.0\", features = [\"full\"] }", - use_mdbook::Language::Rust, SPANS,) }, } CodeBlock { source : { static SPANS : & - [use_mdbook::HighlightSpan] = & [use_mdbook::HighlightSpan::new(0u32..2u32, "k"), - use_mdbook::HighlightSpan::new(3u32..11u32, "f"), - use_mdbook::HighlightSpan::new(11u32..13u32, "p"), - use_mdbook::HighlightSpan::new(14u32..16u32, "p"),]; - use_mdbook::HighlightedSource::from_static_parts("fn it_works() {}", - use_mdbook::Language::Rust, SPANS,) }, name : "included_example.rs".to_string(), - } CodeBlock { source : { static SPANS : & [use_mdbook::HighlightSpan] = & - [use_mdbook::HighlightSpan::new(1u32..12u32, "s"), - use_mdbook::HighlightSpan::new(1u32..105u32, "f"), - use_mdbook::HighlightSpan::new(13u32..24u32, "s"), - use_mdbook::HighlightSpan::new(25u32..32u32, "s"), - use_mdbook::HighlightSpan::new(33u32..39u32, "s"), - use_mdbook::HighlightSpan::new(40u32..49u32, "s"), - use_mdbook::HighlightSpan::new(50u32..77u32, "s"), - use_mdbook::HighlightSpan::new(78u32..86u32, "s"), - use_mdbook::HighlightSpan::new(87u32..104u32, "s"), - use_mdbook::HighlightSpan::new(107u32..118u32, "s"), - use_mdbook::HighlightSpan::new(107u32..209u32, "f"), - use_mdbook::HighlightSpan::new(119u32..130u32, "s"), - use_mdbook::HighlightSpan::new(131u32..138u32, "s"), - use_mdbook::HighlightSpan::new(139u32..145u32, "s"), - use_mdbook::HighlightSpan::new(146u32..155u32, "s"), - use_mdbook::HighlightSpan::new(156u32..181u32, "s"), - use_mdbook::HighlightSpan::new(182u32..190u32, "s"), - use_mdbook::HighlightSpan::new(191u32..208u32, "s"), - use_mdbook::HighlightSpan::new(211u32..222u32, "s"), - use_mdbook::HighlightSpan::new(211u32..352u32, "f"), - use_mdbook::HighlightSpan::new(223u32..234u32, "s"), - use_mdbook::HighlightSpan::new(235u32..242u32, "s"), - use_mdbook::HighlightSpan::new(243u32..249u32, "s"), - use_mdbook::HighlightSpan::new(250u32..259u32, "s"), - use_mdbook::HighlightSpan::new(260u32..324u32, "s"), - use_mdbook::HighlightSpan::new(325u32..333u32, "s"), - use_mdbook::HighlightSpan::new(334u32..351u32, "s"), - use_mdbook::HighlightSpan::new(354u32..365u32, "s"), - use_mdbook::HighlightSpan::new(354u32..507u32, "f"), - use_mdbook::HighlightSpan::new(366u32..377u32, "s"), - use_mdbook::HighlightSpan::new(378u32..385u32, "s"), - use_mdbook::HighlightSpan::new(386u32..392u32, "s"), - use_mdbook::HighlightSpan::new(393u32..402u32, "s"), - use_mdbook::HighlightSpan::new(403u32..479u32, "s"), - use_mdbook::HighlightSpan::new(480u32..488u32, "s"), - use_mdbook::HighlightSpan::new(489u32..506u32, "s"), - use_mdbook::HighlightSpan::new(509u32..520u32, "s"), - use_mdbook::HighlightSpan::new(509u32..652u32, "f"), - use_mdbook::HighlightSpan::new(521u32..532u32, "s"), - use_mdbook::HighlightSpan::new(533u32..540u32, "s"), - use_mdbook::HighlightSpan::new(541u32..548u32, "s"), - use_mdbook::HighlightSpan::new(549u32..555u32, "s"), - use_mdbook::HighlightSpan::new(556u32..651u32, "s"),]; - use_mdbook::HighlightedSource::from_static_parts("{\"timestamp\":\" 9.927s\",\"level\":\"INFO\",\"message\":\"Bundled app successfully!\",\"target\":\"dx::cli::bundle\"}\n{\"timestamp\":\" 9.927s\",\"level\":\"INFO\",\"message\":\"App produced 2 outputs:\",\"target\":\"dx::cli::bundle\"}\n{\"timestamp\":\" 9.927s\",\"level\":\"INFO\",\"message\":\"app - [target/dx/hot_dog/bundle/macos/bundle/macos/HotDog.app]\",\"target\":\"dx::cli::bundle\"}\n{\"timestamp\":\" 9.927s\",\"level\":\"INFO\",\"message\":\"dmg - [target/dx/hot_dog/bundle/macos/bundle/dmg/HotDog_0.1.0_aarch64.dmg]\",\"target\":\"dx::cli::bundle\"}\n{\"timestamp\":\" 9.927s\",\"level\":\"DEBUG\",\"json\":\"{\\\"BundleOutput\\\":{\\\"bundles\\\":[\\\"target/dx/hot_dog/bundle/macos/bundle/macos/HotDog.app\\\"]}}\"}", - use_mdbook::Language::Rust, SPANS,) }, } + static SPANS : & [::dioxus_code::advanced::HighlightSpan] = & + [::dioxus_code::advanced::HighlightSpan::new(0u32..1u32, "p"), + ::dioxus_code::advanced::HighlightSpan::new(1u32..13u32, "pr"), + ::dioxus_code::advanced::HighlightSpan::new(13u32..14u32, "p"), + ::dioxus_code::advanced::HighlightSpan::new(15u32..19u32, "pr"), + ::dioxus_code::advanced::HighlightSpan::new(20u32..21u32, "o"), + ::dioxus_code::advanced::HighlightSpan::new(22u32..29u32, "s"), + ::dioxus_code::advanced::HighlightSpan::new(30u32..36u32, "pr"), + ::dioxus_code::advanced::HighlightSpan::new(37u32..38u32, "o"), + ::dioxus_code::advanced::HighlightSpan::new(39u32..40u32, "p"), + ::dioxus_code::advanced::HighlightSpan::new(41u32..48u32, "pr"), + ::dioxus_code::advanced::HighlightSpan::new(49u32..50u32, "o"), + ::dioxus_code::advanced::HighlightSpan::new(51u32..54u32, "s"), + ::dioxus_code::advanced::HighlightSpan::new(55u32..56u32, "p"), + ::dioxus_code::advanced::HighlightSpan::new(57u32..72u32, "pr"), + ::dioxus_code::advanced::HighlightSpan::new(73u32..74u32, "o"), + ::dioxus_code::advanced::HighlightSpan::new(75u32..76u32, "p"), + ::dioxus_code::advanced::HighlightSpan::new(77u32..84u32, "pr"), + ::dioxus_code::advanced::HighlightSpan::new(85u32..86u32, "o"), + ::dioxus_code::advanced::HighlightSpan::new(87u32..90u32, "s"), + ::dioxus_code::advanced::HighlightSpan::new(90u32..91u32, "p"), + ::dioxus_code::advanced::HighlightSpan::new(92u32..100u32, "pr"), + ::dioxus_code::advanced::HighlightSpan::new(101u32..102u32, "o"), + ::dioxus_code::advanced::HighlightSpan::new(103u32..104u32, "p"), + ::dioxus_code::advanced::HighlightSpan::new(104u32..110u32, "s"), + ::dioxus_code::advanced::HighlightSpan::new(110u32..111u32, "p"), + ::dioxus_code::advanced::HighlightSpan::new(112u32..113u32, "p"), + ::dioxus_code::advanced::HighlightSpan::new(114u32..119u32, "pr"), + ::dioxus_code::advanced::HighlightSpan::new(120u32..121u32, "o"), + ::dioxus_code::advanced::HighlightSpan::new(122u32..123u32, "p"), + ::dioxus_code::advanced::HighlightSpan::new(124u32..131u32, "pr"), + ::dioxus_code::advanced::HighlightSpan::new(132u32..133u32, "o"), + ::dioxus_code::advanced::HighlightSpan::new(134u32..142u32, "s"), + ::dioxus_code::advanced::HighlightSpan::new(142u32..143u32, "p"), + ::dioxus_code::advanced::HighlightSpan::new(144u32..152u32, "pr"), + ::dioxus_code::advanced::HighlightSpan::new(153u32..154u32, "o"), + ::dioxus_code::advanced::HighlightSpan::new(155u32..156u32, "p"), + ::dioxus_code::advanced::HighlightSpan::new(156u32..162u32, "s"), + ::dioxus_code::advanced::HighlightSpan::new(162u32..163u32, "p"), + ::dioxus_code::advanced::HighlightSpan::new(164u32..165u32, "p"),]; + ::dioxus_code::advanced::HighlightedSource::from_static_parts("[dependencies]\naxum = \"0.4.5\"\ndioxus = { version = \"*\" }\ndioxus-liveview = { version = \"*\", features = [\"axum\"] }\ntokio = { version = \"1.15.0\", features = [\"full\"] }", + ::dioxus_code::Language::Rust, SPANS,) }, } CodeBlock { source : { static SPANS : + & [::dioxus_code::advanced::HighlightSpan] = & + [::dioxus_code::advanced::HighlightSpan::new(0u32..2u32, "k"), + ::dioxus_code::advanced::HighlightSpan::new(3u32..11u32, "f"), + ::dioxus_code::advanced::HighlightSpan::new(11u32..13u32, "p"), + ::dioxus_code::advanced::HighlightSpan::new(14u32..16u32, "p"),]; + ::dioxus_code::advanced::HighlightedSource::from_static_parts("fn it_works() {}", + ::dioxus_code::Language::Rust, SPANS,) }, name : "included_example.rs" + .to_string(), } CodeBlock { source : { static SPANS : & + [::dioxus_code::advanced::HighlightSpan] = & + [::dioxus_code::advanced::HighlightSpan::new(1u32..12u32, "s"), + ::dioxus_code::advanced::HighlightSpan::new(1u32..105u32, "f"), + ::dioxus_code::advanced::HighlightSpan::new(13u32..24u32, "s"), + ::dioxus_code::advanced::HighlightSpan::new(25u32..32u32, "s"), + ::dioxus_code::advanced::HighlightSpan::new(33u32..39u32, "s"), + ::dioxus_code::advanced::HighlightSpan::new(40u32..49u32, "s"), + ::dioxus_code::advanced::HighlightSpan::new(50u32..77u32, "s"), + ::dioxus_code::advanced::HighlightSpan::new(78u32..86u32, "s"), + ::dioxus_code::advanced::HighlightSpan::new(87u32..104u32, "s"), + ::dioxus_code::advanced::HighlightSpan::new(107u32..118u32, "s"), + ::dioxus_code::advanced::HighlightSpan::new(107u32..209u32, "f"), + ::dioxus_code::advanced::HighlightSpan::new(119u32..130u32, "s"), + ::dioxus_code::advanced::HighlightSpan::new(131u32..138u32, "s"), + ::dioxus_code::advanced::HighlightSpan::new(139u32..145u32, "s"), + ::dioxus_code::advanced::HighlightSpan::new(146u32..155u32, "s"), + ::dioxus_code::advanced::HighlightSpan::new(156u32..181u32, "s"), + ::dioxus_code::advanced::HighlightSpan::new(182u32..190u32, "s"), + ::dioxus_code::advanced::HighlightSpan::new(191u32..208u32, "s"), + ::dioxus_code::advanced::HighlightSpan::new(211u32..222u32, "s"), + ::dioxus_code::advanced::HighlightSpan::new(211u32..352u32, "f"), + ::dioxus_code::advanced::HighlightSpan::new(223u32..234u32, "s"), + ::dioxus_code::advanced::HighlightSpan::new(235u32..242u32, "s"), + ::dioxus_code::advanced::HighlightSpan::new(243u32..249u32, "s"), + ::dioxus_code::advanced::HighlightSpan::new(250u32..259u32, "s"), + ::dioxus_code::advanced::HighlightSpan::new(260u32..324u32, "s"), + ::dioxus_code::advanced::HighlightSpan::new(325u32..333u32, "s"), + ::dioxus_code::advanced::HighlightSpan::new(334u32..351u32, "s"), + ::dioxus_code::advanced::HighlightSpan::new(354u32..365u32, "s"), + ::dioxus_code::advanced::HighlightSpan::new(354u32..507u32, "f"), + ::dioxus_code::advanced::HighlightSpan::new(366u32..377u32, "s"), + ::dioxus_code::advanced::HighlightSpan::new(378u32..385u32, "s"), + ::dioxus_code::advanced::HighlightSpan::new(386u32..392u32, "s"), + ::dioxus_code::advanced::HighlightSpan::new(393u32..402u32, "s"), + ::dioxus_code::advanced::HighlightSpan::new(403u32..479u32, "s"), + ::dioxus_code::advanced::HighlightSpan::new(480u32..488u32, "s"), + ::dioxus_code::advanced::HighlightSpan::new(489u32..506u32, "s"), + ::dioxus_code::advanced::HighlightSpan::new(509u32..520u32, "s"), + ::dioxus_code::advanced::HighlightSpan::new(509u32..652u32, "f"), + ::dioxus_code::advanced::HighlightSpan::new(521u32..532u32, "s"), + ::dioxus_code::advanced::HighlightSpan::new(533u32..540u32, "s"), + ::dioxus_code::advanced::HighlightSpan::new(541u32..548u32, "s"), + ::dioxus_code::advanced::HighlightSpan::new(549u32..555u32, "s"), + ::dioxus_code::advanced::HighlightSpan::new(556u32..651u32, "s"),]; + ::dioxus_code::advanced::HighlightedSource::from_static_parts("{\"timestamp\":\" 9.927s\",\"level\":\"INFO\",\"message\":\"Bundled app successfully!\",\"target\":\"dx::cli::bundle\"}\n{\"timestamp\":\" 9.927s\",\"level\":\"INFO\",\"message\":\"App produced 2 outputs:\",\"target\":\"dx::cli::bundle\"}\n{\"timestamp\":\" 9.927s\",\"level\":\"INFO\",\"message\":\"app - [target/dx/hot_dog/bundle/macos/bundle/macos/HotDog.app]\",\"target\":\"dx::cli::bundle\"}\n{\"timestamp\":\" 9.927s\",\"level\":\"INFO\",\"message\":\"dmg - [target/dx/hot_dog/bundle/macos/bundle/dmg/HotDog_0.1.0_aarch64.dmg]\",\"target\":\"dx::cli::bundle\"}\n{\"timestamp\":\" 9.927s\",\"level\":\"DEBUG\",\"json\":\"{\\\"BundleOutput\\\":{\\\"bundles\\\":[\\\"target/dx/hot_dog/bundle/macos/bundle/macos/HotDog.app\\\"]}}\"}", + ::dioxus_code::Language::Rust, SPANS,) }, } } } #[derive( @@ -515,15 +518,16 @@ pub fn Chapter2(section: Chapter2Section) -> Element { ": Mobile support is very young. You'll be figuring things out as you go and there are not many support crates for peripherals." } } li { p { strong { "LiveView" } ": LiveView support is very young. You'll be figuring things out as you go. Thankfully, none of it is too hard and any work can be upstreamed into Dioxus." - } } } CodeBlock { source : { static SPANS : & [use_mdbook::HighlightSpan] = & - [use_mdbook::HighlightSpan::new(0u32..2u32, "k"), - use_mdbook::HighlightSpan::new(3u32..7u32, "f"), - use_mdbook::HighlightSpan::new(7u32..9u32, "p"), - use_mdbook::HighlightSpan::new(10u32..11u32, "p"), - use_mdbook::HighlightSpan::new(26u32..27u32, "p"), - use_mdbook::HighlightSpan::new(28u32..29u32, "p"),]; - use_mdbook::HighlightedSource::from_static_parts("fn main() {\n dioxus_rocks;\n}", - use_mdbook::Language::Rust, SPANS,) }, } h2 { id : "features", Link { to : + } } } CodeBlock { source : { static SPANS : & + [::dioxus_code::advanced::HighlightSpan] = & + [::dioxus_code::advanced::HighlightSpan::new(0u32..2u32, "k"), + ::dioxus_code::advanced::HighlightSpan::new(3u32..7u32, "f"), + ::dioxus_code::advanced::HighlightSpan::new(7u32..9u32, "p"), + ::dioxus_code::advanced::HighlightSpan::new(10u32..11u32, "p"), + ::dioxus_code::advanced::HighlightSpan::new(26u32..27u32, "p"), + ::dioxus_code::advanced::HighlightSpan::new(28u32..29u32, "p"),]; + ::dioxus_code::advanced::HighlightedSource::from_static_parts("fn main() {\n dioxus_rocks;\n}", + ::dioxus_code::Language::Rust, SPANS,) }, } h2 { id : "features", Link { to : BookRoute::Chapter2 { section : Chapter2Section::Features, }, class : "header", "Features" } } hr {} table { thead { th { "Feature" } th { "Status" } th { "Description" } } tr { th { "Conditional Rendering" } th { "✅" } th { diff --git a/packages/include_mdbook/packages/mdbook-gen/Cargo.toml b/packages/include_mdbook/packages/mdbook-gen/Cargo.toml index 36a4442b83..033803dd3e 100644 --- a/packages/include_mdbook/packages/mdbook-gen/Cargo.toml +++ b/packages/include_mdbook/packages/mdbook-gen/Cargo.toml @@ -4,22 +4,6 @@ version = "0.0.0" edition = "2021" [dependencies] -arborium = { version = "2.16.0", default-features = false, features = [ - "lang-bash", - "lang-batch", - "lang-css", - "lang-dockerfile", - "lang-html", - "lang-javascript", - "lang-json", - "lang-lua", - "lang-powershell", - "lang-rust", - "lang-toml", - "lang-tsx", - "lang-yaml", -] } -arborium-theme = "2.16.0" proc-macro2 = { version = "1.0" } quote = "1.0" syn = { workspace = true } diff --git a/packages/include_mdbook/packages/mdbook-gen/src/rsx.rs b/packages/include_mdbook/packages/mdbook-gen/src/rsx.rs index 63f43960c3..b971f1e62f 100644 --- a/packages/include_mdbook/packages/mdbook-gen/src/rsx.rs +++ b/packages/include_mdbook/packages/mdbook-gen/src/rsx.rs @@ -773,101 +773,42 @@ fn normalize_code_language(lang: Option<&str>) -> String { } fn highlighted_source_tokens(code: &str, language: &str) -> TokenStream2 { - let code = code.to_string(); - let spans = if language.is_empty() { - Vec::new() - } else { - let mut highlighter = arborium::Highlighter::new(); - highlighter - .highlight_spans(language, &code) - .map(normalize_highlight_spans) - .unwrap_or_default() + let Some(variant) = language_variant_ident(language) else { + return quote! {{ + ::dioxus_code::advanced::HighlightedSource::from_static_parts( + #code, + ::dioxus_code::Language::Rust, + &[], + ) + }}; }; - - let spans = spans.into_iter().map(|span| { - let start = span.start; - let end = span.end; - let tag = span.tag; - quote! { - use_mdbook::HighlightSpan::new(#start..#end, #tag) - } - }); - + let variant_ident = Ident::new(variant, Span::call_site()); quote! {{ - static SPANS: &[use_mdbook::HighlightSpan] = &[#(#spans),*]; - use_mdbook::HighlightedSource::from_static_parts( + ::dioxus_code::code_str!( #code, - use_mdbook::Language::Rust, - SPANS, + ::dioxus_code::CodeOptions::builder() + .with_language(::dioxus_code::Language::#variant_ident) ) }} } -struct NormalizedHighlightSpan { - start: u32, - end: u32, - tag: &'static str, -} - -struct RawHighlightSpan { - start: u32, - end: u32, - tag: Option<&'static str>, - pattern_index: u32, -} - -fn normalize_highlight_spans(spans: Vec) -> Vec { - use std::collections::HashMap; - - let mut deduped: HashMap<(u32, u32), RawHighlightSpan> = HashMap::new(); - for span in spans { - let span = RawHighlightSpan { - start: span.start, - end: span.end, - tag: arborium_theme::tag_for_capture(&span.capture), - pattern_index: span.pattern_index, - }; - let key = (span.start, span.end); - - if let Some(existing) = deduped.get(&key) { - let should_replace = match (span.tag.is_some(), existing.tag.is_some()) { - (true, false) => true, - (false, true) => false, - _ => span.pattern_index >= existing.pattern_index, - }; - if should_replace { - deduped.insert(key, span); - } - } else { - deduped.insert(key, span); - } - } - - let mut spans: Vec<_> = deduped - .into_values() - .filter_map(|span| { - Some(NormalizedHighlightSpan { - start: span.start, - end: span.end, - tag: span.tag?, - }) - }) - .collect(); - - spans.sort_by_key(|span| (span.start, span.end)); - - let mut coalesced: Vec = Vec::with_capacity(spans.len()); - for span in spans { - if let Some(last) = coalesced.last_mut() { - if span.tag == last.tag && span.start <= last.end { - last.end = last.end.max(span.end); - continue; - } - } - coalesced.push(span); - } - - coalesced +fn language_variant_ident(slug: &str) -> Option<&'static str> { + Some(match slug { + "bash" => "Bash", + "batch" => "Batch", + "css" => "Css", + "dockerfile" => "Dockerfile", + "html" => "Html", + "javascript" => "JavaScript", + "json" => "Json", + "lua" => "Lua", + "powershell" => "PowerShell", + "rust" => "Rust", + "toml" => "Toml", + "tsx" => "Tsx", + "yaml" => "Yaml", + _ => return None, + }) } fn transform_code_block( diff --git a/packages/include_mdbook/packages/use-mdbook/Cargo.toml b/packages/include_mdbook/packages/use-mdbook/Cargo.toml index e5d2744d1a..978a60e2ed 100644 --- a/packages/include_mdbook/packages/use-mdbook/Cargo.toml +++ b/packages/include_mdbook/packages/use-mdbook/Cargo.toml @@ -6,7 +6,6 @@ edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -dioxus-code = { workspace = true } lazy_static = "1.4.0" mdbook-macro = { path = "../mdbook-macro" } mdbook-shared = { path = "../mdbook-shared" } diff --git a/packages/include_mdbook/packages/use-mdbook/src/lib.rs b/packages/include_mdbook/packages/use-mdbook/src/lib.rs index c87983f317..653bab377e 100644 --- a/packages/include_mdbook/packages/use-mdbook/src/lib.rs +++ b/packages/include_mdbook/packages/use-mdbook/src/lib.rs @@ -1,9 +1,5 @@ pub use mdbook_shared; -pub use dioxus_code::{ - advanced::{HighlightSpan, HighlightedSource}, - Language, -}; pub use mdbook_macro::*; pub use once_cell::sync::Lazy; pub use yazi; From 9fd12172e756981a43d41bf085e40ba0bb38c950 Mon Sep 17 00:00:00 2001 From: Evan Almloff Date: Mon, 11 May 2026 08:48:24 -0500 Subject: [PATCH 4/7] use a btree for deterministic codegen --- .claude/settings.local.json | 7 - .../packages/mdbook-gen-example/src/router.rs | 557 ++++++++---------- .../packages/mdbook-gen/src/lib.rs | 4 +- 3 files changed, 257 insertions(+), 311 deletions(-) delete mode 100644 .claude/settings.local.json diff --git a/.claude/settings.local.json b/.claude/settings.local.json deleted file mode 100644 index 6676ac5002..0000000000 --- a/.claude/settings.local.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "permissions": { - "allow": [ - "Bash(gh pr list:*)" - ] - } -} diff --git a/packages/include_mdbook/packages/mdbook-gen-example/src/router.rs b/packages/include_mdbook/packages/mdbook-gen-example/src/router.rs index 873e5078a1..108f262c16 100644 --- a/packages/include_mdbook/packages/mdbook-gen-example/src/router.rs +++ b/packages/include_mdbook/packages/mdbook-gen-example/src/router.rs @@ -7,7 +7,7 @@ Hash, Debug, serde::Serialize, - serde::Deserialize, + serde::Deserialize )] pub enum BookRoute { #[route("/./chapter_1#:section")] @@ -24,12 +24,12 @@ impl BookRoute { 0usize => { "# Liveview\n\nLiveview allows apps to *run* on the server and *render* in the browser. It uses WebSockets to communicate between the server and the browser.\n\nExamples:\n\n* [Axum Example](https://github.com/DioxusLabs/dioxus/tree/master/packages/liveview/examples/axum.rs)\n* [Salvo Example](https://github.com/DioxusLabs/dioxus/tree/master/packages/liveview/examples/salvo.rs)\n* [Warp Example](https://github.com/DioxusLabs/dioxus/tree/master/packages/liveview/examples/warp.rs)\n\n## Support\n\nLiveview is currently limited in capability when compared to the Web platform. Liveview apps run on the server in a native thread. This means that browser APIs are not available, so rendering WebGL, Canvas, etc is not as easy as the Web. However, native system APIs are accessible, so streaming, WebSockets, filesystem, etc are all viable APIs.\n\n## Setup\n\nFor this guide, we're going to show how to use Dioxus Liveview with [Axum](https://docs.rs/axum/latest/axum/).\n\nMake sure you have Rust and Cargo installed, and then create a new project:\n\n````shell\ncargo new --bin demo\ncd app\n````\n\nAdd Dioxus and the liveview renderer with the Axum feature as dependencies:\n\n````shell\ncargo add dioxus\ncargo add dioxus-liveview --features axum\n````\n\nNext, add all the Axum dependencies. This will be different if you're using a different Web Framework\n\n````\ncargo add tokio --features full\ncargo add axum\n````\n\nYour dependencies should look roughly like this:\n\n````toml\n[dependencies]\naxum = \"0.4.5\"\ndioxus = { version = \"*\" }\ndioxus-liveview = { version = \"*\", features = [\"axum\"] }\ntokio = { version = \"1.15.0\", features = [\"full\"] }\n````\n\n````rs@included_example.rs\nfn it_works() {}\n\n````\n\n````sh\n{\"timestamp\":\" 9.927s\",\"level\":\"INFO\",\"message\":\"Bundled app successfully!\",\"target\":\"dx::cli::bundle\"}\n{\"timestamp\":\" 9.927s\",\"level\":\"INFO\",\"message\":\"App produced 2 outputs:\",\"target\":\"dx::cli::bundle\"}\n{\"timestamp\":\" 9.927s\",\"level\":\"INFO\",\"message\":\"app - [target/dx/hot_dog/bundle/macos/bundle/macos/HotDog.app]\",\"target\":\"dx::cli::bundle\"}\n{\"timestamp\":\" 9.927s\",\"level\":\"INFO\",\"message\":\"dmg - [target/dx/hot_dog/bundle/macos/bundle/dmg/HotDog_0.1.0_aarch64.dmg]\",\"target\":\"dx::cli::bundle\"}\n{\"timestamp\":\" 9.927s\",\"level\":\"DEBUG\",\"json\":\"{\\\"BundleOutput\\\":{\\\"bundles\\\":[\\\"target/dx/hot_dog/bundle/macos/bundle/macos/HotDog.app\\\"]}}\"}\n````" } - 2usize => { - "# Assets\n\nSome assets:\n![some_external](https://avatars.githubusercontent.com/u/79236386?s=200&v=4)\n![some_local](/example-book/assets/logo.png)\n![some_local1](/example-book/assets/logo1.png)\n![some_local2](/example-book/assets/logo2.png)" - } 1usize => { "# Roadmap & Feature-set\n\nThis feature set and roadmap can help you decide if what Dioxus can do today works for you.\n\nIf a feature that you need doesn't exist or you want to contribute to projects on the roadmap, feel free to get involved by [joining the discord](https://discord.gg/XgGxMSkvUM).\n\nGenerally, here's the status of each platform:\n\n* **Web**: Dioxus is a great choice for pure web-apps – especially for CRUD/complex apps. However, it does lack the ecosystem of React, so you might be missing a component library or some useful hook.\n\n* **SSR**: Dioxus is a great choice for pre-rendering, hydration, and rendering HTML on a web endpoint. Be warned – the VirtualDom is not (currently) `Send + Sync`.\n\n* **Desktop**: You can build very competent single-window desktop apps right now. However, multi-window apps require support from Dioxus core and are not ready.\n\n* **Mobile**: Mobile support is very young. You'll be figuring things out as you go and there are not many support crates for peripherals.\n\n* **LiveView**: LiveView support is very young. You'll be figuring things out as you go. Thankfully, none of it is too hard and any work can be upstreamed into Dioxus.\n\n````rust\nfn main() {\n dioxus_rocks;\n}\n````\n\n## Features\n\n---\n\n|Feature|Status|Description|\n|-------|------|-----------|\n|Conditional Rendering|✅|if/then to hide/show component|\n|Map, Iterator|✅|map/filter/reduce to produce rsx!|\n|Keyed Components|✅|advanced diffing with keys|\n|Web|✅|renderer for web browser|\n|Desktop (webview)|✅|renderer for desktop|\n|Shared State (Context)|✅|share state through the tree|\n|Hooks|✅|memory cells in components|\n|SSR|✅|render directly to string|\n|Component Children|✅|cx.children() as a list of nodes|\n|Headless components|✅|components that don't return real elements|\n|Fragments|✅|multiple elements without a real root|\n|Manual Props|✅|Manually pass in props with spread syntax|\n|Controlled Inputs|✅|stateful wrappers around inputs|\n|CSS/Inline Styles|✅|syntax for inline styles/attribute groups|\n|Custom elements|✅|Define new element primitives|\n|Suspense|✅|schedule future render from future/promise|\n|Integrated error handling|✅|Gracefully handle errors with ? syntax|\n|NodeRef|✅|gain direct access to nodes|\n|Re-hydration|✅|Pre-render to HTML to speed up first contentful paint|\n|Jank-Free Rendering|✅|Large diffs are segmented across frames for silky-smooth transitions|\n|Effects|✅|Run effects after a component has been committed to render|\n|Portals|🛠|Render nodes outside of the traditional tree structure|\n|Cooperative Scheduling|🛠|Prioritize important events over non-important events|\n|Server Components|🛠|Hybrid components for SPA and Server|\n|Bundle Splitting|👀|Efficiently and asynchronously load the app|\n|Lazy Components|👀|Dynamically load the new components as the page is loaded|\n|1st class global state|✅|redux/recoil/mobx on top of context|\n|Runs natively|✅|runs as a portable binary w/o a runtime (Node)|\n|Subtree Memoization|✅|skip diffing static element subtrees|\n|High-efficiency templates|✅|rsx! calls are translated to templates on the DOM's side|\n|Compile-time correct|✅|Throw errors on invalid template layouts|\n|Heuristic Engine|✅|track component memory usage to minimize future allocations|\n|Fine-grained reactivity|👀|Skip diffing for fine-grain updates|\n\n* ✅ = implemented and working\n* 🛠 = actively being worked on\n* 👀 = not yet implemented or being worked on\n\n## Roadmap\n\nThese Features are planned for the future of Dioxus:\n\n### Core\n\n* [x] Release of Dioxus Core\n* [x] Upgrade documentation to include more theory and be more comprehensive\n* [x] Support for HTML-side templates for lightning-fast dom manipulation\n* [ ] Support for multiple renderers for same virtualdom (subtrees)\n* [ ] Support for ThreadSafe (Send + Sync)\n* [ ] Support for Portals\n\n### SSR\n\n* [x] SSR Support + Hydration\n* [ ] Integrated suspense support for SSR\n\n### Desktop\n\n* [ ] Declarative window management\n* [ ] Templates for building/bundling\n* [ ] Access to Canvas/WebGL context natively\n\n### Mobile\n\n* [ ] Mobile standard library\n * [ ] GPS\n * [ ] Camera\n * [ ] filesystem\n * [ ] Biometrics\n * [ ] WiFi\n * [ ] Bluetooth\n * [ ] Notifications\n * [ ] Clipboard\n* [ ] Animations\n\n### Bundling (CLI)\n\n* [x] Translation from HTML into RSX\n* [x] Dev server\n* [x] Live reload\n* [x] Translation from JSX into RSX\n* [ ] Hot module replacement\n* [ ] Code splitting\n* [ ] Asset macros\n* [ ] Css pipeline\n* [ ] Image pipeline\n\n### Essential hooks\n\n* [x] Router\n* [x] Global state management\n* [ ] Resize observer\n\n## Work in Progress\n\n### Build Tool\n\nWe are currently working on our own build tool called [Dioxus CLI](https://github.com/DioxusLabs/dioxus/tree/master/packages/cli) which will support:\n\n* an interactive TUI\n* on-the-fly reconfiguration\n* hot CSS reloading\n* two-way data binding between browser and source code\n* an interpreter for `rsx!`\n* ability to publish to github/netlify/vercel\n* bundling for iOS/Desktop/etc\n\n### Server Component Support\n\nWhile not currently fully implemented, the expectation is that LiveView apps can be a hybrid between Wasm and server-rendered where only portions of a page are \"live\" and the rest of the page is either server-rendered, statically generated, or handled by the host SPA.\n\n### Native rendering\n\nWe are currently working on a native renderer for Dioxus using WGPU called [Blitz](https://github.com/DioxusLabs/blitz/). This will allow you to build apps that are rendered natively for iOS, Android, and Desktop.\n\n## Internal Links\n\nInternal links like [this](./chapter_1.md) are typechecked and will fail to compile if the file is not found." } + 2usize => { + "# Assets\n\nSome assets:\n![some_external](https://avatars.githubusercontent.com/u/79236386?s=200&v=4)\n![some_local](/example-book/assets/logo.png)\n![some_local1](/example-book/assets/logo1.png)\n![some_local2](/example-book/assets/logo2.png)" + } _ => panic!("Invalid page ID:"), } } @@ -54,211 +54,244 @@ impl Default for BookRoute { } } } -pub static LAZY_BOOK: use_mdbook::Lazy> = - use_mdbook::Lazy::new(|| { +pub static LAZY_BOOK: use_mdbook::Lazy> = use_mdbook::Lazy::new(|| +{ + { let mut page_id_mapping = ::std::collections::HashMap::new(); let mut pages = Vec::new(); - let __push_page_0: fn(_, _) = - |_pages: &mut Vec<_>, _page_id_mapping: &mut std::collections::HashMap<_, _>| { - _pages.push((0usize, { - ::use_mdbook::mdbook_shared::Page { - title: "Chapter 1".to_string(), - url: BookRoute::Chapter1 { - section: Chapter1Section::Empty, - }, - segments: vec![], - sections: vec![ - ::use_mdbook::mdbook_shared::Section { - title: "Liveview".to_string(), - id: "liveview".to_string(), - level: 1usize, - }, - ::use_mdbook::mdbook_shared::Section { - title: "Support".to_string(), - id: "support".to_string(), - level: 2usize, - }, - ::use_mdbook::mdbook_shared::Section { - title: "Setup".to_string(), - id: "setup".to_string(), - level: 2usize, + let __push_page_0: fn(_, _) = | + _pages: &mut Vec<_>, + _page_id_mapping: &mut std::collections::HashMap<_, _>| + { + _pages + .push(( + 0usize, + { + ::use_mdbook::mdbook_shared::Page { + title: "Chapter 1".to_string(), + url: BookRoute::Chapter1 { + section: Chapter1Section::Empty, }, - ], - raw: String::new(), - id: ::use_mdbook::mdbook_shared::PageId(0usize), - } - })); - _page_id_mapping.insert( + segments: vec![], + sections: vec![ + ::use_mdbook::mdbook_shared::Section { + title: "Liveview".to_string(), + id: "liveview".to_string(), + level: 1usize, + }, + ::use_mdbook::mdbook_shared::Section { + title: "Support".to_string(), + id: "support".to_string(), + level: 2usize, + }, + ::use_mdbook::mdbook_shared::Section { + title: "Setup".to_string(), + id: "setup".to_string(), + level: 2usize, + }, + ], + raw: String::new(), + id: ::use_mdbook::mdbook_shared::PageId(0usize), + } + }, + )); + _page_id_mapping + .insert( BookRoute::Chapter1 { section: Chapter1Section::Empty, }, ::use_mdbook::mdbook_shared::PageId(0usize), ); - }; + }; __push_page_0(&mut pages, &mut page_id_mapping); - let __push_page_1: fn(_, _) = - |_pages: &mut Vec<_>, _page_id_mapping: &mut std::collections::HashMap<_, _>| { - _pages.push((1usize, { - ::use_mdbook::mdbook_shared::Page { - title: "Chapter 2".to_string(), - url: BookRoute::Chapter2 { - section: Chapter2Section::Empty, - }, - segments: vec![], - sections: vec![ - ::use_mdbook::mdbook_shared::Section { - title: "Roadmap & Feature-set".to_string(), - id: "roadmap--feature-set".to_string(), - level: 1usize, - }, - ::use_mdbook::mdbook_shared::Section { - title: "Features".to_string(), - id: "features".to_string(), - level: 2usize, - }, - ::use_mdbook::mdbook_shared::Section { - title: "Roadmap".to_string(), - id: "roadmap".to_string(), - level: 2usize, - }, - ::use_mdbook::mdbook_shared::Section { - title: "Core".to_string(), - id: "core".to_string(), - level: 3usize, - }, - ::use_mdbook::mdbook_shared::Section { - title: "SSR".to_string(), - id: "ssr".to_string(), - level: 3usize, - }, - ::use_mdbook::mdbook_shared::Section { - title: "Desktop".to_string(), - id: "desktop".to_string(), - level: 3usize, - }, - ::use_mdbook::mdbook_shared::Section { - title: "Mobile".to_string(), - id: "mobile".to_string(), - level: 3usize, - }, - ::use_mdbook::mdbook_shared::Section { - title: "Bundling (CLI)".to_string(), - id: "bundling-cli".to_string(), - level: 3usize, - }, - ::use_mdbook::mdbook_shared::Section { - title: "Essential hooks".to_string(), - id: "essential-hooks".to_string(), - level: 3usize, - }, - ::use_mdbook::mdbook_shared::Section { - title: "Work in Progress".to_string(), - id: "work-in-progress".to_string(), - level: 2usize, - }, - ::use_mdbook::mdbook_shared::Section { - title: "Build Tool".to_string(), - id: "build-tool".to_string(), - level: 3usize, - }, - ::use_mdbook::mdbook_shared::Section { - title: "Server Component Support".to_string(), - id: "server-component-support".to_string(), - level: 3usize, - }, - ::use_mdbook::mdbook_shared::Section { - title: "Native rendering".to_string(), - id: "native-rendering".to_string(), - level: 3usize, - }, - ::use_mdbook::mdbook_shared::Section { - title: "Internal Links".to_string(), - id: "internal-links".to_string(), - level: 2usize, + let __push_page_1: fn(_, _) = | + _pages: &mut Vec<_>, + _page_id_mapping: &mut std::collections::HashMap<_, _>| + { + _pages + .push(( + 1usize, + { + ::use_mdbook::mdbook_shared::Page { + title: "Chapter 2".to_string(), + url: BookRoute::Chapter2 { + section: Chapter2Section::Empty, }, - ], - raw: String::new(), - id: ::use_mdbook::mdbook_shared::PageId(1usize), - } - })); - _page_id_mapping.insert( + segments: vec![], + sections: vec![ + ::use_mdbook::mdbook_shared::Section { + title: "Roadmap & Feature-set".to_string(), + id: "roadmap--feature-set".to_string(), + level: 1usize, + }, + ::use_mdbook::mdbook_shared::Section { + title: "Features".to_string(), + id: "features".to_string(), + level: 2usize, + }, + ::use_mdbook::mdbook_shared::Section { + title: "Roadmap".to_string(), + id: "roadmap".to_string(), + level: 2usize, + }, + ::use_mdbook::mdbook_shared::Section { + title: "Core".to_string(), + id: "core".to_string(), + level: 3usize, + }, + ::use_mdbook::mdbook_shared::Section { + title: "SSR".to_string(), + id: "ssr".to_string(), + level: 3usize, + }, + ::use_mdbook::mdbook_shared::Section { + title: "Desktop".to_string(), + id: "desktop".to_string(), + level: 3usize, + }, + ::use_mdbook::mdbook_shared::Section { + title: "Mobile".to_string(), + id: "mobile".to_string(), + level: 3usize, + }, + ::use_mdbook::mdbook_shared::Section { + title: "Bundling (CLI)".to_string(), + id: "bundling-cli".to_string(), + level: 3usize, + }, + ::use_mdbook::mdbook_shared::Section { + title: "Essential hooks".to_string(), + id: "essential-hooks".to_string(), + level: 3usize, + }, + ::use_mdbook::mdbook_shared::Section { + title: "Work in Progress".to_string(), + id: "work-in-progress".to_string(), + level: 2usize, + }, + ::use_mdbook::mdbook_shared::Section { + title: "Build Tool".to_string(), + id: "build-tool".to_string(), + level: 3usize, + }, + ::use_mdbook::mdbook_shared::Section { + title: "Server Component Support".to_string(), + id: "server-component-support".to_string(), + level: 3usize, + }, + ::use_mdbook::mdbook_shared::Section { + title: "Native rendering".to_string(), + id: "native-rendering".to_string(), + level: 3usize, + }, + ::use_mdbook::mdbook_shared::Section { + title: "Internal Links".to_string(), + id: "internal-links".to_string(), + level: 2usize, + }, + ], + raw: String::new(), + id: ::use_mdbook::mdbook_shared::PageId(1usize), + } + }, + )); + _page_id_mapping + .insert( BookRoute::Chapter2 { section: Chapter2Section::Empty, }, ::use_mdbook::mdbook_shared::PageId(1usize), ); - }; + }; __push_page_1(&mut pages, &mut page_id_mapping); - let __push_page_2: fn(_, _) = - |_pages: &mut Vec<_>, _page_id_mapping: &mut std::collections::HashMap<_, _>| { - _pages.push((2usize, { - ::use_mdbook::mdbook_shared::Page { - title: "Chapter 3".to_string(), - url: BookRoute::Chapter3 { - section: Chapter3Section::Empty, - }, - segments: vec![], - sections: vec![::use_mdbook::mdbook_shared::Section { - title: "Assets".to_string(), - id: "assets".to_string(), - level: 1usize, - }], - raw: String::new(), - id: ::use_mdbook::mdbook_shared::PageId(2usize), - } - })); - _page_id_mapping.insert( + let __push_page_2: fn(_, _) = | + _pages: &mut Vec<_>, + _page_id_mapping: &mut std::collections::HashMap<_, _>| + { + _pages + .push(( + 2usize, + { + ::use_mdbook::mdbook_shared::Page { + title: "Chapter 3".to_string(), + url: BookRoute::Chapter3 { + section: Chapter3Section::Empty, + }, + segments: vec![], + sections: vec![ + ::use_mdbook::mdbook_shared::Section { + title: "Assets".to_string(), + id: "assets".to_string(), + level: 1usize, + }, + ], + raw: String::new(), + id: ::use_mdbook::mdbook_shared::PageId(2usize), + } + }, + )); + _page_id_mapping + .insert( BookRoute::Chapter3 { section: Chapter3Section::Empty, }, ::use_mdbook::mdbook_shared::PageId(2usize), ); - }; + }; __push_page_2(&mut pages, &mut page_id_mapping); ::use_mdbook::mdbook_shared::MdBook { summary: ::use_mdbook::mdbook_shared::Summary { title: Some("Summary".to_string()), prefix_chapters: vec![], numbered_chapters: vec![ - ::use_mdbook::mdbook_shared::SummaryItem::Link( - ::use_mdbook::mdbook_shared::Link { - name: "Chapter 1".to_string(), - location: Some(BookRoute::Chapter1 { - section: Chapter1Section::Empty, - }), - number: Some(::use_mdbook::mdbook_shared::SectionNumber(vec![1u32])), - nested_items: vec![], - }, - ), - ::use_mdbook::mdbook_shared::SummaryItem::Link( - ::use_mdbook::mdbook_shared::Link { - name: "Chapter 2".to_string(), - location: Some(BookRoute::Chapter2 { - section: Chapter2Section::Empty, - }), - number: Some(::use_mdbook::mdbook_shared::SectionNumber(vec![2u32])), - nested_items: vec![], - }, - ), - ::use_mdbook::mdbook_shared::SummaryItem::Link( - ::use_mdbook::mdbook_shared::Link { - name: "Chapter 3".to_string(), - location: Some(BookRoute::Chapter3 { - section: Chapter3Section::Empty, - }), - number: Some(::use_mdbook::mdbook_shared::SectionNumber(vec![3u32])), - nested_items: vec![], - }, - ), + ::use_mdbook::mdbook_shared::SummaryItem::Link(::use_mdbook::mdbook_shared::Link { + name: "Chapter 1".to_string(), + location: Some(BookRoute::Chapter1 { + section: Chapter1Section::Empty, + }), + number: Some( + ::use_mdbook::mdbook_shared::SectionNumber(vec![1u32]), + ), + nested_items: vec![], + }), + ::use_mdbook::mdbook_shared::SummaryItem::Link(::use_mdbook::mdbook_shared::Link { + name: "Chapter 2".to_string(), + location: Some(BookRoute::Chapter2 { + section: Chapter2Section::Empty, + }), + number: Some( + ::use_mdbook::mdbook_shared::SectionNumber(vec![2u32]), + ), + nested_items: vec![], + }), + ::use_mdbook::mdbook_shared::SummaryItem::Link(::use_mdbook::mdbook_shared::Link { + name: "Chapter 3".to_string(), + location: Some(BookRoute::Chapter3 { + section: Chapter3Section::Empty, + }), + number: Some( + ::use_mdbook::mdbook_shared::SectionNumber(vec![3u32]), + ), + nested_items: vec![], + }), ], suffix_chapters: vec![], }, pages: pages.into_iter().collect(), page_id_mapping, } - }); + } +}); #[derive( - Clone, Copy, PartialEq, Eq, Hash, Debug, Default, serde::Serialize, serde::Deserialize, + Clone, + Copy, + PartialEq, + Eq, + Hash, + Debug, + Default, + serde::Serialize, + serde::Deserialize )] pub enum Chapter1Section { #[default] @@ -276,7 +309,9 @@ impl std::str::FromStr for Chapter1Section { "support" => Ok(Self::Support), "setup" => Ok(Self::Setup), _ => { - Err("Invalid section name. Expected one of Chapter1Sectionliveview, support, setup") + Err( + "Invalid section name. Expected one of Chapter1Sectionliveview, support, setup", + ) } } } @@ -312,125 +347,41 @@ pub fn Chapter1(section: Chapter1Section) -> Element { "For this guide, we're going to show how to use Dioxus Liveview with " Link { to : "https://docs.rs/axum/latest/axum/", "Axum" } "." } p { "Make sure you have Rust and Cargo installed, and then create a new project:" } - CodeBlock { source : { static SPANS : & [::dioxus_code::advanced::HighlightSpan] - = & [::dioxus_code::advanced::HighlightSpan::new(0u32..5u32, "f"), - ::dioxus_code::advanced::HighlightSpan::new(10u32..15u32, "co"), - ::dioxus_code::advanced::HighlightSpan::new(21u32..23u32, "f"),]; - ::dioxus_code::advanced::HighlightedSource::from_static_parts("cargo new --bin demo\ncd app", - ::dioxus_code::Language::Rust, SPANS,) }, } p { + CodeBlock { source : { ::dioxus_code::code_str!("cargo new --bin demo\ncd app", + ::dioxus_code::CodeOptions::builder() + .with_language(::dioxus_code::Language::Bash)) }, } p { "Add Dioxus and the liveview renderer with the Axum feature as dependencies:" } - CodeBlock { source : { static SPANS : & [::dioxus_code::advanced::HighlightSpan] - = & [::dioxus_code::advanced::HighlightSpan::new(0u32..5u32, "f"), - ::dioxus_code::advanced::HighlightSpan::new(17u32..22u32, "f"), - ::dioxus_code::advanced::HighlightSpan::new(43u32..53u32, "co"),]; - ::dioxus_code::advanced::HighlightedSource::from_static_parts("cargo add dioxus\ncargo add dioxus-liveview --features axum", - ::dioxus_code::Language::Rust, SPANS,) }, } p { + CodeBlock { source : { + ::dioxus_code::code_str!("cargo add dioxus\ncargo add dioxus-liveview --features axum", + ::dioxus_code::CodeOptions::builder() + .with_language(::dioxus_code::Language::Bash)) }, } p { "Next, add all the Axum dependencies. This will be different if you're using a different Web Framework" - } CodeBlock { source : { static SPANS : & - [::dioxus_code::advanced::HighlightSpan] = & []; + } CodeBlock { source : { ::dioxus_code::advanced::HighlightedSource::from_static_parts("cargo add tokio --features full\ncargo add axum", - ::dioxus_code::Language::Rust, SPANS,) }, } p { + ::dioxus_code::Language::Rust, & [],) }, } p { "Your dependencies should look roughly like this:" } CodeBlock { source : { - static SPANS : & [::dioxus_code::advanced::HighlightSpan] = & - [::dioxus_code::advanced::HighlightSpan::new(0u32..1u32, "p"), - ::dioxus_code::advanced::HighlightSpan::new(1u32..13u32, "pr"), - ::dioxus_code::advanced::HighlightSpan::new(13u32..14u32, "p"), - ::dioxus_code::advanced::HighlightSpan::new(15u32..19u32, "pr"), - ::dioxus_code::advanced::HighlightSpan::new(20u32..21u32, "o"), - ::dioxus_code::advanced::HighlightSpan::new(22u32..29u32, "s"), - ::dioxus_code::advanced::HighlightSpan::new(30u32..36u32, "pr"), - ::dioxus_code::advanced::HighlightSpan::new(37u32..38u32, "o"), - ::dioxus_code::advanced::HighlightSpan::new(39u32..40u32, "p"), - ::dioxus_code::advanced::HighlightSpan::new(41u32..48u32, "pr"), - ::dioxus_code::advanced::HighlightSpan::new(49u32..50u32, "o"), - ::dioxus_code::advanced::HighlightSpan::new(51u32..54u32, "s"), - ::dioxus_code::advanced::HighlightSpan::new(55u32..56u32, "p"), - ::dioxus_code::advanced::HighlightSpan::new(57u32..72u32, "pr"), - ::dioxus_code::advanced::HighlightSpan::new(73u32..74u32, "o"), - ::dioxus_code::advanced::HighlightSpan::new(75u32..76u32, "p"), - ::dioxus_code::advanced::HighlightSpan::new(77u32..84u32, "pr"), - ::dioxus_code::advanced::HighlightSpan::new(85u32..86u32, "o"), - ::dioxus_code::advanced::HighlightSpan::new(87u32..90u32, "s"), - ::dioxus_code::advanced::HighlightSpan::new(90u32..91u32, "p"), - ::dioxus_code::advanced::HighlightSpan::new(92u32..100u32, "pr"), - ::dioxus_code::advanced::HighlightSpan::new(101u32..102u32, "o"), - ::dioxus_code::advanced::HighlightSpan::new(103u32..104u32, "p"), - ::dioxus_code::advanced::HighlightSpan::new(104u32..110u32, "s"), - ::dioxus_code::advanced::HighlightSpan::new(110u32..111u32, "p"), - ::dioxus_code::advanced::HighlightSpan::new(112u32..113u32, "p"), - ::dioxus_code::advanced::HighlightSpan::new(114u32..119u32, "pr"), - ::dioxus_code::advanced::HighlightSpan::new(120u32..121u32, "o"), - ::dioxus_code::advanced::HighlightSpan::new(122u32..123u32, "p"), - ::dioxus_code::advanced::HighlightSpan::new(124u32..131u32, "pr"), - ::dioxus_code::advanced::HighlightSpan::new(132u32..133u32, "o"), - ::dioxus_code::advanced::HighlightSpan::new(134u32..142u32, "s"), - ::dioxus_code::advanced::HighlightSpan::new(142u32..143u32, "p"), - ::dioxus_code::advanced::HighlightSpan::new(144u32..152u32, "pr"), - ::dioxus_code::advanced::HighlightSpan::new(153u32..154u32, "o"), - ::dioxus_code::advanced::HighlightSpan::new(155u32..156u32, "p"), - ::dioxus_code::advanced::HighlightSpan::new(156u32..162u32, "s"), - ::dioxus_code::advanced::HighlightSpan::new(162u32..163u32, "p"), - ::dioxus_code::advanced::HighlightSpan::new(164u32..165u32, "p"),]; - ::dioxus_code::advanced::HighlightedSource::from_static_parts("[dependencies]\naxum = \"0.4.5\"\ndioxus = { version = \"*\" }\ndioxus-liveview = { version = \"*\", features = [\"axum\"] }\ntokio = { version = \"1.15.0\", features = [\"full\"] }", - ::dioxus_code::Language::Rust, SPANS,) }, } CodeBlock { source : { static SPANS : - & [::dioxus_code::advanced::HighlightSpan] = & - [::dioxus_code::advanced::HighlightSpan::new(0u32..2u32, "k"), - ::dioxus_code::advanced::HighlightSpan::new(3u32..11u32, "f"), - ::dioxus_code::advanced::HighlightSpan::new(11u32..13u32, "p"), - ::dioxus_code::advanced::HighlightSpan::new(14u32..16u32, "p"),]; - ::dioxus_code::advanced::HighlightedSource::from_static_parts("fn it_works() {}", - ::dioxus_code::Language::Rust, SPANS,) }, name : "included_example.rs" - .to_string(), } CodeBlock { source : { static SPANS : & - [::dioxus_code::advanced::HighlightSpan] = & - [::dioxus_code::advanced::HighlightSpan::new(1u32..12u32, "s"), - ::dioxus_code::advanced::HighlightSpan::new(1u32..105u32, "f"), - ::dioxus_code::advanced::HighlightSpan::new(13u32..24u32, "s"), - ::dioxus_code::advanced::HighlightSpan::new(25u32..32u32, "s"), - ::dioxus_code::advanced::HighlightSpan::new(33u32..39u32, "s"), - ::dioxus_code::advanced::HighlightSpan::new(40u32..49u32, "s"), - ::dioxus_code::advanced::HighlightSpan::new(50u32..77u32, "s"), - ::dioxus_code::advanced::HighlightSpan::new(78u32..86u32, "s"), - ::dioxus_code::advanced::HighlightSpan::new(87u32..104u32, "s"), - ::dioxus_code::advanced::HighlightSpan::new(107u32..118u32, "s"), - ::dioxus_code::advanced::HighlightSpan::new(107u32..209u32, "f"), - ::dioxus_code::advanced::HighlightSpan::new(119u32..130u32, "s"), - ::dioxus_code::advanced::HighlightSpan::new(131u32..138u32, "s"), - ::dioxus_code::advanced::HighlightSpan::new(139u32..145u32, "s"), - ::dioxus_code::advanced::HighlightSpan::new(146u32..155u32, "s"), - ::dioxus_code::advanced::HighlightSpan::new(156u32..181u32, "s"), - ::dioxus_code::advanced::HighlightSpan::new(182u32..190u32, "s"), - ::dioxus_code::advanced::HighlightSpan::new(191u32..208u32, "s"), - ::dioxus_code::advanced::HighlightSpan::new(211u32..222u32, "s"), - ::dioxus_code::advanced::HighlightSpan::new(211u32..352u32, "f"), - ::dioxus_code::advanced::HighlightSpan::new(223u32..234u32, "s"), - ::dioxus_code::advanced::HighlightSpan::new(235u32..242u32, "s"), - ::dioxus_code::advanced::HighlightSpan::new(243u32..249u32, "s"), - ::dioxus_code::advanced::HighlightSpan::new(250u32..259u32, "s"), - ::dioxus_code::advanced::HighlightSpan::new(260u32..324u32, "s"), - ::dioxus_code::advanced::HighlightSpan::new(325u32..333u32, "s"), - ::dioxus_code::advanced::HighlightSpan::new(334u32..351u32, "s"), - ::dioxus_code::advanced::HighlightSpan::new(354u32..365u32, "s"), - ::dioxus_code::advanced::HighlightSpan::new(354u32..507u32, "f"), - ::dioxus_code::advanced::HighlightSpan::new(366u32..377u32, "s"), - ::dioxus_code::advanced::HighlightSpan::new(378u32..385u32, "s"), - ::dioxus_code::advanced::HighlightSpan::new(386u32..392u32, "s"), - ::dioxus_code::advanced::HighlightSpan::new(393u32..402u32, "s"), - ::dioxus_code::advanced::HighlightSpan::new(403u32..479u32, "s"), - ::dioxus_code::advanced::HighlightSpan::new(480u32..488u32, "s"), - ::dioxus_code::advanced::HighlightSpan::new(489u32..506u32, "s"), - ::dioxus_code::advanced::HighlightSpan::new(509u32..520u32, "s"), - ::dioxus_code::advanced::HighlightSpan::new(509u32..652u32, "f"), - ::dioxus_code::advanced::HighlightSpan::new(521u32..532u32, "s"), - ::dioxus_code::advanced::HighlightSpan::new(533u32..540u32, "s"), - ::dioxus_code::advanced::HighlightSpan::new(541u32..548u32, "s"), - ::dioxus_code::advanced::HighlightSpan::new(549u32..555u32, "s"), - ::dioxus_code::advanced::HighlightSpan::new(556u32..651u32, "s"),]; - ::dioxus_code::advanced::HighlightedSource::from_static_parts("{\"timestamp\":\" 9.927s\",\"level\":\"INFO\",\"message\":\"Bundled app successfully!\",\"target\":\"dx::cli::bundle\"}\n{\"timestamp\":\" 9.927s\",\"level\":\"INFO\",\"message\":\"App produced 2 outputs:\",\"target\":\"dx::cli::bundle\"}\n{\"timestamp\":\" 9.927s\",\"level\":\"INFO\",\"message\":\"app - [target/dx/hot_dog/bundle/macos/bundle/macos/HotDog.app]\",\"target\":\"dx::cli::bundle\"}\n{\"timestamp\":\" 9.927s\",\"level\":\"INFO\",\"message\":\"dmg - [target/dx/hot_dog/bundle/macos/bundle/dmg/HotDog_0.1.0_aarch64.dmg]\",\"target\":\"dx::cli::bundle\"}\n{\"timestamp\":\" 9.927s\",\"level\":\"DEBUG\",\"json\":\"{\\\"BundleOutput\\\":{\\\"bundles\\\":[\\\"target/dx/hot_dog/bundle/macos/bundle/macos/HotDog.app\\\"]}}\"}", - ::dioxus_code::Language::Rust, SPANS,) }, } + ::dioxus_code::code_str!("[dependencies]\naxum = \"0.4.5\"\ndioxus = { version = \"*\" }\ndioxus-liveview = { version = \"*\", features = [\"axum\"] }\ntokio = { version = \"1.15.0\", features = [\"full\"] }", + ::dioxus_code::CodeOptions::builder() + .with_language(::dioxus_code::Language::Toml)) }, } CodeBlock { source : { + ::dioxus_code::code_str!("fn it_works() {}", + ::dioxus_code::CodeOptions::builder() + .with_language(::dioxus_code::Language::Rust)) }, name : "included_example.rs" + .to_string(), } CodeBlock { source : { + ::dioxus_code::code_str!("{\"timestamp\":\" 9.927s\",\"level\":\"INFO\",\"message\":\"Bundled app successfully!\",\"target\":\"dx::cli::bundle\"}\n{\"timestamp\":\" 9.927s\",\"level\":\"INFO\",\"message\":\"App produced 2 outputs:\",\"target\":\"dx::cli::bundle\"}\n{\"timestamp\":\" 9.927s\",\"level\":\"INFO\",\"message\":\"app - [target/dx/hot_dog/bundle/macos/bundle/macos/HotDog.app]\",\"target\":\"dx::cli::bundle\"}\n{\"timestamp\":\" 9.927s\",\"level\":\"INFO\",\"message\":\"dmg - [target/dx/hot_dog/bundle/macos/bundle/dmg/HotDog_0.1.0_aarch64.dmg]\",\"target\":\"dx::cli::bundle\"}\n{\"timestamp\":\" 9.927s\",\"level\":\"DEBUG\",\"json\":\"{\\\"BundleOutput\\\":{\\\"bundles\\\":[\\\"target/dx/hot_dog/bundle/macos/bundle/macos/HotDog.app\\\"]}}\"}", + ::dioxus_code::CodeOptions::builder() + .with_language(::dioxus_code::Language::Bash)) }, } } } #[derive( - Clone, Copy, PartialEq, Eq, Hash, Debug, Default, serde::Serialize, serde::Deserialize, + Clone, + Copy, + PartialEq, + Eq, + Hash, + Debug, + Default, + serde::Serialize, + serde::Deserialize )] pub enum Chapter2Section { #[default] @@ -518,19 +469,13 @@ pub fn Chapter2(section: Chapter2Section) -> Element { ": Mobile support is very young. You'll be figuring things out as you go and there are not many support crates for peripherals." } } li { p { strong { "LiveView" } ": LiveView support is very young. You'll be figuring things out as you go. Thankfully, none of it is too hard and any work can be upstreamed into Dioxus." - } } } CodeBlock { source : { static SPANS : & - [::dioxus_code::advanced::HighlightSpan] = & - [::dioxus_code::advanced::HighlightSpan::new(0u32..2u32, "k"), - ::dioxus_code::advanced::HighlightSpan::new(3u32..7u32, "f"), - ::dioxus_code::advanced::HighlightSpan::new(7u32..9u32, "p"), - ::dioxus_code::advanced::HighlightSpan::new(10u32..11u32, "p"), - ::dioxus_code::advanced::HighlightSpan::new(26u32..27u32, "p"), - ::dioxus_code::advanced::HighlightSpan::new(28u32..29u32, "p"),]; - ::dioxus_code::advanced::HighlightedSource::from_static_parts("fn main() {\n dioxus_rocks;\n}", - ::dioxus_code::Language::Rust, SPANS,) }, } h2 { id : "features", Link { to : - BookRoute::Chapter2 { section : Chapter2Section::Features, }, class : "header", - "Features" } } hr {} table { thead { th { "Feature" } th { "Status" } th { - "Description" } } tr { th { "Conditional Rendering" } th { "✅" } th { + } } } CodeBlock { source : { + ::dioxus_code::code_str!("fn main() {\n dioxus_rocks;\n}", + ::dioxus_code::CodeOptions::builder() + .with_language(::dioxus_code::Language::Rust)) }, } h2 { id : "features", Link { + to : BookRoute::Chapter2 { section : Chapter2Section::Features, }, class : + "header", "Features" } } hr {} table { thead { th { "Feature" } th { "Status" } + th { "Description" } } tr { th { "Conditional Rendering" } th { "✅" } th { "if/then to hide/show component" } } tr { th { "Map, Iterator" } th { "✅" } th { "map/filter/reduce to produce rsx!" } } tr { th { "Keyed Components" } th { "✅" } th { "advanced diffing with keys" } } tr { th { "Web" } th { "✅" } th { @@ -673,7 +618,15 @@ pub fn Chapter2(section: Chapter2Section) -> Element { } } #[derive( - Clone, Copy, PartialEq, Eq, Hash, Debug, Default, serde::Serialize, serde::Deserialize, + Clone, + Copy, + PartialEq, + Eq, + Hash, + Debug, + Default, + serde::Serialize, + serde::Deserialize )] pub enum Chapter3Section { #[default] diff --git a/packages/include_mdbook/packages/mdbook-gen/src/lib.rs b/packages/include_mdbook/packages/mdbook-gen/src/lib.rs index c92496cb0c..6aa7a3014d 100644 --- a/packages/include_mdbook/packages/mdbook-gen/src/lib.rs +++ b/packages/include_mdbook/packages/mdbook-gen/src/lib.rs @@ -1,4 +1,4 @@ -use std::collections::HashMap; +use std::collections::BTreeMap; use std::path::Path; use std::path::PathBuf; @@ -70,7 +70,7 @@ pub fn generate_router_as_file( pub fn generate_router(mdbook_dir: PathBuf, book: mdbook_shared::MdBook) -> TokenStream2 { let mdbook = write_book_with_routes(&book); - let mut page_markdown_map = HashMap::new(); + let mut page_markdown_map = BTreeMap::new(); let book_pages = book.pages().iter().map(|(_, page)| { let name = path_to_route_variant(&page.url).unwrap(); From 8cf0466dc54ed9325fbb2284d3bdc8bb9a5721e7 Mon Sep 17 00:00:00 2001 From: Evan Almloff Date: Mon, 11 May 2026 09:12:16 -0500 Subject: [PATCH 5/7] remove dead submodules --- .gitmodules | 9 --------- Cargo.lock | 5 ----- .../packages/mdbook-gen-example/Cargo.toml | 7 ------- .../packages/mdbook-gen-example/build.rs | 16 ---------------- .../packages/mdbook-gen/Packages | 1 - .../packages/mdbook-gen/rust-enhanced | 1 - .../packages/mdbook-gen/src/lib.rs | 18 ------------------ .../mdbook-gen/sublime_toml_highlighting | 1 - 8 files changed, 58 deletions(-) delete mode 100644 .gitmodules delete mode 100644 packages/include_mdbook/packages/mdbook-gen-example/build.rs delete mode 160000 packages/include_mdbook/packages/mdbook-gen/Packages delete mode 160000 packages/include_mdbook/packages/mdbook-gen/rust-enhanced delete mode 160000 packages/include_mdbook/packages/mdbook-gen/sublime_toml_highlighting diff --git a/.gitmodules b/.gitmodules deleted file mode 100644 index 64a4da2715..0000000000 --- a/.gitmodules +++ /dev/null @@ -1,9 +0,0 @@ -[submodule "packages/include_mdbook/packages/mdbook-gen/sublime_toml_highlighting"] - path = packages/include_mdbook/packages/mdbook-gen/sublime_toml_highlighting - url = https://github.com/jasonwilliams/sublime_toml_highlighting -[submodule "packages/include_mdbook/packages/mdbook-gen/Packages"] - path = packages/include_mdbook/packages/mdbook-gen/Packages - url = https://github.com/sublimehq/Packages.git -[submodule "packages/include_mdbook/packages/mdbook-gen/rust-enhanced"] - path = packages/include_mdbook/packages/mdbook-gen/rust-enhanced - url = https://github.com/rust-lang/rust-enhanced diff --git a/Cargo.lock b/Cargo.lock index 4e2eb738db..874694a84c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4573,13 +4573,8 @@ name = "mdbook-gen-example" version = "0.0.0" dependencies = [ "dioxus", - "dioxus-autofmt", "dioxus-code", - "mdbook-gen", - "mdbook-shared", - "prettyplease", "serde", - "syn 2.0.117", "use-mdbook", ] diff --git a/packages/include_mdbook/packages/mdbook-gen-example/Cargo.toml b/packages/include_mdbook/packages/mdbook-gen-example/Cargo.toml index 71419ce83d..56e7f4bcce 100644 --- a/packages/include_mdbook/packages/mdbook-gen-example/Cargo.toml +++ b/packages/include_mdbook/packages/mdbook-gen-example/Cargo.toml @@ -8,10 +8,3 @@ dioxus-code = { workspace = true } serde = {version = "1.0.163", features = ["derive"]} use-mdbook = { workspace = true } dioxus = { workspace = true, features = ["router"] } - -[build-dependencies] -mdbook-gen = { path = "../mdbook-gen", features = ["manganis"] } -mdbook-shared = { path = "../mdbook-shared" } -dioxus-autofmt = { workspace = true } -prettyplease = "0.2.20" -syn = { workspace = true } diff --git a/packages/include_mdbook/packages/mdbook-gen-example/build.rs b/packages/include_mdbook/packages/mdbook-gen-example/build.rs deleted file mode 100644 index eead20d545..0000000000 --- a/packages/include_mdbook/packages/mdbook-gen-example/build.rs +++ /dev/null @@ -1,16 +0,0 @@ -use std::{env::current_dir, path::PathBuf}; - -fn main() { - // // re-run only if the "example-book" directory changes - // println!("cargo:rerun-if-changed=example-book"); - - // let manifest_dir = PathBuf::from(std::env::var("CARGO_MANIFEST_DIR").unwrap()); - // let mdbook_dir = manifest_dir.join("./example-book").canonicalize().unwrap(); - // let out_dir = current_dir().unwrap().join("src"); - - // let mut out = mdbook_gen::generate_router_build_script(mdbook_dir); - // out.push_str("\n"); - // out.push_str("use super::*;\n"); - - // std::fs::write(out_dir.join("router.rs"), out).unwrap(); -} diff --git a/packages/include_mdbook/packages/mdbook-gen/Packages b/packages/include_mdbook/packages/mdbook-gen/Packages deleted file mode 160000 index 466e8bfa11..0000000000 --- a/packages/include_mdbook/packages/mdbook-gen/Packages +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 466e8bfa1166fef08282cffdbd0825e12bc8a09f diff --git a/packages/include_mdbook/packages/mdbook-gen/rust-enhanced b/packages/include_mdbook/packages/mdbook-gen/rust-enhanced deleted file mode 160000 index dec2e11325..0000000000 --- a/packages/include_mdbook/packages/mdbook-gen/rust-enhanced +++ /dev/null @@ -1 +0,0 @@ -Subproject commit dec2e1132517945b8e6c07fa7f0a10d13c1f976d diff --git a/packages/include_mdbook/packages/mdbook-gen/src/lib.rs b/packages/include_mdbook/packages/mdbook-gen/src/lib.rs index 6aa7a3014d..f478b1bbfb 100644 --- a/packages/include_mdbook/packages/mdbook-gen/src/lib.rs +++ b/packages/include_mdbook/packages/mdbook-gen/src/lib.rs @@ -8,7 +8,6 @@ use mdbook_shared::MdBook; use proc_macro2::Ident; use proc_macro2::Span; use proc_macro2::TokenStream as TokenStream2; -use quote::format_ident; use quote::quote; use quote::ToTokens; use syn::LitStr; @@ -24,7 +23,6 @@ pub fn make_docs_from_ws(version: &str) { let mut out = generate_router_build_script(mdbook_dir); out.push_str("use dioxus_docs_examples::*;\n"); out.push_str("use dioxus::prelude::*;\n"); - let version_flattened = version.replace(".", ""); let filename = format!("docsgen.rs"); std::fs::write(out_dir.join(filename), out).unwrap(); } @@ -331,19 +329,3 @@ pub(crate) fn path_to_route_enum_with_section( }) } -fn rustfmt_via_cli(input: &str) -> String { - let tmpfile = std::env::temp_dir().join(format!("mdbook-gen-{}.rs", std::process::id())); - std::fs::write(&tmpfile, input).unwrap(); - - let file = std::fs::File::open(&tmpfile).unwrap(); - let output = std::process::Command::new("rustfmt") - .arg("--edition=2021") - .stdin(file) - .stdout(std::process::Stdio::piped()) - .output() - .unwrap(); - - _ = std::fs::remove_file(tmpfile); - - String::from_utf8(output.stdout).unwrap() -} diff --git a/packages/include_mdbook/packages/mdbook-gen/sublime_toml_highlighting b/packages/include_mdbook/packages/mdbook-gen/sublime_toml_highlighting deleted file mode 160000 index f5a57e8bff..0000000000 --- a/packages/include_mdbook/packages/mdbook-gen/sublime_toml_highlighting +++ /dev/null @@ -1 +0,0 @@ -Subproject commit f5a57e8bff694a4e6c52a491dae579aabc7427cf From 8db6734f465b4b5f00fad2cc92d5da797f0ad51f Mon Sep 17 00:00:00 2001 From: Evan Almloff Date: Mon, 11 May 2026 09:19:01 -0500 Subject: [PATCH 6/7] handle more aliases --- .../packages/mdbook-gen/src/rsx.rs | 60 +++++++------------ 1 file changed, 23 insertions(+), 37 deletions(-) diff --git a/packages/include_mdbook/packages/mdbook-gen/src/rsx.rs b/packages/include_mdbook/packages/mdbook-gen/src/rsx.rs index b971f1e62f..5ac358254e 100644 --- a/packages/include_mdbook/packages/mdbook-gen/src/rsx.rs +++ b/packages/include_mdbook/packages/mdbook-gen/src/rsx.rs @@ -361,8 +361,7 @@ impl<'a, I: Iterator>> RsxMarkdownParser<'a, I> { if lang.as_deref() == Some("inject-dioxus") { self.start_node(parse_str::(&raw_code).unwrap()); } else { - let language = normalize_code_language(lang.as_deref()); - let source = highlighted_source_tokens(raw_code.trim_end(), &language); + let source = highlighted_source_tokens(raw_code.trim_end(), lang.as_deref()); let fname = if let Some(fname) = fname { quote! { name: #fname.to_string() } @@ -750,30 +749,11 @@ impl<'a, I: Iterator>> Iterator for ResolveCodeBlock<'a, I> { } } -fn normalize_code_language(lang: Option<&str>) -> String { - let lang = lang - .unwrap_or_default() - .trim() - .split(|ch: char| ch.is_whitespace() || ch == ',') - .next() - .unwrap_or_default() - .to_ascii_lowercase(); - - match lang.as_str() { - "bash" | "sh" | "shell" => "bash", - "cmd" => "batch", - "js" => "javascript", - "jsx" => "tsx", - "plain" | "text" | "txt" => "", - "rs" => "rust", - "yml" => "yaml", - language => language, - } - .to_string() -} - -fn highlighted_source_tokens(code: &str, language: &str) -> TokenStream2 { - let Some(variant) = language_variant_ident(language) else { +fn highlighted_source_tokens(code: &str, lang: Option<&str>) -> TokenStream2 { + let Some(variant) = language_variant_ident(lang) else { + // Unknown/plain text: emit empty highlight spans so no tokens are styled. + // `Language` has no `PlainText` variant; the tag is unused when spans are empty, + // so we pick `Rust` arbitrarily as the metadata placeholder. return quote! {{ ::dioxus_code::advanced::HighlightedSource::from_static_parts( #code, @@ -782,33 +762,39 @@ fn highlighted_source_tokens(code: &str, language: &str) -> TokenStream2 { ) }}; }; - let variant_ident = Ident::new(variant, Span::call_site()); quote! {{ ::dioxus_code::code_str!( #code, ::dioxus_code::CodeOptions::builder() - .with_language(::dioxus_code::Language::#variant_ident) + .with_language(::dioxus_code::Language::#variant) ) }} } -fn language_variant_ident(slug: &str) -> Option<&'static str> { - Some(match slug { - "bash" => "Bash", - "batch" => "Batch", +fn language_variant_ident(lang: Option<&str>) -> Option { + let lang = lang? + .trim() + .split(|ch: char| ch.is_whitespace() || ch == ',') + .next()? + .to_ascii_lowercase(); + + let variant = match lang.as_str() { + "bash" | "sh" | "shell" => "Bash", + "batch" | "cmd" => "Batch", "css" => "Css", "dockerfile" => "Dockerfile", "html" => "Html", - "javascript" => "JavaScript", + "javascript" | "js" => "JavaScript", "json" => "Json", "lua" => "Lua", "powershell" => "PowerShell", - "rust" => "Rust", + "rs" | "rust" => "Rust", "toml" => "Toml", - "tsx" => "Tsx", - "yaml" => "Yaml", + "jsx" | "tsx" => "Tsx", + "yaml" | "yml" => "Yaml", _ => return None, - }) + }; + Some(Ident::new(variant, Span::call_site())) } fn transform_code_block( From 2a880b201447f411190d11e7653df399995810e3 Mon Sep 17 00:00:00 2001 From: Evan Almloff Date: Mon, 11 May 2026 09:19:49 -0500 Subject: [PATCH 7/7] fix formatting --- packages/docs-router/src/lib.rs | 2 +- packages/docsite/src/components/learn.rs | 5 +- .../packages/mdbook-gen-example/src/router.rs | 401 ++++++++---------- .../packages/mdbook-gen/src/lib.rs | 1 - packages/notion-to-blog/src/main.rs | 6 +- 5 files changed, 185 insertions(+), 230 deletions(-) diff --git a/packages/docs-router/src/lib.rs b/packages/docs-router/src/lib.rs index e489feed54..3047b80fa7 100644 --- a/packages/docs-router/src/lib.rs +++ b/packages/docs-router/src/lib.rs @@ -1,7 +1,7 @@ #![allow(unused)] use dioxus::prelude::*; -use dioxus_code::{advanced::HighlightedSource, Code, CodeTheme, Theme}; +use dioxus_code::{Code, CodeTheme, Theme, advanced::HighlightedSource}; pub mod doc_examples; pub use doc_examples::*; diff --git a/packages/docsite/src/components/learn.rs b/packages/docsite/src/components/learn.rs index 5369fc9f6d..ed57b108ea 100644 --- a/packages/docsite/src/components/learn.rs +++ b/packages/docsite/src/components/learn.rs @@ -252,7 +252,10 @@ fn SidebarChapter(chapter: &'static SummaryItem, nest: usize pub fn RightNav() -> Element { let page = R::use_route(); let short_version = R::short_version(); - let llms_url = format!("{}/llms.txt", page.global_route().to_string().trim_end_matches('/')); + let llms_url = format!( + "{}/llms.txt", + page.global_route().to_string().trim_end_matches('/') + ); let mut copied = use_signal(|| false); let edit_github_url = use_resource(use_reactive!(|(page,)| async move { diff --git a/packages/include_mdbook/packages/mdbook-gen-example/src/router.rs b/packages/include_mdbook/packages/mdbook-gen-example/src/router.rs index 108f262c16..a0f5342db1 100644 --- a/packages/include_mdbook/packages/mdbook-gen-example/src/router.rs +++ b/packages/include_mdbook/packages/mdbook-gen-example/src/router.rs @@ -7,7 +7,7 @@ Hash, Debug, serde::Serialize, - serde::Deserialize + serde::Deserialize, )] pub enum BookRoute { #[route("/./chapter_1#:section")] @@ -54,244 +54,211 @@ impl Default for BookRoute { } } } -pub static LAZY_BOOK: use_mdbook::Lazy> = use_mdbook::Lazy::new(|| -{ - { +pub static LAZY_BOOK: use_mdbook::Lazy> = + use_mdbook::Lazy::new(|| { let mut page_id_mapping = ::std::collections::HashMap::new(); let mut pages = Vec::new(); - let __push_page_0: fn(_, _) = | - _pages: &mut Vec<_>, - _page_id_mapping: &mut std::collections::HashMap<_, _>| - { - _pages - .push(( - 0usize, - { - ::use_mdbook::mdbook_shared::Page { - title: "Chapter 1".to_string(), - url: BookRoute::Chapter1 { - section: Chapter1Section::Empty, + let __push_page_0: fn(_, _) = + |_pages: &mut Vec<_>, _page_id_mapping: &mut std::collections::HashMap<_, _>| { + _pages.push((0usize, { + ::use_mdbook::mdbook_shared::Page { + title: "Chapter 1".to_string(), + url: BookRoute::Chapter1 { + section: Chapter1Section::Empty, + }, + segments: vec![], + sections: vec![ + ::use_mdbook::mdbook_shared::Section { + title: "Liveview".to_string(), + id: "liveview".to_string(), + level: 1usize, }, - segments: vec![], - sections: vec![ - ::use_mdbook::mdbook_shared::Section { - title: "Liveview".to_string(), - id: "liveview".to_string(), - level: 1usize, - }, - ::use_mdbook::mdbook_shared::Section { - title: "Support".to_string(), - id: "support".to_string(), - level: 2usize, - }, - ::use_mdbook::mdbook_shared::Section { - title: "Setup".to_string(), - id: "setup".to_string(), - level: 2usize, - }, - ], - raw: String::new(), - id: ::use_mdbook::mdbook_shared::PageId(0usize), - } - }, - )); - _page_id_mapping - .insert( + ::use_mdbook::mdbook_shared::Section { + title: "Support".to_string(), + id: "support".to_string(), + level: 2usize, + }, + ::use_mdbook::mdbook_shared::Section { + title: "Setup".to_string(), + id: "setup".to_string(), + level: 2usize, + }, + ], + raw: String::new(), + id: ::use_mdbook::mdbook_shared::PageId(0usize), + } + })); + _page_id_mapping.insert( BookRoute::Chapter1 { section: Chapter1Section::Empty, }, ::use_mdbook::mdbook_shared::PageId(0usize), ); - }; + }; __push_page_0(&mut pages, &mut page_id_mapping); - let __push_page_1: fn(_, _) = | - _pages: &mut Vec<_>, - _page_id_mapping: &mut std::collections::HashMap<_, _>| - { - _pages - .push(( - 1usize, - { - ::use_mdbook::mdbook_shared::Page { - title: "Chapter 2".to_string(), - url: BookRoute::Chapter2 { - section: Chapter2Section::Empty, + let __push_page_1: fn(_, _) = + |_pages: &mut Vec<_>, _page_id_mapping: &mut std::collections::HashMap<_, _>| { + _pages.push((1usize, { + ::use_mdbook::mdbook_shared::Page { + title: "Chapter 2".to_string(), + url: BookRoute::Chapter2 { + section: Chapter2Section::Empty, + }, + segments: vec![], + sections: vec![ + ::use_mdbook::mdbook_shared::Section { + title: "Roadmap & Feature-set".to_string(), + id: "roadmap--feature-set".to_string(), + level: 1usize, }, - segments: vec![], - sections: vec![ - ::use_mdbook::mdbook_shared::Section { - title: "Roadmap & Feature-set".to_string(), - id: "roadmap--feature-set".to_string(), - level: 1usize, - }, - ::use_mdbook::mdbook_shared::Section { - title: "Features".to_string(), - id: "features".to_string(), - level: 2usize, - }, - ::use_mdbook::mdbook_shared::Section { - title: "Roadmap".to_string(), - id: "roadmap".to_string(), - level: 2usize, - }, - ::use_mdbook::mdbook_shared::Section { - title: "Core".to_string(), - id: "core".to_string(), - level: 3usize, - }, - ::use_mdbook::mdbook_shared::Section { - title: "SSR".to_string(), - id: "ssr".to_string(), - level: 3usize, - }, - ::use_mdbook::mdbook_shared::Section { - title: "Desktop".to_string(), - id: "desktop".to_string(), - level: 3usize, - }, - ::use_mdbook::mdbook_shared::Section { - title: "Mobile".to_string(), - id: "mobile".to_string(), - level: 3usize, - }, - ::use_mdbook::mdbook_shared::Section { - title: "Bundling (CLI)".to_string(), - id: "bundling-cli".to_string(), - level: 3usize, - }, - ::use_mdbook::mdbook_shared::Section { - title: "Essential hooks".to_string(), - id: "essential-hooks".to_string(), - level: 3usize, - }, - ::use_mdbook::mdbook_shared::Section { - title: "Work in Progress".to_string(), - id: "work-in-progress".to_string(), - level: 2usize, - }, - ::use_mdbook::mdbook_shared::Section { - title: "Build Tool".to_string(), - id: "build-tool".to_string(), - level: 3usize, - }, - ::use_mdbook::mdbook_shared::Section { - title: "Server Component Support".to_string(), - id: "server-component-support".to_string(), - level: 3usize, - }, - ::use_mdbook::mdbook_shared::Section { - title: "Native rendering".to_string(), - id: "native-rendering".to_string(), - level: 3usize, - }, - ::use_mdbook::mdbook_shared::Section { - title: "Internal Links".to_string(), - id: "internal-links".to_string(), - level: 2usize, - }, - ], - raw: String::new(), - id: ::use_mdbook::mdbook_shared::PageId(1usize), - } - }, - )); - _page_id_mapping - .insert( + ::use_mdbook::mdbook_shared::Section { + title: "Features".to_string(), + id: "features".to_string(), + level: 2usize, + }, + ::use_mdbook::mdbook_shared::Section { + title: "Roadmap".to_string(), + id: "roadmap".to_string(), + level: 2usize, + }, + ::use_mdbook::mdbook_shared::Section { + title: "Core".to_string(), + id: "core".to_string(), + level: 3usize, + }, + ::use_mdbook::mdbook_shared::Section { + title: "SSR".to_string(), + id: "ssr".to_string(), + level: 3usize, + }, + ::use_mdbook::mdbook_shared::Section { + title: "Desktop".to_string(), + id: "desktop".to_string(), + level: 3usize, + }, + ::use_mdbook::mdbook_shared::Section { + title: "Mobile".to_string(), + id: "mobile".to_string(), + level: 3usize, + }, + ::use_mdbook::mdbook_shared::Section { + title: "Bundling (CLI)".to_string(), + id: "bundling-cli".to_string(), + level: 3usize, + }, + ::use_mdbook::mdbook_shared::Section { + title: "Essential hooks".to_string(), + id: "essential-hooks".to_string(), + level: 3usize, + }, + ::use_mdbook::mdbook_shared::Section { + title: "Work in Progress".to_string(), + id: "work-in-progress".to_string(), + level: 2usize, + }, + ::use_mdbook::mdbook_shared::Section { + title: "Build Tool".to_string(), + id: "build-tool".to_string(), + level: 3usize, + }, + ::use_mdbook::mdbook_shared::Section { + title: "Server Component Support".to_string(), + id: "server-component-support".to_string(), + level: 3usize, + }, + ::use_mdbook::mdbook_shared::Section { + title: "Native rendering".to_string(), + id: "native-rendering".to_string(), + level: 3usize, + }, + ::use_mdbook::mdbook_shared::Section { + title: "Internal Links".to_string(), + id: "internal-links".to_string(), + level: 2usize, + }, + ], + raw: String::new(), + id: ::use_mdbook::mdbook_shared::PageId(1usize), + } + })); + _page_id_mapping.insert( BookRoute::Chapter2 { section: Chapter2Section::Empty, }, ::use_mdbook::mdbook_shared::PageId(1usize), ); - }; + }; __push_page_1(&mut pages, &mut page_id_mapping); - let __push_page_2: fn(_, _) = | - _pages: &mut Vec<_>, - _page_id_mapping: &mut std::collections::HashMap<_, _>| - { - _pages - .push(( - 2usize, - { - ::use_mdbook::mdbook_shared::Page { - title: "Chapter 3".to_string(), - url: BookRoute::Chapter3 { - section: Chapter3Section::Empty, - }, - segments: vec![], - sections: vec![ - ::use_mdbook::mdbook_shared::Section { - title: "Assets".to_string(), - id: "assets".to_string(), - level: 1usize, - }, - ], - raw: String::new(), - id: ::use_mdbook::mdbook_shared::PageId(2usize), - } - }, - )); - _page_id_mapping - .insert( + let __push_page_2: fn(_, _) = + |_pages: &mut Vec<_>, _page_id_mapping: &mut std::collections::HashMap<_, _>| { + _pages.push((2usize, { + ::use_mdbook::mdbook_shared::Page { + title: "Chapter 3".to_string(), + url: BookRoute::Chapter3 { + section: Chapter3Section::Empty, + }, + segments: vec![], + sections: vec![::use_mdbook::mdbook_shared::Section { + title: "Assets".to_string(), + id: "assets".to_string(), + level: 1usize, + }], + raw: String::new(), + id: ::use_mdbook::mdbook_shared::PageId(2usize), + } + })); + _page_id_mapping.insert( BookRoute::Chapter3 { section: Chapter3Section::Empty, }, ::use_mdbook::mdbook_shared::PageId(2usize), ); - }; + }; __push_page_2(&mut pages, &mut page_id_mapping); ::use_mdbook::mdbook_shared::MdBook { summary: ::use_mdbook::mdbook_shared::Summary { title: Some("Summary".to_string()), prefix_chapters: vec![], numbered_chapters: vec![ - ::use_mdbook::mdbook_shared::SummaryItem::Link(::use_mdbook::mdbook_shared::Link { - name: "Chapter 1".to_string(), - location: Some(BookRoute::Chapter1 { - section: Chapter1Section::Empty, - }), - number: Some( - ::use_mdbook::mdbook_shared::SectionNumber(vec![1u32]), - ), - nested_items: vec![], - }), - ::use_mdbook::mdbook_shared::SummaryItem::Link(::use_mdbook::mdbook_shared::Link { - name: "Chapter 2".to_string(), - location: Some(BookRoute::Chapter2 { - section: Chapter2Section::Empty, - }), - number: Some( - ::use_mdbook::mdbook_shared::SectionNumber(vec![2u32]), - ), - nested_items: vec![], - }), - ::use_mdbook::mdbook_shared::SummaryItem::Link(::use_mdbook::mdbook_shared::Link { - name: "Chapter 3".to_string(), - location: Some(BookRoute::Chapter3 { - section: Chapter3Section::Empty, - }), - number: Some( - ::use_mdbook::mdbook_shared::SectionNumber(vec![3u32]), - ), - nested_items: vec![], - }), + ::use_mdbook::mdbook_shared::SummaryItem::Link( + ::use_mdbook::mdbook_shared::Link { + name: "Chapter 1".to_string(), + location: Some(BookRoute::Chapter1 { + section: Chapter1Section::Empty, + }), + number: Some(::use_mdbook::mdbook_shared::SectionNumber(vec![1u32])), + nested_items: vec![], + }, + ), + ::use_mdbook::mdbook_shared::SummaryItem::Link( + ::use_mdbook::mdbook_shared::Link { + name: "Chapter 2".to_string(), + location: Some(BookRoute::Chapter2 { + section: Chapter2Section::Empty, + }), + number: Some(::use_mdbook::mdbook_shared::SectionNumber(vec![2u32])), + nested_items: vec![], + }, + ), + ::use_mdbook::mdbook_shared::SummaryItem::Link( + ::use_mdbook::mdbook_shared::Link { + name: "Chapter 3".to_string(), + location: Some(BookRoute::Chapter3 { + section: Chapter3Section::Empty, + }), + number: Some(::use_mdbook::mdbook_shared::SectionNumber(vec![3u32])), + nested_items: vec![], + }, + ), ], suffix_chapters: vec![], }, pages: pages.into_iter().collect(), page_id_mapping, } - } -}); + }); #[derive( - Clone, - Copy, - PartialEq, - Eq, - Hash, - Debug, - Default, - serde::Serialize, - serde::Deserialize + Clone, Copy, PartialEq, Eq, Hash, Debug, Default, serde::Serialize, serde::Deserialize, )] pub enum Chapter1Section { #[default] @@ -309,9 +276,7 @@ impl std::str::FromStr for Chapter1Section { "support" => Ok(Self::Support), "setup" => Ok(Self::Setup), _ => { - Err( - "Invalid section name. Expected one of Chapter1Sectionliveview, support, setup", - ) + Err("Invalid section name. Expected one of Chapter1Sectionliveview, support, setup") } } } @@ -373,15 +338,7 @@ pub fn Chapter1(section: Chapter1Section) -> Element { } } #[derive( - Clone, - Copy, - PartialEq, - Eq, - Hash, - Debug, - Default, - serde::Serialize, - serde::Deserialize + Clone, Copy, PartialEq, Eq, Hash, Debug, Default, serde::Serialize, serde::Deserialize, )] pub enum Chapter2Section { #[default] @@ -618,15 +575,7 @@ pub fn Chapter2(section: Chapter2Section) -> Element { } } #[derive( - Clone, - Copy, - PartialEq, - Eq, - Hash, - Debug, - Default, - serde::Serialize, - serde::Deserialize + Clone, Copy, PartialEq, Eq, Hash, Debug, Default, serde::Serialize, serde::Deserialize, )] pub enum Chapter3Section { #[default] diff --git a/packages/include_mdbook/packages/mdbook-gen/src/lib.rs b/packages/include_mdbook/packages/mdbook-gen/src/lib.rs index f478b1bbfb..e9c9d5ba11 100644 --- a/packages/include_mdbook/packages/mdbook-gen/src/lib.rs +++ b/packages/include_mdbook/packages/mdbook-gen/src/lib.rs @@ -328,4 +328,3 @@ pub(crate) fn path_to_route_enum_with_section( } }) } - diff --git a/packages/notion-to-blog/src/main.rs b/packages/notion-to-blog/src/main.rs index fadaf8fe72..306e7a4849 100644 --- a/packages/notion-to-blog/src/main.rs +++ b/packages/notion-to-blog/src/main.rs @@ -88,7 +88,11 @@ async fn process_markdown_file( .and_then(|s| s.to_str()) .unwrap_or("assets"); let input_assets_folder = md_path.parent().unwrap().join(assets_folder_name); - let output_assets_folder = output_md_path.parent().unwrap().join("assets").join(output_name); + let output_assets_folder = output_md_path + .parent() + .unwrap() + .join("assets") + .join(output_name); // Process images if assets folder exists let mut image_mapping = HashMap::new();