Skip to content

Commit 4ed7590

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

18 files changed

+519
-12
lines changed

.travis.yml

+2-2
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

+7-2
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 = "[email protected]", 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

+6-3
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

+1-1
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

+3-1
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

+90
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

+76
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

+7-2
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

+2-1
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.
175 KB
Binary file not shown.
165 KB
Binary file not shown.
177 KB
Binary file not shown.
+85
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
<!DOCTYPE html>
2+
<html xmlns="http://www.w3.org/1999/xhtml"$if(lang)$ lang="$lang$" xml:lang="$lang$"$endif$>
3+
4+
<head>
5+
6+
<meta charset="utf-8">
7+
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
8+
<meta name="generator" content="pandoc" />
9+
<meta name="viewport" content="width=device-width, initial-scale=1">
10+
11+
<title>$if(title)$$title$$endif$</title>
12+
13+
<link href="https://fonts.googleapis.com/css?family=Roboto+Slab:100,300,400,700" rel="stylesheet"/>
14+
<link href="https://fonts.googleapis.com/css?family=Roboto+Condensed:300,300i,400,400i,700,700i" rel="stylesheet"/>
15+
<link href="https://fonts.googleapis.com/css?family=Roboto:100,100i,300,300i,400,400i,500,500i,700,700i,900,900i" rel="stylesheet"/>
16+
17+
$for(header-includes)$
18+
$header-includes$
19+
$endfor$
20+
21+
$if(highlightjs)$
22+
<style type="text/css">code{white-space: pre;}</style>
23+
<link rel="stylesheet"
24+
href="$highlightjs$/$if(highlightjs-theme)$$highlightjs-theme$$else$default$endif$.css"
25+
$if(html5)$$else$type="text/css" $endif$/>
26+
<script src="$highlightjs$/highlight.js"></script>
27+
<script type="text/javascript">
28+
if (window.hljs && document.readyState && document.readyState === "complete") {
29+
window.setTimeout(function() {
30+
hljs.initHighlighting();
31+
}, 0);
32+
}
33+
</script>
34+
$endif$
35+
36+
$if(highlighting-css)$
37+
<style type="text/css">code{white-space: pre;}</style>
38+
<style type="text/css">
39+
$highlighting-css$
40+
</style>
41+
$endif$
42+
43+
$for(css)$
44+
<link rel="stylesheet" href="$css$" $if(html5)$$else$type="text/css" $endif$/>
45+
$endfor$
46+
47+
</head>
48+
49+
<body>
50+
<div class="container">
51+
52+
<h1>$if(title)$$title$$endif$</h1>
53+
54+
$for(include-before)$
55+
$include-before$
56+
$endfor$
57+
58+
$if(toc)$
59+
<div id="$idprefix$TOC">
60+
$toc$
61+
</div>
62+
$endif$
63+
64+
$body$
65+
66+
$for(include-after)$
67+
$include-after$
68+
$endfor$
69+
70+
</div>
71+
72+
$if(mathjax-url)$
73+
<!-- dynamically load mathjax for compatibility with self-contained -->
74+
<script>
75+
(function () {
76+
var script = document.createElement("script");
77+
script.type = "text/javascript";
78+
script.src = "$mathjax-url$";
79+
document.getElementsByTagName("head")[0].appendChild(script);
80+
})();
81+
</script>
82+
$endif$
83+
84+
</body>
85+
</html>

0 commit comments

Comments
 (0)