This vignette serves as a primer to help write detailed and
consistent Examples Sections in function documentation using the custom
rdx_roclet() , which lives in the {admiraldev} package
functionality - please see demo_fun() for a dummy example
and derive_extreme_records.R
in admiral for an example of this in action. These examples are
often beneficial for the more complex {admiral} functions to help answer
questions like: “what does this function do?” or “how does this argument
work?”.
In practice, the guidance shown below cannot always be applied to the letter, because each function and its context are different and may have varying requirements. As such, developers are encouraged to treat these directives heuristically and always apply their judgment when constructing Examples Sections.
Successive example blocks should build in complexity. The first
examples should showcase the most “minimal” execution of the function,
with only the required arguments being triggered and the default values
discussed. The data in these examples should be as concise as possible
and may not be ADaM compliant, e.g., STUDYID may not be
included or AVISITN may be present without
AVISIT.
Later blocks should then bring in one/a few more arguments at a time as the use-case becomes more involved. If possible, they should build on top of earlier blocks (i.e. use the same data but changing the scope of the function call to add complexity), but if this is not possible, then new scenarios can be considered.
As mentioned previously, all example blocks should answer questions like “what does this function do?” or “how does this argument work?”.
If all examples can be run on the same/similar data, you may wish to (optionally) include a “Data setup” block at the start of the Examples Section to create the dummy dataset(s) that can then be used in each block. Please see derive_summary_records() as an example.