Skip to content

Commit

Permalink
adding documentation to report utils functions
Browse files Browse the repository at this point in the history
  • Loading branch information
DouglasMesquita committed Dec 19, 2023
1 parent 24259e1 commit 7074624
Show file tree
Hide file tree
Showing 7 changed files with 85 additions and 1 deletion.
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,4 @@ importFrom(testthat,ListReporter)
importFrom(utils,globalVariables)
importFrom(utils,menu)
importFrom(utils,read.table)
importFrom(withr,with_dir)
1 change: 0 additions & 1 deletion R/shiny_benchmark-class.R
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
#' @importFrom methods new
#'
#' @export

shiny_benchmark_class <- setClass(
Class = "shiny_benchmark",
representation(
Expand Down
41 changes: 41 additions & 0 deletions R/utils_report.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,19 @@
#' @param performance_list list of tests containing commits with dates, duration
#' time and test name
#'
#' @return data.frame combining all the elements from performance list. Also, it
#' adds the branch name for each one of the tables.
#'
#' @examples
#' performance1 <- data.frame(t1 = 1, t2 = 2)
#' performance2 <- data.frame(t1 = 3, t2 = 4)
#' performance_list <- list(
#' branch1 = performance1,
#' branch2 = performance2
#' )
#'
#' combine_performances(performance_list)
#'
#' @export
combine_performances <- function(performance_list) {
# create an unique data.frame for all branches and repetitions
Expand Down Expand Up @@ -33,7 +46,23 @@ combine_performances <- function(performance_list) {
#'
#' @return None. This function is called for side effects
#'
#' report_params <- list(
#' performance = data.frame(
#' date = Sys.time(),
#' rep_id = 1,
#' test_name = rep(c("t1", "t2"), each = 10),
#' duration_ms = rpois(n = 20, lambda = 10),
#' branch = paste0("b", 1:10)
#' )
#' )
#'
#' create_report(
#' report_params = report_params,
#' file = tempfile(fileext = ".html")
#' )
#'
#' @importFrom quarto quarto_render
#' @importFrom withr with_dir
#' @export
create_report <- function(report_params, file = NULL) {
# stop execution in case file is not provided
Expand Down Expand Up @@ -70,6 +99,13 @@ create_report <- function(report_params, file = NULL) {
#' the package to the user's directory
#'
#' @param report_dir name of the folder where the report should be saved
#'
#' @return character. Path to report.qmd
#'
#' @examples
#' if (interactive()) {
#' prepare_dir_and_template(report_dir = tempdir())
#' }
prepare_dir_and_template <- function(report_dir) {
# create folders if needed
file_paths <- prepare_file_paths(report_dir)
Expand Down Expand Up @@ -103,6 +139,11 @@ prepare_dir_and_template <- function(report_dir) {
#' @param report_dir name of the folder where the report should be saved
#'
#' @return two-element vector with paths to template reports
#'
#' @examples
#' if (interactive()) {
#' prepare_file_paths(report_dir = tempdir())
#' }
prepare_file_paths <- function(report_dir) {
template_file_pkg <- system.file(
"templates",
Expand Down
15 changes: 15 additions & 0 deletions man/combine_performances.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 15 additions & 0 deletions man/create_report.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions man/prepare_dir_and_template.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions man/prepare_file_paths.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 7074624

Please sign in to comment.