문제

Is it possible to detect if there was a problem when running roxygenize (package roxygen2)?

I want to automate the process documenting, checking and building a package, and would like to stop when documenting goes wrong.

The roxygenize help says the return value is NULL, and I searched stackoverflow without success. Currently, I need to look at the output and search if there was a line starting with "Error".

Any hint appreciated!

도움이 되었습니까?

해결책

When roxygenize finds an error, for example, you included stop("Raise an error") in your code, then roxygenize will return an error.

The other scenario (which is what you are getting at), is that roxygenise is able to finish, but some aspects of the documentation process are incorrect. In this case, these errors are stored as warnings. So one solution is to change warnings to errors.

For example, suppose you had a file containing the line:

#' @XXX 

This would cause:

roxygenise("pkg/")

to raise a warning

  Warning: XXX is an unknown key in block AllGenerics.R:5

If we changed warnings to errors:

##All warnings are now errors
options(warn=2)

Then

roxygenise("pkg/")

would raise the error:

Error: (converted from warning) XXX is an unknown key in block AllGenerics.R:5

You can then use the standard tryCatch technique for dealing with errors.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top