Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[I think really good to do] Create a Tour like examples #484

Open
zhiburt opened this issue Jan 24, 2025 · 1 comment
Open

[I think really good to do] Create a Tour like examples #484

zhiburt opened this issue Jan 24, 2025 · 1 comment
Labels
documentation Improvements or additions to documentation enhancement New feature or request good first issue Good for newcomers

Comments

@zhiburt
Copy link
Owner

zhiburt commented Jan 24, 2025

I think it maybe be useful to add a few examples,
Or maybe even the whole new markdown file with a good explanation and a step by step guide for different settings.

Maybe markdown is better.
Maybe even a markdown book or how it's called?
I do do do like it.

Something which looks like, but shorter and more clear.
I think it's already too big 😅

//! [COMMENTED] A list of examples for a span use.

use tabled::{
    settings::{style::BorderSpanCorrection, Alignment, Span, Style},
    Table,
};

fn main() {
    let data = [
        (1, 2, 3),
        (4, 5, 6),
        (7, 8, 9),
        (10, 11, 12),
        (13, 14, 15),
        (16, 17, 18),
        (19, 20, 21),
    ];
    let mut table = Table::new(data);

    table.with(Style::modern_rounded());

    // Here we show how original table looks.
    println!("{table}");

    // Then there's a list of Span appliences and it's affects.

    // Spread cell by 1 column to the right.
    table.modify((0, 1), Span::column(2));

    // Spread cell all the way to the right,
    // Which essentially covers all row.
    table.modify((1, 0), Span::column(isize::MAX));

    // Spread cell by 1 column to the left.
    table.modify((2, 1), Span::column(-1));

    // Spread cell all the way to the left.
    table.modify((3, 2), Span::column(isize::MIN));

    // Spread cell to cover the whole row.
    table.modify((4, 0), Span::column(0));

    // Spread cell to cover the whole row.
    table.modify((5, 1), Span::column(0));

    // Spread cell to cover the whole row.
    table.modify((6, 2), Span::column(0));

    // Set a default span for a cell,
    // Essentially removing a span setting for it.
    table.modify((4, 0), Span::column(1));

    // Correct the style to look good
    table.with(BorderSpanCorrection);
    table.with(Alignment::center());

    println!("{table}");
}
@zhiburt zhiburt added documentation Improvements or additions to documentation enhancement New feature or request good first issue Good for newcomers labels Jan 24, 2025
@zhiburt
Copy link
Owner Author

zhiburt commented Jan 25, 2025

ref #486

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

1 participant