# 4.2. How to document R functions¶

## 4.2.1. Creating a manual file¶

All R functions in the R packages must have a manual that is a file in the man/ directory. The file has the same name as the function that is being documented except for the extension that is .Rd instead of .R

The structure should be as follows:

\name{functionName}
\alias{functionName}
\alias{FUNCTIONNAME}
\title{
A short description (one line)
}
\description{
A longer description
}
\usage{
functionName(arg1, arg2)
}
\arguments{
\item{arg1}{
Description of arg1
}
\item{arg2}{
Description of arg2
}
}
\details{
Some detailled description
}
\value{
description of what is returned.
}
\author{
}
\seealso{
Pointers to related R objects, using \code{\link{...}} to refer to them (\code
is the correct markup for R object names, and \link produces hyperlinks in
output formats which support this.
}
\examples{
data(CNOlistToy,package="CellNOptR")
data(ToyModel,package="CellNOptR")
checkSignals(CNOlistToy,ToyModel)

\dontrun{Some computationally expensive code can be shown but not run.}
\dontshow{log(x)}    # Only run.
}
\keyword{file}
\note{}

Some fields are optional (e.g., seealso, examples)

The layout is not of importance but to ease the writing/reading of code for developers, please use this layout for the argument section:

\arguments{
\item{MIDASfile}{
a CSV MIDAS file (see details)
}
\item{verbose}{
logical (default to TRUE).
}
}

See the R guidelines

To test if the Rd file is correct, type this command:

R CMD Rd2pdf --vanilla functionName.Rd

If the file is compiled correctly, you should see the PDF is your favorite PDF reader.

## 4.2.2. Some standard arguments¶

Many arguments in CellNOptR and related packages appear often. For instance, CNOlist, Model and so on. Instead of rewriting again and again the text for these arguments, you can use the following convention:

CNOlist: a CNOlist structure, as created by \code{makeCNOlist} a model structure, as created by \code{readSIF}, normally pre-processed but that is not a requirement of this function a list of indexes of the species stimulated/inhibited/measured, as created by \code{indexFinder} from a model. same as indexList a SimList structure as created by \code{prep4sim}, that has also already been cut to contain only the reactions to be evaluated