cynkra / indiedown
Showing 1 of 8 files from the diff.
Newly tracked file
R/dr_down.R created.
Other files ignored by Codecov

@@ -0,0 +1,114 @@
Loading
1 +
#' Hardware report (experimental)
2 +
#'
3 +
#' `dr_down` analyzes the R markdown capabilities of the hardware.
4 +
#'
5 +
#' @export
6 +
#' @examples
7 +
#' \dontrun{
8 +
#'   indiedown::dr_down()
9 +
#' }
10 +
dr_down <- function() {
11 +
12 +
  # Check the version
13 +
  pandoc_v <- as.character(rmarkdown::pandoc_version())
14 +
  r_v <- paste(version$major, version$minor, sep = ".")
15 +
16 +
  if (Sys.getenv("RSTUDIO") == "1" && requireNamespace("rstudioapi", quietly = TRUE)) {
17 +
    rstudio_v <- as.character(rstudioapi::versionInfo()$version)
18 +
  } else {
19 +
    rstudio_v <- NA_character_
20 +
  }
21 +
22 +
  if(requireNamespace("tinytex", quietly = TRUE)){
23 +
    tinytex_v <- as.character(packageVersion("tinytex"))
24 +
    is_tinytex <- tinytex::is_tinytex()
25 +
  } else{
26 +
    tinytex_v <- NA_character_
27 +
    is_tinytex <- FALSE
28 +
  }
29 +
30 +
  version_info <- c(
31 +
    r = r_v,
32 +
    rstudio = rstudio_v,
33 +
    tinytex = tinytex_v,
34 +
    pandoc = pandoc_v
35 +
  )
36 +
37 +
  # test different latex engine to compile a basic document
38 +
  latex_engines <- c(
39 +
    "lualatex",
40 +
    "xelatex",
41 +
    "pdflatex"
42 +
  )
43 +
44 +
  tdir <- tempfile("dr_down")
45 +
  fs::dir_create(tdir)
46 +
  a <- fs::file_copy(
47 +
    fs::path_package("indiedown", "dr_down", "test.Rmd"),
48 +
    tdir
49 +
  )
50 +
51 +
  try_with_engine <- function(latex_engines) {
52 +
    tryCatch(
53 +
      suppressWarnings(
54 +
        rmarkdown::render(
55 +
          fs::path(tdir, "test.Rmd"),
56 +
          rmarkdown::pdf_document(latex_engine = latex_engines),
57 +
          quiet = TRUE
58 +
        )
59 +
      ),
60 +
      error = identity
61 +
    )
62 +
  }
63 +
64 +
  ans <- lapply(latex_engines, try_with_engine)
65 +
  success <- setNames(!sapply(ans, inherits, "error"), latex_engines)
66 +
67 +
  # clean up
68 +
  fs::dir_delete(tdir)
69 +
70 +
71 +
  cli_h1("System Information")
72 +
73 +
  cli_alert_info("R-Version: {version_info['r']}")
74 +
75 +
  cli_alert_info("Operating System: {R.Version()$os}")
76 +
77 +
  if (is_tinytex) {
78 +
    cli_alert_success("tinytex Version: {version_info['tinytex']}")
79 +
  } else {
80 +
    cli_alert_warning("tinytex not installed")
81 +
  }
82 +
83 +
  if (rmarkdown::pandoc_available()) {
84 +
    cli_alert_success("pandoc Version: {version_info['pandoc']}")
85 +
  } else {
86 +
    cli_alert_warning("pandoc not available")
87 +
  }
88 +
89 +
  cli_alert_info("indiedown Version: {packageVersion('indiedown')}")
90 +
91 +
  if (!is.na(version_info['rstudio'])) {
92 +
    cli_alert_success("RStudio: {version_info['rstudio']}")
93 +
  } else {
94 +
    cli_alert_info("Running outside of RStudio")
95 +
  }
96 +
97 +
98 +
  cli_h1("Test Runs")
99 +
  text <- paste("Running", names(success), ifelse(success, "successfully", "unsuccessfully"))
100 +
  for (i in seq_along(text)) {
101 +
    if (success[i]) {
102 +
      cli_alert_success(text[i])
103 +
    } else {
104 +
      cli_alert_danger(text[i])
105 +
    }
106 +
  }
107 +
108 +
  ans <- list(
109 +
    version_info = version_info,
110 +
    success = success,
111 +
    is_tinytex = is_tinytex
112 +
  )
113 +
  invisible(ans)
114 +
}
Files Coverage
R 79.82%
Project Totals (4 files) 79.82%

No yaml found.

Create your codecov.yml to customize your Codecov experience

Sunburst
The inner-most circle is the entire project, moving away from the center are folders then, finally, a single file. The size and color of each slice is representing the number of statements and the coverage, respectively.
Icicle
The top section represents the entire project. Proceeding with folders and finally individual files. The size and color of each slice is representing the number of statements and the coverage, respectively.
Grid
Each block represents a single file in the project. The size and color of each block is represented by the number of statements and the coverage, respectively.
Loading