Is there any easy way how to add graph to my scaladoc documentation?
I have found only the possibility to generate class hierarchy graphs but I want to include my own graph.
The only way I have found is to create external image and include it into documentation but it is too complicated.
I'm looking for a way how to include graph description directly into scaladoc comments. Something like
/** My class description
*
* #digraph{
* new -> open
* open -> closed
* closed -> open
* }
*/
The dot language is preferred for me but any other graph description language is also acceptable.
Related
I'm new to both {box} and {roxygen2} and have never written a package - so please bear with me.
I've got a script that has a smallish function in it which I've verified works at my end. It's sited in a bespoke folder I've created, called R, inside the 'package' folder, e.g. 'Module1/R/functionscript1.R'. The script contains all the bits of {roxygen2} commenting that I think I need, including #' #export. I can't quite figure out the next stages despite reading many blogs. How do I turn this into a fully documented {box} module?
I've tried setting my working directory to the Module1 directory then using devtools::document(), which errors out telling me it can't find the package root (" Is . inside a package?"). No version of box::use() is doing anything I think it should. What am I missing?? Please explain like I'm a toddler.....
Thanks
With ‘box’, there’s no need to call devtools::document(). And in fact you can see from the error message that it doesn’t work.
Writing your documentation comment inside the module is all that’s required. When you now load the module you can display its documentation.
Let’s say your Module1/R/functionscript.R looks like this:
#' Some test function
#' #param n a number
#' #return the modified number
#' #export
modify = function (n) {
n * 2 - 1
}
Then you can load your module (note that having R in the directory name is a bit weird when working with modules, since it will become part of the module name):
box::use(./Module1/R/functionscript)
After loading the module you can use it:
functionscript$modify(5)
# [1] 9
And you can display its documentation via box::help:
box::help(functionscript$modify)
And this will display the help, e.g.:
I'm developing an R package where I frequently use functions from other packages. I know it's usually best practice to be explicit about other packages in your source code (as in dplyr::filter()), but, for example, in plotting functions which are based on ggplot2 it becomes tedious and verbose to write something like ggplot2::ggplot(data, ggplot2::aes(x = ...)), and so on.
Let's say I follow the recommendations and add the #import ggplot2 tag as a roxygen comment in the respective function. Now, this adds import(ggplot2) to the NAMESPACE file, which is nice. But, it does not add ggplot2 to the Imports: section in the DESCRIPTION file, which is exactly what I would like to do. Calling roxygen2::roxygenize() does not do this either.
Note that the same question was basically asked here, but unless I missed something, the question is not answered (after all, the Imports: section is not automatically generated, only the NAMESPACE file).
I am aware of the importance of a correctly maintained NAMESPACE file, and given there are easy and convenient ways to populate it, I guess my main question is whether there is a function to automatically "translate" the NAMESPACE imports into the respective field in the DESCRIPTION. I know you can manually edit your DESCRIPTION file via usethis::use_package("ggplot2") but it seems odd to me to have to specify the same information twice, and in two completely different ways.
I need my code block to look like this -
CREATE OR REPLACE PACKAGE
/* *******************
* my comment block
* *******************/
my_package AS
However, when I hit use format code option in TOAD, the formatted output I get looks like this -
CREATE OR REPLACE PACKAGE /* *******************
* my comment block
* *******************/
my_package AS
I couldn't find the option specific to this particular formatting setting in View->Formatting Options. Can anyone point out the setting that lets me keep my comment block aligned to left?
[I am using TOAD for Oracle 10.6.1.3]
This appears to be a bug! Please report it to them or at least add your example to that post on Toad World. I have found bugs and they were real quick to jump on them.
http://www.toadworld.com/products/toad-for-oracle/toad_for_oracle_beta_program/f/86/t/24464.aspx
For the purpose of uniformity in my code, I repeatedly type four hashes followed by a tab, like this (#### ). Is there a way to create a shortcut key-combination in R/Rstudio where such a string can be defined?
Although it doesn't answer your question, it might still be helpful for what you are trying to do.
You can organize your code in RStudio using "sections". A typical section looks like this:
# Some Section -------------------------
These can be manually entered (like the code chunk above, and with a few other variations) or you can use the convenient shortcut, Ctrl + Shift + R.
One great result of using these sections is that you can navigate to a particular section by its name, as shown in the screenshot below:
Does RStudio support any automated roxygen template creation?
In Emacs-ESS, C-x C-o will produce an roxygen template for a function. For example, it will automagically convert this:
foo <- function(x,y) x+y
into this:
##' .. content for \description{} (no empty lines) ..
##'
##' .. content for \details{} ..
##' #title
##' #param x
##' #param y
##' #return
##' #author David
foo <- function(x,y) x+y
Does similar functionality exist within RStudio?
updates
as of ESS 12.09-2, the command has been changed to C-c C-o C-o
this feature has been implemented in Rstudio: CTRL+ALT+SHIFT+R
(Converting #Crops comment into a full answer)
In RStudio v0.99 there is a new option under the "Code" menu for .R files: "Insert Roxygen Skeleton". There is an image of it in RStudio's blog post about v0.99 preview.
The silence that followed your question should tell you something...
The answer, currently, is NO is doesn't. I know of several people who use EMACS for precisely this reason, and would not consider switching to RStudio until that has full roxygen support.
That said, there has been some discussion about this between users and the makers of RStudio. Considering all the cool things that have been added to RStudio recently, I would not be surprised to see it happen. In fact, I think it is quite likely it will happen. But don't hold your breath for it, it may be a long wait...
Alternatively you can use the R package RoxygenReady to create Roxygen skeletons / Roxygen templates.
My solution was to use a text expander (PhraseExpress in my case) to do this.