Skip to content

Commit

Permalink
fix: Exports S3 methods, silence roxygen warnings
Browse files Browse the repository at this point in the history
Roxygen throws warnings. Export of s3 methods required. See discussion here: r-lib/roxygen2#1592
  • Loading branch information
markheckmann authored Sep 14, 2024
1 parent b6f053c commit 04c9dcb
Show file tree
Hide file tree
Showing 8 changed files with 33 additions and 1 deletion.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Type: Package
Package: officer
Title: Manipulation of Microsoft Word and PowerPoint Documents
Version: 0.6.7.011
Version: 0.6.7.012
Authors@R: c(
person("David", "Gohel", , "david.gohel@ardata.fr", role = c("aut", "cre")),
person("Stefan", "Moog", , "moogs@gmx.de", role = "aut"),
Expand Down
10 changes: 10 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
# Generated by roxygen2: do not edit by hand

S3method("[",core_properties)
S3method("[",custom_properties)
S3method("[<-",core_properties)
S3method("[<-",custom_properties)
S3method(as.character,fp_tab)
S3method(as.character,fp_tabs)
S3method(as.character,officer_cursor)
S3method(as.data.frame,external_img)
S3method(as.data.frame,fpar)
S3method(as.matrix,rpptx)
S3method(body_add,block_caption)
S3method(body_add,block_list)
Expand All @@ -18,6 +25,7 @@ S3method(body_add,numeric)
S3method(body_add,plot_instr)
S3method(body_add,run_columnbreak)
S3method(body_add,run_pagebreak)
S3method(dim,external_img)
S3method(format,fp_cell)
S3method(format,fp_par)
S3method(format,fp_text)
Expand All @@ -31,6 +39,8 @@ S3method(fortify_location,location_type)
S3method(length,rdocx)
S3method(length,rpptx)
S3method(length,rxlsx)
S3method(ph_from_location,location_label)
S3method(ph_from_location,location_type)
S3method(ph_with,block_list)
S3method(ph_with,character)
S3method(ph_with,data.frame)
Expand Down
6 changes: 6 additions & 0 deletions R/core_properties.R
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ default_cp_tags <- list(
category = list(ns = "cp", attrs = NA_character_)
)


#' @export
`[<-.core_properties` <- function( x, i, j, value ){
if( !i %in% x$data[,"name"] ) {
attrs <- ifelse(is.na(default_cp_tags[[i]]$attrs), "", paste0(" ", default_cp_tags[[i]]$attrs))
Expand All @@ -61,10 +63,14 @@ default_cp_tags <- list(
}
x
}


#' @export
`[.core_properties` <- function( x, i, j ){
x$data[i,j]
}


write_core_properties <- function(core_matrix, package_dir){
ns_ <- core_matrix$ns
core_matrix <- core_matrix$data
Expand Down
5 changes: 5 additions & 0 deletions R/custom_properties.R
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ read_custom_properties <- function(package_dir) {
z
}


#' @export
`[<-.custom_properties` <- function(x, i, j, value) {
if (!i %in% x$data[, "name"]) {
if (nrow(x$data) < 1) {
Expand All @@ -50,6 +52,9 @@ read_custom_properties <- function(package_dir) {
}
x
}


#' @export
`[.custom_properties` <- function(x, i, j) {
if (nrow(x$data) < 1) {
return(character())
Expand Down
3 changes: 3 additions & 0 deletions R/docx_cursor.R
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,9 @@ officer_cursor <- function(node) {
class(x) <- "officer_cursor"
x
}


#' @export
as.character.officer_cursor <- function(x, ...) {
if (length(x$nodes_names) < 1) {
return(NA_character_)
Expand Down
2 changes: 2 additions & 0 deletions R/ooxml_block_objects.R
Original file line number Diff line number Diff line change
Expand Up @@ -886,6 +886,7 @@ fortify_fpar <- function(x){
}


#' @export
as.data.frame.fpar <- function( x, ...){
chks <- fortify_fpar(x)
chks <- chks[sapply(chks, function(x) inherits(x, "ftext"))]
Expand All @@ -897,6 +898,7 @@ as.data.frame.fpar <- function( x, ...){
rbind_match_columns(chks)
}


#' @export
to_wml.fpar <- function(x, add_ns = FALSE, style_id = NULL, ...) {

Expand Down
4 changes: 4 additions & 0 deletions R/ooxml_run_objects.R
Original file line number Diff line number Diff line change
Expand Up @@ -1050,11 +1050,15 @@ external_img <- function(src, width = .5, height = .2, unit = "in", guess_size =
src
}


#' @export
dim.external_img <- function(x) {
x <- attr(x, "dims")
data.frame(width = x$width, height = x$height)
}


#' @export
as.data.frame.external_img <- function(x, ...) {
dimx <- attr(x, "dims")
data.frame(path = as.character(x), width = dimx$width, height = dimx$height, alt = attr(x, "alt"), stringsAsFactors = FALSE)
Expand Down
2 changes: 2 additions & 0 deletions R/ppt_notes.R
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ ph_from_location <- function(loc, doc, ...){
}


#' @export
ph_from_location.location_label <- function(loc, doc, ...) {
xfrm <- doc$notesMaster$xfrm()
location <- xfrm[xfrm$ph_label == loc$ph_label, ]
Expand All @@ -155,6 +156,7 @@ ph_from_location.location_label <- function(loc, doc, ...) {
}


#' @export
ph_from_location.location_type <- function(loc, doc, ...) {
xfrm <- doc$notesMaster$xfrm()
location <- xfrm[xfrm$type == loc$type, ]
Expand Down

0 comments on commit 04c9dcb

Please sign in to comment.