Skip to content

Commit

Permalink
shindig
Browse files Browse the repository at this point in the history
More getting rid of with_flair
  • Loading branch information
kbodwin committed Feb 10, 2021
1 parent bc0a195 commit 6f2327b
Show file tree
Hide file tree
Showing 24 changed files with 109 additions and 107 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,5 @@ old_R
dev
doc
Meta
.Rhistory
joss
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,4 @@ VignetteBuilder:
knitr
Encoding: UTF-8
LazyData: true
RoxygenNote: 7.1.0
RoxygenNote: 7.1.1
14 changes: 7 additions & 7 deletions NAMESPACE
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
# Generated by roxygen2: do not edit by hand

S3method(flair_all,decorated)
S3method(flair_all,default)
S3method(flair_all,with_flair)
S3method(flair_lines,decorated)
S3method(flair_lines,default)
S3method(flair_lines,with_flair)
S3method(flair_rx,decorated)
S3method(flair_rx,default)
S3method(flair_rx,with_flair)
S3method(mask_rx,decorated)
S3method(mask_rx,default)
S3method(mask_rx,with_flair)
S3method(print,with_flair)
S3method(print,decorated)
export("%>%")
export(decorate)
export(decorate_chunk)
export(decorate_code)
export(decorated)
export(flair)
export(flair_all)
export(flair_args)
Expand All @@ -21,7 +22,7 @@ export(flair_input_vals)
export(flair_lines)
export(flair_quick)
export(flair_rx)
export(knit_print.with_flair)
export(knit_print.decorated)
export(mask)
export(mask_quick)
export(mask_rx)
Expand All @@ -38,7 +39,6 @@ export(txt_style)
export(txt_tag)
export(txt_tocode)
export(txt_ul)
export(with_flair)
export(wrap_html)
import(stringr)
importFrom(glue,glue)
Expand Down
4 changes: 2 additions & 2 deletions R/decorate.R
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

#' Builds a \code{\link{with_flair}} object from either a code chunk or a
#' Builds a \code{\link{decorated}} object from either a code chunk or a
#' string object containing source code.
#'
#' \code{decorate} does its best to guess if it has been given a code string or
Expand All @@ -8,7 +8,7 @@
#' @param x A string, containing either a chunk label or R code.
#' @param ... Chunk options to pass along
#'
#' @return A \code{with_flair} object.
#' @return A \code{decorated} object.
#'
#' @seealso \code{\link{decorate_chunk}}, \code{\link{decorate_code}}
#'
Expand Down
16 changes: 8 additions & 8 deletions R/flair.R
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@
#'
#' If input is a string object, \code{flair} returns a formatted string.
#'
#' If input is a \code{\link{with_flair}} object, \code{flair} returns a
#' \code{\link{with_flair}} object with the source elements formatted.
#' If input is a \code{\link{decorated}} object, \code{flair} returns a
#' \code{\link{decorated}} object with the source elements formatted.
#'
#' Currently, \code{flair} is only built for html formatting.
#'
#' @param x A string or \code{\link{with_flair}} object
#' @param x A string or \code{\link{decorated}} object
#' @param pattern A pattern to match. By default, this is a fixed pattern;
#' use \code{flair_rx} for regular expressions.
#' @param before String giving specific html tags to insert before matched text.
Expand Down Expand Up @@ -48,12 +48,12 @@ flair_rx <- function(x, pattern,
UseMethod("flair_rx")
}

#' S3 method for \code{\link{with_flair}} objects
#' S3 method for \code{\link{decorated}} objects
#'
#' @importFrom purrr map
#' @rdname flair
#' @export
flair_rx.with_flair = function(x, pattern,
flair_rx.decorated = function(x, pattern,
before = NULL, after = NULL,
...) {

Expand All @@ -68,7 +68,7 @@ flair_rx.with_flair = function(x, pattern,
x[where_sources] <- purrr::map(x[where_sources],
function(x) structure(list(src = x), class = "source"))

attr(x, "class") <- "with_flair"
attr(x, "class") <- "decorated"

return(x)

Expand Down Expand Up @@ -159,7 +159,7 @@ flair_all.default <- function(x, ...) {

#' @rdname flair
#' @export
flair_all.with_flair <- function(x, ...) {
flair_all.decorated <- function(x, ...) {

where_sources <- map(x, ~attr(.x, "class")) == "source"

Expand All @@ -171,7 +171,7 @@ flair_all.with_flair <- function(x, ...) {
x[where_sources] <- purrr::map(x[where_sources],
function(x) structure(list(src = x), class = "source"))

attr(x, "class") <- "with_flair"
attr(x, "class") <- "decorated"

return(x)

Expand Down
14 changes: 7 additions & 7 deletions R/flair_lines.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
#'
#' \code{flair_lines} returns a string with formatting wrappers(currently only
#' html), or applies the formatting to the source elements of a
#' \code{\link{with_flair}} object.
#' \code{\link{decorated}} object.
#'
#' @param x A string or \code{\link{with_flair}} object
#' @param x A string or \code{\link{decorated}} object
#' @param lines Integer vector indicating which lines to apply the flair styling to.
# @param ... Formatting style options, passed to \code{\link{txt_style}}
#'
Expand Down Expand Up @@ -38,21 +38,21 @@ flair_lines.default <- function(x, lines) {

}

#' S3 method for \code{\link{with_flair}} objects
#' S3 method for \code{\link{decorated}} objects
#'
#' Applies flair to the appropriate line(s) of source code.
#'
#' @param x An object of class \code{\link{with_flair}}.
#' @param x An object of class \code{\link{decorated}}.
#' @param lines An integer vector specifying code lines to highlight.
# @param ... Formatting style options, passed to \code{\link{txt_style}}
#'
#' @return An object of class \code{\link{with_flair}}.
#' @return An object of class \code{\link{decorated}}.
#'
#' @importFrom stringr str_split str_trim str_remove_all
#' @importFrom purrr map map2
#'
#' @export
flair_lines.with_flair <- function(x, lines) {
flair_lines.decorated <- function(x, lines) {

where_sources <- map(x, ~attr(.x, "class")) == "source"

Expand All @@ -74,7 +74,7 @@ flair_lines.with_flair <- function(x, lines) {

#x <- c(x, script)

attr(x, "class") <- "with_flair"
attr(x, "class") <- "decorated"

return(x)

Expand Down
2 changes: 1 addition & 1 deletion R/txt_style.R
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#' \code{txt_*} are shortcuts for specific individual style options
#'
#' Warning: These are simple direct wrappers for strings only. If you are using
#' \code{\link{with_flair}} objects, you should instead use the
#' \code{\link{decorated}} objects, you should instead use the
#' \code{\link{flair}} functions.
#'
#' @param x The string to be wrapped
Expand Down
4 changes: 2 additions & 2 deletions man/decorate.Rd

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

4 changes: 2 additions & 2 deletions man/decorate_chunk.Rd

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

6 changes: 3 additions & 3 deletions man/decorate_code.Rd

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

12 changes: 6 additions & 6 deletions man/with_flair.Rd → man/decorated.Rd

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

14 changes: 7 additions & 7 deletions man/flair.Rd

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

4 changes: 2 additions & 2 deletions man/flair_lines.Rd

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

12 changes: 6 additions & 6 deletions man/flair_lines.with_flair.Rd → man/flair_lines.decorated.Rd

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

19 changes: 19 additions & 0 deletions man/knit_print.decorated.Rd

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

Loading

0 comments on commit 6f2327b

Please sign in to comment.