diff --git a/src/line/code.rs b/src/line/code.rs index eb0c4df..d213e00 100644 --- a/src/line/code.rs +++ b/src/line/code.rs @@ -11,16 +11,19 @@ pub struct Code { } impl Code { - // Inline + // Constructors + + /// Parse inline `Self` from string pub fn inline_from(line: &str) -> Option { Inline::from(line) } - // Multiline + /// Begin multi-line parse `Self` from string pub fn multiline_begin_from(line: &str) -> Option { Multiline::begin_from(line) } + /// Continue multi-line parse `Self` from string pub fn multiline_continue_from(this: &mut Multiline, line: &str) -> Result<(), Error> { match Multiline::continue_from(this, line) { Ok(()) => Ok(()), diff --git a/src/line/code/inline.rs b/src/line/code/inline.rs index e52d03d..7607595 100644 --- a/src/line/code/inline.rs +++ b/src/line/code/inline.rs @@ -1,10 +1,14 @@ use glib::{Regex, RegexCompileFlags, RegexMatchFlags}; +/// Inline [preformatted](https://geminiprotocol.net/docs/gemtext-specification.gmi#in-pre-formatted-mode) entity holder pub struct Inline { pub value: String, } impl Inline { + // Constructors + + /// Parse `Self` from string pub fn from(line: &str) -> Option { // Parse line let regex = Regex::split_simple( diff --git a/src/line/code/multiline.rs b/src/line/code/multiline.rs index 06ab1de..4275d5b 100644 --- a/src/line/code/multiline.rs +++ b/src/line/code/multiline.rs @@ -1,9 +1,12 @@ pub mod error; pub use error::Error; +// Shared defaults + pub const NEW_LINE: char = '\n'; pub const TAG: &str = "```"; +/// Multi-line [preformatted](https://geminiprotocol.net/docs/gemtext-specification.gmi#in-pre-formatted-mode) entity holder pub struct Multiline { pub alt: Option, pub value: String, @@ -11,6 +14,8 @@ pub struct Multiline { } impl Multiline { + // Constructors + /// Search in line for tag open, /// return Self constructed on success or None pub fn begin_from(line: &str) -> Option { diff --git a/src/line/header.rs b/src/line/header.rs index 35cfab4..16c920e 100644 --- a/src/line/header.rs +++ b/src/line/header.rs @@ -1,17 +1,22 @@ use glib::{GString, Regex, RegexCompileFlags, RegexMatchFlags}; +/// [Header](https://geminiprotocol.net/docs/gemtext-specification.gmi#heading-lines) type holder pub enum Level { H1, H2, H3, } +/// [Header](https://geminiprotocol.net/docs/gemtext-specification.gmi#heading-lines) entity holder pub struct Header { pub value: GString, pub level: Level, } impl Header { + // Constructors + + /// Parse `Self` from string pub fn from(line: &str) -> Option { // Parse line let regex = Regex::split_simple( diff --git a/src/line/link.rs b/src/line/link.rs index 99f4047..fdd3cd1 100644 --- a/src/line/link.rs +++ b/src/line/link.rs @@ -1,5 +1,6 @@ use glib::{DateTime, Regex, RegexCompileFlags, RegexMatchFlags, TimeZone, Uri, UriFlags}; +/// [Link](https://geminiprotocol.net/docs/gemtext-specification.gmi#link-lines) entity holder pub struct Link { pub alt: Option, // [optional] alternative link description pub is_external: Option, // [optional] external link indication, on base option provided @@ -8,6 +9,9 @@ pub struct Link { } impl Link { + // Constructors + + /// Parse `Self` from string pub fn from(line: &str, base: Option<&Uri>, timezone: Option<&TimeZone>) -> Option { // Define initial values let mut alt = None; diff --git a/src/line/list.rs b/src/line/list.rs index 39f6c82..e2fc029 100644 --- a/src/line/list.rs +++ b/src/line/list.rs @@ -1,11 +1,13 @@ use glib::{Regex, RegexCompileFlags, RegexMatchFlags}; -/// [List item](https://geminiprotocol.net/docs/gemtext-specification.gmi#list-items) +/// [List](https://geminiprotocol.net/docs/gemtext-specification.gmi#list-items) entity holder pub struct List { pub value: String, } impl List { + // Constructors + /// Parse `Self` from string pub fn from(line: &str) -> Option { // Parse line diff --git a/src/line/quote.rs b/src/line/quote.rs index 986095f..c85cdd1 100644 --- a/src/line/quote.rs +++ b/src/line/quote.rs @@ -1,10 +1,14 @@ use glib::{Regex, RegexCompileFlags, RegexMatchFlags}; +/// [Quote](https://geminiprotocol.net/docs/gemtext-specification.gmi#quote-lines) entity holder pub struct Quote { pub value: String, } impl Quote { + // Constructors + + /// Parse `Self` from string pub fn from(line: &str) -> Option { // Parse line let regex = Regex::split_simple(