Skip to main content

SurfDocBuilder

Struct SurfDocBuilder 

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

Fluent builder for constructing SurfDoc documents programmatically.

§Example

use surf_parse::builder::SurfDocBuilder;
use surf_parse::types::CalloutType;

let doc = SurfDocBuilder::new()
    .title("My Doc")
    .heading(1, "Welcome")
    .callout(CalloutType::Info, "Important note")
    .build();

assert_eq!(doc.blocks.len(), 2);

Implementations§

Source§

impl SurfDocBuilder

Source

pub fn new() -> Self

Create a new empty builder.

Source

pub fn title(self, title: &str) -> Self

Set the document title.

Source

pub fn doc_type(self, dt: DocType) -> Self

Set the document type.

Source

pub fn status(self, s: DocStatus) -> Self

Set the document status.

Source

pub fn author(self, author: &str) -> Self

Set the document author.

Source

pub fn tags(self, tags: Vec<String>) -> Self

Set the document tags.

Source

pub fn description(self, desc: &str) -> Self

Set the document description.

Source

pub fn front_matter(self, fm: FrontMatter) -> Self

Set the entire front matter at once.

Source

pub fn markdown(self, content: &str) -> Self

Add a raw markdown block.

Source

pub fn heading(self, level: u8, text: &str) -> Self

Add a markdown heading (syntactic sugar for markdown("## text")).

Source

pub fn callout(self, callout_type: CalloutType, content: &str) -> Self

Add a callout block.

Source

pub fn callout_titled( self, callout_type: CalloutType, title: &str, content: &str, ) -> Self

Add a callout block with a title.

Source

pub fn code(self, content: &str, lang: Option<&str>) -> Self

Add a code block with optional language.

Source

pub fn code_file(self, content: &str, lang: &str, file: &str) -> Self

Add a code block with language and file path.

Source

pub fn data_table(self, headers: Vec<String>, rows: Vec<Vec<String>>) -> Self

Add a data table block.

Source

pub fn task(self, text: &str, done: bool) -> Self

Add a single task item.

Source

pub fn tasks(self, items: Vec<TaskItem>) -> Self

Add a tasks block with multiple items.

Source

pub fn decision(self, status: DecisionStatus, content: &str) -> Self

Add a decision block.

Source

pub fn metric(self, label: &str, value: &str) -> Self

Add a metric block.

Source

pub fn metric_with_trend( self, label: &str, value: &str, trend: Trend, unit: Option<&str>, ) -> Self

Add a metric block with trend and optional unit.

Source

pub fn summary(self, content: &str) -> Self

Add a summary block.

Source

pub fn figure(self, src: &str) -> Self

Add a figure block.

Source

pub fn figure_with_caption( self, src: &str, caption: &str, alt: Option<&str>, ) -> Self

Add a figure block with caption and optional alt text.

Source

pub fn quote(self, content: &str) -> Self

Add a quote block.

Source

pub fn quote_attributed(self, content: &str, attribution: &str) -> Self

Add a quote block with attribution.

Source

pub fn cta(self, label: &str, href: &str, primary: bool) -> Self

Add a call-to-action block.

Source

pub fn hero_image(self, src: &str, alt: Option<&str>) -> Self

Add a hero image block.

Source

pub fn testimonial( self, content: &str, author: Option<&str>, role: Option<&str>, company: Option<&str>, ) -> Self

Add a testimonial block.

Source

pub fn style(self, properties: Vec<StyleProperty>) -> Self

Add a style block.

Source

pub fn faq(self, items: Vec<FaqItem>) -> Self

Add an FAQ block.

Source

pub fn pricing_table(self, headers: Vec<String>, rows: Vec<Vec<String>>) -> Self

Add a pricing table block.

Source

pub fn site(self, domain: Option<&str>, properties: Vec<StyleProperty>) -> Self

Add a site configuration block.

Source

pub fn page( self, route: &str, layout: Option<&str>, title: Option<&str>, content: &str, ) -> Self

Add a page block.

Source

pub fn nav(self, items: Vec<NavItem>, logo: Option<&str>) -> Self

Add a navigation block.

Source

pub fn embed( self, src: &str, embed_type: Option<EmbedType>, title: Option<&str>, ) -> Self

Add an embed block.

Source

pub fn form(self, fields: Vec<FormField>, submit_label: Option<&str>) -> Self

Add a form block.

Source

pub fn gallery(self, items: Vec<GalleryItem>, columns: Option<u32>) -> Self

Add a gallery block.

Source

pub fn footer( self, sections: Vec<FooterSection>, copyright: Option<&str>, social: Vec<SocialLink>, ) -> Self

Add a footer block.

Source

pub fn tabs(self, tabs: Vec<TabPanel>) -> Self

Add a tabs block.

Source

pub fn columns(self, columns: Vec<ColumnContent>) -> Self

Add a columns block.

Source

pub fn hero( self, headline: Option<&str>, subtitle: Option<&str>, badge: Option<&str>, buttons: Vec<HeroButton>, ) -> Self

Add a hero section block.

Source

pub fn features(self, cards: Vec<FeatureCard>, cols: Option<u32>) -> Self

Add a features card grid block.

Source

pub fn steps(self, steps: Vec<StepItem>) -> Self

Add a steps block.

Source

pub fn stats(self, items: Vec<StatItem>) -> Self

Add a stats block.

Source

pub fn comparison( self, headers: Vec<String>, rows: Vec<Vec<String>>, highlight: Option<&str>, ) -> Self

Add a comparison table block.

Add a logo block.

Source

pub fn toc(self, depth: u32) -> Self

Add a table-of-contents block.

Source

pub fn before_after( self, before_items: Vec<BeforeAfterItem>, after_items: Vec<BeforeAfterItem>, transition: Option<&str>, ) -> Self

Add a before/after comparison block.

Source

pub fn pipeline(self, steps: Vec<PipelineStep>) -> Self

Add a pipeline flow block.

Source

pub fn section( self, bg: Option<&str>, headline: Option<&str>, subtitle: Option<&str>, content: &str, ) -> Self

Add a section container block.

Source

pub fn product_card( self, title: &str, subtitle: Option<&str>, badge: Option<&str>, badge_color: Option<&str>, body: &str, features: Vec<String>, cta_label: Option<&str>, cta_href: Option<&str>, ) -> Self

Add a product card block.

Source

pub fn app( self, name: &str, binary: Option<&str>, region: Option<&str>, port: Option<u32>, children: Vec<Block>, ) -> Self

Add an app manifest container block.

Source

pub fn deploy( self, env: &str, app: Option<&str>, machines: Option<u32>, memory: Option<u32>, ) -> Self

Add a deploy block.

Source

pub fn infra_database(self, name: Option<&str>, shared_auth: bool) -> Self

Add an infrastructure database block.

Source

pub fn build(self) -> SurfDoc

Consume the builder and produce a SurfDoc.

Trait Implementations§

Source§

impl Default for SurfDocBuilder

Source§

fn default() -> Self

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

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