More consistent documentation 📝

This commit is contained in:
Laurenz 2021-03-22 10:48:29 +01:00
parent 83fa2c075e
commit 39f55481ed
7 changed files with 27 additions and 27 deletions

View File

@ -3,7 +3,7 @@ use crate::pretty::pretty;
use super::*; use super::*;
/// `type`: Get the name of a value's type. /// `type`: The name of a value's type.
/// ///
/// # Positional parameters /// # Positional parameters
/// - Any value. /// - Any value.
@ -17,7 +17,7 @@ pub fn type_(ctx: &mut EvalContext, args: &mut FuncArgs) -> Value {
} }
} }
/// `repr`: Get the string representation of a value. /// `repr`: The string representation of a value.
/// ///
/// # Positional parameters /// # Positional parameters
/// - Any value. /// - Any value.
@ -31,7 +31,7 @@ pub fn repr(ctx: &mut EvalContext, args: &mut FuncArgs) -> Value {
} }
} }
/// `rgb`: Construct an RGB(A) color. /// `rgb`: Create an RGB(A) color.
/// ///
/// # Positional parameters /// # Positional parameters
/// - Red component: of type `float`, between 0.0 and 1.0. /// - Red component: of type `float`, between 0.0 and 1.0.

View File

@ -6,7 +6,7 @@ use crate::layout::{
AnyNode, Areas, Element, Fragment, Frame, Image, Layout, LayoutContext, AnyNode, Areas, Element, Fragment, Frame, Image, Layout, LayoutContext,
}; };
/// `image`: Insert an image. /// `image`: An image.
/// ///
/// Supports PNG and JPEG files. /// Supports PNG and JPEG files.
/// ///

View File

