Skip to content

Commit

Permalink
fix: update .Rbuildignore
Browse files Browse the repository at this point in the history
  • Loading branch information
edalfon committed Apr 25, 2024
1 parent 9b6437e commit 9590949
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 34 deletions.
9 changes: 9 additions & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,11 @@
^.*\.Rproj$
^\.Rproj\.user$
.github
.radian_profile

# Exclude specified non-standard files and directory
LICENSE\.md$
README\.Rmd$
_pkgdown\.yml$
^docs$

36 changes: 16 additions & 20 deletions R/duckdb_explain_hook.R
Original file line number Diff line number Diff line change
Expand Up @@ -20,38 +20,34 @@
#' # you want to override standard printing of sql chunks
#' efun::duckdb_explain_hook()
#' }
duckdb_explain_hook <- function (all = NULL)
{
duckdb_explain_hook <- function(all = NULL) {
# Add a custom chunk hook, as documented here:
# https://bookdown.org/yihui/rmarkdown-cookbook/chunk-hooks.html
# Which basically allows you to execute code before and after
# the chunk, when when the value of this chunk option is not NULL.
# So let's call the chunk option `duckdb_explain`
knitr::knit_hooks$set(duckdb_explain = function(before) {
if (before) {
#' Now, before running the chunk we want to sets a custom
#' printing function for SQL code chunks. It overrides the
#' default behavior for rendering SQL code, by setting the
#' `sql.print` option of knitr. When you set this, knitr
#' will call that function passing the data that results from
#' the query and then print the result using cat. Note also
#' that we wrap this in code display tags, because when you
#' use the sql.print option, knitr will force the results='asis'.
#' See line 653 of the sql knitr engine.
#' https://github.com/yihui/knitr/blob/master/R/engine.R
#' if (!is.null(sql.print)) {
#' options$results = 'asis'
#' cat(sql.print(data))
#' }
# Now, before running the chunk we want to sets a custom
# printing function for SQL code chunks. It overrides the
# default behavior for rendering SQL code, by setting the
# `sql.print` option of knitr. When you set this, knitr
# will call that function passing the data that results from
# the query and then print the result using cat. Note also
# that we wrap this in code display tags, because when you
# use the sql.print option, knitr will force the results='asis'.
# See line 653 of the sql knitr engine.
# https://github.com/yihui/knitr/blob/master/R/engine.R
# if (!is.null(sql.print)) {
# options$results = 'asis'
# cat(sql.print(data))
# }
knitr::opts_knit$set(sql.print = function(x) {
paste0("<pre><code>", x$explain_value, "</code></pre>")
})
}
else {
} else {
knitr::opts_knit$set(sql.print = NULL)
}
})
knitr::opts_chunk$set(duckdb_explain = all)
}


14 changes: 0 additions & 14 deletions man/duckdb_explain_hook.Rd

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

0 comments on commit 9590949

Please sign in to comment.