-module(tobble@table_render_opts). -compile([no_auto_import, nowarn_unused_vars, nowarn_unused_function, nowarn_nomatch]). -define(FILEPATH, "src/tobble/table_render_opts.gleam"). -export([table_width/1, column_width/1, line_type_ascii/0, line_type_box_drawing_characters/0, line_type_rounded_corner_box_drawing_characters/0, line_type_blank/0, title_position_top/0, title_position_bottom/0, hide_title/0, horizontal_rules_only_after_header/0, horizontal_rules_after_every_row/0, no_horizontal_rules/0, apply_options/2]). -export_type([option/0]). -if(?OTP_RELEASE >= 27). -define(MODULEDOC(Str), -moduledoc(Str)). -define(DOC(Str), -doc(Str)). -else. -define(MODULEDOC(Str), -compile([])). -define(DOC(Str), -compile([])). -endif. ?MODULEDOC( " Configure the way your table is rendered. Every function in this module\n" " will return an `Option` type that can be passed to the render functions\n" " of the `tobble` module.\n" ). -opaque option() :: {option, fun((tobble@internal@render:context()) -> tobble@internal@render:context())}. -file("src/tobble/table_render_opts.gleam", 17). ?DOC( " Render the table with a width of, at most, the given width. Note that this\n" " is best effort, and there are pathological cases where Tobble will decide\n" " to render your tables slightly wider than requested (e.g. requesting a\n" " width too small to even fit the table borders). By default, the table\n" " width is unconstrained.\n" ). -spec table_width(integer()) -> option(). table_width(Width) -> {option, fun(Context) -> tobble@internal@render:apply_table_width(Context, Width) end}. -file("src/tobble/table_render_opts.gleam", 24). ?DOC( " Render the table where each column's text has the given width. If a width\n" " less than 1 is given, this will default to 1. By default, columns are as\n" " wide as the longest row within them.\n" ). -spec column_width(integer()) -> option(). column_width(Width) -> {option, fun(Context) -> tobble@internal@render:apply_column_width(Context, Width) end}. -file("src/tobble/table_render_opts.gleam", 40). ?DOC( " Render the table with ASCII characters for the borders.\n" " This is the default setting.\n" "\n" " ```text\n" " +---------+--------------+\n" " | | Output |\n" " +---------+--------------+\n" " | Stage 1 | Wibble |\n" " | Stage 2 | Wobble |\n" " | Stage 3 | WibbleWobble |\n" " +---------+--------------+\n" " ```\n" ). -spec line_type_ascii() -> option(). line_type_ascii() -> {option, fun(Context) -> tobble@internal@render:apply_line_type(Context, a_s_c_i_i_line_type) end}. -file("src/tobble/table_render_opts.gleam", 55). ?DOC( " Renders the table with box drawing characters for the borders.\n" "\n" "
┌─────────┬──────────────┐\n"
    " │         │ Output       │\n"
    " ├─────────┼──────────────┤\n"
    " │ Stage 1 │ Wibble       │\n"
    " │ Stage 2 │ Wobble       │\n"
    " │ Stage 3 │ WibbleWobble │\n"
    " └─────────┴──────────────┘
\n" ). -spec line_type_box_drawing_characters() -> option(). line_type_box_drawing_characters() -> {option, fun(Context) -> tobble@internal@render:apply_line_type( Context, box_drawing_chars_line_type ) end}. -file("src/tobble/table_render_opts.gleam", 71). ?DOC( " Renders the table with box drawing characters for the borders, but\n" " with rounded corners.\n" "\n" "
╭─────────┬──────────────╮\n"
    " │         │ Output       │\n"
    " ├─────────┼──────────────┤\n"
    " │ Stage 1 │ Wibble       │\n"
    " │ Stage 2 │ Wobble       │\n"
    " │ Stage 3 │ WibbleWobble │\n"
    " ╰─────────┴──────────────╯
\n" ). -spec line_type_rounded_corner_box_drawing_characters() -> option(). line_type_rounded_corner_box_drawing_characters() -> {option, fun(Context) -> tobble@internal@render:apply_line_type( Context, box_drawing_chars_with_rounded_corners_line_type ) end}. -file("src/tobble/table_render_opts.gleam", 92). ?DOC( " Renders the table with spaces for the borders.\n" " Note that this does not strip trailing spaces, the borders that\n" " you see in other line types are simply replaced with spaces. It\n" " will, however, remove the top and bottom borders for you.\n" "\n" " ```text\n" " Output\n" "\n" " Stage 1 Wibble\n" " Stage 2 Wobble\n" " Stage 3 WibbleWobble\n" " ```\n" ). -spec line_type_blank() -> option(). line_type_blank() -> {option, fun(Context) -> tobble@internal@render:apply_line_type(Context, blank_line_type) end}. -file("src/tobble/table_render_opts.gleam", 100). ?DOC( " Place the title above the table. If the table does not have a title set, this option is ignored.\n" " By default, the title will render at the top.\n" ). -spec title_position_top() -> option(). title_position_top() -> {option, fun(Context) -> tobble@internal@render:apply_title_position( Context, top_title_position ) end}. -file("src/tobble/table_render_opts.gleam", 107). ?DOC(" Place the title above the table. If the table does not have a title set, this option is ignored.\n"). -spec title_position_bottom() -> option(). title_position_bottom() -> {option, fun(Context) -> tobble@internal@render:apply_title_position( Context, bottom_title_position ) end}. -file("src/tobble/table_render_opts.gleam", 114). ?DOC(" Render a table that has a title set, but without its title.\n"). -spec hide_title() -> option(). hide_title() -> {option, fun(Context) -> tobble@internal@render:apply_hide_title(Context) end}. -file("src/tobble/table_render_opts.gleam", 129). ?DOC( " Renders the table with only the header having a horizontal rule beneath it. This is the default setting.\n" "\n" " ```text\n" " +---------+--------------+\n" " | | Output |\n" " +---------+--------------+\n" " | Stage 1 | Wibble |\n" " | Stage 2 | Wobble |\n" " | Stage 3 | WibbleWobble |\n" " +---------+--------------+\n" " ```\n" ). -spec horizontal_rules_only_after_header() -> option(). horizontal_rules_only_after_header() -> {option, fun(Context) -> tobble@internal@render:apply_horizontal_rules( Context, header_only_horizontal_rules ) end}. -file("src/tobble/table_render_opts.gleam", 148). ?DOC( " Renders the table with every row the header having a horizontal rule beneath it.\n" "\n" " ```text\n" " +---------+--------------+\n" " | | Output |\n" " +---------+--------------+\n" " | Stage 1 | Wibble |\n" " +---------+--------------+\n" " | Stage 2 | Wobble |\n" " +---------+--------------+\n" " | Stage 3 | WibbleWobble |\n" " +---------+--------------+\n" " ```\n" ). -spec horizontal_rules_after_every_row() -> option(). horizontal_rules_after_every_row() -> {option, fun(Context) -> tobble@internal@render:apply_horizontal_rules( Context, every_row_has_horizontal_rules ) end}. -file("src/tobble/table_render_opts.gleam", 164). ?DOC( " Renders the table without any horizontal rules interleaved with the table's rows.\n" "\n" " ```text\n" " +---------+--------------+\n" " | | Output |\n" " | Stage 1 | Wibble |\n" " | Stage 2 | Wobble |\n" " | Stage 3 | WibbleWobble |\n" " +---------+--------------+\n" " ```\n" ). -spec no_horizontal_rules() -> option(). no_horizontal_rules() -> {option, fun(Context) -> tobble@internal@render:apply_horizontal_rules( Context, no_horizontal_rules ) end}. -file("src/tobble/table_render_opts.gleam", 171). ?DOC(false). -spec apply_options(tobble@internal@render:context(), list(option())) -> tobble@internal@render:context(). apply_options(Context, Options) -> gleam@list:fold( Options, Context, fun(Context@1, Option) -> (erlang:element(2, Option))(Context@1) end ).