@ -28,7 +28,7 @@ pub fn parbreak(_: &mut EvalContext, _: &mut FuncArgs) -> Value {
}) })
} }
/// `strong`: Signify important text by setting it in bold. /// `strong`: Strong text.
/// ///
/// # Syntax /// # Syntax
/// This function has dedicated syntax. /// This function has dedicated syntax.
@ -40,7 +40,7 @@ pub fn parbreak(_: &mut EvalContext, _: &mut FuncArgs) -> Value {
/// - Body: optional, of type `template`. /// - Body: optional, of type `template`.
/// ///
/// # Return value /// # Return value
/// A template that flips the strongness of text. The effect is scoped to the /// A template that flips the boldness of text. The effect is scoped to the
/// body if present. /// body if present.
pub fn strong(ctx: &mut EvalContext, args: &mut FuncArgs) -> Value { pub fn strong(ctx: &mut EvalContext, args: &mut FuncArgs) -> Value {
let body = args.find::<TemplateValue>(ctx); let body = args.find::<TemplateValue>(ctx);
@ -55,7 +55,7 @@ pub fn strong(ctx: &mut EvalContext, args: &mut FuncArgs) -> Value {
}) })
} }
/// `emph`: Emphasize text by setting it in italics. /// `emph`: Emphasized text.
/// ///
/// # Syntax /// # Syntax
/// This function has dedicated syntax. /// This function has dedicated syntax.
@ -67,8 +67,8 @@ pub fn strong(ctx: &mut EvalContext, args: &mut FuncArgs) -> Value {
/// - Body: optional, of type `template`. /// - Body: optional, of type `template`.
/// ///
/// # Return value /// # Return value
/// A template that flips whether text is emphasized. The effect is scoped to /// A template that flips whether text is set in italics. The effect is scoped
/// the body if present. /// to the body if present.
pub fn emph(ctx: &mut EvalContext, args: &mut FuncArgs) -> Value { pub fn emph(ctx: &mut EvalContext, args: &mut FuncArgs) -> Value {
let body = args.find::<TemplateValue>(ctx); let body = args.find::<TemplateValue>(ctx);
Value::template(Node::EMPH, move |ctx| { Value::template(Node::EMPH, move |ctx| {
@ -146,7 +146,7 @@ pub fn heading(ctx: &mut EvalContext, args: &mut FuncArgs) -> Value {
/// type `boolean`. /// type `boolean`.
/// ///
/// # Return value /// # Return value
/// A template that sets the text raw, that is, in monospace with optional /// A template that sets the text raw, that is, in monospace and optionally with
/// syntax highlighting. /// syntax highlighting.
pub fn raw(ctx: &mut EvalContext, args: &mut FuncArgs) -> Value { pub fn raw(ctx: &mut EvalContext, args: &mut FuncArgs) -> Value {
let text = args.require::<String>(ctx, RawNode::TEXT).unwrap_or_default(); let text = args.require::<String>(ctx, RawNode::TEXT).unwrap_or_default();

View File

@ -53,12 +53,12 @@ pub fn _new() -> Scope {
} }
// Syntax functions. // Syntax functions.
func!(Node::EMPH, emph);
func!(Node::HEADING, heading);
func!(Node::STRONG, strong);
func!(Node::RAW, raw);
func!(Node::LINEBREAK, linebreak); func!(Node::LINEBREAK, linebreak);
func!(Node::PARBREAK, parbreak); func!(Node::PARBREAK, parbreak);
func!(Node::STRONG, strong);
func!(Node::EMPH, emph);
func!(Node::HEADING, heading);
func!(Node::RAW, raw);
// Library functions. // Library functions.
func!("align", align); func!("align", align);

View File

@ -14,7 +14,7 @@ use crate::layout::PadNode;
/// - Bottom padding: `bottom`, of type `linear` relative to parent height. /// - Bottom padding: `bottom`, of type `linear` relative to parent height.
/// ///
/// # Return value /// # Return value
/// A template that pads the body at the sides. /// A template that sets the body into a padded area.
pub fn pad(ctx: &mut EvalContext, args: &mut FuncArgs) -> Value { pub fn pad(ctx: &mut EvalContext, args: &mut FuncArgs) -> Value {
let all = args.find(ctx); let all = args.find(ctx);
let left = args.get(ctx, "left"); let left = args.get(ctx, "left");

View File

@ -4,7 +4,7 @@ use super::*;
use crate::color::Color; use crate::color::Color;
use crate::layout::{BackgroundNode, BackgroundShape, Fill, FixedNode, PadNode}; use crate::layout::{BackgroundNode, BackgroundShape, Fill, FixedNode, PadNode};
/// `rect`: Create a rectangle. /// `rect`: A rectangle with optional content.
/// ///
/// # Positional parameters /// # Positional parameters
/// - Body: optional, of type `template`. /// - Body: optional, of type `template`.
@ -15,7 +15,7 @@ use crate::layout::{BackgroundNode, BackgroundShape, Fill, FixedNode, PadNode};
/// - Fill color: `fill`, of type `color`. /// - Fill color: `fill`, of type `color`.
/// ///
/// # Return value /// # Return value
/// A template that places the body into a rectangle. /// A template that inserts a rectangle and sets the body into it.
pub fn rect(ctx: &mut EvalContext, args: &mut FuncArgs) -> Value { pub fn rect(ctx: &mut EvalContext, args: &mut FuncArgs) -> Value {
let width = args.get(ctx, "width"); let width = args.get(ctx, "width");
let height = args.get(ctx, "height"); let height = args.get(ctx, "height");
@ -24,7 +24,7 @@ pub fn rect(ctx: &mut EvalContext, args: &mut FuncArgs) -> Value {
rect_impl("rect", width, height, None, fill, body) rect_impl("rect", width, height, None, fill, body)
} }
/// `square`: Create a square. /// `square`: A square with optional content.
/// ///
/// # Positional parameters /// # Positional parameters
/// - Body: optional, of type `template`. /// - Body: optional, of type `template`.
@ -40,7 +40,7 @@ pub fn rect(ctx: &mut EvalContext, args: &mut FuncArgs) -> Value {
/// to its parent's size, which isn't possible by setting the side length. /// to its parent's size, which isn't possible by setting the side length.
/// ///
/// # Return value /// # Return value
/// A template that places the body into a square. /// A template that inserts a square and sets the body into it.
pub fn square(ctx: &mut EvalContext, args: &mut FuncArgs) -> Value { pub fn square(ctx: &mut EvalContext, args: &mut FuncArgs) -> Value {
let length = args.get::<Length>(ctx, "length").map(Linear::from); let length = args.get::<Length>(ctx, "length").map(Linear::from);
let width = length.or_else(|| args.get(ctx, "width")); let width = length.or_else(|| args.get(ctx, "width"));
@ -77,7 +77,7 @@ fn rect_impl(
}) })
} }
/// `ellipse`: Create an ellipse. /// `ellipse`: An ellipse with optional content.
/// ///
/// # Positional parameters /// # Positional parameters
/// - Body: optional, of type `template`. /// - Body: optional, of type `template`.
@ -88,7 +88,7 @@ fn rect_impl(
/// - Fill color: `fill`, of type `color`. /// - Fill color: `fill`, of type `color`.
/// ///
/// # Return value /// # Return value
/// A template that places the body into an ellipse. /// A template that inserts an ellipse and sets the body into it.
pub fn ellipse(ctx: &mut EvalContext, args: &mut FuncArgs) -> Value { pub fn ellipse(ctx: &mut EvalContext, args: &mut FuncArgs) -> Value {
let width = args.get(ctx, "width"); let width = args.get(ctx, "width");
let height = args.get(ctx, "height"); let height = args.get(ctx, "height");
@ -97,7 +97,7 @@ pub fn ellipse(ctx: &mut EvalContext, args: &mut FuncArgs) -> Value {
ellipse_impl("ellipse", width, height, None, fill, body) ellipse_impl("ellipse", width, height, None, fill, body)
} }
/// `circle`: Create a circle. /// `circle`: A circle with optional content.
/// ///
/// # Positional parameters /// # Positional parameters
/// - Body: optional, of type `template`. /// - Body: optional, of type `template`.
@ -113,7 +113,7 @@ pub fn ellipse(ctx: &mut EvalContext, args: &mut FuncArgs) -> Value {
/// to its parent's size, which isn't possible by setting the radius. /// to its parent's size, which isn't possible by setting the radius.
/// ///
/// # Return value /// # Return value
/// A template that places the body into a circle. /// A template that inserts a circle and sets the body into it.
pub fn circle(ctx: &mut EvalContext, args: &mut FuncArgs) -> Value { pub fn circle(ctx: &mut EvalContext, args: &mut FuncArgs) -> Value {
let radius = args.get::<Length>(ctx, "radius").map(|r| 2.0 * Linear::from(r)); let radius = args.get::<Length>(ctx, "radius").map(|r| 2.0 * Linear::from(r));
let width = radius.or_else(|| args.get(ctx, "width")); let width = radius.or_else(|| args.get(ctx, "width"));

View File

@ -1,24 +1,24 @@
use super::*; use super::*;
use crate::layout::SpacingNode; use crate::layout::SpacingNode;
/// `h`: Insert horizontal spacing. /// `h`: Horizontal spacing.
/// ///
/// # Positional parameters /// # Positional parameters
/// - Amount of spacing: of type `linear` relative to current font size. /// - Amount of spacing: of type `linear` relative to current font size.
/// ///
/// # Return value /// # Return value
/// A template that adds horizontal spacing. /// A template that inserts horizontal spacing.
pub fn h(ctx: &mut EvalContext, args: &mut FuncArgs) -> Value { pub fn h(ctx: &mut EvalContext, args: &mut FuncArgs) -> Value {
spacing_impl(ctx, args, SpecAxis::Horizontal) spacing_impl(ctx, args, SpecAxis::Horizontal)
} }
/// `v`: Insert vertical spacing. /// `v`: Vertical spacing.
/// ///
/// # Positional parameters /// # Positional parameters
/// - Amount of spacing: of type `linear` relative to current font size. /// - Amount of spacing: of type `linear` relative to current font size.
/// ///
/// # Return value /// # Return value
/// A template that adds vertical spacing. /// A template that inserts vertical spacing.
pub fn v(ctx: &mut EvalContext, args: &mut FuncArgs) -> Value { pub fn v(ctx: &mut EvalContext, args: &mut FuncArgs) -> Value {
spacing_impl(ctx, args, SpecAxis::Vertical) spacing_impl(ctx, args, SpecAxis::Vertical)
} }