Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ export(add_card_button_ui)
export(as.teal_report)
export(as_yaml_auto)
export(code_chunk)
export(code_output)
export(doc)
export(download_report_button_srv)
export(download_report_button_ui)
Expand Down
17 changes: 0 additions & 17 deletions R/doc.R
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,6 @@ edit_doc <- function(x, modify = NULL, append = NULL, after = length(x)) {
#' class(my_chunk)
#' attributes(my_chunk)$param
#' @export
#' @rdname code_output
code_chunk <- function(code, ...) {
checkmate::assert_character(code)
params <- list(...)
Expand All @@ -196,22 +195,6 @@ code_chunk <- function(code, ...) {
)
}

#' Format R code as a simple Markdown code block string
#'
#' This function takes a character string of R code and wraps it in
#' Markdown's triple backticks for code blocks.
#'
#' @param code A character string containing the R code.
#' @return A character string representing a simple Markdown code block.
#' @seealso [code_chunk()] for creating structured code chunk objects with options.
#' @examples
#' code_output("y <- rnorm(5)")
#' @export
#' @rdname code_output
code_output <- function(code) {
sprintf("```\n%s\n```", code)
}

#' @title Keep Objects In Report
#' @description Utility function to change behavior of `doc` elements to be
#' kept (`keep = TRUE`) or discarded (`keep = FALSE`) from the final `.Rmd` file containing the downloaded report.
Expand Down
12 changes: 0 additions & 12 deletions man/code_output.Rd → man/code_chunk.Rd

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

18 changes: 6 additions & 12 deletions tests/testthat/test-doc.R
Original file line number Diff line number Diff line change
Expand Up @@ -15,35 +15,35 @@ testthat::test_that("doc creates a doc with initial elements", {
testthat::describe("c.doc combines with", {
doc_base <- doc("a", "b")

it("character element and retains class", {
testthat::it("character element and retains class", {
doc_result <- c(doc_base, "c")
testthat::expect_s3_class(doc_result, "doc")
testthat::expect_length(doc_result, 3)
testthat::expect_equal(doc_result[[3]], "c")
})

it("multiple character elements and retains class", {
testthat::it("multiple character elements and retains class", {
doc_result <- c(doc_base, "c", list("d"))
testthat::expect_s3_class(doc_result, "doc")
testthat::expect_length(doc_result, 4)
testthat::expect_equal(doc_result[[3]], "c")
})

it("multiple character elements and retains class", {
testthat::it("multiple character elements and retains class", {
doc_result <- c(doc_base, "c", list("d", "e"))
testthat::expect_s3_class(doc_result, "doc")
testthat::expect_length(doc_result, 4)
testthat::expect_equal(doc_result[[4]], list("d", "e"))
})

it("doc with multiple elements and retains class", {
testthat::it("doc with multiple elements and retains class", {
doc_result <- c(doc_base, doc("c", "d"))
testthat::expect_s3_class(doc_result, "doc")
testthat::expect_length(doc_result, 4)
testthat::expect_equal(doc_result[[3]], "c") # Assuming it unnests the doc
})

it("with single ggplot2 element and retains class", {
testthat::it("with single ggplot2 element and retains class", {
plot <- ggplot2::ggplot(mtcars, ggplot2::aes(x = wt, y = mpg)) +
ggplot2::geom_point()
doc_result <- c(doc_base, plot)
Expand All @@ -52,7 +52,7 @@ testthat::describe("c.doc combines with", {
testthat::expect_identical(doc_result[[3]], plot)
})

it("ggplot2 section and retains class", {
testthat::it("ggplot2 section and retains class", {
plot <- ggplot2::ggplot(mtcars, ggplot2::aes(x = wt, y = mpg)) +
ggplot2::geom_point()
doc_result <- c(doc_base, doc("# Plot", plot))
Expand Down Expand Up @@ -126,12 +126,6 @@ testthat::test_that("code_chunk creates a code_chunk object with params", {
testthat::expect_equal(attributes(chunk)$params, list(echo = FALSE, eval = TRUE))
})

testthat::test_that("code_output formats code as markdown string", {
output <- code_output("x <- 1")
testthat::expect_type(output, "character")
testthat::expect_equal(output, "```\nx <- 1\n```")
})

testthat::test_that("keep_in_report sets the 'keep' attribute", {
obj1 <- "some text"
kept_obj1 <- keep_in_report(obj1, TRUE)
Expand Down