Use intra-doc links instead of manual links
This commit is contained in:
parent
f15ed2d080
commit
a558473795
|
@ -29,7 +29,7 @@ pub type DOMTree<T> = Box<dyn Node<T>>;
|
|||
///
|
||||
/// This structure is designed to be easily walked in order to render a DOM tree
|
||||
/// or diff against an existing tree. It's the stringly typed version of
|
||||
/// [`Node`][Node].
|
||||
/// [`Node`].
|
||||
///
|
||||
/// It can be constructed from any ['Node'][Node]:
|
||||
///
|
||||
|
@ -38,8 +38,6 @@ pub type DOMTree<T> = Box<dyn Node<T>>;
|
|||
/// <p>"But how does she "<em>"eat?"</em></p>
|
||||
/// ).vnode()
|
||||
/// ```
|
||||
///
|
||||
/// [Node]: trait.Node.html
|
||||
pub enum VNode<'a, T: OutputType + 'a> {
|
||||
Text(&'a str),
|
||||
UnsafeText(&'a str),
|
||||
|
@ -56,20 +54,13 @@ pub struct VElement<'a, T: OutputType + 'a> {
|
|||
|
||||
/// Trait for rendering a typed HTML node.
|
||||
///
|
||||
/// All [HTML elements][elements] implement this, in addition to
|
||||
/// [`TextNode`][TextNode].
|
||||
/// All [HTML elements][crate::elements] implement this, in addition to
|
||||
/// [`TextNode`].
|
||||
///
|
||||
/// It implements [`Display`][Display] for rendering to strings, and the
|
||||
/// [`vnode()`][vnode] method can be used to render a virtual DOM structure.
|
||||
///
|
||||
/// [Display]: https://doc.rust-lang.org/std/fmt/trait.Display.html
|
||||
/// [TextNode]: struct.TextNode.html
|
||||
/// [elements]: ../elements/index.html
|
||||
/// [vnode]: #tymethod.vnode
|
||||
/// It implements [`Display`] for rendering to strings, and the
|
||||
/// [`vnode()`][Self::vnode] method can be used to render a virtual DOM structure.
|
||||
pub trait Node<T: OutputType + Send>: Display + Send {
|
||||
/// Render the node into a [`VNode`][VNode] tree.
|
||||
///
|
||||
/// [VNode]: enum.VNode.html
|
||||
/// Render the node into a [`VNode`] tree.
|
||||
fn vnode(&mut self) -> VNode<T>;
|
||||
}
|
||||
|
||||
|
@ -87,9 +78,7 @@ where
|
|||
|
||||
/// Trait for querying a typed HTML element.
|
||||
///
|
||||
/// All [HTML elements][elements] implement this.
|
||||
///
|
||||
/// [elements]: ../elements/index.html
|
||||
/// All [HTML elements][crate::elements] implement this.
|
||||
pub trait Element<T: OutputType + Send>: Node<T> {
|
||||
/// Get the name of the element.
|
||||
fn name() -> &'static str;
|
||||
|
@ -189,10 +178,8 @@ macro_rules! unsafe_text {
|
|||
impl<T: OutputType + Send> TextNode<T> {
|
||||
/// Construct a text node.
|
||||
///
|
||||
/// The preferred way to construct a text node is with the [`text!()`][text]
|
||||
/// The preferred way to construct a text node is with the [`text!()`][crate::text]
|
||||
/// macro.
|
||||
///
|
||||
/// [text]: ../macro.text.html
|
||||
pub fn new<S: Into<String>>(s: S) -> Self {
|
||||
TextNode(s.into(), PhantomData)
|
||||
}
|
||||
|
@ -234,10 +221,8 @@ impl<T: OutputType + Send> PhrasingContent<T> for TextNode<T> {}
|
|||
impl<T: OutputType + Send> UnsafeTextNode<T> {
|
||||
/// Construct a unsafe text node.
|
||||
///
|
||||
/// The preferred way to construct a unsafe text node is with the [`unsafe_text!()`][unsafe_text]
|
||||
/// The preferred way to construct a unsafe text node is with the [`unsafe_text!()`][crate::unsafe_text]
|
||||
/// macro.
|
||||
///
|
||||
/// [unsafe_text]: ../macro.unsafe_text.html
|
||||
pub fn new<S: Into<String>>(s: S) -> Self {
|
||||
UnsafeTextNode(s.into(), PhantomData)
|
||||
}
|
||||
|
|
|
@ -75,14 +75,14 @@
|
|||
//! (see the Syntax section above).
|
||||
//!
|
||||
//! The `html!` macro will add an [`.into()`][Into::into] call to the value
|
||||
//! expression, so that you can use any type that has an [`Into<A>`][Into] trait
|
||||
//! expression, so that you can use any type that has an [`Into<A>`] trait
|
||||
//! defined for the actual attribute type `A`.
|
||||
//!
|
||||
//! As a special case, if you use a string literal, the macro will instead use the
|
||||
//! [`FromStr<A>`][FromStr] trait to try and parse the string literal into the
|
||||
//! [`FromStr<A>`][std::str::FromStr] trait to try and parse the string literal into the
|
||||
//! expected type. This is extremely useful for eg. CSS classes, letting you type
|
||||
//! `class="css-class-1 css-class-2"` instead of going to the trouble of
|
||||
//! constructing a [`SpacedSet<Class>`][SpacedSet]. The big caveat for this:
|
||||
//! constructing a [`SpacedSet<Class>`][types::SpacedSet]. The big caveat for this:
|
||||
//! currently, the macro is not able to validate the string at compile time, and the
|
||||
//! conversion will panic at runtime if the string is invalid.
|
||||
//!
|
||||
|
@ -112,7 +112,7 @@
|
|||
//! # Generated Nodes
|
||||
//!
|
||||
//! Brace blocks in the child node position are expected to return an
|
||||
//! [`IntoIterator`][IntoIterator] of [`DOMTree`][DOMTree]s. You can return single
|
||||
//! [`IntoIterator`] of [`DOMTree`][dom::DOMTree]s. You can return single
|
||||
//! elements or text nodes, as they both implement `IntoIterator` for themselves.
|
||||
//! The macro will consume this iterator at runtime and insert the generated nodes
|
||||
//! as children in the expected position.
|
||||
|
@ -141,9 +141,9 @@
|
|||
//!
|
||||
//! ## Render to a string
|
||||
//!
|
||||
//! The DOM tree data structure implements [`Display`][Display], so you can call
|
||||
//! [`to_string()`][to_string] on it to render it to a [`String`][String]. If you
|
||||
//! plan to do this, the type of the tree should be [`DOMTree<String>`][DOMTree] to
|
||||
//! The DOM tree data structure implements [`Display`], so you can call
|
||||
//! [`to_string()`][std::string::ToString::to_string] on it to render it to a [`String`]. If you
|
||||
//! plan to do this, the type of the tree should be [`DOMTree<String>`][dom::DOMTree] to
|
||||
//! ensure you're not using any event handlers that can't be printed.
|
||||
//!
|
||||
//! ```
|
||||
|
@ -161,7 +161,7 @@
|
|||
//! ## Render to a virtual DOM
|
||||
//!
|
||||
//! The DOM tree structure also implements a method called `vnode()`, which renders
|
||||
//! the tree to a tree of [`VNode`][VNode]s, which is a mirror of the generated tree
|
||||
//! the tree to a tree of [`VNode`][dom::VNode]s, which is a mirror of the generated tree
|
||||
//! with every attribute value rendered into `String`s. You can walk this virtual
|
||||
//! DOM tree and pass it on to your favourite virtual DOM system.
|
||||
//!
|
||||
|
@ -174,17 +174,6 @@
|
|||
//! <http://mozilla.org/MPL/2.0/>.
|
||||
//!
|
||||
//! [JSX]: https://reactjs.org/docs/introducing-jsx.html
|
||||
//! [Display]: https://doc.rust-lang.org/std/fmt/trait.Display.html
|
||||
//! [String]: https://doc.rust-lang.org/std/string/struct.String.html
|
||||
//! [to_string]: https://doc.rust-lang.org/std/string/trait.ToString.html#tymethod.to_string
|
||||
//! [Node]: dom/trait.Node.html
|
||||
//! [VNode]: dom/enum.VNode.html
|
||||
//! [FromStr]: https://doc.rust-lang.org/std/str/trait.FromStr.html
|
||||
//! [SpacedSet]: types/struct.SpacedSet.html
|
||||
//! [IntoIterator]: https://doc.rust-lang.org/std/iter/trait.IntoIterator.html
|
||||
//! [Into]: https://doc.rust-lang.org/std/convert/trait.Into.html
|
||||
//! [Into::into]: https://doc.rust-lang.org/std/convert/trait.Into.html#method.into
|
||||
//! [DOMTree]: dom/type.DOMTree.html
|
||||
|
||||
pub extern crate htmlescape;
|
||||
|
||||
|
|
|
@ -12,9 +12,7 @@ use super::Id;
|
|||
/// and is followed by any number of alphanumeric characters and the
|
||||
/// `_`, `-` and `.` characters.
|
||||
///
|
||||
/// See also [`Id`][Id].
|
||||
///
|
||||
/// [Id]: struct.Id.html
|
||||
/// See also [`Id`].
|
||||
#[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Debug)]
|
||||
pub struct Class(String);
|
||||
|
||||
|
|
|
@ -12,9 +12,7 @@ use super::Class;
|
|||
/// and is followed by any number of alphanumeric characters and the
|
||||
/// `_`, `-` and `.` characters.
|
||||
///
|
||||
/// See also [`Class`][Class].
|
||||
///
|
||||
/// [Class]: struct.Class.html
|
||||
/// See also [`Class`].
|
||||
#[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Debug)]
|
||||
pub struct Id(String);
|
||||
|
||||
|
|
|
@ -8,9 +8,7 @@ use std::str::FromStr;
|
|||
///
|
||||
/// This type represents a list of non-unique values represented as a string of
|
||||
/// values separated by spaces in HTML attributes. This is rarely used; a
|
||||
/// [`SpacedSet`][SpacedSet] of unique values is much more common.
|
||||
///
|
||||
/// [SpacedSet]: struct.SpacedSet.html
|
||||
/// [`SpacedSet`][super::SpacedSet] of unique values is much more common.
|
||||
#[derive(Clone, PartialEq, Eq, Hash)]
|
||||
pub struct SpacedList<A>(Vec<A>);
|
||||
|
||||
|
|
Loading…
Reference in New Issue