-
Notifications
You must be signed in to change notification settings - Fork 114
feat: change defaults of master and layout arg in add_slide(), add layout_default()
(#635)
#644
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: change defaults of master and layout arg in add_slide(), add layout_default()
(#635)
#644
Conversation
`layout_default()` sets a default layout for `add_slide()`
`print.rpptx` now uses pluralization and marks the default layout (if set by `layout_default()`) with an asterisk (davidgohel#635)
Codecov ReportAttention: Patch coverage is
❗ Your organization needs to install the Codecov GitHub app to enable full functionality. Additional details and impacted files@@ Coverage Diff @@
## master #644 +/- ##
==========================================
+ Coverage 86.42% 86.47% +0.04%
==========================================
Files 43 43
Lines 7235 7275 +40
==========================================
+ Hits 6253 6291 +38
- Misses 982 984 +2 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
@markheckmann thanks, I will not be able to work on the PR this week, hopefully next week I will try to avoid this breaking changes. We can totally afford changing flextable or autoslider.core but there are lot of scripts in companies that will be affected and we must not break their codes. |
okay, then I suggest the following modification to avoid potential breaking changes for user code. @davidgohel Please let me know, in case you have any doubts or further suggestions New approach We maintain the current This approach should not cause any revdep issues and also no problem in user code. I will make the changes and check the former. |
To avoid breaking changes in old code, `read_pptx()` automatically sets the default layout `"Slide and Content"`, if it exists. This makes sure, that the behavior of `add_slide()` does not change.
Updated PRHi @davidgohel , I updated the PR as follows: Summary
Changes1.
|
`add_slide()` now throws a deprecation warning, if no layout is specified (either via the `layout` arg or by setting a default layout). It then uses the `layout` arg's former default value (`"Title and Content"`). This makes sure, that the behavior of `add_slide()` does not change and avoids backward compatibility issues
PR Update No. 2@davidgohel I gave it a second thought and what I suggested is no good idea. I think the proper way to do it is as follows.
So these are the complete changes: Changes1. add_slide(): removing default settings for args layout and master.library(officer)
x <- read_pptx()
x <- add_slide(x) # still works but with deprecation warning
#> Warning in add_slide(x): Calling `add_slide()` without specifying a `layout` is deprecated.
#> Please pass a `layout` or use `layout_default()` to set a default.
#> => I will now continue with the former `layout` default "Title and Content" for backwards compatibility...
# new expected way:
x <- add_slide(x, "Title and Content") # pass a layout
x <- x |>
layout_default("Title and Content") |> # set a default layout
add_slide() Created on 2025-04-20 with reprex v2.1.1 2. layout_default() to set (and unset) a default layout used by add_slide()library(officer)
x <- read_pptx() |>
layout_default("Title and Content") |> # set default layout to "Title and Content"
add_slide() |> # add slide with layout "Title and Content"
layout_default("Comparison") |> # change default layout to "Comparison"
add_slide()
# note that layout "Comparison" is marked as default now
x
#> pptx document with 2 slides
#> Available layouts and their associated master(s):
#> (*) = Default layout
#> layout master
#> 1 Title Slide Office Theme
#> 2 Title and Content Office Theme
#> 3 Section Header Office Theme
#> 4 Two Content Office Theme
#> 5 Comparison Office Theme *
#> 6 Title Only Office Theme
#> 7 Blank Office Theme
x <- x |> layout_default() # remove default
# Without a default layout, again a deprecation warning is raised.
x |> add_slide()
#> Warning in add_slide(x): Calling `add_slide()` without specifying a `layout` is deprecated.
#> Please pass a `layout` or use `layout_default()` to set a default.
#> => I will now continue with the former default layout "Title and Content" for backwards compatibility...
#> pptx document with 3 slides
#> Available layouts and their associated master(s):
#> layout master
#> 1 Title Slide Office Theme
#> 2 Title and Content Office Theme
#> 3 Section Header Office Theme
#> 4 Two Content Office Theme
#> 5 Comparison Office Theme
#> 6 Title Only Office Theme
#> 7 Blank Office Theme Created on 2025-04-20 with reprex v2.1.1 3. revdep checksAs the behavior of We checked 75 reverse dependencies, comparing R CMD check results across CRAN and dev versions of this package.
* We saw 0 new problems
* We failed to check 4 packages
Issues with CRAN packages are summarised below.
### Failed to check
* esquisse (NA)
* reservr (NA)
* rvg (NA)
* statgenGWAS (NA) |
Really appreciate the PR, it’s very well done! Sorry for the delayed response — I finally had time to review it. |
Summary
Hi @davidgohel , this PR closes #635:
add_slide()
: remove default settings for argslayout
andmaster
layout_default()
: new function to set a default layout foradd_slide()
revdeps: Luckily, there are only 2 revdep problems, both easy to fix (however, 11 pkgs failed to check). Please find the complete revdep results at the bottom. Once this PR is accepted, I am happy to submit patch PRs for both packages (
flextable
&autoslider.core
) affected by the{officer}
0.6.9 release, if you like.Changes
1.
add_slide()
: removing default settings for argslayout
andmaster
add_slide()
requires arglayout
nowmaster
is only required, if thelayout
is not unique across mastersbefore
after
Created on 2025-03-29 with reprex v2.0.2
2.
layout_default()
to set (and unset) a default layout foradd_slide()
print.rpptx
now indicates if a default layout is set:Created on 2025-03-29 with reprex v2.0.2
revdep checks
I checked the source code of all packages listed under
failed to check
manually to see ifadd_slide()
was used without an explicit layout name. This was not the case, so there should be no problems in these packages.