klmr / box

Write reusable, composable and modular R code
https://klmr.me/box/
MIT License
862 stars 48 forks source link

Get warning message when requesting help #278

Closed ggrothendieck closed 1 year ago

ggrothendieck commented 2 years ago

Error description

If this file, called test.R, is in current directory


#' Add two numbers.
#'
#' @param x the first number.
#' @param y the second number.
#' @return The sum.
#' @note This is just a simple example.
#'
#' This function is a simple example intended to show how to use the modules
#' package with roxygen2.
add2 <- function(x, y) x + y

and then I use this on a vanilla instance of R:

box::use(./test)
box::help(test$addfun)

I get this (except I have changed the username below from the actual username for security); however, the help does come up.

Loading required namespace: roxygen2

REDIRECT:topic   add2 -> Rtxt28885142422f [ FAIL ]
REDIRECT:file    Rtxt28885142422f -> Rtxt28885142422f [ FAIL ]starting httpd help server ... done
Warning message:
In file(file, ifelse(append, "a", "w")) :
  cannot open file 'C:/Users/xxx/AppData/Local/Temp/help/Rtxt28885142422f': No such file or directory

Also

is there some way of getting the help without invoking box::use first? Something like this:

box::help(./test/add2)

I would like to use it only for documentation but do not need to actually create any modules. Will use source to get the source. Also when I use the use command it complains about library commands but since I am not actually using the module, just the help I don't want to see these. Also is it possible to create something analogous to help(package = myPackage) for the functions in a file that have roxygen2 documentation using box?

R version

platform       x86_64-w64-mingw32                         
arch           x86_64                                     
os             mingw32                                    
system         x86_64, mingw32                            
status         Patched                                    
major          4                                          
minor          1.3                                        
year           2022                                       
month          03                                         
day            10                                         
svn rev        81883                                      
language       R                                          
version.string R version 4.1.3 Patched (2022-03-10 r81883)
nickname       One Push-Up

‘box’ version

1.1.2

klmr commented 2 years ago
  1. The warning is a bug in ‘box’, it’s tracked in #255. I have a candidate fix, but doing this properly is more complicated than anticipated. However, I should be able to push a fix soon.

  2. I’m afraid the feature request is definitely out of scope for ‘box’: fundamentally, the purpose and long-term vision of ‘box’ is to provide a consistent ecosystem for modules which entirely replaces the use of source in R (and I believe that this aim has been achieved with the current version of ‘box’). Adding support for non-module R code would be actively counter-productive to this intent.