Skip to main content

Pretty

Struct Pretty 

Source
pub struct Pretty { /* private fields */ }
Expand description

A renderable that pretty prints a value. Mirrors rich.pretty.Pretty.

Implementations§

Source§

impl Pretty

Source

pub fn new(value: &impl Debug) -> Self

Pretty-print value ({:#?}, multi-line and indented) and highlight it. Not upstream’s layout; see Pretty::from_value.

Source

pub fn compact(value: &impl Debug) -> Self

Format value compactly on one line ({:?}) and highlight it.

Source

pub fn from_value(value: PrettyValue) -> Self

Pretty-print a Python value as upstream’s Pretty(obj) does.

Source

pub fn highlighter( self, highlighter: impl Highlighter + Send + Sync + 'static, ) -> Self

The highlighter applied to the repr (upstream highlighter, default ReprHighlighter).

Source

pub fn indent_size(self, indent_size: usize) -> Self

Spaces per indent level (upstream indent_size, default 4).

Source

pub fn justify(self, justify: Option<Justify>) -> Self

Justify method, or None for the console’s (upstream justify).

Source

pub fn overflow(self, overflow: Option<Overflow>) -> Self

Overflow method, or None for the console’s (upstream overflow).

Source

pub fn no_wrap(self, no_wrap: Option<bool>) -> Self

Disable wrapping, or None for the console’s (upstream no_wrap, default False).

Source

pub fn indent_guides(self, indent_guides: bool) -> Self

Draw indent guides (upstream indent_guides).

Source

pub fn max_length(self, max_length: Option<usize>) -> Self

Abbreviate containers longer than this (upstream max_length).

Source

pub fn max_string(self, max_string: Option<usize>) -> Self

Truncate strings longer than this (upstream max_string).

Source

pub fn max_depth(self, max_depth: Option<usize>) -> Self

Stop at this depth of nesting (upstream max_depth).

Source

pub fn expand_all(self, expand_all: bool) -> Self

Expand every container (upstream expand_all).

Source

pub fn margin(self, margin: usize) -> Self

Cells taken off the width, so containers expand sooner (upstream margin).

Source

pub fn insert_line(self, insert_line: bool) -> Self

Start with a blank line when the output has several lines (upstream insert_line).

Trait Implementations§

Source§

impl Renderable for Pretty

Source§

fn rich_render( &self, console: &Console, options: &ConsoleOptions, ) -> Vec<Segment>

Source§

fn measure(&self, console: &Console, options: &ConsoleOptions) -> Measurement

The (minimum, maximum) cell width this renderable wants. Port of __rich_measure__. The default is what upstream’s Measurement.get returns for a renderable without one: anything from nothing to the whole width, (0, max_width).
Source§

fn fit_to_measurement(&self) -> bool

Whether a top-level Console::print shrinks this renderable to its measured width. Upstream renders every top-level renderable at the full console width, so the default is false; an extension may opt in.
Source§

fn vertical(&self) -> Option<VerticalAlign>

The vertical alignment a Table cell holding this renderable uses in place of its column’s. Upstream reads getattr(renderable, "vertical", None); Align sets it.
Source§

fn print_end_line(&self, _options: &ConsoleOptions) -> bool

Whether a top-level print ends this renderable’s last line. This port’s renderables separate lines, where upstream’s end each line with "\n", so a print adds the final line break. A renderable whose upstream output stops without one (Screen, LiveRender, a Rule whose end has no newline) returns false, and the next output continues its last line. options are the print’s options.

Auto Trait Implementations§

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> 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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.