From 2b2aa35dbde019e64719fc91db12afff1431a913 Mon Sep 17 00:00:00 2001 From: cjrace Date: Thu, 15 Feb 2024 15:46:11 +0000 Subject: [PATCH] add return values and examples to existing functions --- R/standard_panels.R | 22 ++++++++++++++-------- R/testing.R | 4 +++- man/support_panel.Rd | 27 ++++++++++++++++++--------- man/tidy_code.Rd | 13 +++++++++++-- 4 files changed, 46 insertions(+), 20 deletions(-) diff --git a/R/standard_panels.R b/R/standard_panels.R index 47cfe68..4318b60 100644 --- a/R/standard_panels.R +++ b/R/standard_panels.R @@ -10,8 +10,8 @@ library(shinyGovstyle) #' @param repo_name The repository name as listed on GitHub #' @param ees_publication Whether the source publication is hosted on #' Explore Education Statistics -#' @param publication_name The source publication name -#' @param publication_stub The source publication stub on +#' @param publication_name The source publication title +#' @param publication_slug The source publication slug on #' Explore Education Statistics #' @param alt_href Alternative link to the parent publication #' (if not hosted on Explore Education Statistics) @@ -22,14 +22,20 @@ library(shinyGovstyle) #' @export #' #' @examples -#' # TODO: add basic example of EES publication -#' # TODO: add basic example of non-EES publication +#' support_panel( +#' team_email = "my.team@@education.gov.uk", +#' repo_name = "https://github.com/dfe-analytical-services/my-repo", +#' publication_name = "My publication title", +#' publication_slug = "my-publication-title", +#' form_url = "www.myform.com", +#' cookie_status_output = "cookie_status" +#' ) support_panel <- function( team_email = "", repo_name = "", ees_publication = TRUE, publication_name = NULL, - publication_stub = "", + publication_slug = "", alt_href = NULL, form_url = NULL, cookie_status_output = "") { @@ -115,7 +121,7 @@ support_panel <- function( href = paste0( "https://explore-education-statistics.service.gov.uk /find-statistics/", - publication_stub + publication_slug ), ifelse(!is.null(publication_name), publication_name, @@ -128,7 +134,7 @@ support_panel <- function( href = paste0( "https://explore-education-statistics .service.gov.uk/find-statistics/", - publication_stub, + publication_slug, "/data guidance" ), "data guidance", @@ -139,7 +145,7 @@ support_panel <- function( href = paste0( "https://explore-education-statistics .service.gov.uk/find-statistics/", - publication_stub, + publication_slug, "#explore-data-and-files" ), "tools to access and interogate the underling data", diff --git a/R/testing.R b/R/testing.R index 5bb61b7..21ca046 100644 --- a/R/testing.R +++ b/R/testing.R @@ -6,10 +6,12 @@ #' @param subdirs List of sub-directories to #' recursively search for R scripts to be styled #' -#' @return +#' @return A vector with TRUE or FALSE for every script checked #' @export #' #' @examples +#' tidy_code() +#' tidy_code(subdirs = c("R", "tests", "data")) tidy_code <- function(subdirs = c("R", "tests")) { message("----------------------------------------") message("App scripts") diff --git a/man/support_panel.Rd b/man/support_panel.Rd index 472064f..2370c9e 100644 --- a/man/support_panel.Rd +++ b/man/support_panel.Rd @@ -9,25 +9,31 @@ support_panel( repo_name = "", ees_publication = TRUE, publication_name = NULL, - publication_stub = "", + publication_slug = "", alt_href = NULL, - form_url = NULL + form_url = NULL, + cookie_status_output = "" ) } \arguments{ -\item{team_email}{Your team e-mail address as a string, this must be a education.gov.uk email} +\item{team_email}{Your team e-mail address, must be a education.gov.uk email} \item{repo_name}{The repository name as listed on GitHub} -\item{ees_publication}{Whether the parent publication is hosted on Explore Education Statistics} +\item{ees_publication}{Whether the source publication is hosted on +Explore Education Statistics} -\item{publication_name}{The parent publication name} +\item{publication_name}{The source publication title} -\item{publication_stub}{The parent publication stub on Explore Education Statistics} +\item{publication_slug}{The source publication slug on +Explore Education Statistics} -\item{alt_href}{Alternative link to the parent publication (if not hosted on Explore Education Statistics)} +\item{alt_href}{Alternative link to the parent publication +(if not hosted on Explore Education Statistics)} \item{form_url}{URL to a feedback form for the dashboard} + +\item{cookie_status_output}{name of cookie status output object} } \value{ a standardised panel for a public R Shiny dashboard in DfE @@ -39,6 +45,9 @@ Create the standard DfE R-Shiny support and feedback dashboard panel. support_panel( team_email = "my.team@education.gov.uk", repo_name = "https://github.com/dfe-analytical-services/my-repo", - publication_stub = ? - ) + publication_name = "My publication title", + publication_slug = "my-publication-title", + form_url = "www.myform.com", + cookie_status_output = "cookie_status" +) } diff --git a/man/tidy_code.Rd b/man/tidy_code.Rd index c17aeb0..39c21ad 100644 --- a/man/tidy_code.Rd +++ b/man/tidy_code.Rd @@ -7,8 +7,17 @@ tidy_code(subdirs = c("R", "tests")) } \arguments{ -\item{subdirs}{List of sub-directories to (recursively search for R scripts to be styled)} +\item{subdirs}{List of sub-directories to +recursively search for R scripts to be styled} +} +\value{ +A vector with TRUE or FALSE for every script checked } \description{ -Script to apply styler code styling to scripts within the shiny directory structure. +Script to apply styler code styling to scripts +within the shiny directory structure. +} +\examples{ +tidy_code() +tidy_code(subdirs = c("R", "tests", "data")) }