From e7e79bf32c385fa8c30a45be262ca3d6d8f1f653 Mon Sep 17 00:00:00 2001 From: Nadrieril Date: Sat, 13 Apr 2019 00:44:58 +0200 Subject: Document all of the API Closes #64 --- dhall/src/lib.rs | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'dhall/src/lib.rs') diff --git a/dhall/src/lib.rs b/dhall/src/lib.rs index 73f3c1b..51fb6b7 100644 --- a/dhall/src/lib.rs +++ b/dhall/src/lib.rs @@ -13,7 +13,7 @@ //! [Dhall][dhall] is a programmable configuration language that provides a non-repetitive //! alternative to JSON and YAML. //! -//! You can think of Dhall as: JSON/YAML + types + imports + functions +//! You can think of Dhall as: JSON + types + imports + functions //! //! For a description of the dhall language, examples, tutorials, and more, see the [language //! website][dhall]. @@ -130,10 +130,19 @@ mod typecheck; pub use crate::traits::{Deserialize, SimpleStaticType, StaticType}; #[doc(hidden)] pub use dhall_generator::SimpleStaticType; +/// When manipulating Dhall expressions goes wrong. pub mod error; pub mod expr; mod serde; +/// Deserialize an instance of type T from a string of Dhall text. +/// +/// This will recursively resolve all imports in the expression, and +/// typecheck it. More control over this process is not yet available +/// but will be in a coming verions of this crate. +/// +/// If a type is provided, this additionally checks that the provided +/// expression has that type. pub fn from_str<'a, T: Deserialize<'a>>( s: &'a str, ty: Option<&crate::expr::Type>, @@ -141,6 +150,12 @@ pub fn from_str<'a, T: Deserialize<'a>>( T::from_str(s, ty) } +/// Deserialize an instance of type T from a string of Dhall text, +/// additionally checking that it matches the type of T. +/// +/// This will recursively resolve all imports in the expression, and +/// typecheck it. More control over this process is not yet available +/// but will be in a coming verions of this crate. pub fn from_str_auto_type<'a, T: Deserialize<'a> + StaticType>( s: &'a str, ) -> crate::error::Result { -- cgit v1.2.3