diff --git a/.github/workflows/R-CMD-check.yaml b/.github/workflows/R-CMD-check.yaml index 44040410..e6cfee1a 100644 --- a/.github/workflows/R-CMD-check.yaml +++ b/.github/workflows/R-CMD-check.yaml @@ -70,7 +70,7 @@ jobs: - name: Check env: _R_CHECK_CRAN_INCOMING_REMOTE_: false - run: rcmdcheck::rcmdcheck(args = c("--no-manual", "--as-cran"), error_on = "warning", check_dir = "check") + run: rcmdcheck::rcmdcheck(args = c("--no-manual", "--as-cran"), error_on = "error", check_dir = "check") shell: Rscript {0} - name: Upload check results diff --git a/DESCRIPTION b/DESCRIPTION index a540a8b3..dad3fbf2 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: codecheck Title: Helper Functions for CODECHECK Project -Version: 0.1.0.9006 +Version: 0.2.0 Authors@R: c(person(given = "Stephen", family = "Eglen", @@ -32,10 +32,11 @@ Imports: rorcid, osfr, httr, - zen4R + zen4R, + whisker Encoding: UTF-8 LazyData: true -RoxygenNote: 7.2.1 +RoxygenNote: 7.3.1 VignetteBuilder: knitr Suggests: tinytest, diff --git a/NAMESPACE b/NAMESPACE index 3b57edaa..ed758bf2 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -36,6 +36,7 @@ importFrom(stringr,str_replace_all) importFrom(utils,capture.output) importFrom(utils,read.csv) importFrom(utils,tail) +importFrom(whisker,whisker.render) importFrom(xtable,xtable) importFrom(yaml,read_yaml) importFrom(yaml,yaml.load) diff --git a/R/register.R b/R/register.R index 6dacf862..cbee56ab 100644 --- a/R/register.R +++ b/R/register.R @@ -1,3 +1,9 @@ +CONFIG <- new.env() +CONFIG$FILTER_SUB_GROUPS <- list( + venues = list("community", "journal", "conference", "codecheck nl") +) +CONFIG$MD_COLUMNS_WIDTHS <- "|:-------|:--------------------------------|:------------------|:---|:--------------------------|:----------|" + #' Function for rendering the register into different view #' #' NOTE: You should put a GitHub API token inth the environment variable `GITHUB_PAT` to fix rate limits. Acquire one at see https://github.com/settings/tokens. @@ -19,14 +25,27 @@ #' #' @export register_render <- function(register = read.csv("register.csv", as.is = TRUE), + filter_by = c("venues"), outputs = c("html", "md", "json")) { + CONFIG$MD_TEMPLATE <- system.file("extdata", "templates/template_register.md", package = "codecheck") + register_table <- preprocess_register(register) - md_columns_widths <- "|:-------|:--------------------------------|:------------------|:---|:--------------------------|:----------|" + # Creating list of of register tables with indices being the filter types + list_register_tables <- c() + list_register_tables[["none"]] <- list("original"= register_table) + + if (length(filter_by)!=0){ + # Creating filtered register csvs + create_filtered_register_csvs(filter_by, register) + # Creating and adding filtered registered tables to list of tables + list_register_tables <- add_filtered_register_tables(list_register_tables, register_table, filter_by) + } - if ("md" %in% outputs) render_register_md(register_table, md_columns_widths) - if ("html" %in% outputs) render_register_html(register_table, register, md_columns_widths) - if ("json" %in% outputs) render_register_json(register_table, register) + # Rendering files + if ("md" %in% outputs) render_register_mds(list_register_tables) + if ("html" %in% outputs) render_register_htmls(list_register_tables) + if ("json" %in% outputs) render_register_jsons(list_register_tables) return(register_table) } @@ -57,7 +76,7 @@ register_check <- function(register = read.csv("register.csv", as.is = TRUE), # check certificate IDs if there is a codecheck.yml codecheck_yaml <- get_codecheck_yml(entry$Repository) - check_certificate_id(codecheck_yaml) + check_certificate_id(entry, codecheck_yaml) check_issue_status(entry) cat("Completed checking registry entry", toString(register[i, "Certificate"]), "\n") } diff --git a/R/utils_create_filtered_register_csvs.R b/R/utils_create_filtered_register_csvs.R new file mode 100644 index 00000000..c087a436 --- /dev/null +++ b/R/utils_create_filtered_register_csvs.R @@ -0,0 +1,82 @@ +#' Creates filtered register csv files +#' +#' Each csv file is saved in the appropriate output_dir. +#' +#' @param filter_by A vector of strings specifying the names of the columns to filter by. +#' @param register A dataframe representing the register data to be filtered. +create_filtered_register_csvs <- function(filter_by, register){ + + for (filter in filter_by){ + column_name <- determine_filter_column_name(filter) + unique_values <- unique(register[[column_name]]) + + for (value in unique_values) { + filtered_register <- register[register[[column_name]]==value, ] + output_dir <- paste0(get_output_dir(filter, value), "register.csv") + + if (!dir.exists(dirname(output_dir))) { + dir.create(dirname(output_dir), recursive = TRUE, showWarnings = TRUE) + } + + write.csv(filtered_register, output_dir, row.names=FALSE) + } + } +} + +#' Determines the register table's column name to filter the data by. +#' +#' @param filter The filter name +#' @return The column name to filter by +determine_filter_column_name <- function(filter) { + filter_column_name <- switch(filter, + "venues" = "Type", + NULL # Default case is set to NULL + ) + if (is.null(filter_column_name)) { + stop(paste("Filter", filter, "is not recognized.")) + } + + return(filter_column_name) +} + +#' Gets the output dir depending on the filter name and the value of the filtered column +#' +#' @param filter The filter name +#' @param column_value The value of the column the filter applies to +#' @return The directory to save files to +get_output_dir <- function(filter, column_value) { + if (filter=="none"){ + return(paste0("docs/")) + } + + else if (filter=="venues"){ + venue_category <- determine_venue_category(column_value) + # In case the venue_category itself has no further subgroups we do not need subgroups + if (venue_category==tolower(column_value)){ + return(paste0("docs/", filter, "/", gsub(" ", "_", venue_category), "/")) + } + + # Removing the venue category to obtain the venue name and replace the brackets + venue_name <- trimws(gsub("[()]", "", gsub(venue_category, "", column_value))) + venue_name <- gsub(" ", "_", venue_name) + return(paste0("docs/", filter, "/", venue_category, "/", venue_name, "/")) } + + else{ + return(paste0("docs/", filter, "/", gsub(" ", "_", tolower(column_value)), "/")) + } +} + +#' Determines the venue category based on the venue_name +#' +#' @param venue_name The venue_name obtained from the "Type" column of the register +#' @return The venue category. If the venue does not belong to any category the venue_name is returned +determine_venue_category <- function(venue_name){ + list_venue_categories <- CONFIG$FILTER_SUB_GROUPS[["venues"]] + for (category in list_venue_categories){ + if (grepl(category, venue_name, ignore.case=TRUE)) { + return(category) + } + } + warning(paste("Register venue", venue_name, "does not fall into any of the following venue categories:", toString(list_venue_categories))) + return(venue_name) +} diff --git a/R/utils_filter_register_table.R b/R/utils_filter_register_table.R new file mode 100644 index 00000000..7c3ca164 --- /dev/null +++ b/R/utils_filter_register_table.R @@ -0,0 +1,36 @@ +#' Function for adding filtered register tables to a list based on specified filters. +#' Each entry in the resulting list is a filtered register table by the filter type provided. +#' +#' @param list_register_tables A list to store the filtered tables +#' @param register_table The register table to filter +#' @param filter_by A vector of strings specifying the filter types +#' @return A list of filtered register tables +add_filtered_register_tables <- function(list_register_tables, register_table, filter_by) { + + for (filter in filter_by){ + list_register_tables[[filter]] <- create_filtered_register_tables(register_table, filter) + } + + return(list_register_tables) +} + +#' Function for creating a list of register tables that is filtered based on the filter type. +#' Each entry in the resulting list is the filtered register table with index corresponding to unique values in that column. +#' +#' @param register_table The register table +#' @param filter The filter name +#' @return A list of filtered register tables +create_filtered_register_tables <- function(register_table, filter) { + list_filtered_register_tables <- list() + + filter_column_name <- determine_filter_column_name(filter) + unique_values <- unique(register_table[[filter_column_name]]) + # Loop over the unique values. We create a sorted table for each value + for (value in unique_values) { + filtered_table <- register_table[register_table[[filter_column_name]]==value, ] + rownames(filtered_table) <- NULL # Reset row names to remove row numbers + list_filtered_register_tables[[value]] <- filtered_table + } + + return(list_filtered_register_tables) +} diff --git a/R/utils_preprocess_register.R b/R/utils_preprocess_register.R index d95e5c41..6c6a79e1 100644 --- a/R/utils_preprocess_register.R +++ b/R/utils_preprocess_register.R @@ -11,12 +11,11 @@ register_clear_cache <- function() { unlink(path, recursive = TRUE) } -#' Function for adding clickable links to the repor for each entry in the register table. +#' Function for adding clickable links to the report for each entry in the register table. #' #' @param register_table The register table #' @param register The register from the register.csv file -#' @return register_table - +#' @return The adjusted register table add_report_links <- function(register_table, register) { reports <- c() @@ -39,8 +38,7 @@ add_report_links <- function(register_table, register) { #' #' @param register_table The register table #' @param register The register from the register.csv file -#' @return register_table - +#' @return The adjusted register table add_issue_number_links <- function(register_table, register) { register_table$Issue <- sapply( X = register$Issue, @@ -60,53 +58,11 @@ add_issue_number_links <- function(register_table, register) { return(register_table) } -#' Function for adding repository links to each report in the register table. -#' -#' @param register_table The register table -#' @param register The register from the register.csv file -#' @return register_table - -add_repository_links <- function(register_table, register) { - register_table$Repository <- sapply( - X = register$Repository, - FUN = function(repository) { - spec <- parse_repository_spec(repository) - if (!any(is.na(spec))) { - urrl <- "#" - - switch(spec["type"], - "github" = { - urrl <- paste0("https://github.com/", spec[["repo"]]) - paste0("[", spec[["repo"]], "](", urrl, ")") - }, - "osf" = { - urrl <- paste0("https://osf.io/", spec[["repo"]]) - paste0("[", spec[["repo"]], "](", urrl, ")") - }, - "gitlab" = { - urrl <- paste0("https://gitlab.com/", spec[["repo"]]) - paste0("[", spec[["repo"]], "](", urrl, ")") - }, - - # Type is none of the above - { - repository - } - ) - } else { - repository - } - } - ) - return(register_table) -} - #' Function for adding check time to each report in the register table. #' #' @param register_table The register table #' @param register The register from the register.csv file -#' @return register_table - +#' @return The adjusted register table add_check_time <- function(register_table, register) { check_times <- c() @@ -127,16 +83,13 @@ add_check_time <- function(register_table, register) { return(register_table) } -#' Function for preprocessing the register to create and return the register_table. -#' -#' @param register_table The register table -#' @return register_table - +#' Function for preprocessing the register to create and return the preprocessed register table. +#' @param register The register +#' @return The preprocessed register table preprocess_register <- function(register) { register_table <- register register_table <- add_report_links(register_table, register) register_table <- add_issue_number_links(register_table, register) - register_table <- add_repository_links(register_table, register) register_table <- add_check_time(register_table, register) return(register_table) } \ No newline at end of file diff --git a/R/utils_register_check.R b/R/utils_register_check.R index 885d6cde..cc5de4d1 100644 --- a/R/utils_register_check.R +++ b/R/utils_register_check.R @@ -2,9 +2,9 @@ #' If there is a mismatch a stop is sent. Else a warning is thrown. #' #' @param codecheck_yaml The codecheck yaml file +#' @param entry The registry entry #' @return None - -check_certificate_id <- function(codecheck_yaml) { +check_certificate_id <- function(entry, codecheck_yaml) { # Codecheck.yml found, proceeding to check certificate id if (!is.null(codecheck_yaml)) { # validate config file @@ -30,7 +30,6 @@ check_certificate_id <- function(codecheck_yaml) { #' #' @param entry The codecheck entry #' @return None - check_issue_status <- function(entry) { if (!is.na(entry$Issue)) { # get the status and labels from an issue diff --git a/R/utils_render_register.R b/R/utils_render_register.R deleted file mode 100644 index 76954a1f..00000000 --- a/R/utils_render_register.R +++ /dev/null @@ -1,157 +0,0 @@ -#' Function for rendering the register markdown file. -#' -#' @param register_table The register table -#' @param md_columns_widths The column widths for the markdown file -#' @return None - -render_register_md <- function(register_table, md_columns_widths) { - capture.output( - cat("---\ntitle: CODECHECK Register\n---"), - knitr::kable(register_table, format = "markdown"), - file = "register.md" - ) - # hack to reduce column width of 4th column - md_table <- readLines("register.md") - md_table[6] <- md_columns_widths - writeLines(md_table, "docs/register.md") - file.remove("register.md") - # TODO: fix table column width, e.g. via using a register.Rm -} - -#' Function for rendering the register html file. -#' The html file is rendered from the markdown file. -#' -#' @param register_table The register table -#' @param md_columns_widths The column widths for the markdown file -#' @return None - -render_register_html <- function(register_table, register, md_columns_widths) { - # add icons to the Repository column for HTML output, use a copy of the register.md - # so the inline HTML is not in the .md output - register_table$Repository <- sapply( - X = register$Repository, - FUN = function(repository) { - spec <- parse_repository_spec(repository) - - if (!any(is.na(spec))) { - urrl <- "#" - - if (spec[["type"]] == "github") { - urrl <- paste0("https://github.com/", spec[["repo"]]) - paste0(" [", spec[["repo"]], "](", urrl, ")") - } else if (spec[["type"]] == "osf") { - urrl <- paste0("https://osf.io/", spec[["repo"]]) - paste0(" [", spec[["repo"]], "](", urrl, ")") - } else if (spec[["type"]] == "gitlab") { - urrl <- paste0("https://gitlab.com/", spec[["repo"]]) - paste0(" [", spec[["repo"]], "](", urrl, ")") - } else { - repository - } - } else { - repository - } - } - ) - capture.output( - cat("---\ntitle: CODECHECK Register\n---"), - knitr::kable(register_table, format = "markdown"), - file = "docs/register-icons.md" - ) - md_table <- readLines("docs/register-icons.md") - file.remove("docs/register-icons.md") - md_table[6] <- md_columns_widths - writeLines(md_table, "docs/register-icons.md") - - rmarkdown::render( - input = "docs/register-icons.md", - # next paths are relative to input file - output_yaml = "html_document.yml", - output_file = "index.html" - ) - file.remove("docs/register-icons.md") -} - -#' Function for rendering the register json file. -#' -#' @param register_table The register table -#' @param register The register from the register.csv file -#' @return None - -render_register_json <- function(register_table, register) { - # Get paper titles and references - titles <- c() - references <- c() - - for (i in seq_len(nrow(register))) { - config_yml <- get_codecheck_yml(register[i, ]$Repo) - - title <- NA - reference <- NA - if (!is.null(config_yml)) { - title <- config_yml$paper$title - reference <- config_yml$paper$reference - } - - titles <- c(titles, title) - references <- c(references, reference) - } - - register_table$Title <- stringr::str_trim(titles) - register_table$`Paper reference` <- stringr::str_trim(references) - register_table$`Repository Link` <- sapply( - X = register$Repository, - FUN = function(repository) { - spec <- parse_repository_spec(repository) - if (spec[["type"]] == "github") { - paste0("https://github.com/", spec[["repo"]]) - } else if (spec[["type"]] == "osf") { - paste0("https://osf.io/", spec[["repo"]]) - } else if (spec[["type"]] == "gitlab") { - paste0("https://gitlab.com/", spec[["repo"]]) - } else { - repository - } - } - ) - - jsonlite::write_json( - register_table[, c( - "Certificate", - "Repository Link", - "Type", - "Report", - "Title", - "Paper reference", - "Check date" - )], - path = "docs/register.json", - pretty = TRUE - ) - - jsonlite::write_json( - utils::tail(register_table, 10)[, c( - "Certificate", - "Repository Link", - "Type", - "Report", - "Title", - "Paper reference", - "Check date" - )], - path = "docs/featured.json", - pretty = TRUE - ) - - jsonlite::write_json( - list( - source = "https://codecheck.org.uk/register/register.json", - cert_count = nrow(register_table) - # TODO count conferences, preprints, - # journals, etc. - ), - auto_unbox = TRUE, - path = "docs/stats.json", - pretty = TRUE - ) -} diff --git a/R/utils_render_register_json.R b/R/utils_render_register_json.R new file mode 100644 index 00000000..e15ba65c --- /dev/null +++ b/R/utils_render_register_json.R @@ -0,0 +1,119 @@ +#' Function for adding repository links in the register table for the creation of the json file. +#' +#' @param register_table The register table +#' @return Register table with adjusted repository links +add_repository_links_json <- function(register_table) { + register_table$`Repository Link` <- sapply( + X = register_table$Repository, + FUN = function(repository) { + spec <- parse_repository_spec(repository) + if (spec[["type"]] == "github") { + paste0("https://github.com/", spec[["repo"]]) + } else if (spec[["type"]] == "osf") { + paste0("https://osf.io/", spec[["repo"]]) + } else if (spec[["type"]] == "gitlab") { + paste0("https://gitlab.com/", spec[["repo"]]) + } else { + repository + } + } + ) + return(register_table) +} + +#' Set "Title" and "Paper reference" columns and values to the register_table +#' +#' @param register_table The register table +#' @return Updated register table including "Title" and "Paper reference" columns +set_paper_title_references <- function(register_table){ + titles <- c() + references <- c() + for (i in seq_len(nrow(register_table))) { + config_yml <- get_codecheck_yml(register_table[i, ]$Repository) + + title <- NA + reference <- NA + if (!is.null(config_yml)) { + title <- config_yml$paper$title + reference <- config_yml$paper$reference + } + + titles <- c(titles, title) + references <- c(references, reference) + } + register_table$Title <- stringr::str_trim(titles) + register_table$`Paper reference` <- stringr::str_trim(references) + + return(register_table) +} + +#' Renders register json for a single register_table +#' +#' @param filter The filter +#' @param register_table The register table +#' @param register_table_name The register table name +render_register_json <- function(filter, register_table, register_table_name) { + register_table <- add_repository_links_json(register_table) + + # Set paper titles and references + register_table <- set_paper_title_references(register_table) + + output_dir <- get_output_dir(filter, register_table_name) + if (!dir.exists(output_dir)) { + dir.create(output_dir, recursive = TRUE, showWarnings = TRUE) + } + + jsonlite::write_json( + register_table[, c( + "Certificate", + "Repository Link", + "Type", + "Report", + "Title", + "Paper reference", + "Check date" + )], + path = paste0(output_dir, "register.json"), + pretty = TRUE + ) + + jsonlite::write_json( + utils::tail(register_table, 10)[, c( + "Certificate", + "Repository Link", + "Type", + "Report", + "Title", + "Paper reference", + "Check date" + )], + path = paste0(output_dir, "featured.json"), + pretty = TRUE + ) + + jsonlite::write_json( + list( + source = generate_href(filter, register_table_name, "json"), + cert_count = nrow(register_table) + # TODO count conferences, preprints, + # journals, etc. + ), + auto_unbox = TRUE, + path = paste0(output_dir, "/stats.json"), + pretty = TRUE + ) +} + +#' Renders register jsons for a list of register tables +#' +#' @param list_register_table List of register tables +render_register_jsons <- function(list_register_tables){ + # Loop over each register table and render a json + for (filter in names(list_register_tables)){ + for (register_table_name in names(list_register_tables[[filter]])) { + register_table <- list_register_tables[[filter]][[register_table_name]] + render_register_json(filter, register_table, register_table_name) + } + } +} + diff --git a/R/utils_render_register_mds.R b/R/utils_render_register_mds.R new file mode 100644 index 00000000..66992cf4 --- /dev/null +++ b/R/utils_render_register_mds.R @@ -0,0 +1,126 @@ +#' Function to load the markdown table +#' +#' @param template_path The path to the markdown template +#' @return The markdown table template +load_md_template <- function(template_path){ + if (!file.exists(template_path)){ + stop("No register table template found") + } + + md_table <- readLines(template_path) + return(md_table) +} + +#' Function to adjust the markdown title based on the specific register table name. +#' +#' @param markdown_table The markdown template where the title needs to be adjusted +#' @param register_table_name The name of the register table +#' +#' @return The modified markdown table +adjust_markdown_title <- function(md_table, register_table_name){ + if (register_table_name == "original"){ + title_addition <- "" + } + + else { + title_addition <- paste("for", register_table_name) + } + + md_table <- gsub("\\$title_addition\\$", title_addition, md_table) + return(md_table) +} + +#' Function for adding repository links in the register table for the creation of the markdown file. +#' +#' @param register_table The register table +#' @return Register table with adjusted repository links +add_repository_links_md <- function(register_table) { + register_table$Repository <- sapply( + X = register_table$Repository, + FUN = function(repository) { + spec <- parse_repository_spec(repository) + if (!any(is.na(spec))) { + urrl <- "#" + + switch(spec["type"], + "github" = { + urrl <- paste0("https://github.com/", spec[["repo"]]) + paste0("[", spec[["repo"]], "](", urrl, ")") + }, + "osf" = { + urrl <- paste0("https://osf.io/", spec[["repo"]]) + paste0("[", spec[["repo"]], "](", urrl, ")") + }, + "gitlab" = { + urrl <- paste0("https://gitlab.com/", spec[["repo"]]) + paste0("[", spec[["repo"]], "](", urrl, ")") + }, + + # Type is none of the above + { + repository + } + ) + } else { + repository + } + } + ) + return(register_table) +} + +#' Renders register md for a single register_table +#' +#' @param filter The filter +#' @param register_table The register table +#' @param register_table_name The register table name +#' @param for_html_file Flag for whether we are rendering register md for html file. +#' Set to FALSE by default. If TRUE, no repo links are added to the repository table. +render_register_md <- function(filter, register_table, register_table_name, for_html_file=FALSE) { + # If we are rendering md for html file, we do not need to add repo links + if (for_html_file == FALSE){ + register_table <- add_repository_links_md(register_table) + } + # Fill in the content + md_table <- load_md_template(CONFIG$MD_TEMPLATE) + + markdown_content <- capture.output(kable(register_table, format = "markdown")) + md_table <- adjust_markdown_title(md_table, register_table_name) + md_table <- gsub("\\$content\\$", paste(markdown_content, collapse = "\n"), md_table) + + # Adjusting the column widths + md_table <- unlist(strsplit(md_table, "\n", fixed = TRUE)) + # Determining which line to add the md column widths in + alignment_line_index <- grep("^\\|:---", md_table) + md_table[alignment_line_index] <- CONFIG$MD_COLUMNS_WIDTHS + + # Determining the directory and saving the file + output_dir <- get_output_dir(filter, register_table_name) + + if (!dir.exists(output_dir)) { + dir.create(output_dir, recursive = TRUE, showWarnings = TRUE) + } + + # If rendering md for html file we create a temp file + if (for_html_file){ + output_dir <- paste0(output_dir, "temp.md") + } + + else{ + output_dir <- paste0(output_dir, "register.md") + } + + writeLines(md_table, output_dir) +} + +#' Renders register mds for a list of register tables +#' +#' @param list_register_table List of register tables +render_register_mds <- function(list_register_tables){ + for (filter in names(list_register_tables)){ + for (register_table_name in names(list_register_tables[[filter]])){ + register_table <- list_register_tables[[filter]][[register_table_name]] + render_register_md(filter, register_table, register_table_name) + } + } +} diff --git a/R/utils_render_reigster_html.r b/R/utils_render_reigster_html.r new file mode 100644 index 00000000..4d9e4e3b --- /dev/null +++ b/R/utils_render_reigster_html.r @@ -0,0 +1,226 @@ +#' Function for adding repository links in the register table for the creation of the html file. +#' +#' @param register_table The register table +#' @return Register table with adjusted repository links +add_repository_links_html <- function(register_table) { + register_table$Repository <- sapply( + X = register_table$Repository, + FUN = function(repository) { + spec <- parse_repository_spec(repository) + if (!any(is.na(spec))) { + urrl <- "#" + if (spec[["type"]] == "github") { + urrl <- paste0("https://github.com/", spec[["repo"]]) + paste0(" [", spec[["repo"]], "](", urrl, ")") + } else if (spec[["type"]] == "osf") { + urrl <- paste0("https://osf.io/", spec[["repo"]]) + paste0(" [", spec[["repo"]], "](", urrl, ")") + } else if (spec[["type"]] == "gitlab") { + urrl <- paste0("https://gitlab.com/", spec[["repo"]]) + paste0(" [", spec[["repo"]], "](", urrl, ")") + } else { + repository + } + } else { + repository + } + } + ) + return(register_table) +} + +#' Dynamically generates a html_document.yml with the full paths to the index header, prefix +#' and postfix.html files. +#' +#' @param filter The filter name +#' @param register_table_name The register table name +generate_html_document_yml <- function(filter, register_table_name) { + dir <- paste0(getwd(), "/", get_output_dir(filter, register_table_name)) + + yaml_content <- sprintf( + "# DO NOT EDIT THIS FILE MANUALLY + html_document: + includes: + in_header: '%sindex_header.html' + before_body: '%sindex_prefix.html' + after_body: '%sindex_postfix.html' + mathjax: null + highlight: null + self_contained: false + lib_dir: libs", + dir, dir, dir + ) + writeLines(yaml_content, paste0(dir, "html_document.yml")) +} + +#' Dynamically generates the index_postfix.html from a template file +#' +#' @param filter The filter name +#' @param register_table_name The register table name +#' +#' @importFrom whisker whisker.render +create_index_postfix_html <- function(filter, register_table_name){ + hrefs <- generate_html_postfix_hrefs(filter, register_table_name) + + # Using the index_postfix_template + postfix_template <- readLines(paste0(getwd(), "/docs/index_postfix_template.html"), warn = FALSE) + # Render the template with the correct hrefs + output <- whisker.render(postfix_template, hrefs) + writeLines(output, paste0(get_output_dir(filter, register_table_name), "index_postfix.html")) +} + +#' Dynamically generates the index_prefix.html from a template file +#' +#' @param filter The filter name +#' @param register_table_name The register table name +create_index_prefix_html <- function(filter, register_table_name){ + # Using the index_prefix_template + prefix_template <- readLines(paste0(getwd(), "/docs/index_prefix_template.html"), warn = FALSE) + + writeLines(prefix_template, paste0(get_output_dir(filter, register_table_name), "index_prefix.html")) +} + +#' Dynamically generates the index_header.html from a template file +#' +#' @param filter The filter name +#' @param register_table_name The register table name +create_index_header_html <- function(filter, register_table_name){ + # Using the index_header_template + header_template <- readLines(paste0(getwd(), "/docs/index_header_template.html"), warn = FALSE) + + writeLines(header_template, paste0(get_output_dir(filter, register_table_name), "index_header.html")) +} + +#' Generates the hrefs to set in the postfix.html file. +#' +#' @param filter The filter name +#' @param register_table_name The register table name +generate_html_postfix_hrefs <- function(filter, register_table_name) { + hrefs <- list( + csv_source_href = generate_href(filter, register_table_name, "csv_source"), + searchable_csv_href = generate_href(filter, register_table_name, "searchable_csv"), + json_href = generate_href(filter, register_table_name, "json"), + md_href = generate_href(filter, register_table_name, "md") + ) + return(hrefs) +} + +#' Generate full href for for different href types. +#' +#' @param filter The filter name +#' @param register_table_name The register table name +#' @param href_type The href type (e.g., 'csv_source', 'searchable_csv', 'json', 'md') +#' +#' @return String representing the full URL to access the specified resource +generate_href <- function(filter, register_table_name, href_type) { + # Determine base path based on the resource type + href_details <- switch(href_type, + "csv_source" = list(base_url = "https://raw.githubusercontent.com/codecheckers/register/master/", ext = ".csv"), + "searchable_csv" = list(base_url ="https://github.com/codecheckers/register/blob/master/", ext = ".csv"), + "json" = list(base_url = "https://codecheck.org.uk/register/", ext = ".json"), + "md" = list(base_url = "https://codecheck.org.uk/register/", ext = ".md") + ) + + if (filter == "none") { + return(paste0(href_details$base_url, "register", href_details$ext)) + } else if (filter == "venues") { + venue_category <- determine_venue_category(register_table_name) + venue_name <- trimws(gsub("[()]", "", gsub(venue_category, "", register_table_name))) + venue_name <- gsub(" ", "_", venue_name) + return(paste0(href_details$base_url, filter, "/", venue_category, "/", venue_name, "/register", href_details$ext)) + } else { + return(paste0(href_details$base_url, filter, "/", register_table_name, "/register", href_details$ext)) + } +} + +#' Creates html files for each index section- the index postfix, prefix and the header +#' +#' @param filter The filter name +#' @param register_table_name The register table name +create_index_section_files <- function(filter, register_table_name) { + create_index_postfix_html(filter, register_table_name) + create_index_prefix_html(filter, register_table_name) + create_index_header_html(filter, register_table_name) +} + +#' Renders register html for a single register_table +#' +#' @param filter The filter +#' @param register_table The register table +#' @param register_table_name The register table name +render_register_html <- function(filter, register_table, register_table_name){ + # Add icons to the Repository column for HTML output, use a copy of the register.md + register_table <- add_repository_links_html(register_table) + + # Dynamically create the index header, prefix and postfix files + create_index_section_files(filter, register_table_name) + generate_html_document_yml(filter, register_table_name) + + output_dir <- get_output_dir(filter, register_table_name) + # Capture the HTML output from a markdown file + # Note that the temp md file must be created even if a md exists because the register table + # now has different icons under "Repository" column + render_register_md(filter, register_table, register_table_name, for_html_file=TRUE) + temp_md_file_path <- paste0(output_dir, "temp.md") + + yaml_path <- normalizePath(file.path(getwd(), paste0(output_dir, "html_document.yml"))) + + # Render HTML from markdown + rmarkdown::render( + input = temp_md_file_path, + output_file = "index.html", + output_dir = output_dir, + output_yaml = yaml_path + ) + + file.remove(temp_md_file_path) + + # For all registered tables besides the original we change the html + # file so that the path to the libs folder refers to the libs folder "docs/libs". + # This is done to remove duplicates of "libs" folders. + if (register_table_name != "original"){ + html_file_path <- paste0(output_dir, "index.html") + edit_html_lib_paths(html_file_path) + # Deleting the libs folder after changing the html lib path + unlink(paste0(output_dir, "/libs"), recursive = TRUE) + } +} + +#' Renders register htmls for a list of register tables +#' +#' @param list_register_table List of register tables +render_register_htmls <- function(list_register_tables) { + # Loop over each register table + for (filter in names(list_register_tables)){ + for (register_table_name in names(list_register_tables[[filter]])) { + register_table <- list_register_tables[[filter]][[register_table_name]] + render_register_html(filter, register_table, register_table_name) + } + } +} + +#' Loads a html file and replaces the libs path in the html file to the libs folder in "docs/libs" +#' This is done so all html files can share one libs folder. +#' +#' @param html_file_path The path to the html file that needs to be edited. +edit_html_lib_paths <- function(html_file_path) { + + path_components <- strsplit(html_file_path, "/")[[1]] + # The count of dirs one needs to move up to reach "docs" folder. "-2" is used because both "docs" + # "index.html" are elements in path_components. + count_dir_up <- length(path_components) - 2 + up_dirs_string <- rep("../", count_dir_up) + + # Relative path to the "docs/libs" folder + path_to_base <- paste0(up_dirs_string, collapse = "") + relative_libs_dir <- paste0(path_to_base, "libs/") + + # Read the HTML file lines into a vector + html_lines <- readLines(html_file_path) + + # Replace lines containing "=libs/" with the appropriate relative path to "docs/libs" + edited_lines <- gsub('="libs/', paste0('="', relative_libs_dir), html_lines) + + # Write the edited lines back to the file + writeLines(edited_lines, html_file_path) +} \ No newline at end of file diff --git a/inst/extdata/templates/template_register.md b/inst/extdata/templates/template_register.md new file mode 100644 index 00000000..fd0c86e8 --- /dev/null +++ b/inst/extdata/templates/template_register.md @@ -0,0 +1,5 @@ +--- +title: CODECHECK Register $title_addition$ +--- + +$content$ diff --git a/man/add_check_time.Rd b/man/add_check_time.Rd new file mode 100644 index 00000000..63bd2241 --- /dev/null +++ b/man/add_check_time.Rd @@ -0,0 +1,19 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/utils_preprocess_register.R +\name{add_check_time} +\alias{add_check_time} +\title{Function for adding check time to each report in the register table.} +\usage{ +add_check_time(register_table, register) +} +\arguments{ +\item{register_table}{The register table} + +\item{register}{The register from the register.csv file} +} +\value{ +The adjusted register table +} +\description{ +Function for adding check time to each report in the register table. +} diff --git a/man/add_filtered_register_tables.Rd b/man/add_filtered_register_tables.Rd new file mode 100644 index 00000000..6e49d133 --- /dev/null +++ b/man/add_filtered_register_tables.Rd @@ -0,0 +1,23 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/utils_filter_register_table.R +\name{add_filtered_register_tables} +\alias{add_filtered_register_tables} +\title{Function for adding filtered register tables to a list based on specified filters. +Each entry in the resulting list is a filtered register table by the filter type provided.} +\usage{ +add_filtered_register_tables(list_register_tables, register_table, filter_by) +} +\arguments{ +\item{list_register_tables}{A list to store the filtered tables} + +\item{register_table}{The register table to filter} + +\item{filter_by}{A vector of strings specifying the filter types} +} +\value{ +A list of filtered register tables +} +\description{ +Function for adding filtered register tables to a list based on specified filters. +Each entry in the resulting list is a filtered register table by the filter type provided. +} diff --git a/man/add_issue_number_links.Rd b/man/add_issue_number_links.Rd new file mode 100644 index 00000000..c7ebe51e --- /dev/null +++ b/man/add_issue_number_links.Rd @@ -0,0 +1,19 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/utils_preprocess_register.R +\name{add_issue_number_links} +\alias{add_issue_number_links} +\title{Function for adding clickable links to the issue number of each report in the register table.} +\usage{ +add_issue_number_links(register_table, register) +} +\arguments{ +\item{register_table}{The register table} + +\item{register}{The register from the register.csv file} +} +\value{ +The adjusted register table +} +\description{ +Function for adding clickable links to the issue number of each report in the register table. +} diff --git a/man/add_report_links.Rd b/man/add_report_links.Rd new file mode 100644 index 00000000..2cdb7781 --- /dev/null +++ b/man/add_report_links.Rd @@ -0,0 +1,19 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/utils_preprocess_register.R +\name{add_report_links} +\alias{add_report_links} +\title{Function for adding clickable links to the report for each entry in the register table.} +\usage{ +add_report_links(register_table, register) +} +\arguments{ +\item{register_table}{The register table} + +\item{register}{The register from the register.csv file} +} +\value{ +The adjusted register table +} +\description{ +Function for adding clickable links to the report for each entry in the register table. +} diff --git a/man/add_repository_links_html.Rd b/man/add_repository_links_html.Rd new file mode 100644 index 00000000..8ebbbefb --- /dev/null +++ b/man/add_repository_links_html.Rd @@ -0,0 +1,17 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/utils_render_reigster_html.r +\name{add_repository_links_html} +\alias{add_repository_links_html} +\title{Function for adding repository links in the register table for the creation of the html file.} +\usage{ +add_repository_links_html(register_table) +} +\arguments{ +\item{register_table}{The register table} +} +\value{ +Register table with adjusted repository links +} +\description{ +Function for adding repository links in the register table for the creation of the html file. +} diff --git a/man/add_repository_links_json.Rd b/man/add_repository_links_json.Rd new file mode 100644 index 00000000..dca35231 --- /dev/null +++ b/man/add_repository_links_json.Rd @@ -0,0 +1,17 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/utils_render_register_json.R +\name{add_repository_links_json} +\alias{add_repository_links_json} +\title{Function for adding repository links in the register table for the creation of the json file.} +\usage{ +add_repository_links_json(register_table) +} +\arguments{ +\item{register_table}{The register table} +} +\value{ +Register table with adjusted repository links +} +\description{ +Function for adding repository links in the register table for the creation of the json file. +} diff --git a/man/add_repository_links_md.Rd b/man/add_repository_links_md.Rd new file mode 100644 index 00000000..d4903b2f --- /dev/null +++ b/man/add_repository_links_md.Rd @@ -0,0 +1,17 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/utils_render_register_mds.R +\name{add_repository_links_md} +\alias{add_repository_links_md} +\title{Function for adding repository links in the register table for the creation of the markdown file.} +\usage{ +add_repository_links_md(register_table) +} +\arguments{ +\item{register_table}{The register table} +} +\value{ +Register table with adjusted repository links +} +\description{ +Function for adding repository links in the register table for the creation of the markdown file. +} diff --git a/man/adjust_markdown_title.Rd b/man/adjust_markdown_title.Rd new file mode 100644 index 00000000..48dc5ff1 --- /dev/null +++ b/man/adjust_markdown_title.Rd @@ -0,0 +1,19 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/utils_render_register_mds.R +\name{adjust_markdown_title} +\alias{adjust_markdown_title} +\title{Function to adjust the markdown title based on the specific register table name.} +\usage{ +adjust_markdown_title(md_table, register_table_name) +} +\arguments{ +\item{register_table_name}{The name of the register table} + +\item{markdown_table}{The markdown template where the title needs to be adjusted} +} +\value{ +The modified markdown table +} +\description{ +Function to adjust the markdown title based on the specific register table name. +} diff --git a/man/check_certificate_id.Rd b/man/check_certificate_id.Rd new file mode 100644 index 00000000..0089e990 --- /dev/null +++ b/man/check_certificate_id.Rd @@ -0,0 +1,21 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/utils_register_check.R +\name{check_certificate_id} +\alias{check_certificate_id} +\title{Function for checking ceritificate id if there is a codecheck_yaml. +If there is a mismatch a stop is sent. Else a warning is thrown.} +\usage{ +check_certificate_id(entry, codecheck_yaml) +} +\arguments{ +\item{entry}{The registry entry} + +\item{codecheck_yaml}{The codecheck yaml file} +} +\value{ +None +} +\description{ +Function for checking ceritificate id if there is a codecheck_yaml. +If there is a mismatch a stop is sent. Else a warning is thrown. +} diff --git a/man/check_issue_status.Rd b/man/check_issue_status.Rd new file mode 100644 index 00000000..6c1e2fe2 --- /dev/null +++ b/man/check_issue_status.Rd @@ -0,0 +1,19 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/utils_register_check.R +\name{check_issue_status} +\alias{check_issue_status} +\title{Function issue status. If the issue is not closed a warning is thrown +stating that the issue is still open.} +\usage{ +check_issue_status(entry) +} +\arguments{ +\item{entry}{The codecheck entry} +} +\value{ +None +} +\description{ +Function issue status. If the issue is not closed a warning is thrown +stating that the issue is still open. +} diff --git a/man/create_filtered_register_csvs.Rd b/man/create_filtered_register_csvs.Rd new file mode 100644 index 00000000..33c9437c --- /dev/null +++ b/man/create_filtered_register_csvs.Rd @@ -0,0 +1,16 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/utils_create_filtered_register_csvs.R +\name{create_filtered_register_csvs} +\alias{create_filtered_register_csvs} +\title{Creates filtered register csv files} +\usage{ +create_filtered_register_csvs(filter_by, register) +} +\arguments{ +\item{filter_by}{A vector of strings specifying the names of the columns to filter by.} + +\item{register}{A dataframe representing the register data to be filtered.} +} +\description{ +Each csv file is saved in the appropriate output_dir. +} diff --git a/man/create_filtered_register_tables.Rd b/man/create_filtered_register_tables.Rd new file mode 100644 index 00000000..72c275e6 --- /dev/null +++ b/man/create_filtered_register_tables.Rd @@ -0,0 +1,21 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/utils_filter_register_table.R +\name{create_filtered_register_tables} +\alias{create_filtered_register_tables} +\title{Function for creating a list of register tables that is filtered based on the filter type. +Each entry in the resulting list is the filtered register table with index corresponding to unique values in that column.} +\usage{ +create_filtered_register_tables(register_table, filter) +} +\arguments{ +\item{register_table}{The register table} + +\item{filter}{The filter name} +} +\value{ +A list of filtered register tables +} +\description{ +Function for creating a list of register tables that is filtered based on the filter type. +Each entry in the resulting list is the filtered register table with index corresponding to unique values in that column. +} diff --git a/man/create_index_header_html.Rd b/man/create_index_header_html.Rd new file mode 100644 index 00000000..f84a5da7 --- /dev/null +++ b/man/create_index_header_html.Rd @@ -0,0 +1,16 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/utils_render_reigster_html.r +\name{create_index_header_html} +\alias{create_index_header_html} +\title{Dynamically generates the index_header.html from a template file} +\usage{ +create_index_header_html(filter, register_table_name) +} +\arguments{ +\item{filter}{The filter name} + +\item{register_table_name}{The register table name} +} +\description{ +Dynamically generates the index_header.html from a template file +} diff --git a/man/create_index_postfix_html.Rd b/man/create_index_postfix_html.Rd new file mode 100644 index 00000000..7c12ec4a --- /dev/null +++ b/man/create_index_postfix_html.Rd @@ -0,0 +1,16 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/utils_render_reigster_html.r +\name{create_index_postfix_html} +\alias{create_index_postfix_html} +\title{Dynamically generates the index_postfix.html from a template file} +\usage{ +create_index_postfix_html(filter, register_table_name) +} +\arguments{ +\item{filter}{The filter name} + +\item{register_table_name}{The register table name} +} +\description{ +Dynamically generates the index_postfix.html from a template file +} diff --git a/man/create_index_prefix_html.Rd b/man/create_index_prefix_html.Rd new file mode 100644 index 00000000..e7884961 --- /dev/null +++ b/man/create_index_prefix_html.Rd @@ -0,0 +1,16 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/utils_render_reigster_html.r +\name{create_index_prefix_html} +\alias{create_index_prefix_html} +\title{Dynamically generates the index_prefix.html from a template file} +\usage{ +create_index_prefix_html(filter, register_table_name) +} +\arguments{ +\item{filter}{The filter name} + +\item{register_table_name}{The register table name} +} +\description{ +Dynamically generates the index_prefix.html from a template file +} diff --git a/man/create_index_section_files.Rd b/man/create_index_section_files.Rd new file mode 100644 index 00000000..032d7c25 --- /dev/null +++ b/man/create_index_section_files.Rd @@ -0,0 +1,16 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/utils_render_reigster_html.r +\name{create_index_section_files} +\alias{create_index_section_files} +\title{Creates html files for each index section- the index postfix, prefix and the header} +\usage{ +create_index_section_files(filter, register_table_name) +} +\arguments{ +\item{filter}{The filter name} + +\item{register_table_name}{The register table name} +} +\description{ +Creates html files for each index section- the index postfix, prefix and the header +} diff --git a/man/determine_filter_column_name.Rd b/man/determine_filter_column_name.Rd new file mode 100644 index 00000000..fd8acafb --- /dev/null +++ b/man/determine_filter_column_name.Rd @@ -0,0 +1,17 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/utils_create_filtered_register_csvs.R +\name{determine_filter_column_name} +\alias{determine_filter_column_name} +\title{Determines the register table's column name to filter the data by.} +\usage{ +determine_filter_column_name(filter) +} +\arguments{ +\item{filter}{The filter name} +} +\value{ +The column name to filter by +} +\description{ +Determines the register table's column name to filter the data by. +} diff --git a/man/determine_venue_category.Rd b/man/determine_venue_category.Rd new file mode 100644 index 00000000..cf0f369e --- /dev/null +++ b/man/determine_venue_category.Rd @@ -0,0 +1,17 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/utils_create_filtered_register_csvs.R +\name{determine_venue_category} +\alias{determine_venue_category} +\title{Determines the venue category based on the venue_name} +\usage{ +determine_venue_category(venue_name) +} +\arguments{ +\item{venue_name}{The venue_name obtained from the "Type" column of the register} +} +\value{ +The venue category. If the venue does not belong to any category the venue_name is returned +} +\description{ +Determines the venue category based on the venue_name +} diff --git a/man/edit_html_lib_paths.Rd b/man/edit_html_lib_paths.Rd new file mode 100644 index 00000000..b4df9df1 --- /dev/null +++ b/man/edit_html_lib_paths.Rd @@ -0,0 +1,16 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/utils_render_reigster_html.r +\name{edit_html_lib_paths} +\alias{edit_html_lib_paths} +\title{Loads a html file and replaces the libs path in the html file to the libs folder in "docs/libs" +This is done so all html files can share one libs folder.} +\usage{ +edit_html_lib_paths(html_file_path) +} +\arguments{ +\item{html_file_path}{The path to the html file that needs to be edited.} +} +\description{ +Loads a html file and replaces the libs path in the html file to the libs folder in "docs/libs" +This is done so all html files can share one libs folder. +} diff --git a/man/generate_href.Rd b/man/generate_href.Rd new file mode 100644 index 00000000..05e8082c --- /dev/null +++ b/man/generate_href.Rd @@ -0,0 +1,21 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/utils_render_reigster_html.r +\name{generate_href} +\alias{generate_href} +\title{Generate full href for for different href types.} +\usage{ +generate_href(filter, register_table_name, href_type) +} +\arguments{ +\item{filter}{The filter name} + +\item{register_table_name}{The register table name} + +\item{href_type}{The href type (e.g., 'csv_source', 'searchable_csv', 'json', 'md')} +} +\value{ +String representing the full URL to access the specified resource +} +\description{ +Generate full href for for different href types. +} diff --git a/man/generate_html_document_yml.Rd b/man/generate_html_document_yml.Rd new file mode 100644 index 00000000..f11c6b10 --- /dev/null +++ b/man/generate_html_document_yml.Rd @@ -0,0 +1,18 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/utils_render_reigster_html.r +\name{generate_html_document_yml} +\alias{generate_html_document_yml} +\title{Dynamically generates a html_document.yml with the full paths to the index header, prefix +and postfix.html files.} +\usage{ +generate_html_document_yml(filter, register_table_name) +} +\arguments{ +\item{filter}{The filter name} + +\item{register_table_name}{The register table name} +} +\description{ +Dynamically generates a html_document.yml with the full paths to the index header, prefix +and postfix.html files. +} diff --git a/man/generate_html_postfix_hrefs.Rd b/man/generate_html_postfix_hrefs.Rd new file mode 100644 index 00000000..b08227d9 --- /dev/null +++ b/man/generate_html_postfix_hrefs.Rd @@ -0,0 +1,16 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/utils_render_reigster_html.r +\name{generate_html_postfix_hrefs} +\alias{generate_html_postfix_hrefs} +\title{Generates the hrefs to set in the postfix.html file.} +\usage{ +generate_html_postfix_hrefs(filter, register_table_name) +} +\arguments{ +\item{filter}{The filter name} + +\item{register_table_name}{The register table name} +} +\description{ +Generates the hrefs to set in the postfix.html file. +} diff --git a/man/get_output_dir.Rd b/man/get_output_dir.Rd new file mode 100644 index 00000000..2cf209b3 --- /dev/null +++ b/man/get_output_dir.Rd @@ -0,0 +1,19 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/utils_create_filtered_register_csvs.R +\name{get_output_dir} +\alias{get_output_dir} +\title{Gets the output dir depending on the filter name and the value of the filtered column} +\usage{ +get_output_dir(filter, column_value) +} +\arguments{ +\item{filter}{The filter name} + +\item{column_value}{The value of the column the filter applies to} +} +\value{ +The directory to save files to +} +\description{ +Gets the output dir depending on the filter name and the value of the filtered column +} diff --git a/man/load_md_template.Rd b/man/load_md_template.Rd new file mode 100644 index 00000000..a2d45aeb --- /dev/null +++ b/man/load_md_template.Rd @@ -0,0 +1,17 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/utils_render_register_mds.R +\name{load_md_template} +\alias{load_md_template} +\title{Function to load the markdown table} +\usage{ +load_md_template(template_path) +} +\arguments{ +\item{template_path}{The path to the markdown template} +} +\value{ +The markdown table template +} +\description{ +Function to load the markdown table +} diff --git a/man/preprocess_register.Rd b/man/preprocess_register.Rd new file mode 100644 index 00000000..94ab5031 --- /dev/null +++ b/man/preprocess_register.Rd @@ -0,0 +1,17 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/utils_preprocess_register.R +\name{preprocess_register} +\alias{preprocess_register} +\title{Function for preprocessing the register to create and return the preprocessed register table.} +\usage{ +preprocess_register(register) +} +\arguments{ +\item{register}{The register} +} +\value{ +The preprocessed register table +} +\description{ +Function for preprocessing the register to create and return the preprocessed register table. +} diff --git a/man/register_clear_cache.Rd b/man/register_clear_cache.Rd index c12b07f4..6124e7f3 100644 --- a/man/register_clear_cache.Rd +++ b/man/register_clear_cache.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/register.R +% Please edit documentation in R/utils_preprocess_register.R \name{register_clear_cache} \alias{register_clear_cache} \title{Function for clearing the register cache} diff --git a/man/register_render.Rd b/man/register_render.Rd index a460c746..d46c2ac5 100644 --- a/man/register_render.Rd +++ b/man/register_render.Rd @@ -6,6 +6,7 @@ \usage{ register_render( register = read.csv("register.csv", as.is = TRUE), + filter_by = c("venues"), outputs = c("html", "md", "json") ) } diff --git a/man/render_register_html.Rd b/man/render_register_html.Rd new file mode 100644 index 00000000..8b48daed --- /dev/null +++ b/man/render_register_html.Rd @@ -0,0 +1,18 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/utils_render_reigster_html.r +\name{render_register_html} +\alias{render_register_html} +\title{Renders register html for a single register_table} +\usage{ +render_register_html(filter, register_table, register_table_name) +} +\arguments{ +\item{filter}{The filter} + +\item{register_table}{The register table} + +\item{register_table_name}{The register table name} +} +\description{ +Renders register html for a single register_table +} diff --git a/man/render_register_htmls.Rd b/man/render_register_htmls.Rd new file mode 100644 index 00000000..26ac4c84 --- /dev/null +++ b/man/render_register_htmls.Rd @@ -0,0 +1,14 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/utils_render_reigster_html.r +\name{render_register_htmls} +\alias{render_register_htmls} +\title{Renders register htmls for a list of register tables} +\usage{ +render_register_htmls(list_register_tables) +} +\arguments{ +\item{list_register_table}{List of register tables} +} +\description{ +Renders register htmls for a list of register tables +} diff --git a/man/render_register_json.Rd b/man/render_register_json.Rd new file mode 100644 index 00000000..a84972ff --- /dev/null +++ b/man/render_register_json.Rd @@ -0,0 +1,18 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/utils_render_register_json.R +\name{render_register_json} +\alias{render_register_json} +\title{Renders register json for a single register_table} +\usage{ +render_register_json(filter, register_table, register_table_name) +} +\arguments{ +\item{filter}{The filter} + +\item{register_table}{The register table} + +\item{register_table_name}{The register table name} +} +\description{ +Renders register json for a single register_table +} diff --git a/man/render_register_jsons.Rd b/man/render_register_jsons.Rd new file mode 100644 index 00000000..c3fd2599 --- /dev/null +++ b/man/render_register_jsons.Rd @@ -0,0 +1,14 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/utils_render_register_json.R +\name{render_register_jsons} +\alias{render_register_jsons} +\title{Renders register jsons for a list of register tables} +\usage{ +render_register_jsons(list_register_tables) +} +\arguments{ +\item{list_register_table}{List of register tables} +} +\description{ +Renders register jsons for a list of register tables +} diff --git a/man/render_register_md.Rd b/man/render_register_md.Rd new file mode 100644 index 00000000..4f208de4 --- /dev/null +++ b/man/render_register_md.Rd @@ -0,0 +1,26 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/utils_render_register_mds.R +\name{render_register_md} +\alias{render_register_md} +\title{Renders register md for a single register_table} +\usage{ +render_register_md( + filter, + register_table, + register_table_name, + for_html_file = FALSE +) +} +\arguments{ +\item{filter}{The filter} + +\item{register_table}{The register table} + +\item{register_table_name}{The register table name} + +\item{for_html_file}{Flag for whether we are rendering register md for html file. +Set to FALSE by default. If TRUE, no repo links are added to the repository table.} +} +\description{ +Renders register md for a single register_table +} diff --git a/man/render_register_mds.Rd b/man/render_register_mds.Rd new file mode 100644 index 00000000..b9f429d4 --- /dev/null +++ b/man/render_register_mds.Rd @@ -0,0 +1,14 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/utils_render_register_mds.R +\name{render_register_mds} +\alias{render_register_mds} +\title{Renders register mds for a list of register tables} +\usage{ +render_register_mds(list_register_tables) +} +\arguments{ +\item{list_register_table}{List of register tables} +} +\description{ +Renders register mds for a list of register tables +} diff --git a/man/set_paper_title_references.Rd b/man/set_paper_title_references.Rd new file mode 100644 index 00000000..260bf2fc --- /dev/null +++ b/man/set_paper_title_references.Rd @@ -0,0 +1,17 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/utils_render_register_json.R +\name{set_paper_title_references} +\alias{set_paper_title_references} +\title{Set "Title" and "Paper reference" columns and values to the register_table} +\usage{ +set_paper_title_references(register_table) +} +\arguments{ +\item{register_table}{The register table} +} +\value{ +Updated register table including "Title" and "Paper reference" columns +} +\description{ +Set "Title" and "Paper reference" columns and values to the register_table +}