Doc

Struct Doc 

Source
pub struct Doc {
    payload: String,
    tokens: Vec<Token>,
}
Expand description

String with styled segments.

You can add style information to generated documentation and help messages For simpliest possible results you can also pass a string slice in all the places that require impl Into<Doc>

Fields§

§payload: String

string info saved here

§tokens: Vec<Token>

string meta info tokens

Implementations§

Source§

impl Doc

Source

pub fn monochrome(&self, full: bool) -> String

Render a monochrome version of the document

full indicates if full message should be rendered, this makes difference for rendered help message, otherwise you can pass true.

Source

pub(crate) fn render_console( &self, full: bool, color: Color, max_width: usize, ) -> String

Source§

impl Doc

Source

pub fn render_markdown(&self, full: bool) -> String

Render doc into markdown document, used by documentation sample generator

Source§

impl Doc

Source

pub fn text(&mut self, text: &str)

Append a fragment of plain text to Doc

See Doc for usage examples

Source

pub fn literal(&mut self, text: &str)

Append a fragment of literal text to Doc

See Doc for usage examples

Source

pub fn emphasis(&mut self, text: &str)

Append a fragment of text with emphasis to Doc

See Doc for usage examples

Source

pub fn invalid(&mut self, text: &str)

Append a fragment of unexpected user input to Doc

See Doc for usage examples

Source

pub fn meta(&mut self, meta: MetaInfo<'_>, for_usage: bool)

Append a fragment of parser metadata to Doc

See Doc for usage examples

Source

pub fn doc(&mut self, buf: &Doc)

Append a Doc to Doc

See Doc for usage examples

Source

pub fn em_doc(&mut self, buf: &Doc)

Append a Doc to Doc for plaintext documents try to format first line as a help section header

Source§

impl Doc

Source

pub(crate) fn write_shortlong(&mut self, name: &ShortLong)

Source

pub(crate) fn write_item(&mut self, item: &Item)

Source

pub(crate) fn write_meta(&mut self, meta: &Meta, for_usage: bool)

Source§

impl Doc

Source

pub(crate) fn is_empty(&self) -> bool

Source

pub(crate) fn first_line(&self) -> Option<Doc>

Source§

impl Doc

Source

pub(crate) fn token(&mut self, token: Token)

Source

pub(crate) fn write<T>(&mut self, input: T, style: Style)
where T: Display,

Source

fn set_style(&mut self, len: usize, style: Style)

Source

pub(crate) fn write_str(&mut self, input: &str, style: Style)

Source

pub(crate) fn write_char(&mut self, c: char, style: Style)

Source§

impl Doc

Source

pub(crate) fn metavar(&mut self, metavar: Metavar)

Source§

impl Doc

Source

pub(crate) fn write_help_item_groups( &mut self, items: HelpItems<'_>, include_env: bool, )

Source

fn write_help_items( &mut self, items: &HelpItems<'_>, ty: HiTy, name: &str, include_env: bool, )

Source

pub(crate) fn write_path(&mut self, path: &[String])

Trait Implementations§

Source§

impl Clone for Doc

Source§

fn clone(&self) -> Doc

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Doc

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Doc

Source§

fn default() -> Doc

Returns the “default value” for a type. Read more
Source§

impl Display for Doc

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl From<&[(&str, Style)]> for Doc

Source§

fn from(val: &[(&str, Style)]) -> Self

Converts to this type from the input type.
Source§

impl<const N: usize> From<&'static [(&'static str, Style); N]> for Doc

Source§

fn from(val: &'static [(&'static str, Style); N]) -> Self

Converts to this type from the input type.
Source§

impl From<&str> for Doc

Source§

fn from(value: &str) -> Self

Converts to this type from the input type.

Auto Trait Implementations§

§

impl Freeze for Doc

§

impl RefUnwindSafe for Doc

§

impl Send for Doc

§

impl Sync for Doc

§

impl Unpin for Doc

§

impl UnwindSafe for Doc

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.