devtools::document creating empty sections

Hello I am having an issue that a lot empty sections are created that show up as a note in r cmd check
it is a similar issues as mentioned here but unfortunately no working solution is presented:

i am using rstudio 1.3.959 and using roxyen2 7.1.0 and devtools 2.3.0.

using devtools::document() on the following code:

#' Function to retry failed functions after a time out of 5 seconds. Especially useful for failed api calls.
#'
#' @param max maximum number of retries, default = 2
#' @param init initial state of retries should always be left zero.
#' @param retryfun function to retry
#'
#' @return
#' @export
#'
#' @examples  retry(sum(1,"a"), max = 2)
retry <- function(retryfun, max = 2, init = 0){
  suppressWarnings( tryCatch({
    if (init < max) retryfun
  }, error = function(e){message(paste0("api request failed, automatically retrying time ",init + 1)) ;Sys.sleep(time = 5); retry(retryfun, max, init = init + 1)}))
}

leads to and retry.Rd file that looks like this:

% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/refinitiv.r
\name{retry}
\alias{retry}
\title{Function to retry failed functions after a time out of 5 seconds. Especially useful for failed api calls.}
\usage{
retry(retryfun, max = 2, init = 0)
}
\arguments{
\item{retryfun}{function to retry.}

\item{max}{maximum number of retries, default = 2}

\item{init}{initial state of retries should always be left zero, default = zero}
}
\value{

}
\description{
Function to retry failed functions after a time out of 5 seconds. Especially useful for failed api calls.
}
\examples{
 retry(sum(1,"a"), max = 2)
}

and when using devtools::check(document = FALSE) this leads to the following note:

> checking Rd files ... NOTE
   prepare_Rd: retry.Rd:16-18: Dropping empty section \value

Can someone please tell me what I am doing wrong here please.

To remove the empty section, remove the tag E.g.

#' Function to retry failed functions after a time out of 5 seconds. Especially useful for failed api calls.
#'
#' @param max maximum number of retries, default = 2
#' @param init initial state of retries should always be left zero.
#' @param retryfun function to retry
#'
#' @export
#'
#' @examples  retry(sum(1,"a"), max = 2)
retry <- function(retryfun, max = 2, init = 0){
  suppressWarnings( tryCatch({
    if (init < max) retryfun
  }, error = function(e){message(paste0("api request failed, automatically retrying time ",init + 1)) ;Sys.sleep(time = 5); retry(retryfun, max, init = init + 1)}))
}

However if you plan to submit your package to CRAN, note that return seems to have become a compulsory field, see this issue and this repo: “If a function does not return a value, please document that too, e.g. \value{None} .” i.e.

#' Function to retry failed functions after a time out of 5 seconds. Especially useful for failed api calls.
#'
#' @param max maximum number of retries, default = 2
#' @param init initial state of retries should always be left zero.
#' @param retryfun function to retry
#'
#' @return None
#' @export
#'
#' @examples  retry(sum(1,"a"), max = 2)
retry <- function(retryfun, max = 2, init = 0){
  suppressWarnings( tryCatch({
    if (init < max) retryfun
  }, error = function(e){message(paste0("api request failed, automatically retrying time ",init + 1)) ;Sys.sleep(time = 5); retry(retryfun, max, init = init + 1)}))
}
1 Like

thanks a lot that really helped, I have been struggling with this for days!

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.