From c79f2c004da0fee2ac1a221569bd07e0145499f2 Mon Sep 17 00:00:00 2001 From: David Gohel Date: Tue, 19 Nov 2024 19:05:21 +0100 Subject: [PATCH] internals: move unit to the end of args - avoid breaking code for those who don't name their args --- DESCRIPTION | 2 +- R/docx_add.R | 10 +++++----- man/body_add.Rd | 10 +++++----- man/body_add_gg.Rd | 8 ++++---- man/body_add_img.Rd | 8 ++++---- man/body_add_plot.Rd | 8 ++++---- 6 files changed, 23 insertions(+), 23 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 1d7fbac3..b0ef3858 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Type: Package Package: officer Title: Manipulation of Microsoft Word and PowerPoint Documents -Version: 0.6.8.002 +Version: 0.6.8.003 Authors@R: c( person("David", "Gohel", , "david.gohel@ardata.fr", role = c("aut", "cre")), person("Stefan", "Moog", , "moogs@gmx.de", role = "aut"), diff --git a/R/docx_add.R b/R/docx_add.R index 11f6b813..13c28e02 100644 --- a/R/docx_add.R +++ b/R/docx_add.R @@ -41,7 +41,7 @@ body_add_break <- function(x, pos = "after") { #' #' print(doc, target = tempfile(fileext = ".docx")) #' @family functions for adding content -body_add_img <- function(x, src, style = NULL, width, height, unit = "in", pos = "after") { +body_add_img <- function(x, src, style = NULL, width, height, pos = "after", unit = "in") { if (is.null(style)) { style <- x$default_styles$paragraph } @@ -151,7 +151,7 @@ body_add_docx <- function(x, src, pos = "after") { #' } #' @family functions for adding content #' @importFrom ragg agg_png -body_add_gg <- function(x, value, width = 6, height = 5, unit = "in", res = 300, style = "Normal", scale = 1, pos = "after", ...) { +body_add_gg <- function(x, value, width = 6, height = 5, res = 300, style = "Normal", scale = 1, pos = "after", unit = "in", ...) { if (!requireNamespace("ggplot2")) { stop("package ggplot2 is required to use this function") } @@ -417,7 +417,7 @@ body_add_toc <- function(x, level = 3, pos = "after", style = NULL, separator = #' #' print(doc, target = tempfile(fileext = ".docx")) #' @family functions for adding content -body_add_plot <- function(x, value, width = 6, height = 5, unit = "in", res = 300, style = "Normal", pos = "after", ...) { +body_add_plot <- function(x, value, width = 6, height = 5, res = 300, style = "Normal", pos = "after", unit = "in", ...) { unit <- check_unit(unit, c("in", "cm", "mm")) file <- tempfile(fileext = ".png") @@ -924,7 +924,7 @@ body_add.run_columnbreak <- function(x, value, style = NULL, ...) { #' arguments are expressed: "in", "cm" or "mm". #' @param res resolution of the png image in ppi #' @param scale Multiplicative scaling factor, same as in ggsave -body_add.gg <- function(x, value, width = 6, height = 5, unit = "in", res = 300, style = "Normal", scale = 1, ...) { +body_add.gg <- function(x, value, width = 6, height = 5, res = 300, style = "Normal", scale = 1, unit = "in", ...) { if (!requireNamespace("ggplot2")) { stop("package ggplot2 is required to use this function") } @@ -943,7 +943,7 @@ body_add.gg <- function(x, value, width = 6, height = 5, unit = "in", res = 300, #' @export #' @describeIn body_add add a base plot with a [plot_instr] object. -body_add.plot_instr <- function(x, value, width = 6, height = 5, unit = "in", res = 300, style = "Normal", ...) { +body_add.plot_instr <- function(x, value, width = 6, height = 5, res = 300, style = "Normal", unit = "in", ...) { unit <- check_unit(unit, c("in", "cm", "mm")) file <- tempfile(fileext = ".png") diff --git a/man/body_add.Rd b/man/body_add.Rd index 95e99113..ffd5707f 100644 --- a/man/body_add.Rd +++ b/man/body_add.Rd @@ -56,10 +56,10 @@ body_add(x, value, ...) value, width = 6, height = 5, - unit = "in", res = 300, style = "Normal", scale = 1, + unit = "in", ... ) @@ -68,9 +68,9 @@ body_add(x, value, ...) value, width = 6, height = 5, - unit = "in", res = 300, style = "Normal", + unit = "in", ... ) @@ -106,12 +106,12 @@ values must be "l" (left), "r" (right) or "c" (center).} \item{width, height}{plot size in units expressed by the unit argument. Defaults to a width of 6 and a height of 5 "in"ches.} -\item{unit}{One of the following units in which the width and height -arguments are expressed: "in", "cm" or "mm".} - \item{res}{resolution of the png image in ppi} \item{scale}{Multiplicative scaling factor, same as in ggsave} + +\item{unit}{One of the following units in which the width and height +arguments are expressed: "in", "cm" or "mm".} } \description{ This function add objects into a Word document. Values are added diff --git a/man/body_add_gg.Rd b/man/body_add_gg.Rd index 12dc5f56..312fe5f5 100644 --- a/man/body_add_gg.Rd +++ b/man/body_add_gg.Rd @@ -9,11 +9,11 @@ body_add_gg( value, width = 6, height = 5, - unit = "in", res = 300, style = "Normal", scale = 1, pos = "after", + unit = "in", ... ) } @@ -25,9 +25,6 @@ body_add_gg( \item{width, height}{plot size in units expressed by the unit argument. Defaults to a width of 6 and a height of 5 "in"ches.} -\item{unit}{One of the following units in which the width and height -arguments are expressed: "in", "cm" or "mm".} - \item{res}{resolution of the png image in ppi} \item{style}{paragraph style} @@ -37,6 +34,9 @@ arguments are expressed: "in", "cm" or "mm".} \item{pos}{where to add the new element relative to the cursor, one of "after", "before", "on".} +\item{unit}{One of the following units in which the width and height +arguments are expressed: "in", "cm" or "mm".} + \item{...}{Arguments to be passed to png function.} } \description{ diff --git a/man/body_add_img.Rd b/man/body_add_img.Rd index 65a248c3..c490429b 100644 --- a/man/body_add_img.Rd +++ b/man/body_add_img.Rd @@ -4,7 +4,7 @@ \alias{body_add_img} \title{Add an image in a 'Word' document} \usage{ -body_add_img(x, src, style = NULL, width, height, unit = "in", pos = "after") +body_add_img(x, src, style = NULL, width, height, pos = "after", unit = "in") } \arguments{ \item{x}{an rdocx object} @@ -16,11 +16,11 @@ body_add_img(x, src, style = NULL, width, height, unit = "in", pos = "after") \item{width, height}{image size in units expressed by the unit argument. Defaults to "in"ches.} -\item{unit}{One of the following units in which the width and height -arguments are expressed: "in", "cm" or "mm".} - \item{pos}{where to add the new element relative to the cursor, one of "after", "before", "on".} + +\item{unit}{One of the following units in which the width and height +arguments are expressed: "in", "cm" or "mm".} } \description{ add an image into an rdocx object. diff --git a/man/body_add_plot.Rd b/man/body_add_plot.Rd index 8b443fea..3c177fb8 100644 --- a/man/body_add_plot.Rd +++ b/man/body_add_plot.Rd @@ -9,10 +9,10 @@ body_add_plot( value, width = 6, height = 5, - unit = "in", res = 300, style = "Normal", pos = "after", + unit = "in", ... ) } @@ -24,9 +24,6 @@ body_add_plot( \item{width, height}{plot size in units expressed by the unit argument. Defaults to a width of 6 and a height of 5 "in"ches.} -\item{unit}{One of the following units in which the width and height -arguments are expressed: "in", "cm" or "mm".} - \item{res}{resolution of the png image in ppi} \item{style}{paragraph style} @@ -34,6 +31,9 @@ arguments are expressed: "in", "cm" or "mm".} \item{pos}{where to add the new element relative to the cursor, one of "after", "before", "on".} +\item{unit}{One of the following units in which the width and height +arguments are expressed: "in", "cm" or "mm".} + \item{...}{Arguments to be passed to png function.} } \description{