roxygen2 "Error: titlerequires a value"
Asked Answered
I

2

6

I'm receiving an error from roxygenize() that I can't understand. I have a package of my miscellaneous functions in which the .Rd files are generated via roxygen.

The error is Error: titlerequires a value, which suggests that there is no @title tag. However there is an @title tag in the kmmisc-package.R file, so I'm not sure what the problem is.

kmmisc-package.R contains:

##' Miscellaneous Functions
##' 
##' \tabular{ll}{
##' Package: \tab kmmisc\cr
##' Type: \tab Package\cr
##' Version: \tab 0.1-2\cr
##' Date: \tab 2011-10-06\cr    
##' License: \tab GPL-2\cr
##' LazyLoad: \tab yes\cr
##' LazyData: \tab yes\cr
##' }
##' 
##' @author Me \email{my@@email}
##' 
##' Maintainer: Me \email{my@@email}
##'
##' @name kmmisc-package
##' @docType package
##' @title KM Misc
##' @keywords package
##' 
NULL

I'm using R 2.13.2 with roxygen2 2.1 just reinstalled from CRAN. The complete sessionInfo() is in the gist at https://gist.github.com/1268056

Edit

At @andrie's suggestion, I now have

#' Miscellaneous Functions
#' 
#' \tabular{ll}{
#' Package: \tab kmmisc\cr
#' Type: \tab Package\cr
#' Version: \tab 0.1-2\cr
#' Date: \tab 2011-09-14\cr    
#' License: \tab GPL-2\cr
#' LazyLoad: \tab yes\cr
#' LazyData: \tab yes\cr
#' }
#' 
#' @author Me \email{my@@email}
#' 
#' Maintainer: Me \email{my@@email}
#' @name package-kmmisc
#' @docType package
#' @title KM Misc
#' @keywords package
#' @aliases kmmisc package-kmmisc
#'
#' 
NULL

which is still generating the same error.

Income answered 6/10, 2011 at 17:38 Comment(8)
I just spotted that maintainer doesn't have an @. Does this make a difference?Undoubted
I don't think so. I might be overlooking something, but, as far as I can tell, I have the same basic structure as the roxygen docs: github.com/klutometis/roxygen/blob/master/R/roxygen.R I don't have examples or seealso, but I can't think that matters.Income
One more suggestion: upgrade to roxygen2. I found this to be more a bit more forgiving and helpful in its hints when it encounters errors in the roxygen lines.Undoubted
Unfortunately, this is with roxygen2 (ver. 2.1).Income
Sorry, I'm running out of suggestions. Except maybe this: Delete all .rd files. Then comment out all roxygen lines. Then uncomment them function by function and run roxygenize(). In that way you can systematically eliminate potential issues.Undoubted
Thanks for trying. Actually usually this runs as a shell script, the first step of which is deleting all the .Rd files. I'll see if I can reduce it down to the minimum possible set that compiles.Income
File a bug at github.com/klutometis/roxygen/issues. I haven't had much time to work on roxygen2 lately, but that way it won't get lostWitham
I doubt if the error really came from this file. This is not the only file under the R directory, right? Have you checked other R scripts to make sure there are no empty @title tags or empty first lines?Gomuti
A
2

I could not replicate the error form the your first code... Are you receiving same error message from roxygenize() to the following simple example?

#' A test function
#'
#' Description
#'
#' Details
#'
#' @param x numeric number
f1 <- function(x) {
  x
}

An additional information:

The code by @Andrie, #' @aliases kmmisc package-kmmisc, has a @aliases problem. In roxygen2 2.1, #' @aliases a-b, which has a hyphen, generates the Rd quoted tag \alias{"a-b"}. In this case the code has no problem, but in other case requires some attention. Of course, if you need quoted tags, you add #' @aliases a-b.

So I think that it's better to replace #' @aliases kmmisc package-kmmisc with #' @aliases kmmisc in this case:

#' Miscellaneous Functions
#'
#' \tabular{ll}{
#' Package: \tab kmmisc\cr
#' Type: \tab Package\cr
#' Version: \tab 0.1-2\cr
#' Date: \tab 2011-09-14\cr
#' License: \tab GPL-2\cr
#' LazyLoad: \tab yes\cr
#' LazyData: \tab yes\cr
#' }
#'
#' @author Me \email{my@@email}
#'
#' Maintainer: Me \email{my@@email}
#' @name package-kmmisc
#' @aliases kmmisc
#' @docType package
#' @title KM Misc
#' @keywords package
NULL
Amoeba answered 7/10, 2011 at 1:27 Comment(2)
This is what I wished to fix: github.com/klutometis/roxygen/pull/29 But here I do not see any reason why the title was broken due to incorrect aliases.Gomuti
Sorry for the digression. I revised my post. I'm looking forward to fix: #29.Amoeba
U
1

Try the following:

  • Uncomment your roxygen statements. (This might be a SO artefact, but each roxygen line should start with # ', i.e. a single #)

  • Make the following changes to the documentation

    #' @name package-kmmisc
    #' @aliases kmmisc package-kmmisc

In other words:

  • Change the value of @name
  • Add an alias called kmmisc

These are the only differences between your example and my own package documentation.

Undoubted answered 6/10, 2011 at 17:53 Comment(3)
I still get the same error with these edits (see edit above). Generally though, is ## ' really a problem? That's what ESS does by default (at least I think I have the default settings).Income
If ## works for you, that's great and I've learnt something. I use Eclipse and the Roxygen code highlighting only works with a single #Undoubted
I can confirm ##' certainly works. As Kevin said, this is the default prefix in Emacs. I do not see any obvious problems in the code, and actually I can run roxygen2 with it without any errors (R 2.13.2 under Ubuntu).Gomuti

© 2022 - 2024 — McMap. All rights reserved.