Skip to content

give better error message when erroneously using @example #494

@maxheld83

Description

@maxheld83

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions