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

View file

@ -33,21 +33,45 @@ use clippet::Clippet;
/// A structure for containing border information for boxes. /// A structure for containing border information for boxes.
#[derive(Debug)] #[derive(Debug)]
pub struct Border { pub struct Border {
pub tl: String, // Top left /// Top left glyph
pub tr: String, // Top right pub tl: String,
pub bl: String, // Bottom left
pub br: String, // Bottom right /// Top right glyph
pub sl: String, // Side left pub tr: String,
pub sr: String, // Side right
pub st: String, // Side top /// Bottom left glyph
pub sb: String, // Side bottom pub bl: String,
pub xtra: u32, // Extra padding for top and bottom
pub over: u32, // Extra padding for sides /// 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 { impl Border {
/// Takes in a category and spits out a templated Border structure. /// Takes in a category and spits out a templated Border structure.
/// Available templates include receipt, hashes, blocky and solid. /// 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 { pub fn template(cat: &str) -> Border {
match cat { 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 }, "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 "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 { pub fn new() -> Border {
return Border::template("empty") return Border::template("empty")
} }