update documentation

This commit is contained in:
abbie 2022-09-18 09:37:00 +01:00
parent 29aa1f7ed1
commit 03aa747c29
No known key found for this signature in database
GPG key ID: A575D2415E5E5B6D
2 changed files with 40 additions and 12 deletions

View file

@ -1,7 +1,7 @@
[package]
name = "boxer"
description = "Automatically generate boxes!"
version = "0.1.0"
version = "0.1.1"
edition = "2021"
authors = ["Celeste <colean@colean.cc>"]
license = "MPL-2.0"

View file

@ -33,21 +33,45 @@ use clippet::Clippet;
/// A structure for containing border information for boxes.
#[derive(Debug)]
pub struct Border {
pub tl: String, // Top left
pub tr: String, // Top right
pub bl: String, // Bottom left
pub br: String, // Bottom right
pub sl: String, // Side left
pub sr: String, // Side right
pub st: String, // Side top
pub sb: String, // Side bottom
pub xtra: u32, // Extra padding for top and bottom
pub over: u32, // Extra padding for sides
/// Top left glyph
pub tl: String,
/// Top right glyph
pub tr: String,
/// Bottom left glyph
pub bl: String,
/// Bottom right glyph
pub br: String,
/// Side left glyph
pub sl: String,
/// Side right glyph
pub sr: String,
/// Side top glyph
pub st: String,
/// Side bottom glyph
pub sb: String,
/// Extra padding for top and bottom
pub xtra: u32,
/// Extra padding for sides
pub over: u32,
}
/// Generators for the Border struct.
impl Border {
/// Takes in a category and spits out a templated Border structure.
/// Available templates include receipt, hashes, blocky and solid.
/// ```no_run
/// let x = Border::template("solid");
/// println!("{}", makebox(1, 1, 40, x, "Hello, world!"));
/// ```
pub fn template(cat: &str) -> Border {
match cat {
"empty" => Border { tl: "".to_string(), tr: "".to_string(), bl: "".to_string(), br: "".to_string(), sl: "".to_string(), sr: "".to_string(), st: "".to_string(), sb: "".to_string(), xtra: 0, over: 3 },
@ -59,7 +83,11 @@ impl Border {
"blocky" | _ => Border { tl: "".to_string(), tr: "".to_string(), bl: "".to_string(), br: "".to_string(), sl: "".to_string(), sr: "".to_string(), st: "".to_string(), sb: "".to_string(), xtra: 0, over: 3 }, // Blocky
}
}
/// Equivalent to running `template` with the empty category, a blank Border structure.
/// Outputs a blank Border structure for creating custom borders.
///
/// ```no_run
/// let x = Border::new();
/// ```
pub fn new() -> Border {
return Border::template("empty")
}