[librsvg] Start documenting RsvgNode and create_node



commit d13d881e60c9e589b3ecd52fd2dc4895abdf7e33
Author: Federico Mena Quintero <federico gnome org>
Date:   Mon Dec 16 15:12:57 2019 -0600

    Start documenting RsvgNode and create_node

 rsvg_internals/src/create_node.rs | 15 +++++++++++++++
 rsvg_internals/src/node.rs        | 22 +++++++++++++++++++++-
 2 files changed, 36 insertions(+), 1 deletion(-)
---
diff --git a/rsvg_internals/src/create_node.rs b/rsvg_internals/src/create_node.rs
index d1e443e7..b8aaf1d9 100644
--- a/rsvg_internals/src/create_node.rs
+++ b/rsvg_internals/src/create_node.rs
@@ -1,3 +1,11 @@
+//! Creates tree nodes based on SVG element names.
+//!
+//! The main [`create_node`] function takes an XML element name, and
+//! creates an [`RsvgNode`] for it.
+//!
+//! [`create_node`]: fn.create_node.html
+//! [`RsvgNode`]: ../node/type.RsvgNode.html
+
 use markup5ever::{expanded_name, local_name, namespace_url, ns, QualName};
 use once_cell::sync::Lazy;
 use std::collections::HashMap;
@@ -220,6 +228,13 @@ static NODE_CREATORS: Lazy<HashMap<&'static str, (bool, NodeCreateFn)>> = Lazy::
     creators_table.into_iter().map(|(n, s, f)| (n, (s, f))).collect()
 });
 
+/// Takes an XML element name and a list of attribute/value pairs and creates an [`RsvgNode`].
+///
+/// This operation does not fail.  Unknown element names simply produce a [`NonRendering`]
+/// node.
+///
+/// [`RsvgNode`]: ../node/type.RsvgNode.html
+/// [`NonRendering`]: ../structure/struct.NonRendering.html
 pub fn create_node(name: &QualName, pbag: &PropertyBag) -> RsvgNode {
     let mut id = None;
     let mut class = None;
diff --git a/rsvg_internals/src/node.rs b/rsvg_internals/src/node.rs
index e412f0d0..2c12772d 100644
--- a/rsvg_internals/src/node.rs
+++ b/rsvg_internals/src/node.rs
@@ -1,3 +1,17 @@
+//! Tree nodes, the representation of SVG elements.
+//!
+//! Librsvg uses the [rctree crate][rctree] to represent the SVG tree of elements.
+//! Its [`Node`] struct provides a generic wrapper over nodes in a tree.
+//! Librsvg puts a [`NodeData`] as the type parameter of [`Node`].  For convenience,
+//! librsvg has a type alias `RsvgNode = Node<NodeData>`.
+//!
+//! Nodes are not constructed directly by callers; this is done in the [`create_node`] module.
+//!
+//! [rctree]: ../../rctree/index.html
+//! [`Node`]: ../../rctree/struct.Node.html
+//! [`NodeData`]: struct.NodeData.html
+//! [`create_node`]: ../create_node/index.html
+
 use cairo::Matrix;
 use downcast_rs::*;
 use markup5ever::{expanded_name, local_name, namespace_url, ns, QualName};
@@ -18,8 +32,14 @@ use crate::property_defs::Overflow;
 use locale_config::Locale;
 use rctree;
 
-/// Tree node with specific data
+/// Strong reference to an element in the SVG tree.
+///
+/// See the [module documentation](index.html) for more information.
 pub type RsvgNode = rctree::Node<NodeData>;
+
+/// Weak reference to an element in the SVG tree.
+///
+/// See the [module documentation](index.html) for more information.
 pub type RsvgWeakNode = rctree::WeakNode<NodeData>;
 
 /// Contents of a tree node


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]