3 releases (breaking)

0.3.0 Mar 14, 2023
0.2.0 Dec 2, 2022
0.1.0 Nov 10, 2022

#347 in Template engine

MIT license

23KB
494 lines

Sous

Work with culinary recipes in Rust

NOTE: Sous is still in early development, and the API should be considered unstable at this time.

Sous provides structs for representing culinary recipes in Rust, along with an API for loading and converting them between formats. This package also includes a reference command-line utility demonstrating the library's capabilities.

Installing

Sous is available on crates.io:

$ cargo add sous

Command Line Usage

The Sous CLI can ingest recipes in YAML format, and output them as Markdown:

$ sous test.yml

If a directory is passed to Sous as input, it will operate in Cookbook mode, converting any YAML files within. If the --output directory is not set, Sous will output to a directory called render in the current working directory.


lib.rs:

Library for handling culinary recipes.

This crate provides structs representing various components of a culinary recipe, along with utilities for converting them between various formats.

fn main() {
    let mut recipe = Recipe::new();

    recipe.metadata.name = "Test Recipe".to_string();
    recipe.metadata.author = "Cook Cookerson".to_string();
    recipe.metadata.servings = 2;
    recipe.metadata.cook_minutes = 10;

    recipe.ingredients.push(Ingredient {
        name: "Ingredient".to_string(),
        amount: Some(1.0),
        ..Default::default()
    });
    recipe.steps.push("First step".to_string());
    recipe.steps.push("Second step".to_string());

    let render = MarkdownRenderer::new();
    let md = render.render(&recipe);
}

Dependencies

~9–20MB
~263K SLoC