From 551ea99d05166b0be50792f767ddd38b996e32fa Mon Sep 17 00:00:00 2001 From: Laurenz Date: Wed, 17 May 2023 14:41:46 +0200 Subject: Show default values in documentation Fixes #169 Fixes #1102 --- src/eval/cast.rs | 6 ++++++ src/eval/func.rs | 2 ++ src/eval/value.rs | 2 +- 3 files changed, 9 insertions(+), 1 deletion(-) (limited to 'src/eval') diff --git a/src/eval/cast.rs b/src/eval/cast.rs index b85d6e76..7ef2f1d0 100644 --- a/src/eval/cast.rs +++ b/src/eval/cast.rs @@ -230,6 +230,12 @@ impl Cast for Option { } } +impl> From> for Value { + fn from(spanned: Spanned) -> Self { + spanned.v.into() + } +} + impl> From> for Value { fn from(v: Option) -> Self { match v { diff --git a/src/eval/func.rs b/src/eval/func.rs index 75231fc9..a224c5b8 100644 --- a/src/eval/func.rs +++ b/src/eval/func.rs @@ -279,6 +279,8 @@ pub struct ParamInfo { pub docs: &'static str, /// Valid values for the parameter. pub cast: CastInfo, + /// Creates an instance of the parameter's default value. + pub default: Option Value>, /// Is the parameter positional? pub positional: bool, /// Is the parameter named? diff --git a/src/eval/value.rs b/src/eval/value.rs index bd612cce..36cda80b 100644 --- a/src/eval/value.rs +++ b/src/eval/value.rs @@ -54,7 +54,7 @@ pub enum Value { Styles(Styles), /// An array of values: `(1, "hi", 12cm)`. Array(Array), - /// A dictionary value: `(color: #f79143, pattern: dashed)`. + /// A dictionary value: `(a: 1, b: "hi")`. Dict(Dict), /// An executable function. Func(Func), -- cgit v1.2.3