Skip to content

Export combine_elements() - #6885

Open
dmuenz wants to merge 2 commits into
tidyverse:mainfrom
dmuenz:export-combine-elements
Open

Export combine_elements()#6885
dmuenz wants to merge 2 commits into
tidyverse:mainfrom
dmuenz:export-combine-elements

Conversation

@dmuenz

@dmuenz dmuenz commented Jul 29, 2026

Copy link
Copy Markdown

This PR aims to fix #6882.

ggplot2 does not have an exported function that resolves a theme element object against a parent element object, applying the same resolution logic as calc_element(). In particular, such a function should correctly resolve deferred values like rel() and margin_part(). However, an unexported function named combine_elements() does exactly this -- it is the function that calc_element() uses under the hood.

So this PR simply (1) exports combine_elements, (2) improves its documentation since it will now be user-facing, and (3) for the same reason changes the function's parameter names from e1 and e2 to child and parent. As a bonus, (4) I added some new unit tests to check that deferred value inheritance works.

Note that an exported function named merge_element() exists and appears very similar to combine_elements(). But merge_element() does not resolve deferred values between a child and parent element object. I address this in the revised documentation for combine_elements().

BTW, I'm open to other name ideas for what I'm calling "deferred values", i.e., the return values of the rel() and margin_part() helpers that don't fully specify a value. I use this term in the documentation.

dmuenz added 2 commits July 29, 2026 12:26
* Renamed e1 and e2 parameters to child and parent -- much clearer
* Expanded documentation, with description and examples including comparison with merge_element()
* Ran devtools::document() to create the .Rd file and update NAMESPACE
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.

Public API for resolving a theme element against a parent

1 participant