forked from NOAA-FIMS/collaborative_workflow
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path09-documentation-templates.Rmd
71 lines (61 loc) · 2.57 KB
/
09-documentation-templates.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# Documentation Template
In this section we will describe how to document your code. For more
information about code documentation in general, please see the
[toolbox blog post on code documentation](https://noaa-fisheries-integrated-toolbox.github.io/resources/best-practices/code-documentation/).
This post describes the differences between the types of documentation,
while below we give specific, brief instructions on developer
responsibilities for FIMS.
## Writing function reference
Function reference can be written inline in comments above the function
in either C++ or R. The tools you can use to generate reference from
comments are called Doxygen and Roxygen in C++ and R respectively. Both
can include LaTeX syntax to denote equations, and both use `@` tags to
name components of the function reference
```
/**
* @brief This function calculates the von Bertalanffy growth curve.
* \f$
*
* length\_at\_age = lmin + (lmax - lmin)*\frac{(1.0 -
c^ {(age - a\_min)}))}{(1.0 - c^{(a\_max - a\_min)})}
*
* \f$
*
* @param age
* @param sex
* @return length\_at\_age
*/
```
The only difference between syntax for `R` and `C++` code is how
comments are denoted in the language.
```
#' This function calculates the von Bertalanffy growth curve.
#'
#' @param age
#' @param sex
#' @return length_at_age
```
You should, at minimum, include the tags `@param`, `@return`, and
`@examples` in your function reference if it is an exported function.
Functions that are only called internally do not require an `@examples`
tag. Other useful tags include `@seealso` and `@export` for Roxygen
chunks.
## Writing a vignette
If this is an exported function, a vignette can be a helpful tool to
users to know how to use your function. For now, a rough approximation
of the "get started" vignette is written in the [software user
guide](#software-user-guide) page of this book. If you include a
vignette for your function, you can link to it in the Roxygen
documentation with the following code.
```
#' \code{vignette("help", package = "mypkg")}
```
## Step by step documentation update process
1. Write the function reference in either R or C++ as described above.
2. Check the [software user guide](#software-user-guide) and check that
any changes you have made to the code are reflected in the code snippets
on that page.
2. Push to the feature branch.
3. Ensure that the documentation created by the automated workflow is
correct and that any test cases execute successfully before merging into
main.