Skip to content

Commit 4ed7590

Browse files
committed
removed purrr dependency
1 parent 52539bf commit 4ed7590

File tree

18 files changed

+519
-12
lines changed

18 files changed

+519
-12
lines changed

.travis.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,11 @@ matrix:
2323
sudo: required
2424
env: R_CODECOV=true
2525
- os: osx
26-
osx_image: xcode7.2
26+
osx_image: xcode7.3
2727
brew_packages: hunspell
2828
latex: false
2929
- os: osx
30-
osx_image: beta-xcode6.1
30+
osx_image: xcode6.4
3131
latex: false
3232
disable_homebrew: true
3333

DESCRIPTION

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Package: hrbrthemes
22
Type: Package
33
Title: Additional Themes, Theme Components and Utilities for 'ggplot2'
4-
Version: 0.2.0
4+
Version: 0.3.0
55
Date: 2017-03-01
66
Authors@R: c(
77
person("Bob", "Rudis", email = "bob@rud.is", role = c("aut", "cre")),
@@ -34,6 +34,11 @@ Imports:
3434
grid,
3535
scales,
3636
extrafont,
37-
purrr
37+
knitr,
38+
rmarkdown,
39+
htmltools,
40+
tools,
41+
magrittr
3842
RoxygenNote: 6.0.1
3943
VignetteBuilder: knitr
44+

NAMESPACE

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ export(font_rc)
66
export(font_rc_light)
77
export(gg_check)
88
export(import_roboto_condensed)
9+
export(ipsum)
910
export(ipsum_pal)
1011
export(scale_color_ipsum)
1112
export(scale_colour_ipsum)
@@ -20,7 +21,9 @@ export(update_geom_font_defaults)
2021
import(extrafont)
2122
import(ggplot2)
2223
import(grid)
24+
import(htmltools)
25+
import(knitr)
26+
import(rmarkdown)
2327
import(scales)
24-
importFrom(purrr,"%>%")
25-
importFrom(purrr,map)
26-
importFrom(purrr,walk)
28+
importFrom(magrittr,"%>%")
29+
importFrom(tools,file_path_sans_ext)

R/check.r

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ gg_check <- function(gg, dict, ignore) {
4848

4949
if (length(lbl) > 0) {
5050

51-
purrr::walk(names(lbl), function(lab) {
51+
tmp <- lapply(names(lbl), function(lab) {
5252

5353
words <- stringi::stri_extract_all_words(lbl[[lab]])
5454
words <- unlist(words)

R/hrbrthemes-package.R

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,9 @@
2121
#' @docType package
2222
#' @author Bob Rudis (bob@@rud.is)
2323
#' @import ggplot2 grid scales extrafont
24-
#' @importFrom purrr %>% map walk
24+
#' @importFrom magrittr %>%
25+
#' @import rmarkdown knitr htmltools
26+
#' @importFrom tools file_path_sans_ext
2527
NULL
2628

2729
#' hrbrthemes exported operators

R/ipsum.r

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
#' ipsum R markdown template
2+
#'
3+
#' Template for creating an R markdown document with an emphasis on typography
4+
#'
5+
#' @inheritParams rmarkdown::html_document
6+
#' @param extra_dependencies,... Additional function arguments to pass to the
7+
#' base R Markdown HTML output formatter
8+
#' @export
9+
ipsum <- function(number_sections = FALSE,
10+
fig_width = 7,
11+
fig_height = 5,
12+
fig_retina = if (!fig_caption) 2,
13+
fig_caption = FALSE,
14+
dev = 'png',
15+
smart = TRUE,
16+
self_contained = TRUE,
17+
highlight = "default",
18+
mathjax = "default",
19+
extra_dependencies = NULL,
20+
css = NULL,
21+
includes = NULL,
22+
keep_md = FALSE,
23+
lib_dir = NULL,
24+
md_extensions = NULL,
25+
pandoc_args = NULL,
26+
...) {
27+
28+
toc <- FALSE
29+
toc_depth <- 3
30+
theme <- NULL
31+
template <- "default"
32+
code_folding <- "none"
33+
34+
dep <- htmltools::htmlDependency("ipsum", "0.1.0",
35+
system.file("rmarkdown", "templates", "ipsum", "resources",
36+
package = "hrbrthemes"),
37+
stylesheet="ipsum.css")
38+
39+
extra_dependencies <- append(extra_dependencies, list(dep))
40+
41+
42+
args <- c("--standalone")
43+
args <- c(args, "--section-divs")
44+
args <- c(args, rmarkdown::pandoc_toc_args(toc, toc_depth))
45+
46+
args <- c(args, "--template",
47+
rmarkdown::pandoc_path_arg(system.file("rmarkdown", "templates", "ipsum", "base.html",
48+
package = "hrbrthemes")))
49+
50+
if (number_sections)
51+
args <- c(args, "--number-sections")
52+
53+
for (css_file in css)
54+
args <- c(args, "--css", rmarkdown::pandoc_path_arg(css_file))
55+
56+
pre_processor <- function(metadata, input_file, runtime,
57+
knit_meta, files_dir, output_dir) {
58+
59+
if (is.null(lib_dir)) lib_dir <- files_dir
60+
61+
args <- c()
62+
args <- c(args, pandoc_html_highlight_args(highlight,
63+
template, self_contained, lib_dir,
64+
output_dir))
65+
args <- c(args, includes_to_pandoc_args(includes = includes,
66+
filter = if (identical(runtime, "shiny"))
67+
normalize_path else identity))
68+
args
69+
70+
}
71+
72+
output_format(
73+
knitr = rmarkdown::knitr_options_html(fig_width, fig_height,
74+
fig_retina, keep_md, dev),
75+
pandoc = rmarkdown::pandoc_options(to = "html",
76+
from = from_rmarkdown(fig_caption,
77+
md_extensions),
78+
args = args),
79+
keep_md = keep_md, clean_supporting = self_contained,
80+
pre_processor = pre_processor,
81+
base_format = rmarkdown::html_document_base(smart = smart,
82+
theme = theme,
83+
self_contained = self_contained,
84+
lib_dir = lib_dir,
85+
mathjax = mathjax,
86+
template = template,
87+
pandoc_args = pandoc_args,
88+
extra_dependencies = extra_dependencies,
89+
...))
90+
}

R/utils.r

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
# Most (if not all) from github.com/rstudio/rmarkdown
2+
3+
from_rmarkdown <- function (implicit_figures = TRUE, extensions = NULL) {
4+
extensions <- paste0(extensions, collapse = "")
5+
extensions <- gsub(" ", "", extensions)
6+
if (!implicit_figures && !grepl("implicit_figures", extensions))
7+
extensions <- paste0("-implicit_figures", extensions)
8+
rmarkdown_format(extensions)
9+
}
10+
11+
from_rst <-function (extensions = NULL) {
12+
format <- c("rst")
13+
addExtension <- function(extension) {
14+
if (length(grep(extension, extensions)) == 0)
15+
format <<- c(format, paste0("+", extension))
16+
}
17+
addExtension("autolink_bare_uris")
18+
addExtension("ascii_identifiers")
19+
addExtension("tex_math_single_backslash")
20+
format <- c(format, extensions, recursive = TRUE)
21+
paste(format, collapse = "")
22+
}
23+
24+
pandoc_html_highlight_args <- function (highlight, template, self_contained,
25+
files_dir, output_dir) {
26+
args <- c()
27+
if (is.null(highlight)) {
28+
args <- c(args, "--no-highlight")
29+
}
30+
else if (!identical(template, "default")) {
31+
if (identical(highlight, "default"))
32+
highlight <- "pygments"
33+
args <- c(args, "--highlight-style", highlight)
34+
}
35+
else {
36+
highlight <- match.arg(highlight, html_highlighters())
37+
if (highlight %in% c("default", "textmate")) {
38+
highlight_path <- system.file("rmd/h/highlight", package = "rmarkdown")
39+
if (self_contained)
40+
highlight_path <- pandoc_path_arg(highlight_path)
41+
else {
42+
highlight_path <- normalized_relative_to(output_dir,
43+
render_supporting_files(highlight_path, files_dir))
44+
}
45+
args <- c(args, "--no-highlight")
46+
args <- c(args, "--variable", paste("highlightjs=",
47+
highlight_path, sep = ""))
48+
if (identical(highlight, "textmate")) {
49+
args <- c(args, "--variable", paste("highlightjs-theme=",
50+
highlight, sep = ""))
51+
}
52+
}
53+
else {
54+
args <- c(args, "--highlight-style", highlight)
55+
}
56+
}
57+
args
58+
59+
}
60+
61+
html_highlighters <- function () { c(highlighters(), "textmate") }
62+
highlighters <- function () {
63+
c("default", "tango", "pygments", "kate", "monochrome", "espresso",
64+
"zenburn", "haddock")
65+
}
66+
67+
normalized_relative_to <- function (dir, file) {
68+
relative_to(normalizePath(dir, winslash = "/", mustWork = FALSE),
69+
normalizePath(file, winslash = "/", mustWork = FALSE))
70+
}
71+
72+
normalize_path <- function (path) {
73+
if (is.null(path))
74+
NULL
75+
else normalizePath(path, winslash = "/", mustWork = FALSE)
76+
}

R/zzz.r

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
1-
# Suggestion by @alexwhan
2-
31
.onAttach <- function(libname, pkgname) {
42

3+
if (interactive()) {
4+
packageStartupMessage(paste0("hrbrthemes is under *active* development. ",
5+
"See https://github.com/hrbrmstr/hrbrthemes for info/news."))
6+
}
7+
8+
# Suggestion by @alexwhan
9+
510
if (.Platform$OS.type == "windows") { # nocov start
611
if (interactive()) packageStartupMessage("Registering Windows fonts with R")
712
extrafont::loadfonts("win", quiet = TRUE)

inst/COPYRIGHTS

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
All R source code files are released under the MIT license.
22

3-
The Google Roboto Condensed font <https://github.com/google/roboto/> has the folllowing copyright:
3+
The Google Roboto Condensed & Slab fonts <https://github.com/google/roboto/> have
4+
the folllowing copyright:
45

56

67
Apache License
167 KB
Binary file not shown.

0 commit comments

Comments
 (0)