provide feature hints for the dioxus crate as well

This commit is contained in:
Evan Almloff committed 2024-02-09 12:23:57 -06:00
1 parent b4d17abfc1
commit 162b033c36
8 files changed
+59 -22

No files matched your search

+3
View File
@@ -55,6 +55,9 @@ warp = ["dioxus-fullstack?/warp", "ssr", "dioxus-liveview?/warp"]
rocket = ["dioxus-liveview?/rocket"]
tui = ["dioxus-tui", "dioxus-config-macro/tui"]
# This feature enables some nightly flags that make it more clear what structs/methods are available in each feature
nightly-doc = []
[dev-dependencies]
futures-util = { workspace = true }
tracing = { workspace = true }
+11 -12
View File
@@ -50,7 +50,7 @@ fn main() {
// It's not required, but highly recommended. For example, UpperCamelCase components will not generate a warning.
#[component]
fn App() -> Element {
rsx!("hello world!"))
rsx!("hello world!")
}
```
@@ -97,13 +97,12 @@ If we want to omit the boilerplate of `cx.render`, we can simply pass in
render nodes in match statements.
```rust, ignore
#[component[
#[component]
fn Example() -> Element {
// both of these are equivalent
rsx!("hello world"))
rsx!("hello world");
rsx!("hello world!")
rsx!("hello world!");
}
```
@@ -127,7 +126,7 @@ fn App() -> Element {
))
}
))
)
}
```
@@ -147,7 +146,7 @@ fn App() -> Element {
title: "My App",
color: "red",
}
))
)
}
```
@@ -169,7 +168,7 @@ fn Header(cx: Scope<HeaderProps>) -> Element {
background_color: "{cx.props.color}"
h1 { "{cx.props.title}" }
}
))
)
}
```
@@ -184,7 +183,7 @@ fn Header(title: String, color: String) -> Element {
background_color: "{color}"
h1 { "{title}" }
}
))
)
}
```
@@ -201,13 +200,13 @@ struct HeaderProps<'a> {
}
#[component]
fn Header(props: HeaderProps -> Element {
fn Header(props: HeaderProps) -> Element {
rsx!(
div {
background_color: "{cx.props.color}"
h1 { "{cx.props.title}" }
}
))
)
}
```
@@ -299,7 +298,7 @@ fn App() -> Element {
div { "Count: {count}" }
button { onclick: move |_| count.set(count + 1), "Increment" }
button { onclick: move |_| count.set(count - 1), "Decrement" }
))
)
}
```
+9
View File
@@ -38,6 +38,7 @@ impl LaunchBuilder {
/// Launch your web application.
#[cfg(feature = "web")]
#[cfg_attr(any(docsrs, feature = "nightly-doc"), doc(cfg(feature = "web")))]
pub fn web() -> LaunchBuilder<dioxus_web::Config, UnsendContext> {
LaunchBuilder {
launch_fn: dioxus_web::launch::launch,
@@ -48,6 +49,7 @@ impl LaunchBuilder {
/// Launch your desktop application.
#[cfg(feature = "desktop")]
#[cfg_attr(any(docsrs, feature = "nightly-doc"), doc(cfg(feature = "desktop")))]
pub fn desktop() -> LaunchBuilder<dioxus_desktop::Config, UnsendContext> {
LaunchBuilder {
launch_fn: dioxus_desktop::launch::launch,
@@ -58,6 +60,7 @@ impl LaunchBuilder {
/// Launch your fullstack application.
#[cfg(feature = "fullstack")]
#[cfg_attr(any(docsrs, feature = "nightly-doc"), doc(cfg(feature = "fullstack")))]
pub fn fullstack() -> LaunchBuilder<dioxus_fullstack::Config, SendContext> {
LaunchBuilder {
launch_fn: dioxus_fullstack::launch::launch,
@@ -68,6 +71,7 @@ impl LaunchBuilder {
/// Launch your fullstack application.
#[cfg(feature = "mobile")]
#[cfg_attr(any(docsrs, feature = "nightly-doc"), doc(cfg(feature = "mobile")))]
pub fn mobile() -> LaunchBuilder<dioxus_mobile::Config, UnsendContext> {
LaunchBuilder {
launch_fn: dioxus_mobile::launch::launch,
@@ -77,6 +81,7 @@ impl LaunchBuilder {
}
#[cfg(feature = "tui")]
#[cfg_attr(any(docsrs, feature = "nightly-doc"), doc(cfg(feature = "tui")))]
/// Launch your tui application
pub fn tui() -> LaunchBuilder<dioxus_tui::Config, UnsendContext> {
LaunchBuilder {
@@ -209,24 +214,28 @@ pub fn launch(app: fn() -> Element) {
}
#[cfg(feature = "web")]
#[cfg_attr(any(docsrs, feature = "nightly-doc"), doc(cfg(feature = "web")))]
/// Launch your web application without any additional configuration. See [`LaunchBuilder`] for more options.
pub fn launch_web(app: fn() -> Element) {
LaunchBuilder::web().launch(app)
}
#[cfg(feature = "desktop")]
#[cfg_attr(any(docsrs, feature = "nightly-doc"), doc(cfg(feature = "desktop")))]
/// Launch your desktop application without any additional configuration. See [`LaunchBuilder`] for more options.
pub fn launch_desktop(app: fn() -> Element) {
LaunchBuilder::desktop().launch(app)
}
#[cfg(feature = "fullstack")]
#[cfg_attr(any(docsrs, feature = "nightly-doc"), doc(cfg(feature = "fullstack")))]
/// Launch your fullstack application without any additional configuration. See [`LaunchBuilder`] for more options.
pub fn launch_fullstack(app: fn() -> Element) {
LaunchBuilder::fullstack().launch(app)
}
#[cfg(feature = "tui")]
#[cfg_attr(any(docsrs, feature = "nightly-doc"), doc(cfg(feature = "tui")))]
/// Launch your tui application without any additional configuration. See [`LaunchBuilder`] for more options.
pub fn launch_tui(app: fn() -> Element) {
LaunchBuilder::tui().launch(app)
+26
View File
@@ -1,88 +1,114 @@
#![doc = include_str!("../README.md")]
#![doc(html_logo_url = "https://avatars.githubusercontent.com/u/79236386")]
#![doc(html_favicon_url = "https://avatars.githubusercontent.com/u/79236386")]
#![cfg_attr(any(docsrs, feature = "nightly-doc"), feature(doc_cfg))]
pub use dioxus_core;
#[cfg(feature = "launch")]
#[cfg_attr(any(docsrs, feature = "nightly-doc"), doc(cfg(feature = "launch")))]
mod launch;
#[cfg(feature = "hooks")]
#[cfg_attr(any(docsrs, feature = "nightly-doc"), doc(cfg(feature = "hooks")))]
pub use dioxus_hooks as hooks;
#[cfg(feature = "signals")]
#[cfg_attr(any(docsrs, feature = "nightly-doc"), doc(cfg(feature = "signals")))]
pub use dioxus_signals as signals;
pub mod events {
#[cfg(feature = "html")]
#[cfg_attr(any(docsrs, feature = "nightly-doc"), doc(cfg(feature = "html")))]
pub use dioxus_html::prelude::*;
}
#[cfg(feature = "html")]
#[cfg_attr(any(docsrs, feature = "nightly-doc"), doc(cfg(feature = "html")))]
pub use dioxus_html as html;
#[cfg(feature = "macro")]
#[cfg_attr(any(docsrs, feature = "nightly-doc"), doc(cfg(feature = "macro")))]
pub use dioxus_core_macro as core_macro;
pub mod prelude {
#[cfg(feature = "launch")]
#[cfg_attr(any(docsrs, feature = "nightly-doc"), doc(cfg(feature = "launch")))]
pub use crate::launch::*;
#[cfg(feature = "hooks")]
#[cfg_attr(any(docsrs, feature = "nightly-doc"), doc(cfg(feature = "hooks")))]
pub use crate::hooks::*;
#[cfg(feature = "signals")]
#[cfg_attr(any(docsrs, feature = "nightly-doc"), doc(cfg(feature = "signals")))]
pub use dioxus_signals::*;
pub use dioxus_core::prelude::*;
#[cfg(feature = "macro")]
#[cfg_attr(any(docsrs, feature = "nightly-doc"), doc(cfg(feature = "macro")))]
#[allow(deprecated)]
pub use dioxus_core_macro::{component, format_args_f, inline_props, render, rsx, Props};
#[cfg(feature = "launch")]
#[cfg_attr(any(docsrs, feature = "nightly-doc"), doc(cfg(feature = "launch")))]
pub use dioxus_config_macro::*;
#[cfg(feature = "html")]
#[cfg_attr(any(docsrs, feature = "nightly-doc"), doc(cfg(feature = "html")))]
pub use dioxus_html as dioxus_elements;
#[cfg(feature = "html")]
#[cfg_attr(any(docsrs, feature = "nightly-doc"), doc(cfg(feature = "html")))]
pub use dioxus_elements::{prelude::*, GlobalAttributes, SvgAttributes};
#[cfg(all(not(target_arch = "wasm32"), feature = "hot-reload"))]
#[cfg_attr(any(docsrs, feature = "nightly-doc"), doc(cfg(feature = "hot-reload")))]
pub use dioxus_hot_reload::{self, hot_reload_init};
pub use dioxus_core;
#[cfg(feature = "fullstack")]
#[cfg_attr(any(docsrs, feature = "nightly-doc"), doc(cfg(feature = "fullstack")))]
pub use dioxus_fullstack::prelude::*;
#[cfg(feature = "router")]
#[cfg_attr(any(docsrs, feature = "nightly-doc"), doc(cfg(feature = "router")))]
pub use dioxus_router;
#[cfg(feature = "router")]
#[cfg_attr(any(docsrs, feature = "nightly-doc"), doc(cfg(feature = "router")))]
pub use dioxus_router::prelude::*;
}
#[cfg(feature = "web")]
#[cfg_attr(any(docsrs, feature = "nightly-doc"), doc(cfg(feature = "web")))]
pub use dioxus_web as web;
#[cfg(feature = "router")]
#[cfg_attr(any(docsrs, feature = "nightly-doc"), doc(cfg(feature = "router")))]
pub use dioxus_router as router;
#[cfg(feature = "fullstack")]
#[cfg_attr(any(docsrs, feature = "nightly-doc"), doc(cfg(feature = "fullstack")))]
pub use dioxus_fullstack as fullstack;
#[cfg(feature = "desktop")]
#[cfg_attr(any(docsrs, feature = "nightly-doc"), doc(cfg(feature = "desktop")))]
pub use dioxus_desktop as desktop;
#[cfg(feature = "mobile")]
#[cfg_attr(any(docsrs, feature = "nightly-doc"), doc(cfg(feature = "mobile")))]
pub use dioxus_desktop as mobile;
#[cfg(feature = "liveview")]
#[cfg_attr(any(docsrs, feature = "nightly-doc"), doc(cfg(feature = "liveview")))]
pub use dioxus_liveview as liveview;
#[cfg(feature = "tui")]
#[cfg_attr(any(docsrs, feature = "nightly-doc"), doc(cfg(feature = "tui")))]
pub use dioxus_tui as tui;
#[cfg(feature = "ssr")]
#[cfg_attr(any(docsrs, feature = "nightly-doc"), doc(cfg(feature = "ssr")))]
pub use dioxus_ssr as ssr;