← GDG /

#275 gdtest_gt_tables

#275 gdtest_gt_tables OK INIT
GT tables rendering alongside Markdown tables
Renders Great Tables (GT) output alongside conventional Markdown tables. Tests that GT tables preserve <colgroup> tags, are not wrapped in gd-table-responsive, and are excluded from Bootstrap table-bordered styling, while Markdown tables still receive all responsive enhancements.
View Site → Build Log ๐Ÿงช Test Coverage

Build Mode

○ No great-docs.yml

This package has no pre-supplied config. It tests the full great-docs initgreat-docs build pipeline from scratch, relying entirely on auto-detection of the package layout, docstring style, and exports.

Dimensions

G7 M4 N1
G7Blended UG homepagelanding
M4Subdirectory UGuser_guide
N1Examples sectionsections

Source Files

๐Ÿ“ gdtest_gt_tables/
๐Ÿ“„ __init__.py
"""A test package for GT table rendering."""

__version__ = "0.1.0"
__all__ = ["make_gt_table", "summarize"]


def make_gt_table():
    """
    Create a sample Great Tables table.

    Returns
    -------
    GT
        A styled GT table object.

    Examples
    --------
    ```{python}
    from gdtest_gt_tables import make_gt_table
    make_gt_table()
    ```
    """
    from great_tables import GT
    import pandas as pd

    df = pd.DataFrame({
        "Name": ["Alice", "Bob", "Charlie"],
        "Score": [95, 87, 92],
        "Grade": ["A", "B+", "A-"],
    })
    return GT(df)


def summarize(data: list) -> dict:
    """
    Summarize a list of numbers.

    Parameters
    ----------
    data
        List of numeric values.

    Returns
    -------
    dict
        Summary statistics with keys ``mean``, ``total``, ``count``.
    """
    return {
        "mean": sum(data) / len(data),
        "total": sum(data),
        "count": len(data),
    }
๐Ÿ“ user_guide/
๐Ÿ“„ 01-gt-tables.qmd
---
title: Great Tables Output
---

## A GT Table with Fixed Column Widths

This page renders a Great Tables table with explicit column widths,
which produces a `<colgroup>` element that must be preserved.

```{python}
#| echo: false
from great_tables import GT
import pandas as pd

df = pd.DataFrame({
    "Name": ["Alice", "Bob", "Charlie", "Diana"],
    "Score": [95, 87, 92, 78],
    "Grade": ["A", "B+", "A-", "C+"],
    "Status": ["Pass", "Pass", "Pass", "Pass"],
})

(
    GT(df, id='gt_fixed')
    .tab_header(title="Student Grades", subtitle="Fall 2025")
    .cols_width(Name="150px", Score="80px", Grade="80px", Status="80px")
    .tab_options(quarto_disable_processing=True)
)
```

## A GT Table without Fixed Widths

This table uses default column sizing (no colgroup).

```{python}
#| echo: false
from great_tables import GT
import pandas as pd

df2 = pd.DataFrame({
    "Feature": ["Responsive", "Dark mode", "Scroll"],
    "Supported": ["Yes", "Yes", "Yes"],
})

GT(df2, id='gt_auto').tab_options(quarto_disable_processing=True)
```
๐Ÿ“„ 02-markdown-tables.qmd
---
title: Markdown Tables
---

## A Standard Markdown Table

This page has a conventional Markdown table that should get
responsive wrapping and Bootstrap table styling.

| Name    | Score | Grade | Status |
|---------|-------|-------|--------|
| Alice   | 95    | A     | Pass   |
| Bob     | 87    | B+    | Pass   |
| Charlie | 92    | A-    | Pass   |
| Diana   | 78    | C+    | Pass   |

The table above should:

- Be wrapped in a `gd-table-responsive` div
- NOT have a `<colgroup>` element
- Receive Bootstrap `.table-bordered` styling

## A Second Table

| Feature     | Supported |
|-------------|-----------|
| Responsive  | Yes       |
| Dark mode   | Yes       |
| Scroll      | Yes       |
๐Ÿ“„ 03-gt-page-level.qmd
---
title: GT with Page-Level Processing Disabled
jupyter: python3
html-table-processing: none
---

## GT Table (page-level `html-table-processing: none`)

This page uses the YAML frontmatter option
`html-table-processing: none` to disable Quarto's table
processing at the page level, rather than per-table with
`tab_options(quarto_disable_processing=True)`.

```{python}
#| echo: false
from great_tables import GT
import pandas as pd

df = pd.DataFrame({
    "City": ["London", "Paris", "Tokyo", "Sydney"],
    "Population": [8_982_000, 2_161_000, 13_960_000, 5_312_000],
    "Area_km2": [1_572, 105, 2_194, 12_368],
})

(
    GT(df, id='gt_page_level')
    .tab_header(title="World Cities", subtitle="Population & Area")
    .cols_width(City="120px", Population="120px", Area_km2="100px")
)
```

## Markdown Table on the Same Page

This Markdown table is also on the page with
`html-table-processing: none`, so it should also be free
of Quarto's Bootstrap table classes.

| City    | Country   |
|---------|-----------|
| London  | UK        |
| Paris   | France    |
| Tokyo   | Japan     |
๐Ÿ“„ README.md
# gdtest-gt-tables

Test Great Tables and Markdown tables rendering.
๐Ÿ“„ great-docs.yml
{}