Skip to content
This repository has been archived by the owner on Mar 2, 2021. It is now read-only.

Commit

Permalink
Deny missing docs and missing Debug implementations
Browse files Browse the repository at this point in the history
  • Loading branch information
fitzgen committed Feb 12, 2019
1 parent daa23fe commit 197915d
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/cached.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ use std::ops::{Deref, DerefMut};

/// A renderable that supports caching for when rendering is expensive but can
/// generate the same DOM tree.
#[derive(Debug)]
pub struct Cached<R> {
inner: R,
bump: bumpalo::Bump,
Expand Down
3 changes: 2 additions & 1 deletion src/change_list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,8 @@ impl ChangeList {
}

#[repr(u32)]
pub enum ChangeDiscriminant {
#[derive(Clone, Copy, Debug)]
enum ChangeDiscriminant {
/// Immediates: `(pointer, length)`
///
/// Stack: `[... TextNode] -> [... TextNode]`
Expand Down
1 change: 1 addition & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
//! }
//! }
//! ```
#![deny(missing_docs, missing_debug_implementations)]

// Re-export the `bumpalo` crate.
pub use bumpalo;
Expand Down
4 changes: 4 additions & 0 deletions src/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,13 @@ pub struct Listener<'a> {
pub callback: ListenerCallback<'a>,
}

/// An attribute on a DOM node, such as `id="my-thing"` or
/// `href="https://example.com"`.
#[derive(Clone, Debug)]
pub struct Attribute<'a> {
/// The attribute name, such as `id`.
pub name: &'a str,
/// The attribute value, such as `"my-thing"`.
pub value: &'a str,
}

Expand Down
38 changes: 38 additions & 0 deletions src/render.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,45 @@ use std::any::Any;
use std::rc::Rc;
use wasm_bindgen::UnwrapThrowExt;

/// A trait for any component that can be rendered to HTML.
///
/// Takes a shared reference to `self` and generates the virtual DOM that
/// represents its rendered HTML.
///
/// ## `Bump` Allocation
///
/// `Render` implementations can use the provided `Bump` for very fast
/// allocation for anything that needs to be allocated during rendering.
///
/// ## The `'a: 'bump` Lifetime Bound
///
/// The `'a: 'bump` bounds enforce that `self` outlives the given bump
/// allocator. This means that if `self` contains a string, the string does not
/// need to be copied into the output `Node` and can be used by reference
/// instead (i.e. it prevents accidentally using the string after its been
/// freed). The `'a: 'bump` bound also enables abstractions like
/// `dodrio::Cached` that can re-use cached `Node`s across `render`s without
/// copying them.
///
/// ## Example
///
/// ```no_run
/// use dodrio::{Bump, Node, Render};
///
/// pub struct MyComponent;
///
/// impl Render for MyComponent {
/// fn render<'a, 'bump>(&'a self, bump: &'bump Bump) -> Node<'bump>
/// where
/// 'a: 'bump
/// {
/// Node::text("This is my component rendered!")
/// }
/// }
/// ```
pub trait Render {
/// Render `self` as a virtual DOM. Use the given `Bump` for temporary
/// allocations.
fn render<'a, 'bump>(&'a self, bump: &'bump Bump) -> Node<'bump>
where
'a: 'bump;
Expand Down
1 change: 1 addition & 0 deletions src/vdom.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ use wasm_bindgen_futures::JsFuture;
/// removed. To keep it mounted forever, use the `Vdom::forget` method.
#[must_use = "A `Vdom` will only keep rendering and listening to events while it has not been \
dropped. If you want a `Vdom` to run forever, call `Vdom::forget`."]
#[derive(Debug)]
pub struct Vdom {
inner: Rc<VdomInner>,
}
Expand Down

0 comments on commit 197915d

Please sign in to comment.