-
Notifications
You must be signed in to change notification settings - Fork 109
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
location short forms for ph_with() location
arg
#632
location short forms for ph_with() location
arg
#632
Conversation
…avidgohel#623) Instead of a `location` object created by the `ph_location_*` function family, `ph_with_*` functions now resolves certain short form input into corresponding `location` objects. For example, instead of using `ph_location_label("<label>")` you can now simply pass the `"<label>"` to the `location` arg. The functionn will convert the string into the corresponding location object automatically. Other examples are `"body [1]"` for `ph_location_type(type = "body", type_idx = 1)`, or the integer `1` for `ph_location_id(id = 1)`.
i.e.: $left not $left 0 left 0
* Add tests for resolving short-form location * Moved other ph_location tests from `test-pptx-add.R` into `test-ph-location.R` for a better overview
Also correct corresponding tests
Codecov ReportAll modified and coverable lines are covered by tests ✅
❗ Your organization needs to install the Codecov GitHub app to enable full functionality. Additional details and impacted files@@ Coverage Diff @@
## master #632 +/- ##
==========================================
+ Coverage 86.10% 86.35% +0.25%
==========================================
Files 43 43
Lines 7032 7161 +129
==========================================
+ Hits 6055 6184 +129
Misses 977 977 ☔ View full report in Codecov by Sentry. |
worked but unclear, also caused invisible return
Exportiing it, as it might be helpful if other packages want to use it in their own wrappers.
thank you @markheckmann ! |
This PR implements location short forms as discussed in #623
NB: @davidgohel I use the
styler
package to format my code. I accidentally also reformatted a few lines of your code in the fileR/ph_location.R
usingstyler
. See this commit. If you do not like this format or if you do not want this, please let me know and I will recreate your code's format.The
location
arg inph_with
now understands location short forms (numeric or string). Short forms are an alternative to passing the location object as returned by theph_location_*
functions. The following short forms exist (also listed in theph_with()
help file).ph_location_left()
"left"
ph_location_right()
"right"
ph_location_fullsize()
"fullsize"
ph_location_type("body", 1)
"body [1]"
1
if omitted)ph_location_label("my_label")
"my_label"
ph_location_id(1)
1
ph_location(0, 0, 4, 5)
c(0,0,4,5)
c(top=0, left=0, ...)
The output of the two examples below are identical. The first uses the
ph_location_*
functions, the second their location short form equivalents.Full form
Created on 2025-01-26 with reprex v2.0.2
Short form
NB: The short forms is often achieved by just removing the
ph_location_*
wrapper.Created on 2025-01-26 with reprex v2.0.2