Re: [Rd] Using unit-tests as examples

2014-01-20 Thread Alexey Sergushichev
Yes, this may work, but this way I have to have one test per file, which is not very convenient. --- Alexey On Sat, Jan 18, 2014 at 7:43 PM, Hadley Wickham h.wick...@gmail.com wrote: If you're using roxygen2, you can use @example tag to include an external file into the examples. Hadley

Re: [Rd] Using unit-tests as examples

2014-01-20 Thread Hadley Wickham
The problem with extracting a single test from a file is going to be locating the relevant lines of code and cleanly pulling them out (along with any needed supporting code). It might be better to attack the problem in the opposite direction by having a roxygen2 directive that inserted the block

Re: [Rd] Using unit-tests as examples

2014-01-20 Thread Spencer Graves
You are probably wisest to follow Hadley's recommendation. [library(fortunes); fortune(298)] However, my help files contain various constructs of the following form: \dontshow{stopifnot(} all.equal(fa, fa0) \dontshow{)} where fa is returned by a function, and fa0 is a

[Rd] Using unit-tests as examples

2014-01-18 Thread Alexey Sergushichev
Hi, Which is the best way to use unit tests as examples for documentation? I use testthat, but if there is a good way to do this, for example, only with RUnit, it'd still be good to know. Unit-tests are usually simple and concise, so they are good candidates for example code, but I don't want to

Re: [Rd] Using unit-tests as examples

2014-01-18 Thread Hadley Wickham
If you're using roxygen2, you can use @example tag to include an external file into the examples. Hadley On Sat, Jan 18, 2014 at 7:18 AM, Alexey Sergushichev alserg...@gmail.com wrote: Hi, Which is the best way to use unit tests as examples for documentation? I use testthat, but if there is