Can Roxygen really document R script (not a package) just like Doxygen does for C++?
Asked Answered
Q

2

7

Roxygen is inspired by the Doxygen documentation system that is used by C, C++ programmers. I have used Doxygen and I find it really easy to document any program as long as you have the doxygen comment. It also generate call graphs for functions and classes. I thought roxygen would work the same way but when I search for roxygen help, I only find solution to documenting R packages.

I have checked Hadley Wickham's online roxygen2 help but that does not describe anything about the R script documentation.

My scripts sometimes become 500-1000 lines and have several functions which I always document with the comments. I want to generate PDF or HTML documentation with graph-viz diagrams. Is Roxygen capable of making call-graph and document standalone R scripts?

Queridas answered 20/5, 2016 at 4:39 Comment(2)
Checkout knitr::spin I have used it before and might be what you're looking for. The examples in the doc will give you a flavour of what to expect.Farouche
Thanks! I think I will use it.Queridas
F
3

No, roxygen2 will work only for writing package documentation. Sounds to me you're after a report generating tool. You can use knitr for that. You can include code, comments, text, MathJax, or even use LaTeX. It also supports table of contents and references. This is by no means an exhaustive list of functionality. With some logical limitations, you can produce pdf and html documents, among others.

Franciscka answered 20/5, 2016 at 9:24 Comment(4)
I tried knittr::spin. It works like a report generation tool. As I have mentioned in my question, I am looking for a tool that will generate documentation from the program structure and comments in my script. Such a document includes the function definitions, call-graphs, the argument and the return values of the functions and a table of contents. I am really not looking for generating a report with plots or values from the output of the script. I am looking for a tool to generate a help file for understanding my program for others and myself after a year from now.Queridas
@Xtrim-a ok, however I don't think such a tool exists. If you are willing to bite the bullet and convert your comments into markdown, you can document your script that way.Subtenant
I am using knittr with some options and it is doing a good job for now. Thank you all for your replies! I hope doxygen will extend its support for R someday.Queridas
It is utterly retarded that in order for Roxygen to extract documentation from routines, it must be a package.Lawyer
B
2

Though this is an old thread, for future reference, the following library is able to achieve that:

https://rdrr.io/cran/document/

From its docs: Have you ever been tempted to create 'roxygen2'-style documentation comments for one of your functions that was not part of one of your packages (yet)? This is exactly what this package is about: running 'roxygen2' on (chunks of) a single code file.

Budwig answered 20/7, 2022 at 14:57 Comment(2)
The document package was recently removed from CRAN.Mimimimic
Thought you can still use the one for the archives, at least for now.Budwig

© 2022 - 2024 — McMap. All rights reserved.