Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is roxygen2 only for documenting R packages or also for R projects? [duplicate]

I have a question about the "roxygen2" package:

I have seen a lot of tutorials that make use of it for package documentation (such as the major "object documentation" page by Hadley Wickham)

So what if I do have R code that is not a package, say an R project? Can you document R Projects with roxygen2 as well?

I was still able to run the package.skeleton(name='RoxygenSkeleton', code_files = "Roxygen.R", force=TRUE) function to create the basic package structure and .Rd files were created. But I would desire a nice output in HTML or PDF...

like image 913
Skybrush Avatar asked Oct 19 '22 03:10

Skybrush


1 Answers

As explained elsewhere, as of roxygen2 6.0, the following works to parse documented R source files outside packages.

source_env = roxygen2::env_file(sourcefile)
rd_blocks = roxygen2::parse_file(sourcefile, source_env)
help_topics = roxygen2::roclet_process(roxygen2::rd_roclet(), rd_blocks, source_env, dirname(sourcefile))
rd_code = lapply(help_topics, format)
like image 109
Konrad Rudolph Avatar answered Nov 02 '22 06:11

Konrad Rudolph