Skip to main content

Doc

Struct Doc 

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

文档 / 块序列构建器。也用作引用、列表项的内层块容器。

Implementations§

Source§

impl Doc

Source

pub fn new() -> Self

新建一个空文档构建器。

Source

pub fn build(&self) -> Document

收尾成 Document

Source

pub fn heading<R>( &mut self, level: u8, f: impl FnOnce(&mut ParaBuilder) -> R, ) -> &mut Self

标题(level 取 1..=6,越界夹到范围)。

Source

pub fn paragraph<R>( &mut self, f: impl FnOnce(&mut ParaBuilder) -> R, ) -> &mut Self

段落。

Source

pub fn text(&mut self, s: impl Into<String>) -> &mut Self

便捷:一行纯文字段落。

Source

pub fn quote<R>(&mut self, f: impl FnOnce(&mut Doc) -> R) -> &mut Self

引用块(内层是块容器,可嵌套)。

Source

pub fn list<R>( &mut self, kind: ListKind, f: impl FnOnce(&mut ListBuilder) -> R, ) -> &mut Self

列表(有序 / 无序)。

Source

pub fn code( &mut self, lang: impl Into<String>, text: impl Into<String>, ) -> &mut Self

代码块。lang 空串 = 无语言标签。

Source

pub fn divider(&mut self) -> &mut Self

分割线。

Source

pub fn panel<R>(&mut self, f: impl FnOnce(&mut PanelBuilder) -> R) -> &mut Self

面板(卡片):闭包先配装饰(.bg(..) / .border(..) / .rounded(..) / .pad(..) / .shadow()),内容方法经 Deref 直接用(p.text(..) / p.heading(..) …);全缺省 即主题默认卡片样(浅底 + 细边 + 圆角)。

Source

pub fn columns<R>( &mut self, f: impl FnOnce(&mut ColumnsBuilder) -> R, ) -> &mut Self

显式并排栏:闭包里用 .col(..) / .col_weighted(w, ..) 加栏。

Source

pub fn table<R>(&mut self, f: impl FnOnce(&mut TableBuilder) -> R) -> &mut Self

表格:闭包里用 .head([..]) / .row([..]) / .align([..]) / .width(列, 长)

Source

pub fn progress<R>( &mut self, value: f32, f: impl FnOnce(&mut ProgressBuilder) -> R, ) -> &mut Self

进度条:value 取 0–1(越界渲染时夹取),样式经闭包调 (.height(..) / .fill(..) / .track(..) / .radius(..) / .width_px(..) / .width_percent(..) / .align(..)),全缺省即「铺满内容宽的胶囊条,主题强调色」。

Source

pub fn image_bytes<R>( &mut self, bytes: Vec<u8>, f: impl FnOnce(&mut ImageBuilder) -> R, ) -> &mut Self

块级图(字节来源)。

Source

pub fn image_path<R>( &mut self, path: impl Into<PathBuf>, f: impl FnOnce(&mut ImageBuilder) -> R, ) -> &mut Self

块级图(磁盘路径)。

Trait Implementations§

Source§

impl Default for Doc

Source§

fn default() -> Doc

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

Auto Trait Implementations§

§

impl Freeze for Doc

§

impl RefUnwindSafe for Doc

§

impl Send for Doc

§

impl Sync for Doc

§

impl Unpin for Doc

§

impl UnsafeUnpin 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> 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 = 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.