Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

give better error message when erroneously using @example #494

maxheld83 opened this issue Aug 10, 2016 · 1 comment

give better error message when erroneously using @example #494

maxheld83 opened this issue Aug 10, 2016 · 1 comment


Copy link

@maxheld83 maxheld83 commented Aug 10, 2016

I erroneously wrote @example instead of @examples before, well, an actual example (I'm guessing this happens easily).

Because @example expects a file afterwards as per r-pkgs:

When you use ?add, help("add"), or example("add"), R looks for an .Rd file containing \alias{"add"}.

the whole documentation (and build) failed, because of this section:

#' @example
#' dataset <- civicon_2014$sorts[,,"before"]
#' diag_forced(dataset = dataset,
#'             grid = diag_distro_max(dataset))

This is to be expected, of course, but it took me a quite a while to figure out what the problem was, because the error message is not every informative (I think):

Updating pensieve documentation
Loading pensieve
Error in file(con, "r") : cannot open the connection
Calls: suppressPackageStartupMessages ... process_examples -> unlist -> lapply -> FUN -> file
In addition: Warning message:
In file(con, "r") :
  cannot open file '/Users/Max/GitHub/pensieve/dataset <- civicon_2014$sorts[,,"before"]
diag_forced(dataset = dataset,
            grid = diag_distro_max(dataset))': No such file or directory
Execution halted

Exited with status 1.

Any chance there might be a more informative error message and/or protection against this mistake?

It's now easy for me to see that of course /Users/Max/GitHub/pensieve/dataset <- civicon_2014$sorts[,,"before"]diag_forced(dataset = dataset, grid = diag_distro_max(dataset))' isn't a file, it was somehow hard to see in the printout unless you knew what you were looking for.

Or maybe I'm just unusually dense.

@hadley hadley closed this in a25c7f7 Aug 29, 2016
Copy link

@hadley hadley commented Aug 29, 2016

That frequently messes me up too. Hopefully the new warning is more informative.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants