This document addresses how to update the documentation supporting the package.
Updating package documentation (in RStudio and web-based docs)
The R package is documented in webpages (and in standard help documents viewable in RStudio). Documentation will generally need to be updated in preparation for a new release of the package. Updates may be needed in the following:
Overall, package-wide information/ documents (e.g., README)
Reference docs explaining the R functions
Reference docs explaining the datasets
Articles/ vignettes to help R users with the package
“User Guide” to help people use the web app
Web pages providing all of the above in html format
Each is explained below:
Updating overall, package-wide information/ documents
Package-wide documentation files can be updated/edited and include the following:
DESCRIPTION
,README.Rmd
(for README, edit the .Rmd NOT the .md file), R/EJAM-package.R (EJAM-package
),NEWS.md
,CONTRIBUTING.md
,LICENSE.md
,CITATION
, and others.Some of these are used by and shown by the github.com repository, notably the
README.md
that is generated from theREADME.Rmd
file, and theDESCRIPTION
file that stores package version number and URLs of the package repository, etc.
Reference docs explaining the R functions
roxygen2
package tags define the documentation in the R/*.R files that contain the source code and documentation of functions and datasets.While many functions or objects have their own .R files, some .R files contain code and documentation for multiple functions, so not every function has a .R file of its own.
some utility/helper functions, mostly not exported, are stored in files prefixed with “utils_” such as
R/utils_indexblocks.R
(but not all helper functions are in files named that way).you might find it useful to check docs with
tools::checkDocFiles("EJAM")
Reference docs explaining the datasets
all datasets are documented in the files named with a prefix of “data_” such as
R/data_blockgroupstats.R
which documents theblockgroupstats
dataset.most dataset documentation is created/updated alongside the code that created or updates those datasets. That is best done starting with the overarching file called
data-raw/datacreate_0_UPDATE_ALL_DATASETS.R
which helps walk through updating various datasets as needed and their documentation is often updated in that same process.Many
R/*.R
files for datasets are created automatically, not edited by hand, through thedataset_documenter()
function as used in the scripts withindata-raw/datacreate_*.R
while others are updated by editing the .R file directly.
Articles/ vignettes to help R users with the package
These are written/edited as .Rmd files in the
vignettes
folder. You can test one using something likepkgdown::build_article()
before trying to rebuild the whole pkgdown site.New articles or renamed files require edits to the
_pkgdown.yml
file also.
“User Guide” to help people use the web app
- If you change the UI then new screenshots are needed for a new version of the User Guide that was stored as a .pdf document.
Updating the web pages providing all of the above in html format
The web-based documentation pages should be updated right after any of the above are edited/created. These pkgdown-based webpages should be updated by someone who is managing the package, as follows:
The first step in updating those web pages is updating the yml file. The web-based documentation pages are organized by a file called
_pkgdown.yml
– seeusethis::edit_pkgdown_config()
– which specifies the contents of the webpages of documentation, such as the names of any vignettes files to be shown in the list of articles, which functions are included in the reference pages index, etc. Any new or removed or renamed functions/ vignettes/ datasets, or changes in what is exported, will require edits to the .yml file.The pkgdown-based webpages should be updated by someone who is managing the package, and they should use the
update_pkgdown()
function found indata-raw/datacreate_0_UPDATE_ALL_DOCUMENTATION_pkgdown.R
You have to source() that file and then use the function that it defines. Via that function, the pages get rebuilt by thepkgdown
R package, based on the above files and all other documentation from .R and .md files. For more information about using the pkgdown package to create documentation in the form of webpages, see https://pkgdown.r-lib.org/articles/pkgdown.html. The documentation is created/updated using theroxygen2
andpkgdown
R packages, which read information from the .R files in the R folder, from .Rmd file vignettes (aka “articles”) in the vignettes folder, and from the_pkgdown.yml
file in the root folder of the source package. Theroxygen2
package reads the .R files to create the .Rd files in theman/
directory. Thepkgdown
package uses all those files as well asDESCRIPTION
and others, to generate a website for the package, first created as files in thedocs/
folder, which are then published via github actions and the github repository settings, to be hosted on GitHub Pages. The packagesdevtools
andusethis
are also relevant.the package’s github repository settings define which branch and which folder should hold the html files for deployment (see github and pkgdown documentation on that)
the package’s Github Actions can be used to deploy the webpages when triggered by an event like any push to the main branch, for example.
depending on which folder you publish/deploy from, you might have to remove that folder from
.gitignore
in case it was listed there via some pkgdown or usethis function.