Skip to content

Commit

Permalink
rename class names 'block' to 'knitr_block', and 'inline' to 'knitr_i…
Browse files Browse the repository at this point in the history
…nline' since I need to export the print() methods and the names 'block' and 'inline' are too general
  • Loading branch information
yihui committed Apr 4, 2024
1 parent 08c9edb commit 346e2ec
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 13 deletions.
10 changes: 6 additions & 4 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,13 @@ S3method(knit_print,default)
S3method(knit_print,knit_asis)
S3method(knit_print,knit_asis_url)
S3method(knit_print,knitr_kable)
S3method(print,knitr_block)
S3method(print,knitr_inline)
S3method(print,knitr_kable)
S3method(process_group,block)
S3method(process_group,inline)
S3method(process_tangle,block)
S3method(process_tangle,inline)
S3method(process_group,knitr_block)
S3method(process_group,knitr_inline)
S3method(process_tangle,knitr_block)
S3method(process_tangle,knitr_inline)
S3method(sew,character)
S3method(sew,default)
S3method(sew,error)
Expand Down
8 changes: 4 additions & 4 deletions R/block.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ process_group = function(x) {
UseMethod('process_group', x)
}
#' @export
process_group.block = function(x) call_block(x)
process_group.knitr_block = function(x) call_block(x)
#' @export
process_group.inline = function(x) {
process_group.knitr_inline = function(x) {
x = call_inline(x)
knit_hooks$get('text')(x)
}
Expand Down Expand Up @@ -588,7 +588,7 @@ process_tangle = function(x) {
UseMethod('process_tangle', x)
}
#' @export
process_tangle.block = function(x) {
process_tangle.knitr_block = function(x) {
params = opts_chunk$merge(x$params)
for (o in c('purl', 'eval', 'child')) {
if (inherits(try(params[o] <- list(eval_lang(params[[o]]))), 'try-error')) {
Expand All @@ -615,7 +615,7 @@ process_tangle.block = function(x) {
label_code(code, x)
}
#' @export
process_tangle.inline = function(x) {
process_tangle.knitr_inline = function(x) {

output = if (opts_knit$get('documentation') == 2L) {
output = paste("#'", gsub('\n', "\n#' ", x$input, fixed = TRUE))
Expand Down
11 changes: 6 additions & 5 deletions R/parser.R
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ parse_block = function(code, header, params.src, markdown_mode = out_format('mar
}
}

structure(class = 'block', list(
structure(class = 'knitr_block', list(
params = params, params.src = params.src, params.chunk = parts$src)
)
}
Expand Down Expand Up @@ -196,8 +196,8 @@ partition_chunk = function(engine, code) {
xfun::divide_chunk(engine, code)
}


print.block = function(x, ...) {
#' @export
print.knitr_block = function(x, ...) {
params = x$params
if (opts_knit$get('verbose')) {
code = knit_code$get(params$label)
Expand Down Expand Up @@ -231,11 +231,12 @@ parse_inline = function(input, patterns) {

structure(
list(input = input, location = loc, code = code2, code.src = code1),
class = 'inline'
class = 'knitr_inline'
)
}

print.inline = function(x, ...) {
#' @export
print.knitr_inline = function(x, ...) {
if (opts_knit$get('verbose')) {
cat('\n')
if (nrow(x$location)) {
Expand Down

0 comments on commit 346e2ec

Please sign in to comment.