Skip to content

Commit

Permalink
Renamed parameter show_search_box to search_box
Browse files Browse the repository at this point in the history
  • Loading branch information
karelvaculik committed Sep 16, 2023
1 parent afccfe8 commit 4695ef8
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 25 deletions.
2 changes: 1 addition & 1 deletion docs/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ parameters. The following table shows the parameter alternatives between these t
| `tables-scroll-y-height` | `--tables-scroll-y-height` | `scroll_y_height` in [`print_table()`](../api/pyreball_html/#pyreball.html.print_table) | Height of the tables when `tables-display-option` is set to `scrolling`. Any string compatible with CSS sizing can be used, e.g. `300px`, `20em`, etc. |
| `tables-scroll-x` | `--tables-scroll-x` | `scroll_x` in [`print_table()`](../api/pyreball_html/#pyreball.html.print_table) | Whether to allow scrolling on the x-axis. If turned off, a wide table is allowed to overflow the main container. It is recommended to turn this on. Allowed values: `yes`, `no`. |
| `sortable-tables` | `--sortable-tables` | `sortable` in [`print_table()`](../api/pyreball_html/#pyreball.html.print_table) | Whether to make columns in tables sortable. Allowed values: `yes`, `no`. |
| `tables-search-box` | `--tables-search-box` | `show_search_box` in [`print_table()`](../api/pyreball_html/#pyreball.html.print_table) | Whether to show the search box for the tables. Allowed values: `yes`, `no`. |
| `tables-search-box` | `--tables-search-box` | `search_box` in [`print_table()`](../api/pyreball_html/#pyreball.html.print_table) | Whether to show the search box for the tables. Allowed values: `yes`, `no`. |
| `tables-datatables-style` | `--tables-datatables-style` | `datatables_style` in [`print_table()`](../api/pyreball_html/#pyreball.html.print_table) | Datatables class(es) that affect the tables styling. If multiple classes are provided, separate them either with commas or spaces. See [DataTables documentation](https://datatables.net/manual/styling/classes) with the possible values. |
| `align-figures` | `--align-figures` | `align` in [`print_figure()`](../api/pyreball_html/#pyreball.html.print_figure) | Horizontal alignment of figures. Allowed values: `left`, `center`, `right`. |
| `figure-captions-position` | `--figure-captions-position` | `caption_position` in [`print_figure()`](../api/pyreball_html/#pyreball.html.print_figure) | Caption position for figures. Allowed values: `top`, `bottom`. |
Expand Down
2 changes: 1 addition & 1 deletion docs/examples/table_searching.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@
pb.print_table(
df,
caption="Table with a search box.",
show_search_box=True,
search_box=True,
)
2 changes: 1 addition & 1 deletion docs/tables.md
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ showing all entries on a single page.

## Searching

To allow searching within a table, just set `show_search_box` to `True`.
To allow searching within a table, just set `search_box` to `True`.

{{ inline_source("docs/examples/table_searching.py") }}

Expand Down
23 changes: 11 additions & 12 deletions pyreball/html.py
Original file line number Diff line number Diff line change
Expand Up @@ -578,7 +578,7 @@ def _gather_datatables_setup(
sortable: bool = False,
sorting_definition: Optional[List[Tuple[int, str]]] = None,
paging_sizes: Optional[List[Union[int, str]]] = None,
show_search_box: bool = False,
search_box: bool = False,
col_align_def: Optional[List[Dict[str, Any]]] = None,
datatables_definition: Optional[Dict[str, Any]] = None,
) -> Optional[Dict[str, Any]]:
Expand All @@ -604,8 +604,7 @@ def _gather_datatables_setup(

datatables_setup["info"] = False

# if show_search_box:
datatables_setup["searching"] = show_search_box
datatables_setup["searching"] = search_box

if sortable or sorting_definition is not None:
if sorting_definition is None:
Expand Down Expand Up @@ -685,7 +684,7 @@ def _prepare_table_html(
sortable: bool = False,
sorting_definition: Optional[List[Tuple[int, str]]] = None,
paging_sizes: Optional[List[Union[int, str]]] = None,
show_search_box: bool = False,
search_box: bool = False,
datatables_style: Union[str, List[str]] = "display",
datatables_definition: Optional[Dict[str, Any]] = None,
**kwargs: Any,
Expand All @@ -707,7 +706,7 @@ def _prepare_table_html(
sortable=sortable,
sorting_definition=sorting_definition,
paging_sizes=paging_sizes,
show_search_box=show_search_box,
search_box=search_box,
col_align_def=col_align_def,
datatables_definition=datatables_definition,
)
Expand Down Expand Up @@ -781,7 +780,7 @@ def print_table(
scroll_x: Optional[bool] = None,
sortable: Optional[bool] = None,
sorting_definition: Optional[List[Tuple[int, str]]] = None,
show_search_box: Optional[bool] = None,
search_box: Optional[bool] = None,
datatables_style: Optional[Union[str, List[str]]] = None,
datatables_definition: Optional[Dict[str, Any]] = None,
**kwargs: Any,
Expand Down Expand Up @@ -835,7 +834,7 @@ def print_table(
in the form of a list of tuples (<column_index>, <sorting>),
where <sorting> is either 'asc' or 'desc'.
When None, the columns are not pre-sorted.
show_search_box: Whether to show the search box for the table.
search_box: Whether to show the search box for the table.
Defaults to settings from config or CLI arguments if None.
datatables_style: One or more class names for styling tables using
Datatables styling. See https://datatables.net/manual/styling/classes
Expand All @@ -844,8 +843,8 @@ def print_table(
datatables_definition: Custom setup for datatables in the form of a dictionary.
This dictionary is serialized to json and passed to `DataTable` JavaScript
object as it is. If set (i.e. not None), values of parameters
`display_option`, `scroll_y_height`, `scroll_x`, `sortable`,
`sorting_definition`, `paging_sizes`, and `show_search_box` are ignored.
`col_align`, `display_option`, `paging_sizes`, `scroll_y_height`,
`scroll_x`, `sortable`, `sorting_definition`, and `search_box` are ignored.
Note that `datatables_style` is independent of this parameter.
**kwargs: Other parameters to pandas `to_html()` method. Note that parameter
`sparsify` is explicitly set to `False` by Pyreball, because tables
Expand Down Expand Up @@ -907,9 +906,9 @@ def print_table(
get_parameter_value("tables_paging_sizes")
),
)
show_search_box = bool(
search_box = bool(
merge_values(
primary_value=show_search_box,
primary_value=search_box,
secondary_value=get_parameter_value("tables_search_box"),
)
)
Expand Down Expand Up @@ -939,7 +938,7 @@ def print_table(
sortable=sortable,
sorting_definition=sorting_definition,
paging_sizes=paging_sizes,
show_search_box=show_search_box,
search_box=search_box,
datatables_style=datatables_style,
datatables_definition=datatables_definition,
**kwargs,
Expand Down
20 changes: 10 additions & 10 deletions tests/test_html.py
Original file line number Diff line number Diff line change
Expand Up @@ -861,7 +861,7 @@ def test__compute_length_menu_for_datatables__invalid_values(paging_sizes):
"sortable,"
"sorting_definition,"
"paging_sizes,"
"show_search_box,"
"search_box,"
"col_align_def,"
"datatables_definition,"
"expected_result",
Expand Down Expand Up @@ -967,7 +967,7 @@ def test__compute_length_menu_for_datatables__invalid_values(paging_sizes):
"info": False,
},
),
# display_option = full; scroll_x = False, show_search_box = True
# display_option = full; scroll_x = False, search_box = True
(
"full",
"300px",
Expand Down Expand Up @@ -1085,7 +1085,7 @@ def test__gather_datatables_setup(
sortable,
sorting_definition,
paging_sizes,
show_search_box,
search_box,
col_align_def,
datatables_definition,
expected_result,
Expand All @@ -1097,7 +1097,7 @@ def test__gather_datatables_setup(
sortable,
sorting_definition,
paging_sizes,
show_search_box,
search_box,
col_align_def,
datatables_definition,
)
Expand Down Expand Up @@ -1361,7 +1361,7 @@ def test__prepare_table_html__col_align(
sortable=True,
sorting_definition=None,
paging_sizes=None,
show_search_box=False,
search_box=False,
datatables_definition=None,
)
if set_index:
Expand All @@ -1381,7 +1381,7 @@ def test__prepare_table_html__col_align(
sortable=True,
sorting_definition=None,
paging_sizes=None,
show_search_box=False,
search_box=False,
col_align_def=expected_col_align_def,
datatables_definition=None,
)
Expand Down Expand Up @@ -1453,9 +1453,9 @@ def fake_get_parameter_value_different(key):
("sortable", None, "sortable_tables", False, False),
("paging_sizes", [100, 200], "tables_paging_sizes", "20,All", [100, 200]),
("paging_sizes", None, "tables_paging_sizes", "20,All", [20, "All"]),
("show_search_box", True, "tables_search_box", False, True),
("show_search_box", None, "tables_search_box", True, True),
("show_search_box", None, "tables_search_box", False, False),
("search_box", True, "tables_search_box", False, True),
("search_box", None, "tables_search_box", True, True),
("search_box", None, "tables_search_box", False, False),
(
"datatables_style",
"display",
Expand Down Expand Up @@ -1520,7 +1520,7 @@ def fake_get_parameter_value(key):
sortable=False,
sorting_definition=sorting_definition,
paging_sizes=None,
show_search_box=False,
search_box=False,
datatables_style="display",
datatables_definition=None,
additional_kwarg=42,
Expand Down

0 comments on commit 4695ef8

Please sign in to comment.