set up example scaping for docs.rs (#2450)

This commit is contained in:
Evan Almloff 2024-05-28 22:05:55 +02:00 committed by GitHub
parent afc1c7f31a
commit b3cd4fac10
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
36 changed files with 372 additions and 29 deletions

7
Cargo.lock generated
View file

@ -2299,18 +2299,23 @@ dependencies = [
"dioxus-hot-reload",
"dioxus-html",
"dioxus-interpreter-js",
"dioxus-ssr",
"dunce",
"exitcode",
"futures-channel",
"futures-util",
"generational-box 0.5.2",
"global-hotkey",
"http-range",
"infer 0.11.0",
"muda",
"objc",
"objc_id",
"rand 0.8.5",
"reqwest",
"rfd",
"rustc-hash",
"separator",
"serde",
"serde_json",
"signal-hook",
@ -2577,6 +2582,8 @@ name = "dioxus-router"
version = "0.5.2"
dependencies = [
"axum",
"base64 0.21.7",
"ciborium",
"console_error_panic_hook",
"criterion 0.5.1",
"dioxus",

View file

@ -118,9 +118,6 @@ axum-extra = "0.9.2"
reqwest = "0.11.24"
owo-colors = "4.0.0"
[workspace.dev-dependencies]
isnta = "1.36.1"
# speed up some macros by optimizing them
[profile.dev.package.insta]
opt-level = 3
@ -199,27 +196,139 @@ http = ["reqwest", "http-range"]
[[example]]
name = "login_form"
required-features = ["http"]
doc-scrape-examples = true
[[example]]
name = "dog_app"
required-features = ["http"]
doc-scrape-examples = true
[[example]]
name = "video_stream"
required-features = ["http"]
required-features = ["http", "desktop"]
doc-scrape-examples = true
[[example]]
name = "suspense"
required-features = ["http"]
required-features = ["http", "desktop"]
doc-scrape-examples = true
[[example]]
name = "weather_app"
required-features = ["http"]
doc-scrape-examples = true
[[example]]
name = "image_generator_openai"
required-features = ["http"]
doc-scrape-examples = true
[[example]]
name = "hash_fragment_state"
required-features = ["ciborium", "base64"]
doc-scrape-examples = true
[[example]]
name = "backgrounded_futures"
required-features = ["desktop"]
doc-scrape-examples = true
[[example]]
name = "calculator_mutable"
required-features = ["desktop"]
doc-scrape-examples = true
[[example]]
name = "calculator"
required-features = ["desktop"]
doc-scrape-examples = true
[[example]]
name = "clock"
required-features = ["desktop"]
doc-scrape-examples = true
[[example]]
name = "crm"
required-features = ["desktop"]
doc-scrape-examples = true
[[example]]
name = "custom_html"
required-features = ["desktop"]
doc-scrape-examples = true
[[example]]
name = "custom_menu"
required-features = ["desktop"]
doc-scrape-examples = true
[[example]]
name = "dynamic_asset"
required-features = ["desktop"]
doc-scrape-examples = true
[[example]]
name = "error_handle"
required-features = ["desktop"]
doc-scrape-examples = true
[[example]]
name = "file_explorer"
required-features = ["desktop"]
doc-scrape-examples = true
[[example]]
name = "future"
required-features = ["desktop"]
doc-scrape-examples = true
[[example]]
name = "hydration"
required-features = ["desktop"]
doc-scrape-examples = true
[[example]]
name = "multiwindow"
required-features = ["desktop"]
doc-scrape-examples = true
[[example]]
name = "overlay"
required-features = ["desktop"]
doc-scrape-examples = true
[[example]]
name = "popup"
required-features = ["desktop"]
doc-scrape-examples = true
[[example]]
name = "read_size"
required-features = ["desktop"]
doc-scrape-examples = true
[[example]]
name = "shortcut"
required-features = ["desktop"]
doc-scrape-examples = true
[[example]]
name = "streams"
required-features = ["desktop"]
doc-scrape-examples = true
[[example]]
name = "window_event"
required-features = ["desktop"]
doc-scrape-examples = true
[[example]]
name = "window_focus"
required-features = ["desktop"]
doc-scrape-examples = true
[[example]]
name = "window_zoom"
required-features = ["desktop"]
doc-scrape-examples = true

View file

@ -7,7 +7,7 @@ use dioxus::prelude::*;
use std::fmt::Display;
fn main() {
launch_desktop(app);
launch(app);
}
fn app() -> Element {

View file

@ -9,7 +9,7 @@
use dioxus::prelude::*;
fn main() {
launch_desktop(app);
launch(app);
}
fn app() -> Element {

View file

@ -9,7 +9,7 @@
use dioxus::prelude::*;
fn main() {
launch_desktop(app);
launch(app);
}
fn app() -> Element {

View file

@ -6,7 +6,7 @@
use dioxus::prelude::*;
fn main() {
launch_desktop(app);
launch(app);
}
fn app() -> Element {

View file

@ -8,7 +8,7 @@
use dioxus::prelude::*;
fn main() {
launch_desktop(app);
launch(app);
}
fn app() -> Element {

View file

@ -3,7 +3,7 @@
use dioxus::prelude::*;
fn main() {
launch_desktop(app);
launch(app);
}
fn app() -> Element {

View file

@ -10,7 +10,7 @@ use dioxus::prelude::*;
use std::time::Duration;
fn main() {
launch_desktop(app);
launch(app);
}
fn app() -> Element {

View file

@ -5,7 +5,7 @@
use dioxus::prelude::*;
fn main() {
launch_desktop(app);
launch(app);
}
fn app() -> Element {

View file

@ -25,3 +25,6 @@ prettyplease = { workspace = true }
[dev-dependencies]
pretty_assertions = "1.2.1"
[package.metadata.docs.rs]
cargo-args = ["-Zunstable-options", "-Zrustdoc-scrape-examples"]

View file

@ -159,11 +159,11 @@ impl Display for IssueReport {
#[allow(clippy::enum_variant_names)] // we'll add non-hook ones in the future
/// Issues that might be found via static analysis of a Dioxus file.
pub enum Issue {
/// https://dioxuslabs.com/learn/0.5/reference/hooks#no-hooks-in-conditionals
/// <https://dioxuslabs.com/learn/0.5/reference/hooks#no-hooks-in-conditionals>
HookInsideConditional(HookInfo, ConditionalInfo),
/// https://dioxuslabs.com/learn/0.5/reference/hooks#no-hooks-in-loops
/// <https://dioxuslabs.com/learn/0.5/reference/hooks#no-hooks-in-loops>
HookInsideLoop(HookInfo, AnyLoopInfo),
/// https://dioxuslabs.com/learn/0.5/reference/hooks#no-hooks-in-closures
/// <https://dioxuslabs.com/learn/0.5/reference/hooks#no-hooks-in-closures>
HookInsideClosure(HookInfo, ClosureInfo),
HookOutsideComponent(HookInfo),
}

View file

@ -25,3 +25,6 @@ tauri-utils = { version = "=1.5.*", optional = true }
default = ["read-config"]
cli = ["tauri-bundler", "tauri-utils", "clap", "toml", "cargo_toml"]
read-config = []
[package.metadata.docs.rs]
cargo-args = ["-Zunstable-options", "-Zrustdoc-scrape-examples"]

View file

@ -25,3 +25,6 @@ mobile = []
web = []
ssr = []
liveview = []
[package.metadata.docs.rs]
cargo-args = ["-Zunstable-options", "-Zrustdoc-scrape-examples"]

View file

@ -29,3 +29,6 @@ trybuild = "1.0"
[features]
default = []
[package.metadata.docs.rs]
cargo-args = ["-Zunstable-options", "-Zrustdoc-scrape-examples"]

View file

@ -35,3 +35,6 @@ reqwest = { workspace = true}
[features]
default = []
serialize = ["serde"]
[package.metadata.docs.rs]
cargo-args = ["-Zunstable-options", "-Zrustdoc-scrape-examples"]

View file

@ -81,10 +81,16 @@ gnu = []
[package.metadata.docs.rs]
default-features = false
features = ["tokio_runtime", "hot-reload"]
cargo-args = ["-Zunstable-options", "-Zrustdoc-scrape-examples"]
[dev-dependencies]
dioxus = { workspace = true, features = ["desktop"] }
exitcode = "1.1.2"
reqwest = { version = "0.11.9", features = ["json"] }
http-range = { version = "0.1.5" }
dioxus-ssr = { workspace = true, version = "0.5.0", default-features = false }
separator = "0.4.1"
rand = { version = "0.8.4", features = ["small_rng"] }
# These tests need to be run on the main thread, so they cannot use rust's test harness.
[[test]]
@ -101,3 +107,114 @@ harness = false
name = "check_eval"
path = "headless_tests/eval.rs"
harness = false
# Most of the examples live in the workspace. We include some here so that docs.rs can scrape our examples for better inline docs
[[example]]
name = "video_stream"
path = "../../examples/video_stream.rs"
doc-scrape-examples = true
[[example]]
name = "suspense"
path = "../../examples/suspense.rs"
doc-scrape-examples = true
[[example]]
name = "calculator_mutable"
path = "../../examples/calculator_mutable.rs"
doc-scrape-examples = true
[[example]]
name = "calculator"
path = "../../examples/calculator.rs"
doc-scrape-examples = true
[[example]]
name = "clock"
path = "../../examples/clock.rs"
doc-scrape-examples = true
[[example]]
name = "crm"
path = "../../examples/crm.rs"
doc-scrape-examples = true
[[example]]
name = "custom_html"
path = "../../examples/custom_html.rs"
doc-scrape-examples = true
[[example]]
name = "custom_menu"
path = "../../examples/custom_menu.rs"
doc-scrape-examples = true
[[example]]
name = "dynamic_asset"
path = "../../examples/dynamic_asset.rs"
doc-scrape-examples = true
[[example]]
name = "error_handle"
path = "../../examples/error_handle.rs"
doc-scrape-examples = true
[[example]]
name = "file_explorer"
path = "../../examples/file_explorer.rs"
doc-scrape-examples = true
[[example]]
name = "future"
path = "../../examples/future.rs"
doc-scrape-examples = true
[[example]]
name = "hydration"
path = "../../examples/hydration.rs"
doc-scrape-examples = true
[[example]]
name = "multiwindow"
path = "../../examples/multiwindow.rs"
doc-scrape-examples = true
[[example]]
name = "overlay"
path = "../../examples/overlay.rs"
doc-scrape-examples = true
[[example]]
name = "popup"
path = "../../examples/popup.rs"
doc-scrape-examples = true
[[example]]
name = "read_size"
path = "../../examples/read_size.rs"
doc-scrape-examples = true
[[example]]
name = "shortcut"
path = "../../examples/shortcut.rs"
doc-scrape-examples = true
[[example]]
name = "streams"
path = "../../examples/streams.rs"
doc-scrape-examples = true
[[example]]
name = "window_event"
path = "../../examples/window_event.rs"
doc-scrape-examples = true
[[example]]
name = "window_focus"
path = "../../examples/window_focus.rs"
doc-scrape-examples = true
[[example]]
name = "window_zoom"
path = "../../examples/window_zoom.rs"
doc-scrape-examples = true

View file

@ -25,6 +25,9 @@ dioxus = { workspace = true }
[features]
default = ["macro", "html", "signals", "hooks"]
signals = ["dioxus-signals"]
macro = ["dioxus-core-macro", "dioxus-rsx"]
macro = ["dioxus-core-macro", "dioxus-rsx", "dioxus-config-macro"]
html = ["dioxus-html"]
hooks = ["dioxus-hooks"]
[package.metadata.docs.rs]
cargo-args = ["-Zunstable-options", "-Zrustdoc-scrape-examples"]

View file

@ -35,7 +35,7 @@ pub mod prelude {
#[allow(deprecated)]
pub use dioxus_core_macro::{component, format_args_f, inline_props, render, rsx, Props};
#[cfg(feature = "launch")]
#[cfg(feature = "macro")]
pub use dioxus_config_macro::*;
#[cfg(feature = "html")]

View file

@ -67,3 +67,6 @@ tokio = { workspace = true, features = ["full"] }
[[bench]]
name = "jsframework"
harness = false
[package.metadata.docs.rs]
cargo-args = ["-Zunstable-options", "-Zrustdoc-scrape-examples"]

View file

@ -96,3 +96,7 @@ server = [
"thiserror",
"dioxus-cli-config"
]
[package.metadata.docs.rs]
cargo-args = ["-Zunstable-options", "-Zrustdoc-scrape-examples"]
features = ["axum", "web"]

View file

@ -25,3 +25,6 @@ debug_ownership = []
[[bench]]
name = "lock"
harness = false
[package.metadata.docs.rs]
cargo-args = ["-Zunstable-options", "-Zrustdoc-scrape-examples"]

View file

@ -30,3 +30,6 @@ dioxus-core = { workspace = true }
dioxus = { workspace = true }
web-sys = { version = "0.3.64", features = ["Document", "Window", "Element"] }
tokio = { version = "1.0", features = ["full"] }
[package.metadata.docs.rs]
cargo-args = ["-Zunstable-options", "-Zrustdoc-scrape-examples"]

View file

@ -38,3 +38,6 @@ default = ["dioxus-html"]
custom_file_watcher = ["ignore", "chrono", "notify", "execute", "once_cell", "ignore"]
file_watcher = ["custom_file_watcher", "dioxus-html/hot-reload-context"]
serve = ["axum", "tokio-stream", "futures-util", "tokio", "file_watcher"]
[package.metadata.docs.rs]
cargo-args = ["-Zunstable-options", "-Zrustdoc-scrape-examples"]

View file

@ -78,3 +78,7 @@ wasm-bind = ["web-sys", "wasm-bindgen"]
native-bind = ["tokio"]
hot-reload-context = ["dioxus-rsx"]
html-to-rsx = []
[package.metadata.docs.rs]
cargo-args = ["-Zunstable-options", "-Zrustdoc-scrape-examples"]
feature = ["html-to-rsx", "hot-reload-context", "html-to-rsx", "native-bind", "wasm-bind"]

View file

@ -49,7 +49,9 @@ hot-reload = ["dioxus-hot-reload"]
[[example]]
name = "axum"
required-features = ["axum"]
doc-scrape-examples = true
[[example]]
name = "axum_stress"
required-features = ["axum"]
doc-scrape-examples = true

View file

@ -16,3 +16,6 @@ dioxus-desktop = { workspace = true, features = ["tokio_runtime"] }
doctest = false
# tests suspended until package ready
test = false
[package.metadata.docs.rs]
cargo-args = ["-Zunstable-options", "-Zrustdoc-scrape-examples"]

View file

@ -26,3 +26,6 @@ dioxus = { workspace = true, features = ["router"] }
[features]
default = []
web = []
[package.metadata.docs.rs]
cargo-args = ["-Zunstable-options", "-Zrustdoc-scrape-examples"]

View file

@ -31,6 +31,15 @@ dioxus-fullstack = { workspace = true, optional = true }
tokio = { workspace = true, features = ["full"], optional = true }
dioxus-cli-config = { workspace = true, features = ["read-config"] }
# you need to comment this out when publishing since cargo workspaces is not smart enough to wipe this when dropping
# dev-dependncey crates
[target.'cfg(target_family = "wasm")'.dev-dependencies]
console_error_panic_hook = "0.1.7"
dioxus-router = { workspace = true, features = ["web"] }
# dioxus-web = { workspace = true }
gloo = "0.8.0"
wasm-bindgen-test = "0.3.33"
[features]
default = []
ssr = ["dioxus-ssr/incremental", "tokio", "dioxus-fullstack?/server", "http"]
@ -44,21 +53,55 @@ axum = { workspace = true, features = ["ws"] }
dioxus = { workspace = true, features = ["router"] }
dioxus-ssr = { workspace = true }
criterion = { version = "0.5", features = ["async_tokio", "html_reports"] }
ciborium = { version = "0.2.1" }
base64 = { version = "0.21.0" }
serde = { version = "1", features = ["derive"] }
[[example]]
name = "static_generation"
required-features = ["ssr"]
[package.metadata.docs.rs]
cargo-args = ["-Zunstable-options", "-Zrustdoc-scrape-examples"]
[[bench]]
name = "incremental"
required-features = ["ssr"]
harness = false
# you need to comment this out when publishing since cargo workspaces is not smart enough to wipe this when dropping
# dev-dependncey crates
[target.'cfg(target_family = "wasm")'.dev-dependencies]
console_error_panic_hook = "0.1.7"
dioxus-router = { workspace = true, features = ["web"] }
# dioxus-web = { workspace = true }
gloo = "0.8.0"
wasm-bindgen-test = "0.3.33"
# Most of the examples live in the workspace. We include some here so that docs.rs can scrape our examples for better inline docs
[[example]]
name = "crm"
path = "../../examples/crm.rs"
doc-scrape-examples = true
[[example]]
name = "flat_router"
path = "../../examples/flat_router.rs"
doc-scrape-examples = true
[[example]]
name = "hash_fragment_state"
path = "../../examples/hash_fragment_state.rs"
doc-scrape-examples = true
[[example]]
name = "link"
path = "../../examples/link.rs"
doc-scrape-examples = true
[[example]]
name = "query_segment_search"
path = "../../examples/query_segment_search.rs"
doc-scrape-examples = true
[[example]]
name = "router"
path = "../../examples/router.rs"
doc-scrape-examples = true
[[example]]
name = "simple_router"
path = "../../examples/simple_router.rs"
doc-scrape-examples = true
[[example]]
name = "static_generation"
required-features = ["ssr"]
doc-scrape-examples = true

View file

@ -29,3 +29,6 @@ convert_case = "0.5.0"
[dev-dependencies]
pretty_assertions = "1.2.1"
[package.metadata.docs.rs]
cargo-args = ["-Zunstable-options", "-Zrustdoc-scrape-examples"]

View file

@ -31,3 +31,6 @@ html = []
[dev-dependencies]
insta = "1.36.1"
[package.metadata.docs.rs]
cargo-args = ["-Zunstable-options", "-Zrustdoc-scrape-examples"]

View file

@ -26,3 +26,6 @@ proc-macro = true
axum = ["server_fn_macro/axum"]
server = ["server_fn_macro/ssr"]
reqwest = ["server_fn_macro/reqwest"]
[package.metadata.docs.rs]
cargo-args = ["-Zunstable-options", "-Zrustdoc-scrape-examples"]

View file

@ -32,3 +32,6 @@ simple_logger = "4.2.0"
[features]
default = []
serialize = ["serde"]
[package.metadata.docs.rs]
cargo-args = ["-Zunstable-options", "-Zrustdoc-scrape-examples"]

View file

@ -44,3 +44,6 @@ fs_extra = "1.2.0"
[features]
default = []
incremental = ["dep:tokio", "chrono", "dioxus-cli-config"]
[package.metadata.docs.rs]
cargo-args = ["-Zunstable-options", "-Zrustdoc-scrape-examples"]

View file

@ -32,3 +32,6 @@ dioxus = { workspace = true }
default = []
server = ["dioxus-fullstack/server", "dioxus-router/ssr", "dioxus-ssr", "tokio", "http", "dep:axum", "tower-http", "dioxus-hot-reload", "dioxus-cli-config", "tower"]
web = ["dioxus-fullstack/web", "dioxus-router/web", "dioxus-web"]
[package.metadata.docs.rs]
cargo-args = ["-Zunstable-options", "-Zrustdoc-scrape-examples"]

View file

@ -73,3 +73,6 @@ gloo-timers = "0.2.3"
gloo-dialogs = "0.1.1"
dioxus-web = { path = ".", features = ["hydrate"] }
tracing-wasm = "0.2.1"
[package.metadata.docs.rs]
cargo-args = ["-Zunstable-options", "-Zrustdoc-scrape-examples"]