Arbitrary sections in roxygen docs

RRoxygen

R Problem Overview


The way Roxygen seems to work is that the first line is the \title, everything else is in the \details, and then any @foo directives handle those things. But R documentation is richer than that. I can have "\section{Llamas}{Are they ungulates?}" in .Rd files.

But I can't get Roxygen to do anything other than wrap it all in \details. Am I missing something?

I have a hacky solution, which is to stick an unmatched } before my \section. This then ends the \details section. I then have to not put an ending } in, because roxygen sticks one in thinking its closing the \details. Eeeeeurrrrrrrrgh.

R Solutions


Solution 1 - R

This support has been added (at least in roxygen2). You just need to add @section Llamas: and then anything after that until a new directive is met will be in a Llamas section. Here is an example

#' Llama llama llama
#' 
#' More about llamas
#' 
#' @section Llamas:
#' Are they ungulates?
#' 
#' @section Not llamas:
#' This section is not about llamas.  It is not very interesting.
#' 
#' @param notused A parameter that isn't used at all!
#' @export
llama <- function(notused){
    return("LLAMA LLAMA LLAMA")
}

which gives the following for the .Rd file

\name{llama}
\alias{llama}
\title{Llama llama llama}
\usage{
  llama(notused)
}
\arguments{
  \item{notused}{A parameter that isn't used at all!}
}
\description{
  More about llamas
}
\section{Llamas}{
  Are they ungulates?
}

\section{Not llamas}{
  This section is not about llamas.  It is not very
  interesting.
}

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionSpacedmanView Question on Stackoverflow
Solution 1 - RDasonView Answer on Stackoverflow