Dasonk / docstring

Provides docstring like functionality to R functions without requiring the need to create a package.
57 stars 6 forks source link

Object documentation #35

Open edelgado-ecdc opened 1 year ago

edelgado-ecdc commented 1 year ago

I'm finding trouble when adding documentation for objects (not classes) besides functions. This is one of roxygen2's main features though, as it allows the author to add a bit of info on elements such as reference objects and datasets.

In my case, I'm adding documentation to a Shiny app, and I would like to document certain objects that are created on the fly when the app is running, and consists the basis of the UI structure.

I specific, it would be amazing if we could have something like the following:

#' @title Header's app object
#' 
#' @description  Header object returned from \code{bs4DashNavBar} for the app header.
#' 
#' Filters are spawned here.
#' 
#' @param title dynamic. Depends on \code{title_text}.
#' @param controlbarIcon dynamic. Depends on \code{title_icon}.
#' @param ... \itemize{
#'     \item \strong{use_theme}: call to load the \code{mpp_theme} object.
#'     \item \strong{column, width:3}: column UI element containing the output 
#'       element \code{country_filter_ui}.
#'     \item \strong{column, width:3}: column UI element containing the output 
#'       element \code{date_filter_ui}.
#' }
#' 
#' @references For further details, check 
#'   \href{https://rinterface.github.io/bs4Dash/reference/dashboardHeader.html}{b4DashNavBar reference}.
#' 
#' @note \code{header} is a list object, which contains raw HTML code. 
"header"

Note that I'm following Roxygen2's approach, adding the documentation comment block to a string rather than adding it on top of the code assign. While this is just a matter of personal prefference, I acknowledge that the concept of object (not classes) documentation can be a bit hazy, as objects can be further reassigned and are potentially more mutable than functions or classes; hence why I feel like having a single reference point works best.

Many thanks in advance!