From 95909493784a65f36ba5f23f05160a85c943c917 Mon Sep 17 00:00:00 2001 From: edalfon Date: Thu, 25 Apr 2024 19:32:52 +0200 Subject: [PATCH] fix: update .Rbuildignore --- .Rbuildignore | 9 +++++++++ R/duckdb_explain_hook.R | 36 ++++++++++++++++-------------------- man/duckdb_explain_hook.Rd | 14 -------------- 3 files changed, 25 insertions(+), 34 deletions(-) diff --git a/.Rbuildignore b/.Rbuildignore index 91114bf..07781ef 100644 --- a/.Rbuildignore +++ b/.Rbuildignore @@ -1,2 +1,11 @@ ^.*\.Rproj$ ^\.Rproj\.user$ +.github +.radian_profile + +# Exclude specified non-standard files and directory +LICENSE\.md$ +README\.Rmd$ +_pkgdown\.yml$ +^docs$ + diff --git a/R/duckdb_explain_hook.R b/R/duckdb_explain_hook.R index 140d577..4192ece 100644 --- a/R/duckdb_explain_hook.R +++ b/R/duckdb_explain_hook.R @@ -20,8 +20,7 @@ #' # 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 @@ -29,29 +28,26 @@ duckdb_explain_hook <- function (all = 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("
", x$explain_value, "
") }) - } - else { + } else { knitr::opts_knit$set(sql.print = NULL) } }) knitr::opts_chunk$set(duckdb_explain = all) } - - diff --git a/man/duckdb_explain_hook.Rd b/man/duckdb_explain_hook.Rd index 7ffda78..503226d 100644 --- a/man/duckdb_explain_hook.Rd +++ b/man/duckdb_explain_hook.Rd @@ -28,18 +28,4 @@ formatted query explanations in knitr documents. # you want to override standard printing of sql chunks efun::duckdb_explain_hook() } -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)) -} }