From d10698ce08667b98de0233d8bd907db3ee81bbd2 Mon Sep 17 00:00:00 2001 From: tylermorganwall Date: Sun, 18 Feb 2024 22:06:04 -0500 Subject: [PATCH] raymolecule v0.5.3: Add pkgdown helper function to only run some code in pkgdown during CRAN check --- DESCRIPTION | 2 +- NAMESPACE | 1 + R/get_molecule.R | 17 +++++++++++------ R/run_documentation.R | 13 +++++++++++++ _pkgdown.yml | 4 ++++ man/get_molecule.Rd | 17 +++++++++++------ man/run_documentation.Rd | 18 ++++++++++++++++++ 7 files changed, 59 insertions(+), 13 deletions(-) create mode 100644 R/run_documentation.R create mode 100644 man/run_documentation.Rd diff --git a/DESCRIPTION b/DESCRIPTION index 9afb472..44ccec9 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Package: raymolecule Type: Package Title: Parse and Render Molecular Structures in 3D -Version: 0.5.2 +Version: 0.5.3 Date: 2024-2-18 Authors@R: c(person("Tyler", "Morgan-Wall", email = "tylermw@gmail.com", role = c("aut", "cph", "cre"), comment = c(ORCID = "0000-0002-3131-3814"))) diff --git a/NAMESPACE b/NAMESPACE index d5c8572..82e3e96 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -9,6 +9,7 @@ export(get_molecule) export(read_pdb) export(read_sdf) export(render_model) +export(run_documentation) importFrom(magrittr,"%>%") importFrom(rayrender,add_object) importFrom(rayrender,glossy) diff --git a/R/get_molecule.R b/R/get_molecule.R index 0e9559d..c2905d9 100644 --- a/R/get_molecule.R +++ b/R/get_molecule.R @@ -8,28 +8,33 @@ #' @export #' #' @examples -#' \donttest{ +#' if(run_documentation()) { #' get_molecule("caffeine") %>% #' generate_full_scene() %>% #' render_model() -#' +#' } +#' if(run_documentation()) { #' #estradiol (aka estrogen) #' get_molecule(5757) %>% #' generate_full_scene() %>% #' render_model() -#' +#' } +#' if(run_documentation()) { #' get_molecule("testosterone") %>% #' generate_full_scene() %>% #' render_model() -#' +#' } +#' if(run_documentation()) { #' get_molecule("aspirin") %>% #' generate_full_scene() %>% #' render_model() -#' +#' } +#' if(run_documentation()) { #' get_molecule("rutoside") %>% #' generate_full_scene() %>% #' render_model() -#' +#' } +#' if(run_documentation()) { #' #If the 3D SDF doesn't exist, this function will pull the 2D SDF and inform the user #' get_molecule("cyanocobalamin") %>% #' generate_full_scene() %>% diff --git a/R/run_documentation.R b/R/run_documentation.R new file mode 100644 index 0000000..e89f20b --- /dev/null +++ b/R/run_documentation.R @@ -0,0 +1,13 @@ +#' @title Run Documentation +#' +#' @description This function determines if the examples are being run in pkgdown. It is not meant to be called by the user. +#' +#' @export +#' +#' @return Boolean value. +#' @examples +#' # See if the documentation should be run. +#' run_documentation() +run_documentation = function() { + return(identical(Sys.getenv("IN_PKGDOWN"), "true")) +} diff --git a/_pkgdown.yml b/_pkgdown.yml index a498e98..25d2e31 100644 --- a/_pkgdown.yml +++ b/_pkgdown.yml @@ -21,6 +21,10 @@ reference: desc: "Function to get included example data." contents: - starts_with("get") + - title: "pkgdown utils" + desc: "Internal but must be exported to meet CRAN guidelines" + contents: + - starts_with("run") navbar: title: "raymolecule" diff --git a/man/get_molecule.Rd b/man/get_molecule.Rd index 8bd3104..0b4e61b 100644 --- a/man/get_molecule.Rd +++ b/man/get_molecule.Rd @@ -16,28 +16,33 @@ List giving the atom locations and the connections between atoms. Loads the structure of a molecule by fetching an SDF file from Pubchem, which can be piped to generate_full_scene } \examples{ -\donttest{ +if(run_documentation()) { get_molecule("caffeine") \%>\% generate_full_scene() \%>\% render_model() - +} +if(run_documentation()) { #estradiol (aka estrogen) get_molecule(5757) \%>\% generate_full_scene() \%>\% render_model() - +} +if(run_documentation()) { get_molecule("testosterone") \%>\% generate_full_scene() \%>\% render_model() - +} +if(run_documentation()) { get_molecule("aspirin") \%>\% generate_full_scene() \%>\% render_model() - +} +if(run_documentation()) { get_molecule("rutoside") \%>\% generate_full_scene() \%>\% render_model() - +} +if(run_documentation()) { #If the 3D SDF doesn't exist, this function will pull the 2D SDF and inform the user get_molecule("cyanocobalamin") \%>\% generate_full_scene() \%>\% diff --git a/man/run_documentation.Rd b/man/run_documentation.Rd new file mode 100644 index 0000000..c22b8e7 --- /dev/null +++ b/man/run_documentation.Rd @@ -0,0 +1,18 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/run_documentation.R +\name{run_documentation} +\alias{run_documentation} +\title{Run Documentation} +\usage{ +run_documentation() +} +\value{ +Boolean value. +} +\description{ +This function determines if the examples are being run in pkgdown. It is not meant to be called by the user. +} +\examples{ +# See if the documentation should be run. +run_documentation() +}