@@ -189,13 +189,7 @@ is_ph_location <- function(x) {
189189# ' @param x a location for a placeholder.
190190# ' @param doc an rpptx object
191191# ' @param ... unused arguments
192- # ' @examples
193- # ' doc <- read_pptx()
194- # ' doc <- add_slide(doc,
195- # ' layout = "Title and Content",
196- # ' master = "Office Theme"
197- # ' )
198- # ' fortify_location(ph_location_fullsize(), doc)
192+ # ' @example inst/examples/example_fortify_location.R
199193# ' @seealso [ph_location()], [ph_with()]
200194# ' @family functions for officer extensions
201195# ' @keywords internal
@@ -236,24 +230,7 @@ fortify_location <- function(x, doc, ...) {
236230# ' will be identified with that label in the *Selection Pane* of PowerPoint.
237231# ' This label can then be reused by other functions such as `ph_location_label()`.
238232# ' It can be set with argument `newlabel`.
239- # ' @examples
240- # ' doc <- read_pptx()
241- # ' doc <- add_slide(doc, "Title and Content")
242- # ' doc <- ph_with(doc, "Hello world",
243- # ' location = ph_location(width = 4, height = 3, newlabel = "hello")
244- # ' )
245- # ' print(doc, target = tempfile(fileext = ".pptx"))
246- # '
247- # ' # Set geometry and outline
248- # ' doc <- read_pptx()
249- # ' doc <- add_slide(doc, "Title and Content")
250- # ' loc <- ph_location(
251- # ' left = 1, top = 1, width = 4, height = 3, bg = "steelblue",
252- # ' ln = sp_line(color = "red", lwd = 2.5),
253- # ' geom = "trapezoid"
254- # ' )
255- # ' doc <- ph_with(doc, "", loc = loc)
256- # ' print(doc, target = tempfile(fileext = ".pptx"))
233+ # ' @example inst/examples/example_ph_location.R
257234ph_location <- function (
258235 left = 1 ,
259236 top = 1 ,
@@ -312,16 +289,7 @@ fortify_location.location_manual <- function(x, doc, ...) {
312289# ' @param ... unused arguments
313290# ' @family functions for placeholder location
314291# ' @inherit ph_location details
315- # ' @examples
316- # ' doc <- read_pptx()
317- # ' doc <- add_slide(doc, "Title and Content")
318- # ' doc <- ph_with(doc, "Title",
319- # ' location = ph_location_type(type = "title")
320- # ' )
321- # ' doc <- ph_with(doc, "Hello world",
322- # ' location = ph_location_template(top = 4, type = "title")
323- # ' )
324- # ' print(doc, target = tempfile(fileext = ".pptx"))
292+ # ' @example inst/examples/example_ph_location_template.R
325293# ' @export
326294ph_location_template <- function (
327295 left = 1 ,
@@ -394,33 +362,7 @@ fortify_location.location_template <- function(x, doc, ...) {
394362# ' @param ... unused arguments
395363# ' @family functions for placeholder location
396364# ' @inherit ph_location details
397- # ' @examples
398- # ' # ph_location_type demo ----
399- # '
400- # ' loc_title <- ph_location_type(type = "title")
401- # ' loc_footer <- ph_location_type(type = "ftr")
402- # ' loc_dt <- ph_location_type(type = "dt")
403- # ' loc_slidenum <- ph_location_type(type = "sldNum")
404- # ' loc_body <- ph_location_type(type = "body")
405- # '
406- # '
407- # ' doc <- read_pptx()
408- # ' doc <- add_slide(doc, "Title and Content")
409- # ' doc <- ph_with(x = doc, "Un titre", location = loc_title)
410- # ' doc <- ph_with(x = doc, "pied de page", location = loc_footer)
411- # ' doc <- ph_with(x = doc, format(Sys.Date()), location = loc_dt)
412- # ' doc <- ph_with(x = doc, "slide 1", location = loc_slidenum)
413- # ' doc <- ph_with(x = doc, letters[1:10], location = loc_body)
414- # '
415- # ' loc_subtitle <- ph_location_type(type = "subTitle")
416- # ' loc_ctrtitle <- ph_location_type(type = "ctrTitle")
417- # ' doc <- add_slide(doc, layout = "Title Slide")
418- # ' doc <- ph_with(x = doc, "Un sous titre", location = loc_subtitle)
419- # ' doc <- ph_with(x = doc, "Un titre", location = loc_ctrtitle)
420- # '
421- # ' fileout <- tempfile(fileext = ".pptx")
422- # ' print(doc, target = fileout)
423- # '
365+ # ' @example inst/examples/example_ph_location_type.R
424366ph_location_type <- function (
425367 type = " body" ,
426368 type_idx = NULL ,
@@ -522,26 +464,7 @@ fortify_location.location_type <- function(x, doc, ...) {
522464# ' @param ... unused arguments
523465# ' @family functions for placeholder location
524466# ' @inherit ph_location details
525- # ' @examples
526- # ' # ph_location_label demo ----
527- # '
528- # ' doc <- read_pptx()
529- # ' doc <- add_slide(doc, layout = "Title and Content")
530- # '
531- # ' # all ph_label can be read here
532- # ' layout_properties(doc, layout = "Title and Content")
533- # '
534- # ' doc <- ph_with(doc, head(iris),
535- # ' location = ph_location_label(ph_label = "Content Placeholder 2")
536- # ' )
537- # ' doc <- ph_with(doc, format(Sys.Date()),
538- # ' location = ph_location_label(ph_label = "Date Placeholder 3")
539- # ' )
540- # ' doc <- ph_with(doc, "This is a title",
541- # ' location = ph_location_label(ph_label = "Title 1")
542- # ' )
543- # '
544- # ' print(doc, target = tempfile(fileext = ".pptx"))
467+ # ' @example inst/examples/example_ph_location_label.R
545468ph_location_label <- function (ph_label , newlabel = NULL , ... ) {
546469 x <- list (ph_label = unname(ph_label ), label = unname(newlabel ))
547470 class(x ) <- c(" location_label" , " location_str" )
@@ -633,11 +556,7 @@ fortify_location.location_label <- function(x, doc, ...) {
633556# ' @param newlabel a label to associate with the placeholder.
634557# ' @param ... unused arguments
635558# ' @family functions for placeholder location
636- # ' @examples
637- # ' doc <- read_pptx()
638- # ' doc <- add_slide(doc, "Title and Content")
639- # ' doc <- ph_with(doc, "Hello world", location = ph_location_fullsize())
640- # ' print(doc, target = tempfile(fileext = ".pptx"))
559+ # ' @example inst/examples/example_ph_location_fullsize.R
641560ph_location_fullsize <- function (newlabel = " " , ... ) {
642561 x <- list (label = newlabel )
643562 class(x ) <- c(" location_fullsize" , " location_str" )
@@ -671,12 +590,7 @@ fortify_location.location_fullsize <- function(x, doc, ...) {
671590# ' @param newlabel a label to associate with the placeholder.
672591# ' @param ... unused arguments
673592# ' @family functions for placeholder location
674- # ' @examples
675- # ' doc <- read_pptx()
676- # ' doc <- add_slide(doc, "Title and Content")
677- # ' doc <- ph_with(doc, "Hello left", location = ph_location_left())
678- # ' doc <- ph_with(doc, "Hello right", location = ph_location_right())
679- # ' print(doc, target = tempfile(fileext = ".pptx"))
593+ # ' @example inst/examples/example_ph_location_left.R
680594ph_location_left <- function (newlabel = NULL , ... ) {
681595 x <- list (label = newlabel )
682596 class(x ) <- c(" location_left" , " location_str" )
@@ -715,12 +629,7 @@ fortify_location.location_left <- function(x, doc, ...) {
715629# ' @param newlabel a label to associate with the placeholder.
716630# ' @param ... unused arguments
717631# ' @family functions for placeholder location
718- # ' @examples
719- # ' doc <- read_pptx()
720- # ' doc <- add_slide(doc, "Title and Content")
721- # ' doc <- ph_with(doc, "Hello left", location = ph_location_left())
722- # ' doc <- ph_with(doc, "Hello right", location = ph_location_right())
723- # ' print(doc, target = tempfile(fileext = ".pptx"))
632+ # ' @example inst/examples/example_ph_location_left.R
724633ph_location_right <- function (newlabel = NULL , ... ) {
725634 x <- list (label = newlabel )
726635 class(x ) <- c(" location_right" , " location_str" )
@@ -763,21 +672,7 @@ fortify_location.location_right <- function(x, doc, ...) {
763672# ' @param ... not used.
764673# ' @family functions for placeholder location
765674# ' @inherit ph_location details
766- # ' @examples
767- # ' doc <- read_pptx()
768- # ' doc <- add_slide(doc, "Comparison")
769- # ' plot_layout_properties(doc, "Comparison")
770- # '
771- # ' doc <- ph_with(doc, "The Title", location = ph_location_id(id = 2)) # title
772- # ' doc <- ph_with(doc, "Left Header", location = ph_location_id(id = 3)) # left header
773- # ' doc <- ph_with(doc, "Left Content", location = ph_location_id(id = 4)) # left content
774- # ' doc <- ph_with(doc, "The Footer", location = ph_location_id(id = 8)) # footer
775- # '
776- # ' file <- tempfile(fileext = ".pptx")
777- # ' print(doc, file)
778- # ' \dontrun{
779- # ' file.show(file) # may not work on your system
780- # ' }
675+ # ' @example inst/examples/example_ph_location_id.R
781676ph_location_id <- function (id , newlabel = NULL , ... ) {
782677 ph_id <- id # for disambiguation, store initial value
783678
@@ -867,16 +762,7 @@ fortify_location.location_id <- function(x, doc, ...) {
867762# ' | `2` | Length 1 integer | `ph_location_id(2)` |
868763# ' | `c(0,0,4,5)` | Length 4 numeric, optionally named, `c(top=0, left=0, ...)` | `ph_location(0, 0, 4, 5)` |
869764# '
870- # ' @examples
871- # ' resolve_location("left")
872- # ' resolve_location("right")
873- # ' resolve_location("fullsize")
874- # ' resolve_location("body")
875- # ' resolve_location("body [1]")
876- # ' resolve_location("<some label>")
877- # ' resolve_location(2)
878- # ' resolve_location(c(0, 0, 4, 5))
879- # '
765+ # ' @example inst/examples/example_resolve_location.R
880766resolve_location <- function (x ) {
881767 if (is_ph_location(x )) {
882768 return (x )
0 commit comments