Skip to content

Commit

Permalink
version 0.1.2
Browse files Browse the repository at this point in the history
  • Loading branch information
caprice-j committed Aug 30, 2017
1 parent 4725637 commit 199605c
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 5 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: ggconf
Type: Package
Title: Simpler Appearance Modification of 'ggplot2'
Version: 0.1
Version: 0.1.2
Authors@R: c(person('Yasutaka', 'Tanaka', , '[email protected]', c('aut', 'cre')))
Description: A flexible interface for ggplot2::theme(), potentially saving 50% of your typing.
License: GPL-3
Expand Down
4 changes: 4 additions & 0 deletions R/approx_match.R
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@
#'
#' get_analogue("axis.txt", c("axis.text", "axis.text.x", "axis.ticks"))
#' # returns "axis.text" "axis.text.x" "axis.ticks"
#'
#' get_analogue("p.bg", c("plot.background", "panel.background"))
#' # returns "plot.background" as first, and then "panel.background"
#'
#'
#' @importFrom utils adist
#' @importFrom stats na.omit
Expand Down
9 changes: 5 additions & 4 deletions R/compiler.R
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ ggregex <- list(
charaes = paste0("[a-z]+=('|\\\").*?('|\\\")"),
constaes = "[a-z\\.]+=c\\([0-9\\.,\\)]+", # FIXME adhoc for binw=c(.1, .1)
# Note: ggregex$constaes and t_CONSTAES rules are duplicated
unit = "[0-9\\.,]+\\s*['\"]?(cm|in|inch|inches)['\"]?"
unit = "[0-9\\.,]+\\s*['\"]?(cm|in|inch|inches)['\"]?",
func = "[a-z\\.]+=(arrow|rel|paste|paste0|c)\\([^#]*\\)"
)

Ggplot2Lexer <-
Expand Down Expand Up @@ -69,10 +70,10 @@ Ggplot2Lexer <-
ggconf_dbgmsg(" t_COMMA: ", t$value)
t$type <- "COMMA"; return(t)
},
t_0_FUNC = function(re="[a-z\\.]+=(arrow|rel|paste|paste0)\\([^#]*\\)", t) {
# FIXME any function
t_0_FUNC = function(re = "[a-z\\.]+=(arrow|rel|paste|paste0|c)\\([^#]*\\)(\\[[0-9a-zA-Z\\._]+\\])?", t) {
ggconf_dbgmsg(" t_0_FUNC: ", t$value)
t$type <- "0_FUNC"; return(t)
t$type <- "0_FUNC";
return(t)
},
t_1_NAME = function(re="(\\\"|')?[\\.a-zA-Z0-9_\\(\\)\\-][a-zA-Z_0-9\\.,=\\(\\)\\-\\+\\/\\*]*(\\\"|')?(\\s*inches|\\s*inch|\\s*in|\\s*cm)?(\\\"|')?", t) {
if (grepl("theme\\(", t$value)) {
Expand Down
5 changes: 5 additions & 0 deletions R/ggconf.R
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,10 @@ exec_ggconf <- function(raw_input="",
#' plt.margin(.3, .3, .3, .1, "inch")
#' )
#'
#'
#' ggplot(mtcars) + geom_point(aes(wt, hp, color=cyl)) +
#' theme2(a.txt(family = c("Consolas", "Times")[1]))
#'
#' # all of the following three generate the same plot
#'
#' ggplot(mtcars) + geom_point(aes(wt, hp, color=cyl)) +
Expand All @@ -119,6 +123,7 @@ exec_ggconf <- function(raw_input="",
#' theme2(txt(sz=20, f="bold"), aline(sz=2), l.key(c="black"))
#'
#'
#'
#' }
#'
#'
Expand Down
11 changes: 11 additions & 0 deletions tests/testthat/test-theme2.R
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,17 @@ test_that("theme2", {

ee(theme2(ax.ttl(col=paste0('sky','blue'))),
theme(axis.title = element_text(color=paste0('sky','blue'))))

ee(theme2(a.txt(family=c("consolas", "Times New Roman")[1])),
theme(axis.text = element_text(family="consolas")))

ee(theme2(a.txt(family=c("consolas", "Times New Roman")[2])),
theme(axis.text = element_text(family="Times New Roman")))

my.se_1_ection <<- 1
ee(theme2(a.txt(family=c("consolas", "Times New Roman")[my.se_1_ection])),
theme(axis.text = element_text(family="consolas")))

})

test_that("partial-match", {
Expand Down

0 comments on commit 199605c

Please sign in to comment.