klmr / box

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

Box only exporting one function per script #367

Closed mmmmtoasty19 closed 1 week ago

mmmmtoasty19 commented 2 weeks ago

Error description

The folowing script box can only find the first export function. I have tested this in several ways and am only able to get box to export one function per script

box::use( DBI, RSQLite, here[here], glue[glue], )

' @export

retrieve_data <- function(columns, table) { query <- glue("SELECT {columns} from {table}") con <- DBI$dbConnect( RSQLite$SQLite(), here("app", "synthea.sqlite") ) data <- DBI$dbGetQuery(con, query) DBI$dbDisconnect(con) return(data) }

' @export

test_function <- function() { print("Hello World") }

R version

platform       x86_64-pc-linux-gnu         
arch           x86_64                      
os             linux-gnu                   
system         x86_64, linux-gnu           
status                                     
major          4                           
minor          3.3                         
year           2024                        
month          02                          
day            29                          
svn rev        86002                       
language       R                           
version.string R version 4.3.3 (2024-02-29)
nickname       Angel Food Cake

‘box’ version

‘1.2.0’

ArcadeAntics commented 1 week ago

Hi @mmmmtoasty19 !

Your issue might be related to another issue, #362 .

A whitespace character does not appear after @export in the example you have here, so that may not be the issue, but you should double check your real script to see if that is the case.

klmr commented 1 week ago

Sorry, I can’t reproduce this: I saved your code as test.r and did the following:

box::use(./test)
ls(test)
[1] "retrieve_data" "test_function"

As you can see, both functions are exported.