Skip to content

Commit

Permalink
docs: add style.css entry to API reference docs (#624)
Browse files Browse the repository at this point in the history
* Add docstring for CellStyleCss (style.css)

* Update _quarto.yml with style.css API entry

* Remove pip install of the pointblank package

* Include missing import in tab_spanner() example
  • Loading branch information
rich-iannone authored Mar 3, 2025
1 parent dc82197 commit bca8c4d
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 4 deletions.
1 change: 0 additions & 1 deletion .github/workflows/ci-docs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ jobs:
- name: Install dependencies
run: |
python -m pip install ".[all]"
python -m pip install pointblank
- uses: quarto-dev/quarto-actions/setup@v2
with:
tinytex: true
Expand Down
1 change: 1 addition & 0 deletions docs/_quarto.yml
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@ quartodoc:
- style.fill
- style.text
- style.borders
- style.css
- title: Helper functions
desc: >
An assortment of helper functions is available in the **Great Tables** package. The
Expand Down
5 changes: 3 additions & 2 deletions great_tables/_spanners.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@
import itertools
from typing import TYPE_CHECKING

from typing_extensions import TypeAlias

from ._gt_data import SpannerInfo, Spanners
from ._locations import resolve_cols_c
from ._tbl_data import SelectExpr
from ._text import BaseText, Text
from ._utils import OrderedSet, _assert_list_is_subset
from typing_extensions import TypeAlias

if TYPE_CHECKING:
from ._gt_data import Boxhead
Expand Down Expand Up @@ -92,7 +93,7 @@ def tab_spanner(
performance under a unifying label.
```{python}
from great_tables import GT
from great_tables import GT, md
from great_tables.data import gtcars
colnames = ["model", "hp", "hp_rpm", "trq", "trq_rpm", "mpg_c", "mpg_h"]
Expand Down
25 changes: 24 additions & 1 deletion great_tables/_styles.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

from typing_extensions import Self, TypeAlias

from ._helpers import px, GoogleFont
from ._helpers import GoogleFont, px
from ._tbl_data import PlExpr, TblData, _get_cell, eval_transform

if TYPE_CHECKING:
Expand Down Expand Up @@ -127,6 +127,29 @@ def _raise_if_requires_data(self, loc: Loc):

@dataclass
class CellStyleCss(CellStyle):
"""A style specification for custom CSS rules.
The `style.css()` class is to be used with the `tab_style()` method, which itself allows for
the setting of custom styles to one or more cells. With `style.css()`, you can specify any CSS
rule that you would like to apply to the targeted cells.
Parameters
----------
rule
The CSS rule to apply to the targeted cells. This can be any valid CSS rule, such as
`background-color: red;` or `font-size: 14px;`.
Returns
-------
CellStyleCss
A CellStyleCss object, which is used for a `styles` argument if specifying a custom CSS
rule.
Examples
--------
See [`GT.tab_style()`](`great_tables.GT.tab_style`).
"""

rule: str

def _to_html_style(self):
Expand Down

0 comments on commit bca8c4d

Please sign in to comment.