deny missing docs in router
This commit is contained in:
6 files changed
+71
-22
No files matched your search
@@ -111,7 +111,7 @@ where
|
|||||||
///
|
///
|
||||||
/// # Returns
|
/// # Returns
|
||||||
/// 1. The [`RouterService`].
|
/// 1. The [`RouterService`].
|
||||||
/// 2. A [`Sender`] to send [`RouterMessage`]s to the [`RouterService`].
|
/// 2. An [`UnboundedSender`] to send [`RouterMessage`]s to the [`RouterService`].
|
||||||
/// 3. Access to the [`RouterState`]. **DO NOT WRITE TO THIS!!!** Seriously, **READ ONLY!!!**
|
/// 3. Access to the [`RouterState`]. **DO NOT WRITE TO THIS!!!** Seriously, **READ ONLY!!!**
|
||||||
#[allow(clippy::type_complexity)]
|
#[allow(clippy::type_complexity)]
|
||||||
pub fn new(
|
pub fn new(
|
||||||
|
|||||||
@@ -51,15 +51,63 @@
|
|||||||
|
|
||||||
Dioxus Router is a first-party Router for all your Dioxus Apps. It provides a React-Router style interface that works anywhere: across the browser, SSR, and natively.
|
Dioxus Router is a first-party Router for all your Dioxus Apps. It provides a React-Router style interface that works anywhere: across the browser, SSR, and natively.
|
||||||
|
|
||||||
```rust, ignore
|
```rust ,no_run
|
||||||
fn app() {
|
use dioxus::prelude::*;
|
||||||
cx.render(rsx! {
|
use dioxus_router::prelude::*;
|
||||||
Router {
|
|
||||||
Route { to: "/", Component {} },
|
fn App(cx: Scope) -> Element {
|
||||||
Route { to: "/blog", Blog {} },
|
use_router(
|
||||||
Route { to: "/blog/:id", BlogPost {} },
|
&cx,
|
||||||
|
&|| Default::default(),
|
||||||
|
&|| Segment::content(comp(Index)).fixed(
|
||||||
|
"blog",
|
||||||
|
Route::content(comp(Blog)).nested(
|
||||||
|
Segment::content(comp(BlogList))
|
||||||
|
.catch_all((comp(BlogPost), BlogPost))
|
||||||
|
)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
render! {
|
||||||
|
Outlet { }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn Index(cx: Scope) -> Element {
|
||||||
|
render! {
|
||||||
|
h1 { "Index" }
|
||||||
|
Link {
|
||||||
|
target: "/blog",
|
||||||
|
"Go to the blog"
|
||||||
}
|
}
|
||||||
})
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn Blog(cx: Scope) -> Element {
|
||||||
|
render! {
|
||||||
|
h1 { "Blog" }
|
||||||
|
Outlet { }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn BlogList(cx: Scope) -> Element {
|
||||||
|
render! {
|
||||||
|
h2 { "List of blog posts" }
|
||||||
|
Link {
|
||||||
|
target: "/blog/1",
|
||||||
|
"Blog post 1"
|
||||||
|
}
|
||||||
|
Link {
|
||||||
|
target: "/blog/1",
|
||||||
|
"Blog post 2"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn BlogPost(cx: Scope) -> Element {
|
||||||
|
render! {
|
||||||
|
h2 { "Blog Post" }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|||||||
@@ -10,6 +10,8 @@ use crate::{RouterError, utils::use_router_internal::use_router_internal};
|
|||||||
/// component calling the [`use_router`] hook.
|
/// component calling the [`use_router`] hook.
|
||||||
/// - Otherwise [`Ok`].
|
/// - Otherwise [`Ok`].
|
||||||
///
|
///
|
||||||
|
/// [`use_router`]: crate::hooks::use_router
|
||||||
|
///
|
||||||
/// # Panic
|
/// # Panic
|
||||||
/// - When the calling component is not nested within another component calling the [`use_router`]
|
/// - When the calling component is not nested within another component calling the [`use_router`]
|
||||||
/// hook, but only in debug builds.
|
/// hook, but only in debug builds.
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ use async_rwlock::RwLockReadGuard;
|
|||||||
use dioxus::{core::Component, prelude::ScopeState};
|
use dioxus::{core::Component, prelude::ScopeState};
|
||||||
use dioxus_router_core::RouterState;
|
use dioxus_router_core::RouterState;
|
||||||
|
|
||||||
use crate::{RouterError, utils::use_router_internal::use_router_internal};
|
use crate::{utils::use_router_internal::use_router_internal, RouterError};
|
||||||
|
|
||||||
/// A hook that provides access to information about the current routing location.
|
/// A hook that provides access to information about the current routing location.
|
||||||
///
|
///
|
||||||
@@ -55,7 +55,7 @@ use crate::{RouterError, utils::use_router_internal::use_router_internal};
|
|||||||
/// # assert_eq!(dioxus_ssr::render(&vdom), "<h1>App</h1><h2>Current Path</h2><p>/some/path</p>")
|
/// # assert_eq!(dioxus_ssr::render(&vdom), "<h1>App</h1><h2>Current Path</h2><p>/some/path</p>")
|
||||||
/// ```
|
/// ```
|
||||||
///
|
///
|
||||||
/// [`use_router`]: super::use_router
|
/// [`use_router`]: crate::hooks::use_router
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn use_route<'a>(
|
pub fn use_route<'a>(
|
||||||
cx: &'a ScopeState,
|
cx: &'a ScopeState,
|
||||||
|
|||||||
@@ -27,15 +27,16 @@ use crate::{
|
|||||||
///
|
///
|
||||||
/// # Return values
|
/// # Return values
|
||||||
/// This hook returns the current router state and a navigator. For more information about the
|
/// This hook returns the current router state and a navigator. For more information about the
|
||||||
/// state, see the [`use_route`](super::use_route) hook. For more information about the
|
/// state, see the [`use_route`](crate::hooks::use_route) hook. For more information about the
|
||||||
/// [`Navigator`], see its own documentation and the [`use_navigate`](super::use_navigate) hook.
|
/// [`Navigator`], see its own documentation and the [`use_navigate`](crate::hooks::use_navigate)
|
||||||
|
/// hook.
|
||||||
///
|
///
|
||||||
/// # Panic
|
/// # Panic
|
||||||
/// - When used within a component, that is nested inside another component calling [`use_router`],
|
/// - When used within a component, that is nested inside another component calling [`use_router`],
|
||||||
/// but only in debug builds.
|
/// but only in debug builds.
|
||||||
///
|
///
|
||||||
/// # Example
|
/// # Example
|
||||||
/// ```rust,no_run
|
/// ```rust
|
||||||
/// # use dioxus::prelude::*;
|
/// # use dioxus::prelude::*;
|
||||||
/// # use dioxus_router::prelude::*;
|
/// # use dioxus_router::prelude::*;
|
||||||
/// fn App(cx: Scope) -> Element {
|
/// fn App(cx: Scope) -> Element {
|
||||||
@@ -129,7 +130,7 @@ pub fn use_router<'a>(
|
|||||||
/// Global configuration options for the router.
|
/// Global configuration options for the router.
|
||||||
///
|
///
|
||||||
/// This implements [`Default`], so you can use it like this:
|
/// This implements [`Default`], so you can use it like this:
|
||||||
/// ```rust
|
/// ```rust,no_run
|
||||||
/// # use dioxus_router::prelude::RouterConfiguration;
|
/// # use dioxus_router::prelude::RouterConfiguration;
|
||||||
/// let cfg = RouterConfiguration {
|
/// let cfg = RouterConfiguration {
|
||||||
/// synchronous: false,
|
/// synchronous: false,
|
||||||
|
|||||||
@@ -1,5 +1,8 @@
|
|||||||
|
#![doc = include_str!("../README.md")]
|
||||||
|
// cannot use forbid, because props derive macro generates #[allow(missing_docs)]
|
||||||
|
#![deny(missing_docs)]
|
||||||
|
|
||||||
/// Components interacting with the router.
|
/// Components interacting with the router.
|
||||||
#[deny(missing_docs)]
|
|
||||||
pub mod components {
|
pub mod components {
|
||||||
pub(crate) mod default_errors;
|
pub(crate) mod default_errors;
|
||||||
|
|
||||||
@@ -17,16 +20,12 @@ mod contexts {
|
|||||||
pub(crate) mod router;
|
pub(crate) mod router;
|
||||||
}
|
}
|
||||||
|
|
||||||
#[forbid(missing_docs)]
|
|
||||||
mod error;
|
mod error;
|
||||||
pub use error::RouterError;
|
pub use error::RouterError;
|
||||||
|
|
||||||
pub mod history {
|
pub use dioxus_router_core::history;
|
||||||
pub use dioxus_router_core::history::*;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Hooks for interacting with the router in components.
|
/// Hooks for interacting with the router in components.
|
||||||
#[forbid(missing_docs)]
|
|
||||||
pub mod hooks {
|
pub mod hooks {
|
||||||
mod use_navigate;
|
mod use_navigate;
|
||||||
pub use use_navigate::*;
|
pub use use_navigate::*;
|
||||||
@@ -39,7 +38,6 @@ pub mod hooks {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// A collection of useful items most applications might need.
|
/// A collection of useful items most applications might need.
|
||||||
#[forbid(missing_docs)]
|
|
||||||
pub mod prelude {
|
pub mod prelude {
|
||||||
pub use dioxus_router_core::prelude::*;
|
pub use dioxus_router_core::prelude::*;
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user