Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: quarto option to disable table processing, warn on render #611

Open
wants to merge 9 commits into
base: main
Choose a base branch
from

Conversation

machow
Copy link
Collaborator

@machow machow commented Feb 18, 2025

This PR would replace #603, and implements the following:

  • Expose GT.tab_options(quarto_disable_processing=...). This was already in options and just needed to be added to the .tab_options() signature.
  • Add a render environment specific warnings step. This is run just before any rendering.

Note that I also ran into an issue with imports being collapsed (from 1 individual piece imported on each line), and ended up having to disable my isort vs code extension. But in the process I thrashed and upgraded ruff 😵. We can revert back if useful!

Copy link

codecov bot commented Feb 18, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 90.91%. Comparing base (3d6ad09) to head (49e64d1).
Report is 3 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #611      +/-   ##
==========================================
+ Coverage   90.71%   90.91%   +0.20%     
==========================================
  Files          46       47       +1     
  Lines        5417     5440      +23     
==========================================
+ Hits         4914     4946      +32     
+ Misses        503      494       -9     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@github-actions github-actions bot temporarily deployed to pr-611 February 18, 2025 17:25 Destroyed
@github-actions github-actions bot temporarily deployed to pr-611 February 18, 2025 17:59 Destroyed
@github-actions github-actions bot temporarily deployed to pr-611 February 18, 2025 18:08 Destroyed
@github-actions github-actions bot temporarily deployed to pr-611 February 18, 2025 18:24 Destroyed
@github-actions github-actions bot temporarily deployed to pr-611 February 18, 2025 18:30 Destroyed
@machow machow marked this pull request as ready for review February 18, 2025 18:41
@machow machow requested a review from rich-iannone as a code owner February 18, 2025 18:41
@machow
Copy link
Collaborator Author

machow commented Feb 18, 2025

@cscheid do you mind taking a look at these checks, and letting me know if they look reasonable for Quarto? We could always add a doc page to Great Tables that this warning links to, etc..?!

https://github.com/posit-dev/great-tables/pull/611/files#diff-48ec2d3311f2fce6029d5de1bb811a124b600d9a8eb6bd2bd1135a47f8a9cad1R16

@cscheid
Copy link
Collaborator

cscheid commented Feb 18, 2025

I'll take a look right away, thanks.

return

# cols_widths set ----
if any([col.column_width is not None for col in data._boxhead]):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The width configuration still works fine in Pandoc if it's given in percentages (which is why I wanted to do the fixup in the previous PR as I did). It's only when they're given in pixels that Pandoc doesn't like to parse them.

If I understand the code correctly here, the warning you're giving is maybe too generic, since it will warn in cases where things would still work fine.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, thanks! I'll add a piece that skips the warning if the user puts only percentages, and clarify when I warn that it's because non-percentages were used...

Copy link
Collaborator

@cscheid cscheid left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you intend for this to warn in the situation that all widths are given in percentages? That case shouldn't cause Quarto or Pandoc any trouble.

col_widths = [col.column_width for col in data._boxhead]

is_any_set = any([width is not None for width in col_widths])
is_all_pct = all([width is None or width.rstrip().endswith("%") for width in col_widths])
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We now skip the warning if all col widths are either unset or set to percentages

@@ -706,6 +706,8 @@ def cols_width(self: GTSelf, cases: dict[str, str] | None = None, **kwargs: str)
_assert_list_is_subset(mod_columns, set_list=column_names)

for col, width in new_cases.items():
if not isinstance(width, str):
raise ValueError(f"Width must be a string. Column {col} width received a {type(width)}")
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rich-iannone I noticed the annotations require width to be a string, but it's not enforced. WDYT of raising an error if a non-string is passed? If it's okay for users to pass a number, we could always coerce it to a string here instead!

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I definitely prefer that a string be the required input here. This is a good improvement, thanks!

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Upon discussion with @machow , we decided that a warning is more suitable here.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My understanding is the R program allows integers, so we'll fire a deprecation warning and coerce to a string for a while, just in case this path gets used by folks....!

@github-actions github-actions bot temporarily deployed to pr-611 February 19, 2025 18:14 Destroyed
@github-actions github-actions bot temporarily deployed to pr-611 February 19, 2025 18:15 Destroyed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants