How to document return values for function with side effects?

pkgcheck complains the “functions have no documented return values”. There are lots of functions (plot, write, print) which are called for side effects and have no return value. How to document them properly or stop pkcheck stopping to complain if a function does not have a return value?

Thanks for asking @KlausVigo. Documentation should still have something like @return Nothing. Function called for side-effect only, or a more specific version that describes the side-effect. CRAN also typically ask the same thing these days. Hope that helps.

2 Likes

@mpadge thanks again for the quick answer.

1 Like

Longer term, it’s helpful to return something invisibly, and then document that. Hadley Wickham’s in-progress Tidy Design Principles has some good tips around this.

If you don’t explicitly set anything up, the function will return NULL (see for example test_fn <- function() {}; test_fn()), or whatever the last function you call returns. It’s worthwhile to do something intentional.

3 Likes