Skip to content

Commit fcd318e

Browse files
committed
add docstring
1 parent 90d0a1b commit fcd318e

File tree

2 files changed

+80
-3
lines changed

2 files changed

+80
-3
lines changed

docs/styles.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
--bs-body-bg: white;
33
}
44

5-
.sidebar {
5+
.sidebar-navigation {
66
background-color: white !important;
77
}
88

gt_extras/styling.py

Lines changed: 79 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,90 @@
1111
def gt_add_divider(
1212
gt: GT,
1313
columns: SelectExpr,
14-
sides: Literal["right", "left", "top", "bottom", "all"]
15-
| list[Literal["right", "left", "top", "bottom", "all"]] = "right",
14+
sides: (
15+
Literal["right", "left", "top", "bottom", "all"]
16+
| list[Literal["right", "left", "top", "bottom", "all"]]
17+
) = "right",
1618
color: str = "grey",
1719
divider_style: Literal["solid", "dashed", "dotted", "hidden", "double"] = "solid",
1820
weight: int = 2,
1921
include_labels: bool = True,
2022
) -> GT:
23+
"""
24+
Add dividers to specified columns in a GT table.
25+
26+
The `gt_add_divider()` function takes an existing `GT` object and adds dividers to the specified
27+
columns. Dividers can be applied to one or more sides of the cells, with customizable color,
28+
style, and weight. Optionally, dividers can also be applied to column labels.
29+
30+
Parameters
31+
----------
32+
gt
33+
A `GT` object to modify.
34+
35+
columns
36+
The columns to which dividers should be applied.
37+
38+
sides
39+
The sides of the cells where dividers should be added. Options include `"right"`, `"left"`,
40+
`"top"`, `"bottom"`, or `"all"`. A list of sides can also be provided to apply dividers to
41+
multiple sides.
42+
43+
color
44+
The color of the dividers.
45+
46+
divider_style
47+
The style of the dividers. Options include `"solid"`, `"dashed"`, `"dotted"`, `"hidden"`,
48+
and `"double"`.
49+
50+
weight
51+
The thickness of the dividers in pixels.
52+
53+
include_labels
54+
Whether to include dividers in the column labels. If `True`, dividers will be applied to
55+
both the body and the column labels. If `False`, dividers will only be applied to the body.
56+
57+
Returns
58+
-------
59+
GT
60+
A `GT` object with dividers added to the specified columns.
61+
62+
Examples
63+
--------
64+
```{python}
65+
import pandas as pd
66+
from great_tables import GT
67+
from great_tables.data import peeps
68+
import gt_extras as gte
69+
70+
peeps_mini = peeps.head(6)
71+
72+
gt = (
73+
GT(peeps_mini)
74+
.cols_hide([
75+
"name_family", "postcode", "country", "country_code",
76+
"dob", "gender", "state_prov", "email_addr",
77+
])
78+
.tab_spanner("Location", ["address", "city"])
79+
.tab_spanner("Body Measurements", ["height_cm", "weight_kg"])
80+
)
81+
82+
gt.pipe(
83+
gte.gt_add_divider,
84+
columns="name_given",
85+
color="#FFB90F",
86+
divider_style="double",
87+
weight=8,
88+
).pipe(
89+
gte.gt_add_divider,
90+
columns="phone_number",
91+
color="purple",
92+
sides=["right", "left"],
93+
weight=5,
94+
)
95+
```
96+
"""
97+
2198
locations = [loc.body(columns=columns)]
2299

23100
if include_labels:

0 commit comments

Comments
 (0)