Enum doku::json::Layout[][src]

pub enum Layout {
    OneColumn,
    TwoColumns {
        align: bool,
        spacing: usize,
    },
}
Expand description

Determines whether the document should contain one or two columns.

Variants

OneColumn

Prints types and comments inline, in a single chunk of text:

use doku::Document;

#[derive(Document)]
struct Person {
    /// First name
    /// (aka forename)
    fname: String,

    /// Last name
    /// (aka surname)
    lname: String,
}

let fmt = doku::json::Formatting {
    layout: doku::json::Layout::OneColumn,
    ..Default::default()
};

let doc = doku::to_json_fmt::<Person>(&fmt);

doku::assert_doc!(r#"
  {
    // First name
    // (aka forename)
    "fname": "string",
    // Last name
    // (aka surname)
    "lname": "string"
  }
"#, doc);
TwoColumns

Prints types and comments in two separate columns.

use doku::Document;

#[derive(Document)]
struct Person {
    /// First name
    /// (aka forename)
    fname: String,

    /// Last name
    /// (aka surname)
    lname: String,
}

let fmt = doku::json::Formatting {
    layout: doku::json::Layout::TwoColumns {
        align: true,
        spacing: 1,
    },
    ..Default::default()
};

let doc = doku::to_json_fmt::<Person>(&fmt);

doku::assert_doc!(r#"
  {
    "fname": "string", // First name
                       // (aka forename)
    "lname": "string"  // Last name
                       // (aka surname)
  }
"#, doc);

Fields of TwoColumns

align: bool

Whether the two columns should be aligned or not:

use doku::Document;

#[derive(Document)]
struct Person {
    /// First name
    /// (aka forename)
    fname: String,

    /// Last name
    /// (aka surname)
    lname: String,
}

let fmt = doku::json::Formatting {
    layout: doku::json::Layout::TwoColumns {
        align: false,
        spacing: 1,
    },
    ..Default::default()
};

let doc = doku::to_json_fmt::<Person>(&fmt);

doku::assert_doc!(r#"
  {
    "fname": "string", // First name
                       // (aka forename)
    "lname": "string" // Last name
                      // (aka surname)
  }
"#, doc);
spacing: usize

Size of the horizontal spacing between both columns:

use doku::Document;

#[derive(Document)]
struct Person {
    /// First name
    /// (aka forename)
    fname: String,

    /// Last name
    /// (aka surname)
    lname: String,
}

let fmt = doku::json::Formatting {
    layout: doku::json::Layout::TwoColumns {
        align: true,
        spacing: 5,
    },
    ..Default::default()
};

let doc = doku::to_json_fmt::<Person>(&fmt);

doku::assert_doc!(r#"
  {
    "fname": "string",     // First name
                           // (aka forename)
    "lname": "string"      // Last name
                           // (aka surname)
  }
"#, doc);

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

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

Deserialize this value from the given Serde deserializer. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The resulting type after obtaining ownership.

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

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

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

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.