Repository: yonicd/carbonate Branch: master Commit: 071a9f828e40 Files: 85 Total size: 339.3 KB Directory structure: gitextract_2w4rwpo4/ ├── .Rbuildignore ├── .github/ │ ├── ISSUE_TEMPLATE/ │ │ ├── Bug_report.md │ │ ├── Feature_request.md │ │ ├── Question.md │ │ └── Tips.md │ ├── PULL_REQUEST_TEMPLATE.md │ ├── stale.yml │ └── weekly-digest.yml ├── .gitignore ├── .travis.yml ├── CRAN-RELEASE ├── DESCRIPTION ├── LICENSE ├── NAMESPACE ├── R/ │ ├── carbon.R │ ├── carbon_fields.R │ ├── carbonate.R │ ├── helpers.R │ ├── selenium_functions.R │ ├── set_get_functions.R │ └── uri_functions.R ├── README.Rmd ├── README.md ├── _pkgdown.yml ├── carbonate.Rproj ├── codecov.yml ├── cran-comments.md ├── docs/ │ ├── 404.html │ ├── LICENSE-text.html │ ├── PULL_REQUEST_TEMPLATE.html │ ├── articles/ │ │ ├── index.html │ │ └── tests_and_coverage.html │ ├── authors.html │ ├── bootstrap-toc.css │ ├── bootstrap-toc.js │ ├── docsearch.css │ ├── docsearch.js │ ├── index.html │ ├── pkgdown.css │ ├── pkgdown.js │ ├── pkgdown.yml │ ├── reference/ │ │ ├── browse.html │ │ ├── carbon.html │ │ ├── carbon_chrome.html │ │ ├── carbon_fields.html │ │ ├── carbon_gecko.html │ │ ├── carbon_selenium.html │ │ ├── carbonate.html │ │ ├── encode.html │ │ ├── get_carbon.html │ │ ├── index.html │ │ ├── options.html │ │ ├── reprex_to_carbon_browser.html │ │ ├── rtweet.html │ │ ├── set_carbon.html │ │ ├── tiny.html │ │ ├── tinyurl.html │ │ └── uri.html │ └── sitemap.xml ├── hextools/ │ └── create_hex.R ├── inst/ │ └── rstudio/ │ └── addins.dcf ├── man/ │ ├── browse.Rd │ ├── carbon.Rd │ ├── carbon_chrome.Rd │ ├── carbon_fields.Rd │ ├── carbon_gecko.Rd │ ├── carbon_selenium.Rd │ ├── carbonate.Rd │ ├── encode.Rd │ ├── get_carbon.Rd │ ├── options.Rd │ ├── rtweet.Rd │ ├── set_carbon.Rd │ ├── tiny.Rd │ ├── tinyurl.Rd │ └── uri.Rd ├── tests/ │ ├── README.md │ ├── testthat/ │ │ ├── helpers.R │ │ ├── test-port.R │ │ ├── test-set.R │ │ ├── test-uri.R │ │ └── test-yml.R │ └── testthat.R └── vignettes/ ├── .gitignore └── tests_and_coverage.Rmd ================================================ FILE CONTENTS ================================================ ================================================ FILE: .Rbuildignore ================================================ ^data-raw$ ^.*\.Rproj$ ^\.Rproj\.user$ ^README.Rmd$ ^_pkgdown\.yml$ ^docs$ ^\.travis\.yml$ ^codecov\.yml$ ^cran-comments\.md$ ^\.github$ hextools ^CRAN-RELEASE$ ================================================ FILE: .github/ISSUE_TEMPLATE/Bug_report.md ================================================ --- name: Bug report about: Create a report to help us improve --- **Describe the bug** A clear and concise description of what the bug is. **To Reproduce** Steps to reproduce the behavior: ```yaml contents of your carbon.yml file ``` **Expected behavior** A clear and concise description of what you expected to happen. **Environment (please complete the following information):**
Session Info ```r # paste here the output of devtools::session_info() ```
**Additional context** Add any other context about the problem here. ================================================ FILE: .github/ISSUE_TEMPLATE/Feature_request.md ================================================ --- name: Feature request about: Suggest an idea for this project --- **Is your feature request related to a problem? Please describe.** A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] **Describe the solution you'd like** A clear and concise description of what you want to happen. **Describe alternatives you've considered** A clear and concise description of any alternative solutions or features you've considered. **Additional context** Add any other context or screenshots about the feature request here. ================================================ FILE: .github/ISSUE_TEMPLATE/Question.md ================================================ --- name: Question about: General Usage Question --- **The problem** A clear and concise description of what the problem is. I'm trying to do [...] **Describe solutions you've considered** A clear and concise description of any alternative solutions you've considered. - [ ] I have looked in Stack Overflow for the solution already **Environment (please complete the following information):**
Session Info ```r # paste here the output of devtools::session_info() ```
**Additional context** Add any other context about the problem here. ================================================ FILE: .github/ISSUE_TEMPLATE/Tips.md ================================================ --- name: Tips about: Pro tips to help others --- **The tip** A clear and concise description of what you are solving. I'm trying to do [...] **Reproducible Solution** ```r # paste here the output of your reprex code ``` **Environment (please complete the following information):**
Session Info ```r # paste here the output of devtools::session_info() ```
**Additional context** Add any other context about the tip here. ================================================ FILE: .github/PULL_REQUEST_TEMPLATE.md ================================================ Hi, thanks for contributing! Please make sure you read our CONTRIBUTING guide. Please fill the fields above: ================================================ FILE: .github/stale.yml ================================================ # Number of days of inactivity before an issue becomes stale daysUntilStale: 60 # Number of days of inactivity before a stale issue is closed daysUntilClose: 7 # Issues with these labels will never be considered stale exemptLabels: - pinned - security # Label to use when marking an issue as stale staleLabel: wontfix # Comment to post when marking an issue as stale. Set to `false` to disable markComment: > This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. # Comment to post when closing a stale issue. Set to `false` to disable closeComment: false ================================================ FILE: .github/weekly-digest.yml ================================================ # Configuration for weekly-digest - https://github.com/apps/weekly-digest publishDay: sun canPublishIssues: true canPublishPullRequests: true canPublishContributors: true canPublishStargazers: true canPublishCommits: true ================================================ FILE: .gitignore ================================================ # History files .Rhistory .Rapp.history # Session Data files .RData # Example code in package build process *-Ex.R # Output files from R CMD build /*.tar.gz # Output files from R CMD check /*.Rcheck/ # RStudio files .Rproj.user/ # produced vignettes vignettes/*.html vignettes/*.pdf # OAuth2 token, see https://github.com/hadley/httr/releases/tag/v0.3 .httr-oauth # knitr and R markdown default cache directories /*_cache/ /cache/ # Temporary files created by R markdown *.utf8.md *.knit.md # Shiny token, see https://shiny.rstudio.com/articles/shinyapps.html rsconnect/ .Rproj.user *.DS_Store hextools/hex inst/doc ================================================ FILE: .travis.yml ================================================ language: R sudo: false cache: packages addons: apt: packages: - libmagick++-dev - xclip after_success: - Rscript -e 'covr::codecov()' - Rscript -e 'devtools::install(); covrpage::covrpage_ci(update_badge=FALSE)' - Rscript -e 'pkgdown::build_article("tests_and_coverage")' r_github_packages: - yonicd/covrpage - yonicd/pkgdown deploy: provider: pages skip-cleanup: true github-token: "$GITHUB_PAT" keep-history: true local-dir: docs on: branch: master env: global: secure: paX28Bf7HldCoa6ZPJOJmSrzTqaBKRDhQEVLk6+F1U5G54e+T2JuO6HcV3S61LXAAp31ZfrF9+uCpAhJvpSSjet/vYxJM/CdqII4DkHRbhGRE0KZ+mlVTj4tl56/N19sUsBX7TmTirudwQg1jXLOoDgtYafDFODdYIDI27XlSWbUwuub9tMVeEju+/Cx1nWgU9ABnnmow9Toio06kVNHc1dYAtE1Jhvp7COCzOKQAOS4UYcxvTMTCmEFG9uXzFQSUfr6pQ6lHNX8lSpqUVvDZbDHZEE6AyjG9Gnj0zA0CZWNEQ0HVXuXFPjYOPUVLpJmB6kHbbGuulERw2QZzPVSUFq9SGw3DnpqkexSPp+jVdkS3FGOeLoaItn3mcVyOgmc3KwMTaVUE3J46fUKWHtjqT6X6N1Fx8S5Z2HzPrAdiZGrT3FRXepmorqzzLcn59sDly0tvUJs2oxlVtIQxBKEpWVT/s3YNzfdxfYvVQdXWBFHsbRMU0yYSqKpUmQvE5Lgl8f8QGKas3z2sBd/YCXxGmB5YF+clw8xUx5O0nWUE6rLownlx68NOKRc0/AC4w2ryDOFJp5/5dg49dbLkxe5EsexesLNMvpNZ4vV+72TEpLjvhSyKN4s/QoKlQoZrlS9712j/u7mE6vBOlq+8GYR2XK/xejT3mNV/NWlcsU4fc0= ================================================ FILE: CRAN-RELEASE ================================================ This package was submitted to CRAN on 2020-02-06. Once it is accepted, delete this file and tag the release (commit 597e31c4a6). ================================================ FILE: DESCRIPTION ================================================ Package: carbonate Title: Interact with 'carbon.js' Version: 0.1.4 Authors@R: person(given = "Jonathan", family = "Sidi", role = c("aut", "cre"), email = "yonicd@gmail.com", comment = c(ORCID = "0000-0002-4222-1819")) Description: Create beautiful images of source code using 'carbon.js'. License: MIT + file LICENSE URL: https://github.com/yonicd/carbonate BugReports: https://github.com/yonicd/carbonate/issues Depends: R (>= 3.2.0) Imports: clipr, details, httpuv, httr, magick, R6, RSelenium, rtweet, utils, wdman, jsonlite, yaml Suggests: covr, knitr, rmarkdown, testthat VignetteBuilder: knitr RdMacros: details Encoding: UTF-8 Roxygen: list(markdown = TRUE,old_usage = TRUE,r6 = FALSE) RoxygenNote: 7.2.1 ================================================ FILE: LICENSE ================================================ YEAR: 2018 COPYRIGHT HOLDER: Jonathan Sidi ================================================ FILE: NAMESPACE ================================================ # Generated by roxygen2: do not edit by hand export(carbon) export(tinyurl) importFrom(R6,R6Class) importFrom(RSelenium,makeFirefoxProfile) importFrom(RSelenium,rsDriver) importFrom(clipr,read_clip) importFrom(clipr,write_clip) importFrom(details,details) importFrom(httpuv,randomPort) importFrom(httr,GET) importFrom(httr,content) importFrom(httr,http_error) importFrom(jsonlite,parse_json) importFrom(magick,image_read) importFrom(magick,image_write) importFrom(rtweet,post_tweet) importFrom(utils,browseURL) importFrom(utils,capture.output) importFrom(wdman,chrome) importFrom(wdman,gecko) importFrom(yaml,as.yaml) importFrom(yaml,read_yaml) ================================================ FILE: R/carbon.R ================================================ #' @title Carbon R6 class #' @description The Carbon generator creates a new `Carbon`-object, which is the class containing #' all the app logic. The class is based on the [R6][R6::R6Class] OO-system and #' is thus reference-based with methods and data attached to each object, in #' contrast to the more well known S3 and S4 systems. #' @format NULL #' @usage NULL #' @section Initialization: #' A new 'Carbon'-object is initialized using the `new()` method on the generator: #' #' \tabular{l}{ #' `x <- carbon$new(code = clipr::read_clip())` #' } #' #' #' @section Fields: #' #' \foldstart{Public Fields} #' #' Description of fields of the R6 object that can be set by the user can be found #' in the following [page][carbonate::carbon-fields]. #' #' \foldend #' #' @section Methods: #' #' \foldstart{Interacting with Browser} #' #' \tabular{ll}{ #' [$carbonate][carbonate::carbon-carbonate] \tab Using RSelenium fetch the carbon image output \cr #' [$browse][carbonate::.browse] \tab open [$uri][carbonate::carbon-uri] in the browser #' } #' #' \foldend #' #' #' \foldstart{ Aesthetics } #' #' \tabular{ll}{ #' [$set_template][carbonate::carbon-set-fields] \tab set $template \cr #' [$get_templates][carbonate::carbon-get-fields] \tab get a list of possible templates \cr #' [$set_window_control_theme][carbonate::carbon-set-fields] \tab set $windows_control_theme \cr #' [$get_windows_control_themes][carbonate::carbon-get-fields] \tab get a list of possible window control themes\cr #' [$set_font_family][carbonate::carbon-set-fields] \tab set $font_family\cr #' [$get_font_families][carbonate::carbon-get-fields] \tab get a list of possible fonts #' } #' #' \foldend #' #' \foldstart{ URI Building } #' #' \tabular{ll}{ #' [$uri][carbonate::carbon-uri] \tab construct valid carbon.js uri \cr #' [$options][carbonate::carbon-options] \tab return all current carbon options\cr #' [$encode][carbonate::carbon-encode] \tab URL encode a string for the $uri \cr #' [$tiny][carbonate::carbon-tinyurl] \tab Create tinyurl from [$uri][carbonate::carbon-uri] \cr #' [$rtweet][carbonate::carbon-rtweet] \tab Send tweets containing media generated from carbon #' } #' #' \foldend #' #' \foldstart{ Webdriver Settings } #' #' \tabular{ll}{ #' [$chromeOptions][carbonate::carbon-chrome] \tab construct a chromeOptions object \cr #' [$chrome_start][carbonate::carbon-chrome] \tab start a chrome session \cr #' [$chrome_stop][carbonate::carbon-chrome] \tab stop a chrome session \cr #' [$start][carbonate::carbon-selenium] \tab start a RSelenium session \cr #' [$stop][carbonate::carbon-selenium] \tab stop a RSelenium session \cr #' [$stop_all][carbonate::carbon-selenium] \tab stop all active RSelenium sessions \cr #' [$get_port][carbonate::carbon-selenium] \tab Get active port \cr #' [$set_port][carbonate::carbon-selenium] \tab Set new port #' } #' #' \foldend #' #' @rdname carbon #' @export #' @importFrom R6 R6Class #' @importFrom clipr read_clip #' @importFrom details details carbon <- R6::R6Class( classname = "Carbon", public = list( initialize = function(code = clipr::read_clip(), yml = "~/carbon.yml", silent_yml = FALSE) { self$code <- code private$parse_yml(yml, silent = silent_yml) self$set_port() }, code = NULL, palette = c(r = 171, g = 184, b = 195, a = 1), template = "seti", window_control_theme = "none", language = "r", add_drop_shadow = TRUE, drop_shadow_offset_y = 20, drop_shadow_blur_radius = 68, add_window_control = TRUE, auto_adjust_width = TRUE, padding_vertical = 48, padding_horizontal = 32, add_line_number = FALSE, font_family = "Hack", font_size = 14, line_height_percent = 133, square_image = FALSE, relative_export_size = 1, add_watermark = FALSE, add_tinyurl = FALSE, tinyurl_location = "southeast", tweet = FALSE, tweet_status = "Created in R using the Carbonate \U0001f4e6", add_timestamp = FALSE, maxiter = 20, carbons = list(), download_path = tempdir(), chrome_args = c("--disable-gpu", "--window-size=1280,800"), chrome_pref = list( "profile.default_content_settings.popups" = 0L, "download.prompt_for_download" = FALSE, "download.directory_upgrade" = TRUE, "safebrowsing.enabled" = TRUE, "download.default_directory" = tempdir() ), firefox_args = c('--width=1280','--height=800','--memory 1024mb','--headless'), firefox_pref = list( 'browser.download.dir' = tempdir(), 'browser.helperApps.neverAsk.saveToDisk' = 'image/png', 'browser.download.folderList' = 2L, 'browser.download.manager.showWhenStarting' = FALSE ), rD = NULL, cDrv = NULL, set_template = function(template = self$get_templates()[16]) { .set_template(self, private, template) }, set_window_control_theme = function(theme = self$get_windows_control_themes()[1]) { .set_window_control_theme(self, private, theme) }, set_font_family = function(family = self$get_font_families()[6]) { .set_font_family(self, private, family) }, get_windows_control_themes = function() { .get_windows_control_themes(self, private) }, get_font_families = function() { .get_font_families(self, private) }, get_templates = function() { .get_templates(self, private) }, options = function(code = self$code) { .options(self, private, code) }, uri = function(code = self$code) { .uri(self, private, code) }, browse = function() { .browse(self, private) }, chromeOptions = function() { .chromeOptions(self, private) }, firefoxOptions = function() { .firefoxOptions(self, private) }, driver = 'firefox', driver_start = function(driver = self$driver) { .driver_start(self, private, driver) }, driver_stop = function() { .driver_stop(self, private) }, start = function(driver = self$driver) { obj <- eval(parse(text = sprintf('self$%sOptions()',driver))) .start(self, private, eCap = obj, driver = driver) }, stop = function() { .stop(self, private) }, stop_all = function() { .stop_all(self, private) }, carbonate = function(file = "rcarbon.png", path = self$download_path, code = self$code, rD = self$rD, driver = self$driver) { .carbonate(self, private, file, path, code, rD, driver) }, encode = function(URL, reserved = FALSE, repeated = FALSE) { .encode(self, private, URL, reserved, repeated) }, tiny = function(clip = FALSE) { .tiny(self, private, clip) }, rtweet = function(media, status = self$tweet_status, media_format = c("png", "gif"), ...) { .rtweet(self, private, media, status, media_format = media_format, ...) }, set_port = function(port = NULL){ .set_port(self,private,port) }, get_port = function(){ .get_port(self,private) } ), private = list( temp_dir = tempdir(), px_vars = c( "drop_shadow_offset_y", "drop_shadow_blur_radius", "padding_vertical", "padding_horizontal", "font_size" ), logical_vars = c( "add_drop_shadow", "add_window_control", "auto_adjust_width", "add_line_number", "square_image", "add_watermark", "add_timestamp" ), var_names = c( palette = "bg", template = "t", window_control_theme = "wt", language = "l", add_drop_shadow = "ds", drop_shadow_offset_y = "dsyoff", drop_shadow_blur_radius = "dsblur", add_window_control = "wc", auto_adjust_width = "wa", padding_vertical = "pv", padding_horizontal = "ph", add_line_number = "ln", font_family = "fm", font_size = "fs", line_height_percent = "lh", square_image = "si", relative_export_size = "es", add_watermark = "wm", add_timestamp = "ts" ), port = NULL, rgba = function(x) { .rgba(self, private, x) }, add_unit = function(x, unit = "px") { .add_unit(self, private, x, unit) }, map_name = function(name) { .map_name(self, private, name) }, add_percent = function(value) { .add_percent(self, private, value) }, convert_logical = function(value) { .convert_logical(self, private, value) }, map = function() { .map(self, private) }, parse_yml = function(yml, silent_yml) { .parse_yml(self, private, yml, silent_yml) } ) ) ================================================ FILE: R/carbon_fields.R ================================================ #' @title Carbon object fields #' @description Fields that can be changed in the [Carbon][carbonate::carbon] object #' @usage NULL #' @param code character, script to embbed, Default: NULL #' @param palette numeric, layout pallete, Default: c(r=171,g=184,b=195,a=1) #' @param template character, layout template, Default: 'seti' #' @param add_window_control boolean, add/remove window controls (circles on top left corner), #' Default: TRUE #' @param window_control_theme character, change window control themes, Default: 'none' #' @param language character, language, Default: 'r' #' @param add_drop_shadow boolean, add/remove dropshadow, Default: TRUE #' @param drop_shadow_offset_y numeric, shadow vertical offset (px), Default: 20 #' @param drop_shadow_blur_radius numeric, shadow blur radius (px), Default: 68 #' @param auto_adjust_width boolean, auto-audjust output width, Default: TRUE #' @param padding_vertical numeric, vertical padding (px), Default: 48 #' @param padding_horizontal numeric, horizontal padding (px), Default: 32 #' @param add_line_number boolean, add/remove line numbers, Default: FALSE #' @param font_family character, layout font family, Default: 'Hack' #' @param font_size numeric, font size (px), Default: 14 #' @param line_height_percent numeric, relative space between lines (percent), Default: 133 #' @param square_image boolean, output image is square, Default: FALSE #' @param relative_export_size numeric, image size in export relative to what is in #' the preview (1,2 or 4), Default: 1 #' @param add_watermark boolean, add official carbon.js watermark, Default: FALSE #' @param add_tinyurl boolean, add tinyurl link to image directing to the carbon page that #' created the image, Default: FALSE #' @param tinyurl_location character, string with [gravity][magick::options] value to place the annotate tinyurl #' address on image, Default: 'southeast' #' @param tweet boolean, tweet out the image using [post_tweet][rtweet::post_tweet] #' @param tweet_status character, status to add to the tweet. If add_tinyurl is TRUE then #' a link to the url will be appended to the status automatically, #' Default: 'Created in R using the Carbonate (Package Icon)' #' @param add_timestamp boolean, add timestamp to output filename, Default: FALSE #' @param carbons list, storage of rendered carbon images, Default: NULL #' @param download_path character, path to download the images, Default: tempdir() #' @param chrome_args character, arguments passed to chrome browser, Default: #' c('--disable-gpu', '--window-size=1280,800') #' @param chrome_pref list, preferences passed to chrome browser, Default: #' list("profile.default_content_settings.popups" = 0L,"download.prompt_for_download" = FALSE,"download.default_directory" = tempdir()) #' @param rD RSelenium Driver object #' @param cDrv Chrome Driver object from wdman #' @name carbon_fields #' @rdname carbon_fields #' @aliases carbon-fields #' @seealso #' [carbon][carbonate::carbon] NULL ================================================ FILE: R/carbonate.R ================================================ #' @title Carbonate script lines to a carbon image #' @description Main function of the package that invokes RSelenium to open #' a browser to the carbon.js uri, create an image and download the file. #' @param self carbon self object #' @param private carbon private object #' @param file character, name of file to save image as #' @param path character, path to save the image #' @param code character, lines of script to make carbon image from #' @param rD RSelenium driver #' @param driver character, select either 'firefox' or 'chrome' driver #' @details Script is passed to is downloaded to the `tempdir()` and appended to the list [$carbons][carbonate::carbon-fields] using RSelenium and Chrome. #' @return image object #' @examples #' if(interactive()){ #' x <- carbon$new('x <- 1') #' x$carbonate() #' } #' @seealso #' [carbon][carbonate::carbon], [rsDriver][RSelenium::rsDriver] #' @rdname carbonate #' @aliases carbon-carbonate carbonate #' @importFrom magick image_read #' @importFrom utils capture.output #' @importFrom rtweet post_tweet .carbonate <- function(self, private, file, path, code, rD, driver) { this_uri <- self$uri(code = code) path <- normalizePath(path,mustWork = FALSE) device <- gsub("^(.*?)\\.", "", basename(file)) if(!dir.exists(path)){ message(sprintf('creating directory: %s', path)) dir.create(path) } if (file.exists(file.path(path, sprintf("carbon.%s", device)))) { unlink(file.path(path, sprintf("carbon.%s", device)), force = TRUE) } if (is.null(rD)) { message(sprintf("starting %s session...", driver)) self$start() rD <- self$rD } if (length(rD$client$getSessions()) == 0) { invisible(utils::capture.output(rD$client$open())) } on.exit({ rD$client$close() }, add = TRUE) remDr <- rD$client # remDr$queryRD( # ipAddr = file.path(remDr$serverURL,"session", # remDr$sessionInfo[["id"]], # "chromium/send_command"), # method = "POST", # qdata = list( # cmd = "Page.setDownloadBehavior", # params = list( # behavior = "allow", # downloadPath = path # ) # ) # ) remDr$navigate(this_uri) asyncr(remDr, using = "xpath", value = '//*[@id="export-menu"]', maxiter = self$maxiter ) asyncr(remDr, using = "xpath", value = sprintf('//*[@id="export-%s"]', device), maxiter = self$maxiter ) file.timeout(private$temp_dir,device) if (file.exists(file.path(private$temp_dir, sprintf("rcarbon.%s", device)))) { unlink(file.path(private$temp_dir, sprintf("rcarbon.%s", device)), force = TRUE) } file.rename(file.path(private$temp_dir, sprintf("carbon.%s", device)), file.path(private$temp_dir, sprintf("rcarbon.%s", device))) file.rename(file.path(private$temp_dir, sprintf("rcarbon.%s", device)), file.path(path, file)) img <- magick::image_read(file.path(path, file)) if (self$add_tinyurl) { tiny_uri <- self$tiny() img <- magick::image_annotate(img, text = tiny_uri, gravity = self$tinyurl_location) magick::image_write(img, file.path(path, file)) self$tweet_status <- sprintf("%s\nCheck out this script at \U0001f517 %s", self$tweet_status, tiny_uri) } if (self$tweet) { if (length(Sys.getenv("TWITTER_SCREEN_NAME")) == 0) { message("missing Environment Variable: 'TWITTER_SCREEN_NAME'\nskipping tweet \U0001f622") } else { self$rtweet(media = file.path(path, file)) } } self$carbons <- append(self$carbons, img) print(img, info = FALSE) } ================================================ FILE: R/helpers.R ================================================ # @title create rgba call for carbon # @description combines rbga vector into a string # @param self carbon self object # @param private carbon private object # @param x named character vector # @return character .rgba <- function(self, private, x) { sprintf("rgba(%s,%s,%s,%s)", x[["r"]], x[["g"]], x[["b"]], x[["a"]]) } # @title make a unit character # @description combines a number with a unit # @param self carbon self object # @param private carbon private object # @param x numeric, value # @param unit character, the unit # @return character .add_unit <- function(self, private, x, unit) { sprintf("%s%s", x, unit) } # @title map carbon R6 field to uri field # @description map the field used in the R6 object into the uri field # carbon.js uses. # @param self carbon self object # @param private carbon private object # @param name name of carbon R6 field # @return character .map_name <- function(self, private, name) { private$var_names[[name]] } # @title escape percent for carbon # @description suffix string with %25 # @param self carbon self object # @param private carbon private object # @param value character, character to combine string to .add_percent <- function(self, private, value) { sprintf("%s%%25", value) } # @title convert logical to carbon logical # @description convert logical to lower case character # @param self carbon self object # @param private carbon private object # @param value boolean, value to lower # @return character .convert_logical <- function(self, private, value) { tolower(as.character(value)) } # @title map name to function # @description map name of private method to constructors # @param self carbon self object # @param private carbon private object # @return list .map <- function(self, private) { l <- lapply(names(private$var_names), function(x) { val <- self[[x]] if (x == "template") { if (!self[[x]] %in% self$get_templates()) { stop(sprintf( "template not valid: %s\nUse the method get_templates() to choose a valid one", self[[x]] )) } val <- gsub("\\s", "%20", self[[x]]) } if (x == "font_family") { val <- gsub("\\s", "%20", self[[x]]) } if (x == "palette") { val <- gsub("[,]", "%2C", private$rgba(self[[x]])) } if (x == "line_height_percent") { val <- private$add_percent(self[[x]]) } if (x %in% "relative_export_size") { val <- private$add_unit(self[[x]], unit = "x") } if (x %in% private$px_vars) { val <- private$add_unit(self[[x]]) } if (x %in% private$logical_vars) { val <- private$convert_logical(self[[x]]) } assign(private$var_names[[x]], value = val) }) names(l) <- unlist(private$var_names) l } # https://goo.gl/jFqKfS asyncr <- function(remDr, using, value, action = NULL, maxiter = 20) { elem <- NULL i <- 0 while (is.null(elem) & (i <= maxiter)) { elem <- tryCatch({ remDr$findElement(using = using, value = value) }, error = function(e) { NULL } ) Sys.sleep(0.02 * (i + 1)) i <- i + 1 } if (is.null(elem) && i >= maxiter) { # assuming this means timed out stop("attempt to fetch image from carbon servers failed, please check network connectivity and try again", call. = FALSE ) } elem$clickElement() } file.timeout <- function(path, device, maxiter = 20) { file_found <- FALSE i <- 0 while (!file_found & (i <= maxiter)) { file_found <- file.exists(file.path(path, sprintf("carbon.%s", device))) Sys.sleep(0.02 * (i + 1)) i <- i + 1 } if (i >= maxiter) { # assuming this means timed out stop("Could not find file in download path, please check network connectivity and try again", call. = FALSE ) } } #' @importFrom yaml read_yaml as.yaml .parse_yml <- function(self, private, yml = "~/carbon.yml", silent = FALSE) { if (!is.null(yml)) { if (file.exists(yml)) { y <- yaml::read_yaml(yml) ny <- names(y) idx <- which(ny %in% names(self)) if (length(idx) > 0) { if ("palette" %in% ny) { y[["palette"]] <- check_palette_yml(x = y[["palette"]], self) } y <- check_get(y, self, silent = silent) ny <- names(y) idx <- which(ny %in% names(self)) y <- y[idx] for (i in seq_along(y)) { self[[ny[i]]] <- y[[i]] } if (!silent) { cat(sprintf("Set via '%s'\n", yml), yaml::as.yaml(y), sep = "") } } } } } check_palette_yml <- function(x, self = self) { x <- unlist(x, use.names = TRUE) if (is.null(names(x))) { names(x) <- c("r", "g", "b", "a")[1:length(x)] } np <- names(x) x <- x[np %in% c("r", "g", "b", "a")] sp <- self[["palette"]] sp[np] <- x x <- sp } check_get <- function(y, self = self, silent = FALSE) { rmx <- c() for (x in c("template", "font_family", "windows_control_theme")) { if (x %in% names(y)) { if (!y[[x]] %in% self[[find_get(x, self)]]()) { y[[x]] <- NULL rmx <- c(rmx, x) } } } if (length(rmx) > 0) { if (!silent) { message(sprintf( "invalid value for the fields in the yml (ignored on load):\n%s", paste0(rmx, collapse = ", ") )) } } return(y) } find_get <- function(x, self = self) { names(self)[startsWith(names(self), sprintf("get_%s", gsub("_(.*?)$", "", x)))] } #' @importFrom httpuv randomPort .random_port <- function(self = self, private = private) { httpuv::randomPort() } #' @importFrom jsonlite parse_json query_defaults <- function(type = "FONTS") { con_lines <- readLines('https://raw.githubusercontent.com/carbon-app/carbon/main/lib/constants.js') # Collapse to single string con_lines_collapse <- paste0(con_lines, collapse = "") con_lines_collapse <- gsub(",\\]", "\\]", con_lines_collapse) # Find and extract type l_matches <- gregexpr(sprintf("\\b%s\\b(.*?)\\]", type), con_lines_collapse) l_raw <- regmatches(con_lines_collapse, l_matches)[[1]][[1]] l_raw <- gsub(sprintf("%s(.*?)= ", type), "", l_raw) # Clean up trailing commas and whitespaces l_raw <- gsub("\\s+", " ", l_raw) l_raw <- gsub("\\}, \\}", "\\}\\}", l_raw) l_raw <- gsub(",\\s*", ",", l_raw) l_raw <- gsub(",\\s*\\}", "\\}", l_raw) l_raw <- gsub("\\{\\s", "\\{", l_raw) # Replace name of elements with quoted names find_l <- regmatches(l_raw,gregexpr("[{,](.*?):", l_raw)) old_chr <- unique(gsub("[ {:,]", "", find_l[[1]])) new_chr <- sprintf('"%s":', old_chr) block_chr <- sprintf("\\b%s\\b:", old_chr) l_out <- l_raw for(i in seq(length(old_chr))) { l_out <- gsub(block_chr[i], new_chr[i], l_out) } #Fix syntax problems l_out <- gsub("' :", '" :', l_out) l_out <- gsub(": '", ': "', l_out) l_out <- gsub("\\{ '", '\\{ "', l_out) l_out <- gsub("' \\}", '" \\}', l_out) l_out <- gsub("'\\}", '"\\}', l_out) l_out <- gsub("',", '",', l_out) l_out <- gsub(",'", ',"', l_out) l_out <- gsub(":'", ':"', l_out) l_out <- gsub('-"', "-", l_out) l_out <- gsub('""', '"', l_out) # Convert to list jsonlite::parse_json(l_out) } ================================================ FILE: R/selenium_functions.R ================================================ #' @title chrome webdriver functions #' @description Functions to open,close,set chrome webdriver #' @param self carbon self object #' @param private carbon private object #' @rdname carbon_chrome #' @aliases carbon-chrome #' @seealso #' [carbon][carbonate::carbon], [chrome][wdman::chrome] .chromeOptions <- function(self, private) { list(chromeOptions = list(args = self$chrome_args, prefs = self$chrome_pref)) } #' @title gecko webdriver functions #' @description Functions to open,close,set gecko webdriver #' @param self carbon self object #' @param private carbon private object #' @rdname carbon_gecko #' @aliases carbon-gecko #' @seealso #' [carbon][carbonate::carbon], [gecko][wdman::gecko] .firefoxOptions <- function(self, private) { append( RSelenium::makeFirefoxProfile(self$firefox_pref), list( "moz:firefoxOptions" = list(args = self$firefox_args)) ) } #' @title RSelenium webdriver functions #' @description Functions to open,stop, stop_all RSelenium sessions #' @param self carbon self object #' @param private carbon private object #' @param eCap chromeOptions passed into [rsDriver][RSelenium::rsDriver] #' @param driver character, select either 'firefox' or 'chrome' driver #' @rdname carbon_selenium #' @aliases carbon-selenium #' @seealso #' [carbon][carbonate::carbon] #' @importFrom RSelenium rsDriver makeFirefoxProfile .start <- function(self, private, eCap, driver = c("firefox", "chrome")) { driver <- match.arg(driver, c("firefox", "chrome")) if (is.null(self$cDrv)) { self$driver_start(driver) } self$rD <- RSelenium::rsDriver( browser = driver, verbose = FALSE, port = private$port, extraCapabilities = eCap ) } #' @rdname carbon_selenium #' @importFrom wdman gecko chrome .driver_start <- function(self, private, driver = c("chrome", "firefox")) { driver <- match.arg(driver, c("chrome", "firefox")) self$cDrv <- switch(driver, chrome = wdman::chrome(port = private$port), firefox = wdman::gecko(port = private$port) ) } #' @rdname carbon_selenium .driver_stop <- function(self, private) { self$cDrv$stop() } #' @rdname carbon_selenium .stop <- function(self, private) { self$rD$client$close() self$driver_stop() } #' @rdname carbon_selenium .stop_all <- function(self, private) { self$rD$client$closeall() self$driver_stop() } #' @rdname carbon_selenium #' @param port integer, port for the [rsDriver][RSelenium::rsDriver] to use, #' if NULL then a random port is selected .set_port <- function(self, private, port = NULL){ if(!is.null(private$port)) private$port if(is.null(port)){ private$port <- .random_port(self, private) }else{ private$port <- as.integer(port) } } #' @rdname carbon_selenium .get_port <- function(self, private){ private$port } ================================================ FILE: R/set_get_functions.R ================================================ #' @title carbon set functions #' @description function that set the aesthetics of the carbon image output #' @param self carbon self object #' @param private carbon private object #' @param template character, name of template to set [$template][carbonate::carbon-fields] to #' @param theme character, theme to set [$theme][carbonate::carbon-fields] to #' @param family character, font family to set [$font_family][carbonate::carbon-fields] to #' @rdname set_carbon #' @aliases carbon-set-fields #' @seealso #' [carbon][carbonate::carbon] .set_template <- function(self, private, template) { self$template <- template } #' @rdname set_carbon .set_window_control_theme <- function(self, private, theme) { self$window_control_theme <- theme } #' @rdname set_carbon .set_font_family <- function(self, private, family) { self$font_family <- family } #' @title carbon get functions #' @description function that gets the available list of aesthetic values of fields #' @param self carbon self object #' @param private carbon private object #' @rdname get_carbon #' @aliases carbon-get-fields #' @seealso #' [carbon][carbonate::carbon] .get_windows_control_themes <- function(self, private) { c("none", "sharp", "bw") } #' @rdname get_carbon .get_font_families <- function(self, private) { # c("Anonymous Pro", "Droid Sans Mono", "Fantasque Sans Mono", # "Fira Code", "Hack", "IBM Plex Mono", "Inconsolata", "Iosevka", # "JetBrains Mono", "Monoid", "Source Code Pro", "Space Mono", # "Ubuntu Mono") sapply(query_defaults('FONTS'),'[[',2) } #' @rdname get_carbon .get_templates <- function(self, private) { # c("3024-night", "a11y-dark", "blackboard", "base16-dark", "base16-light", # "cobalt", "dracula", "duotone-dark", "hopscotch", "lucario", # "material", "monokai", "night-owl", "nord", "oceanic-next", "one-light", # "one-dark", "panda-syntax", "paraiso-dark", "seti", "shades-of-purple", # "solarized dark", "solarized light", "synthwave-84", "twilight", # "verminal", "vscode", "yeti", "zenburn") sapply(query_defaults('THEMES'),'[[',1) } ================================================ FILE: R/uri_functions.R ================================================ #' @title concatenate the carbon options to a string #' @description combine all the carbon options into a carbon.js valid string #' @param self carbon self object #' @param private carbon private object #' @param code character, script to embbed into the uri #' @return OUTPUT_DESCRIPTION #' @rdname options #' @aliases carbon-options #' @seealso #' [carbon][carbonate::carbon] .options <- function(self, private, code) { l <- private$map() s <- paste0(sapply(names(l), function(x) sprintf("%s=%s", x, l[[x]])), collapse = "&") code <- paste0(code, collapse = "\n") sprintf("%s&code=%s", s, self$encode(code)) } #' @title URI constructor #' @description Function that is called in a carbon object to construct valid uri to send to browser #' @param self carbon self object #' @param private carbon private object #' @param code character, script to embbed into the uri #' @examples #' if(interactive()){ #' #' x <- carbon$new('x <- 1') #' #' # populate from self$code #' x$uri() #' #' # enter manually #' x$uri(code = 'x <- y + 3') #' #' } #' @rdname uri #' @aliases carbon-uri #' @seealso #' [carbon][carbonate::carbon] .uri <- function(self, private, code) { sprintf("https://carbon.now.sh/?%s", self$options(code = code)) } #' @title open $uri to in browser window #' @description opens the uri address in [$uri][carbonate::carbon-uri] in the browser window. #' @param self carbon self object #' @param private carbon private object #' @examples #' x <- carbon$new('x <- 1') #' if(interactive()) #' x$browse() #' #' @rdname browse #' @aliases carbon-browse #' @importFrom utils browseURL #' @seealso #' [carbon][carbonate::carbon] .browse <- function(self, private) { utils::browseURL(self$uri()) } #' @title encode uri for carbon.js #' @description encode uri string for carbon.js. #' Augmented version of than [URLencode][utils::URLencode] #' @param self carbon self object #' @param private carbon private object #' @param URL character, uri string to url encode #' @param reserved boolean, should ‘reserved’ characters be encoded? #' @param repeated boolean, should apparently already-encoded URLs be encoded again? #' @return character #' @seealso [URLencode][utils::URLencode], [carbon][carbonate::carbon] #' @rdname encode #' @aliases carbon-encode .encode <- function(self, private, URL, reserved, repeated) { if (!repeated && grepl("%[[:xdigit:]]{2}", URL, useBytes = TRUE)) { return(URL) } OK <- paste0( "[^", if (!reserved) { "][!();?" } , "ABCDEFGHIJKLMNOPQRSTUVWXYZ", "abcdefghijklmnopqrstuvwxyz0123456789._~-", "]" ) x <- strsplit(URL, "")[[1L]] z <- grep(OK, x) z <- sort(c(z, which(x %in% c("[", "]")))) if (length(z)) { y <- sapply(x[z], function(x) paste0("%25", toupper(as.character(charToRaw(x))), collapse = "" )) y <- gsub("%2527", "%27", y) x[z] <- y } paste(x, collapse = "") } #' @title convert carbon uri to tinyurl #' @description convert carbon uri to tinyurl with option to attach to clipboard. #' @param self carbon self object #' @param private carbon private object #' @param clip boolean, write tinyurl to clipboard, Default: FALSE #' @details If clip is set to TRUE [write_clip][clipr::write_clip] will put the #' tinyurl on the clipboard. #' @return character #' @importFrom clipr write_clip #' @rdname tiny #' @aliases carbon-tinyurl .tiny <- function(self, private, clip = FALSE) { RET <- tinyurl(self$uri()) if (clip) { clipr::write_clip(RET) } return(RET) } #' @title send tweets using carbonate outputs #' @description wrapper for [post_tweet][rtweet::post_tweet] to send #' tweets with media created using carbonate. #' @param self carbon self object #' @param private carbon private object #' @param media magick-image object or path to image #' @param status character, status to attach to post, Default: self$tweet_status #' @param media_format character, type of media to tweet, Default: c('png','gif') #' @param \dots arguments to pass to [post_tweet][rtweet::post_tweet] #' @return outcome from rtweet #' @details If multiple images are passed they can be either converted to a gif by #' setting media_format to 'gif' or attached each one to the post. #' @examples #' \dontrun{ #' x <- carbonate::carbon$new() #' x$carbonate(code = readLines(system.file('DESCRIPTION',package='carbonate'))) #' x$carbonate(code = 'x+2') #' #' # using default status value (x$tweet_status) #' x$rtweet(system.file('figures/hex_black_small.png',package='carbonate')) #' #' x$rtweet(status = 'these are two pngs',media = x$carbons,media_format='png') #' x$rtweet(status = 'this is a gif', media = x$carbons,media_format='gif') #' #' } #' @seealso #' [image_write][magick::image_write] #' [post_tweet][rtweet::post_tweet] #' @rdname rtweet #' @aliases carbon-rtweet #' @importFrom magick image_write #' @importFrom rtweet post_tweet .rtweet <- function(self, private, media, status = self$tweet_status, media_format = c("png", "gif"), ...) { td <- file.path(tempdir(), "rtweet_media") mf <- match.arg(media_format) dir.create(td, showWarnings = FALSE) on.exit(unlink(td, recursive = TRUE, force = TRUE), add = TRUE) if (inherits(media, "magick-image")) { if (mf == "gif") { anim <- magick::image_animate(media, fps = 1) magick::image_write( image = anim, path = file.path(td, sprintf("img01.%s", mf)), format = mf ) } else { invisible( lapply(seq_along(media), function(x) { magick::image_write( image = media[x], path = file.path(td, sprintf("img%02d.%s", x, mf)), format = mf ) }) ) } tds <- list.files(td, full.names = TRUE) } else { tds <- media } rtweet::post_tweet(status = status, media = tds, ...) } #' @title convert uri to tinyurl #' @description convert uri to tinyurl. #' @param uri character, the uri to convert #' @return character #' @importFrom httr http_error content GET #' @export tinyurl <- function(uri){ host <- 'tinyurl.com' if(!httr::http_error(host)){ base <- sprintf('http://%s/api-create.php',host) uri <- httr::content(httr::GET(sprintf('%s?url=%s',base,uri))) } uri } ================================================ FILE: README.Rmd ================================================ --- output: github_document always_allow_html: yes --- ```{r, echo = FALSE,message=FALSE,warning=FALSE} knitr::opts_chunk$set( collapse = TRUE, comment = "#>", fig.path = "man/figures/" ) library(magick) ``` [![CRAN_Status_Badge](http://www.r-pkg.org/badges/version/carbonate)](https://cran.r-project.org/package=carbonate) [![](https://cranlogs.r-pkg.org/badges/carbonate)](https://cran.r-project.org/package=carbonate) [![Travis-CI Build Status](https://travis-ci.org/yonicd/carbonate.svg?branch=master)](https://travis-ci.org/yonicd/carbonate) [![Coverage Status](https://img.shields.io/codecov/c/github/yonicd/carbonate/master.svg)](https://codecov.io/github/yonicd/carbonate?branch=master) [![Covrpage Summary](https://img.shields.io/badge/covrpage-Last_Build_2022_08_21-yellowgreen.svg)](https://goo.gl/gNRcCb) "[carbon.js](https://carbon.now.sh/about) is the easiest way to create beautiful images of your source code." This package uses an `R6` api to interact with carbon.js and create directly from the console carbon images. Like the image below: ```{r,include=FALSE} library(carbonate) x <- carbon$new(readLines('DESCRIPTION')) x$carbonate(file = 'myfile.png',path = 'man/figures') ``` ```{r, echo=FALSE} x$carbons ``` ## Installation ```{r,eval= FALSE} #remotes::install_github('yonicd/carbonate') install.packages('carbonate') ``` ## Usage ### Initialize new carbon object ```{r,eval = FALSE} library(carbonate) ``` The default code in the carbon object is taken from the clipboard. ```{r,eval = FALSE} x <- carbon$new() ``` But can also be defined inline. Code can be a character object of any length. ```{r, eval = FALSE} x <- carbon$new(readLines('DESCRIPTION')) ``` The code is kept in the object and can be changed at any time. ```{r} x$code ``` The main job of the R6 object is to convert all the options into a uri that is sent to the carbon url page, where it is processed. ```{r} x$uri() ``` Click the [link](`r x$uri()`) to see the URI works. ### Manipulate carbon object Aesthetics of the carbon object that can be manipulated |Carbon Variable |Carbonate Variable |Description | Default | |:------:|:-----------------------|:-----------|:----:| |l |language |language |r| |bg |palette |layout pallete (vector with c(r,g,b,a)|c(r=171,g=184,b=195,a=1)| |t |template |layout template (listed in get_templates()) |'seti'| |wc |add_window_control |add/remove window controls (circles on top left corner) |TRUE| |wt |window_control_theme |change window control themes (listed in get_windows_control_themes()) |'none'| |ds |add_drop_shadow |add/remove dropshadow |TRUE| |dsyoff |drop_shadow_offset_y |shadow vertical offset (px) |20| |dsblur |drop_shadow_blur_radius |shadow blur radius (px) |68| |wa |auto_adjust_width |auto-audjust output width |TRUE| |pv |padding_vertical |vertical padding (px) |48| |ph |padding_horizontal |horizontal padding (px) |32| |ln |add_line_number |add/remove line numbers |FALSE| |fm |font_family |layout font family (listed in get_font_families()) |'Hack'| |fs |font_size |font size (px) |14| |lh |line_height_percent |relative space between lines (percent) |133| |si |square_image |output image is square |FALSE| |es |relative_export_size |image size in export relative to what is in the preview (1,2 or 4) |1| |wm |add_watermark |add official carbon.js watermark |FALSE| ```{r} x$get_templates() ``` ```{r} x$get_font_families() ``` ```{r} x$get_windows_control_themes() ``` ### Personal Configuration Users can use a file called `carbon.yml` and place it in their home directory (`~`) to override the packages defaults in order to create a session peristent carbon template they like. The config file controls all the [public carbon object fields](#manipulate-carbon-object). The following is an example of such a configuration file. These fields will set - The palette (rgba) `g` and `a` fields to 175 and 0.7 respectively - The template will be set to `panda-syntax` - The font to `Fira Code` - The padding around the output will be made tighter than the system defaults 11px and 14px. ```yml palette: - g: 175.0 - a: 0.7 template: panda-syntax font_family: Fira Code padding_vertical: 11 padding_horizontal: 14 ``` ### Open carbon code in browser ```{r,eval=FALSE} x$browse() ``` ### Set the download directory ```{r,eval = FALSE} x$download_path <- file.path('README_files/download') ``` ### Carbonate code directly to file This function depends on RSelenium ```{r,eval = FALSE} x$carbonate(file = 'myfile.png') ``` ```{r, echo=FALSE} x$carbons ``` ```{r,echo=FALSE} Sys.sleep(2) ``` ```{r} x$template <-'cobalt' x$carbonate(file = 'new_template.png') ``` ```{r,echo=FALSE} Sys.sleep(2) ``` ```{r} x$font_family <-'IBM Plex Mono' x$carbonate(file = 'new_font.png') ``` ### Carbonate code directly to file in specific directory ```{r,echo=FALSE} Sys.sleep(2) ``` ### Closing Browsers Closing all instances of open browsers used by RSelenium. ```r x$stop_all() ``` ### Sharing
Tinyurl You can also put a tinyurl link as a watermark on the image produced that will open to the carbon.now.sh page that has the code in the image. ```{r,echo=FALSE} Sys.sleep(2) ``` ```{r} x$add_tinyurl <- TRUE x$carbonate(file = 'tiny_url.png') ``` If you just want the tinyurl link without the image to use in a tweet you can create it using ```{r} x$tiny() ``` Or you can put the link directly on your clipboard ```{r, eval = interactive()} x$tiny(clip = TRUE) clipr::read_clip() ```
Twitter ##### Direct You can also directly tweet the image. An automatic status is created with two options - Default - `r 'Created in R using the Carbonate \U0001f4e6'` - When `add_tinyurl <- TRUE` - `r sprintf('%s\nCheck out this script at \U0001f517 %s', 'Created in R using the Carbonate \U0001f4e6', x$tiny())` - Manual - Using `tweet_status` you can write your own status. ```{r,eval=FALSE} x <- carbonate::carbon$new() x$tweet <- TRUE x$carbonate() ``` ##### Post process (Batch) If you have images stored in `x$carbons` you can post them also in a tweet using. ```{r,eval = FALSE} # for multiple png attachments x$rtweet(x$carbons,media_type = 'png') #using default status # subsets of images x$rtweet(status='These are images',x$carbons[c(1,3)],media_type = 'png') # for gifs x$rtweet(status='This is a gif', x$carbons,media_type = 'gif') ```
### Post image processing All carbon outputs are collected and saved in the list `x$carbons`
Combining ```{r} x$carbons%>% magick::image_scale('300')%>% magick::image_append() x$carbons%>% magick::image_scale('300')%>% magick::image_append(stack = TRUE) ```
GIFs ```{r} x$carbons%>% magick::image_animate(fps = 1) ```
================================================ FILE: README.md ================================================ [![CRAN_Status_Badge](http://www.r-pkg.org/badges/version/carbonate)](https://cran.r-project.org/package=carbonate) [![](https://cranlogs.r-pkg.org/badges/carbonate)](https://cran.r-project.org/package=carbonate) [![Travis-CI Build Status](https://travis-ci.org/yonicd/carbonate.svg?branch=master)](https://travis-ci.org/yonicd/carbonate) [![Coverage Status](https://img.shields.io/codecov/c/github/yonicd/carbonate/master.svg)](https://codecov.io/github/yonicd/carbonate?branch=master) [![Covrpage Summary](https://img.shields.io/badge/covrpage-Last_Build_2022_08_21-yellowgreen.svg)](https://goo.gl/gNRcCb) “[carbon.js](https://carbon.now.sh/about) is the easiest way to create beautiful images of your source code.” This package uses an `R6` api to interact with carbon.js and create directly from the console carbon images. Like the image below: ![](man/figures/unnamed-chunk-3-1.png) ## Installation ``` r #remotes::install_github('yonicd/carbonate') install.packages('carbonate') ``` ## Usage ### Initialize new carbon object ``` r library(carbonate) ``` The default code in the carbon object is taken from the clipboard. ``` r x <- carbon$new() ``` But can also be defined inline. Code can be a character object of any length. ``` r x <- carbon$new(readLines('DESCRIPTION')) ``` The code is kept in the object and can be changed at any time. ``` r x$code #> [1] "Package: carbonate" #> [2] "Title: Interact with 'carbon.js'" #> [3] "Version: 0.1.4" #> [4] "Authors@R: " #> [5] " person(given = \"Jonathan\"," #> [6] " family = \"Sidi\"," #> [7] " role = c(\"aut\", \"cre\")," #> [8] " email = \"yonicd@gmail.com\"," #> [9] " comment = c(ORCID = \"0000-0002-4222-1819\"))" #> [10] "Description: Create beautiful images of source code using" #> [11] " 'carbon.js'." #> [12] "License: MIT + file LICENSE" #> [13] "URL: https://github.com/yonicd/carbonate" #> [14] "BugReports: https://github.com/yonicd/carbonate/issues" #> [15] "Depends: " #> [16] " R (>= 3.2.0)" #> [17] "Imports: " #> [18] " clipr," #> [19] " details," #> [20] " httpuv," #> [21] " httr," #> [22] " magick," #> [23] " R6," #> [24] " RSelenium," #> [25] " rtweet," #> [26] " utils," #> [27] " wdman," #> [28] " jsonlite," #> [29] " yaml" #> [30] "Suggests: " #> [31] " covr," #> [32] " knitr," #> [33] " rmarkdown," #> [34] " testthat" #> [35] "VignetteBuilder: " #> [36] " knitr" #> [37] "RdMacros: " #> [38] " details" #> [39] "Encoding: UTF-8" #> [40] "Roxygen: list(markdown = TRUE,old_usage = TRUE,r6 = FALSE)" #> [41] "RoxygenNote: 7.2.1" ``` The main job of the R6 object is to convert all the options into a uri that is sent to the carbon url page, where it is processed. ``` r x$uri() #> [1] "https://carbon.now.sh/?bg=rgba(171%2C175%2C195%2C0.7)&t=panda-syntax&wt=none&l=r&ds=true&dsyoff=20px&dsblur=68px&wc=true&wa=true&pv=11px&ph=14px&ln=false&fm=Fira%20Code&fs=14px&lh=133%25&si=false&es=1x&wm=false&ts=false&code=Package%253A%2520carbonate%250ATitle%253A%2520Interact%2520with%2520%27carbon.js%27%250AVersion%253A%25200.1.4%250AAuthors%2540R%253A%2520%250A%2520%2520%2520%2520person(given%2520%253D%2520%2522Jonathan%2522%252C%250A%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520family%2520%253D%2520%2522Sidi%2522%252C%250A%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520role%2520%253D%2520c(%2522aut%2522%252C%2520%2522cre%2522)%252C%250A%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520email%2520%253D%2520%2522yonicd%2540gmail.com%2522%252C%250A%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520comment%2520%253D%2520c(ORCID%2520%253D%2520%25220000-0002-4222-1819%2522))%250ADescription%253A%2520Create%2520beautiful%2520images%2520of%2520source%2520code%2520using%250A%2520%2520%2520%2520%27carbon.js%27%253Chttps%253A%252F%252Fcarbon.now.sh%252Fabout%253E.%250ALicense%253A%2520MIT%2520%252B%2520file%2520LICENSE%250AURL%253A%2520https%253A%252F%252Fgithub.com%252Fyonicd%252Fcarbonate%250ABugReports%253A%2520https%253A%252F%252Fgithub.com%252Fyonicd%252Fcarbonate%252Fissues%250ADepends%253A%2520%250A%2520%2520%2520%2520R%2520(%253E%253D%25203.2.0)%250AImports%253A%2520%250A%2520%2520%2520%2520clipr%252C%250A%2520%2520%2520%2520details%252C%250A%2520%2520%2520%2520httpuv%252C%250A%2520%2520%2520%2520httr%252C%250A%2520%2520%2520%2520magick%252C%250A%2520%2520%2520%2520R6%252C%250A%2520%2520%2520%2520RSelenium%252C%250A%2520%2520%2520%2520rtweet%252C%250A%2520%2520%2520%2520utils%252C%250A%2520%2520%2520%2520wdman%252C%250A%2520%2520%2520%2520jsonlite%252C%250A%2520%2520%2520%2520yaml%250ASuggests%253A%2520%250A%2520%2520%2520%2520covr%252C%250A%2520%2520%2520%2520knitr%252C%250A%2520%2520%2520%2520rmarkdown%252C%250A%2520%2520%2520%2520testthat%250AVignetteBuilder%253A%2520%250A%2520%2520%2520%2520knitr%250ARdMacros%253A%2520%250A%2520%2520%2520%2520details%250AEncoding%253A%2520UTF-8%250ARoxygen%253A%2520list(markdown%2520%253D%2520TRUE%252Cold_usage%2520%253D%2520TRUE%252Cr6%2520%253D%2520FALSE)%250ARoxygenNote%253A%25207.2.1" ``` Click the [link](https://carbon.now.sh/?bg=rgba(171%2C175%2C195%2C0.7)&t=panda-syntax&wt=none&l=r&ds=true&dsyoff=20px&dsblur=68px&wc=true&wa=true&pv=11px&ph=14px&ln=false&fm=Fira%20Code&fs=14px&lh=133%25&si=false&es=1x&wm=false&ts=false&code=Package%253A%2520carbonate%250ATitle%253A%2520Interact%2520with%2520%27carbon.js%27%250AVersion%253A%25200.1.4%250AAuthors%2540R%253A%2520%250A%2520%2520%2520%2520person(given%2520%253D%2520%2522Jonathan%2522%252C%250A%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520family%2520%253D%2520%2522Sidi%2522%252C%250A%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520role%2520%253D%2520c(%2522aut%2522%252C%2520%2522cre%2522)%252C%250A%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520email%2520%253D%2520%2522yonicd%2540gmail.com%2522%252C%250A%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520comment%2520%253D%2520c(ORCID%2520%253D%2520%25220000-0002-4222-1819%2522))%250ADescription%253A%2520Create%2520beautiful%2520images%2520of%2520source%2520code%2520using%250A%2520%2520%2520%2520%27carbon.js%27%253Chttps%253A%252F%252Fcarbon.now.sh%252Fabout%253E.%250ALicense%253A%2520MIT%2520%252B%2520file%2520LICENSE%250AURL%253A%2520https%253A%252F%252Fgithub.com%252Fyonicd%252Fcarbonate%250ABugReports%253A%2520https%253A%252F%252Fgithub.com%252Fyonicd%252Fcarbonate%252Fissues%250ADepends%253A%2520%250A%2520%2520%2520%2520R%2520(%253E%253D%25203.2.0)%250AImports%253A%2520%250A%2520%2520%2520%2520clipr%252C%250A%2520%2520%2520%2520details%252C%250A%2520%2520%2520%2520httpuv%252C%250A%2520%2520%2520%2520httr%252C%250A%2520%2520%2520%2520magick%252C%250A%2520%2520%2520%2520R6%252C%250A%2520%2520%2520%2520RSelenium%252C%250A%2520%2520%2520%2520rtweet%252C%250A%2520%2520%2520%2520utils%252C%250A%2520%2520%2520%2520wdman%252C%250A%2520%2520%2520%2520jsonlite%252C%250A%2520%2520%2520%2520yaml%250ASuggests%253A%2520%250A%2520%2520%2520%2520covr%252C%250A%2520%2520%2520%2520knitr%252C%250A%2520%2520%2520%2520rmarkdown%252C%250A%2520%2520%2520%2520testthat%250AVignetteBuilder%253A%2520%250A%2520%2520%2520%2520knitr%250ARdMacros%253A%2520%250A%2520%2520%2520%2520details%250AEncoding%253A%2520UTF-8%250ARoxygen%253A%2520list(markdown%2520%253D%2520TRUE%252Cold_usage%2520%253D%2520TRUE%252Cr6%2520%253D%2520FALSE)%250ARoxygenNote%253A%25207.2.1) to see the URI works. ### Manipulate carbon object Aesthetics of the carbon object that can be manipulated | Carbon Variable | Carbonate Variable | Description | Default | |:---------------:|:------------------------|:----------------------------------------------------------------------|:------------------------:| | l | language | language | r | | bg | palette | layout pallete (vector with c(r,g,b,a) | c(r=171,g=184,b=195,a=1) | | t | template | layout template (listed in get_templates()) | ‘seti’ | | wc | add_window_control | add/remove window controls (circles on top left corner) | TRUE | | wt | window_control_theme | change window control themes (listed in get_windows_control_themes()) | ‘none’ | | ds | add_drop_shadow | add/remove dropshadow | TRUE | | dsyoff | drop_shadow_offset_y | shadow vertical offset (px) | 20 | | dsblur | drop_shadow_blur_radius | shadow blur radius (px) | 68 | | wa | auto_adjust_width | auto-audjust output width | TRUE | | pv | padding_vertical | vertical padding (px) | 48 | | ph | padding_horizontal | horizontal padding (px) | 32 | | ln | add_line_number | add/remove line numbers | FALSE | | fm | font_family | layout font family (listed in get_font_families()) | ‘Hack’ | | fs | font_size | font size (px) | 14 | | lh | line_height_percent | relative space between lines (percent) | 133 | | si | square_image | output image is square | FALSE | | es | relative_export_size | image size in export relative to what is in the preview (1,2 or 4) | 1 | | wm | add_watermark | add official carbon.js watermark | FALSE | ``` r x$get_templates() #> [1] "3024-night" "a11y-dark" "blackboard" "base16-dark" #> [5] "base16-light" "cobalt" "dracula" "duotone-dark" #> [9] "hopscotch" "lucario" "material" "monokai" #> [13] "night-owl" "nord" "oceanic-next" "one-light" #> [17] "one-dark" "panda-syntax" "paraiso-dark" "seti" #> [21] "shades-of-purple" "solarized dark" "solarized light" "synthwave-84" #> [25] "twilight" "verminal" "vscode" "yeti" #> [29] "zenburn" ``` ``` r x$get_font_families() #> [1] "Anonymous Pro" "Cascadia Code" "Droid Sans Mono" #> [4] "Fantasque Sans Mono" "Fira Code" "Hack" #> [7] "IBM Plex Mono" "Inconsolata" "JetBrains Mono" #> [10] "Monoid" "Source Code Pro" "Space Mono" #> [13] "Ubuntu Mono" ``` ``` r x$get_windows_control_themes() #> [1] "none" "sharp" "bw" ``` ### Personal Configuration Users can use a file called `carbon.yml` and place it in their home directory (`~`) to override the packages defaults in order to create a session peristent carbon template they like. The config file controls all the [public carbon object fields](#manipulate-carbon-object). The following is an example of such a configuration file. These fields will set - The palette (rgba) `g` and `a` fields to 175 and 0.7 respectively - The template will be set to `panda-syntax` - The font to `Fira Code` - The padding around the output will be made tighter than the system defaults 11px and 14px. ``` yml palette: - g: 175.0 - a: 0.7 template: panda-syntax font_family: Fira Code padding_vertical: 11 padding_horizontal: 14 ``` ### Open carbon code in browser ``` r x$browse() ``` ### Set the download directory ``` r x$download_path <- file.path('README_files/download') ``` ### Carbonate code directly to file This function depends on RSelenium ``` r x$carbonate(file = 'myfile.png') ``` ![](man/figures/unnamed-chunk-16-1.png) ``` r x$template <-'cobalt' x$carbonate(file = 'new_template.png') ``` ![](man/figures/unnamed-chunk-18-1.png) ``` r x$font_family <-'IBM Plex Mono' x$carbonate(file = 'new_font.png') ``` ![](man/figures/unnamed-chunk-20-1.png) ### Carbonate code directly to file in specific directory ### Closing Browsers Closing all instances of open browsers used by RSelenium. ``` r x$stop_all() ``` ### Sharing
Tinyurl You can also put a tinyurl link as a watermark on the image produced that will open to the carbon.now.sh page that has the code in the image. ``` r x$add_tinyurl <- TRUE x$carbonate(file = 'tiny_url.png') ``` ![](man/figures/unnamed-chunk-23-1.png) If you just want the tinyurl link without the image to use in a tweet you can create it using ``` r x$tiny() #> [1] "https://tinyurl.com/2n72r6pk" ``` Or you can put the link directly on your clipboard ``` r x$tiny(clip = TRUE) clipr::read_clip() ```
Twitter ##### Direct You can also directly tweet the image. An automatic status is created with two options - Default - Created in R using the Carbonate 📦 - When `add_tinyurl <- TRUE` - Created in R using the Carbonate 📦 Check out this script at 🔗 - Manual - Using `tweet_status` you can write your own status. ``` r x <- carbonate::carbon$new() x$tweet <- TRUE x$carbonate() ``` ##### Post process (Batch) If you have images stored in `x$carbons` you can post them also in a tweet using. ``` r # for multiple png attachments x$rtweet(x$carbons,media_type = 'png') #using default status # subsets of images x$rtweet(status='These are images',x$carbons[c(1,3)],media_type = 'png') # for gifs x$rtweet(status='This is a gif', x$carbons,media_type = 'gif') ```
### Post image processing All carbon outputs are collected and saved in the list `x$carbons`
Combining ``` r x$carbons%>% magick::image_scale('300')%>% magick::image_append() ``` ![](man/figures/unnamed-chunk-28-1.png) ``` r x$carbons%>% magick::image_scale('300')%>% magick::image_append(stack = TRUE) ``` ![](man/figures/unnamed-chunk-28-2.png)
GIFs ``` r x$carbons%>% magick::image_animate(fps = 1) ``` ![](man/figures/unnamed-chunk-29-1.gif)
================================================ FILE: _pkgdown.yml ================================================ hexURL: https://github.com/yonicd/carbonate/blob/master/hextools/hex.gif?raw=true ================================================ FILE: carbonate.Rproj ================================================ Version: 1.0 RestoreWorkspace: No SaveWorkspace: No AlwaysSaveHistory: Default EnableCodeIndexing: Yes UseSpacesForTab: Yes NumSpacesForTab: 2 Encoding: UTF-8 RnwWeave: Sweave LaTeX: pdfLaTeX BuildType: Package PackageUseDevtools: Yes PackageInstallArgs: --no-multiarch --with-keep.source PackageRoxygenize: rd,collate,namespace,vignette QuitChildProcessesOnExit: Yes ================================================ FILE: codecov.yml ================================================ comment: false ================================================ FILE: cran-comments.md ================================================ ## Test environments * local OS X install, R 3.5.1 * ubuntu 12.04 (on travis-ci), R 3.5.1 * win-builder (devel and release) ## R CMD check results 0 errors | 0 warnings | 1 note * This is a new release. ## Reverse dependencies This is a new release, so there are no reverse dependencies. --- * I have run R CMD check on the NUMBER downstream dependencies. (Summary at ...). * FAILURE SUMMARY * All revdep maintainers were notified of the release on RELEASE DATE. ================================================ FILE: docs/404.html ================================================ Page not found (404) • carbonate
Content not found. Please use links in the navbar.

Site built with pkgdown 2.0.6.

================================================ FILE: docs/LICENSE-text.html ================================================ License • carbonate
YEAR: 2018
COPYRIGHT HOLDER: Jonathan Sidi

Site built with pkgdown 2.0.6.

================================================ FILE: docs/PULL_REQUEST_TEMPLATE.html ================================================ NA • carbonate

Hi, thanks for contributing!

Please make sure you read our CONTRIBUTING guide.

Please fill the fields above:

Site built with pkgdown 2.0.6.

================================================ FILE: docs/articles/index.html ================================================ Articles • carbonate

All vignettes

Tests and Coverage

Site built with pkgdown 2.0.6.

================================================ FILE: docs/articles/tests_and_coverage.html ================================================ Tests and Coverage • carbonate

This output is created by covrpage.

Coverage

Coverage summary is created using the covr package.

Object Coverage (%)
carbonate 48.58
R/carbonate.R 0.00
R/selenium_functions.R 0.00
R/uri_functions.R 52.63
R/carbon.R 64.29
R/helpers.R 70.09
R/set_get_functions.R 100.00


Unit Tests

Unit Test summary is created using the testthat package.

file n time error failed skipped warning icon
test-set.R 3 0.013 0 0 0 0
test-uri.R 8 1.352 0 0 1 0 🔶
test-yml.R 6 0.017 0 0 0 0
Show Detailed Test Results
file context test status n time icon
test-set.R set_ set functions: set_template PASS 1 0.011
test-set.R set_ set functions: set_font_family PASS 1 0.001
test-set.R set_ set functions: set_windows_control_theme PASS 1 0.001
test-uri.R uri options: benchmark PASS 1 0.002
test-uri.R uri uri: benchmark PASS 1 0.002
test-uri.R uri uri: 200 PASS 1 0.721
test-uri.R uri encode: encode character PASS 1 0.002
test-uri.R uri encode: no encode character PASS 1 0.001
test-uri.R uri tiny: valid tiny PASS 1 0.620
test-uri.R uri tiny: clipboard SKIPPED 1 0.001 🔶
test-uri.R uri bad template: error uri PASS 1 0.003
test-yml.R yml yaml fields: rgba PASS 1 0.006
test-yml.R yml yaml fields: template PASS 1 0.003
test-yml.R yml yaml fields: bad font family PASS 1 0.002
test-yml.R yml yaml fields: pv PASS 1 0.002
test-yml.R yml yaml fields: ph PASS 1 0.002
test-yml.R yml namesless palette: fill in palette PASS 1 0.002
Failed Warning Skipped
🛑 ⚠️ 🔶
Session Info
Field Value
Version R version 3.5.1 (2018-07-02)
Platform x86_64-apple-darwin15.6.0 (64-bit)
Running macOS 10.14.2
Language en_US
Timezone America/Chicago
Package Version
testthat 2.0.0.9000
covr 3.2.0
covrpage 0.0.69

Site built with pkgdown 2.0.6.

================================================ FILE: docs/authors.html ================================================ Authors and Citation • carbonate
  • Jonathan Sidi. Author, maintainer.

Citation

Source: DESCRIPTION

Sidi J (2022). carbonate: Interact with 'carbon.js'. R package version 0.2.0, https://github.com/yonicd/carbonate.

@Manual{,
  title = {carbonate: Interact with 'carbon.js'},
  author = {Jonathan Sidi},
  year = {2022},
  note = {R package version 0.2.0},
  url = {https://github.com/yonicd/carbonate},
}

Site built with pkgdown 2.0.6.

================================================ FILE: docs/bootstrap-toc.css ================================================ /*! * Bootstrap Table of Contents v0.4.1 (http://afeld.github.io/bootstrap-toc/) * Copyright 2015 Aidan Feldman * Licensed under MIT (https://github.com/afeld/bootstrap-toc/blob/gh-pages/LICENSE.md) */ /* modified from https://github.com/twbs/bootstrap/blob/94b4076dd2efba9af71f0b18d4ee4b163aa9e0dd/docs/assets/css/src/docs.css#L548-L601 */ /* All levels of nav */ nav[data-toggle='toc'] .nav > li > a { display: block; padding: 4px 20px; font-size: 13px; font-weight: 500; color: #767676; } nav[data-toggle='toc'] .nav > li > a:hover, nav[data-toggle='toc'] .nav > li > a:focus { padding-left: 19px; color: #563d7c; text-decoration: none; background-color: transparent; border-left: 1px solid #563d7c; } nav[data-toggle='toc'] .nav > .active > a, nav[data-toggle='toc'] .nav > .active:hover > a, nav[data-toggle='toc'] .nav > .active:focus > a { padding-left: 18px; font-weight: bold; color: #563d7c; background-color: transparent; border-left: 2px solid #563d7c; } /* Nav: second level (shown on .active) */ nav[data-toggle='toc'] .nav .nav { display: none; /* Hide by default, but at >768px, show it */ padding-bottom: 10px; } nav[data-toggle='toc'] .nav .nav > li > a { padding-top: 1px; padding-bottom: 1px; padding-left: 30px; font-size: 12px; font-weight: normal; } nav[data-toggle='toc'] .nav .nav > li > a:hover, nav[data-toggle='toc'] .nav .nav > li > a:focus { padding-left: 29px; } nav[data-toggle='toc'] .nav .nav > .active > a, nav[data-toggle='toc'] .nav .nav > .active:hover > a, nav[data-toggle='toc'] .nav .nav > .active:focus > a { padding-left: 28px; font-weight: 500; } /* from https://github.com/twbs/bootstrap/blob/e38f066d8c203c3e032da0ff23cd2d6098ee2dd6/docs/assets/css/src/docs.css#L631-L634 */ nav[data-toggle='toc'] .nav > .active > ul { display: block; } ================================================ FILE: docs/bootstrap-toc.js ================================================ /*! * Bootstrap Table of Contents v0.4.1 (http://afeld.github.io/bootstrap-toc/) * Copyright 2015 Aidan Feldman * Licensed under MIT (https://github.com/afeld/bootstrap-toc/blob/gh-pages/LICENSE.md) */ (function() { 'use strict'; window.Toc = { helpers: { // return all matching elements in the set, or their descendants findOrFilter: function($el, selector) { // http://danielnouri.org/notes/2011/03/14/a-jquery-find-that-also-finds-the-root-element/ // http://stackoverflow.com/a/12731439/358804 var $descendants = $el.find(selector); return $el.filter(selector).add($descendants).filter(':not([data-toc-skip])'); }, generateUniqueIdBase: function(el) { var text = $(el).text(); var anchor = text.trim().toLowerCase().replace(/[^A-Za-z0-9]+/g, '-'); return anchor || el.tagName.toLowerCase(); }, generateUniqueId: function(el) { var anchorBase = this.generateUniqueIdBase(el); for (var i = 0; ; i++) { var anchor = anchorBase; if (i > 0) { // add suffix anchor += '-' + i; } // check if ID already exists if (!document.getElementById(anchor)) { return anchor; } } }, generateAnchor: function(el) { if (el.id) { return el.id; } else { var anchor = this.generateUniqueId(el); el.id = anchor; return anchor; } }, createNavList: function() { return $(''); }, createChildNavList: function($parent) { var $childList = this.createNavList(); $parent.append($childList); return $childList; }, generateNavEl: function(anchor, text) { var $a = $(''); $a.attr('href', '#' + anchor); $a.text(text); var $li = $('
  • '); $li.append($a); return $li; }, generateNavItem: function(headingEl) { var anchor = this.generateAnchor(headingEl); var $heading = $(headingEl); var text = $heading.data('toc-text') || $heading.text(); return this.generateNavEl(anchor, text); }, // Find the first heading level (`

    `, then `

    `, etc.) that has more than one element. Defaults to 1 (for `

    `). getTopLevel: function($scope) { for (var i = 1; i <= 6; i++) { var $headings = this.findOrFilter($scope, 'h' + i); if ($headings.length > 1) { return i; } } return 1; }, // returns the elements for the top level, and the next below it getHeadings: function($scope, topLevel) { var topSelector = 'h' + topLevel; var secondaryLevel = topLevel + 1; var secondarySelector = 'h' + secondaryLevel; return this.findOrFilter($scope, topSelector + ',' + secondarySelector); }, getNavLevel: function(el) { return parseInt(el.tagName.charAt(1), 10); }, populateNav: function($topContext, topLevel, $headings) { var $context = $topContext; var $prevNav; var helpers = this; $headings.each(function(i, el) { var $newNav = helpers.generateNavItem(el); var navLevel = helpers.getNavLevel(el); // determine the proper $context if (navLevel === topLevel) { // use top level $context = $topContext; } else if ($prevNav && $context === $topContext) { // create a new level of the tree and switch to it $context = helpers.createChildNavList($prevNav); } // else use the current $context $context.append($newNav); $prevNav = $newNav; }); }, parseOps: function(arg) { var opts; if (arg.jquery) { opts = { $nav: arg }; } else { opts = arg; } opts.$scope = opts.$scope || $(document.body); return opts; } }, // accepts a jQuery object, or an options object init: function(opts) { opts = this.helpers.parseOps(opts); // ensure that the data attribute is in place for styling opts.$nav.attr('data-toggle', 'toc'); var $topContext = this.helpers.createChildNavList(opts.$nav); var topLevel = this.helpers.getTopLevel(opts.$scope); var $headings = this.helpers.getHeadings(opts.$scope, topLevel); this.helpers.populateNav($topContext, topLevel, $headings); } }; $(function() { $('nav[data-toggle="toc"]').each(function(i, el) { var $nav = $(el); Toc.init($nav); }); }); })(); ================================================ FILE: docs/docsearch.css ================================================ /* Docsearch -------------------------------------------------------------- */ /* Source: https://github.com/algolia/docsearch/ License: MIT */ .algolia-autocomplete { display: block; -webkit-box-flex: 1; -ms-flex: 1; flex: 1 } .algolia-autocomplete .ds-dropdown-menu { width: 100%; min-width: none; max-width: none; padding: .75rem 0; background-color: #fff; background-clip: padding-box; border: 1px solid rgba(0, 0, 0, .1); box-shadow: 0 .5rem 1rem rgba(0, 0, 0, .175); } @media (min-width:768px) { .algolia-autocomplete .ds-dropdown-menu { width: 175% } } .algolia-autocomplete .ds-dropdown-menu::before { display: none } .algolia-autocomplete .ds-dropdown-menu [class^=ds-dataset-] { padding: 0; background-color: rgb(255,255,255); border: 0; max-height: 80vh; } .algolia-autocomplete .ds-dropdown-menu .ds-suggestions { margin-top: 0 } .algolia-autocomplete .algolia-docsearch-suggestion { padding: 0; overflow: visible } .algolia-autocomplete .algolia-docsearch-suggestion--category-header { padding: .125rem 1rem; margin-top: 0; font-size: 1.3em; font-weight: 500; color: #00008B; border-bottom: 0 } .algolia-autocomplete .algolia-docsearch-suggestion--wrapper { float: none; padding-top: 0 } .algolia-autocomplete .algolia-docsearch-suggestion--subcategory-column { float: none; width: auto; padding: 0; text-align: left } .algolia-autocomplete .algolia-docsearch-suggestion--content { float: none; width: auto; padding: 0 } .algolia-autocomplete .algolia-docsearch-suggestion--content::before { display: none } .algolia-autocomplete .ds-suggestion:not(:first-child) .algolia-docsearch-suggestion--category-header { padding-top: .75rem; margin-top: .75rem; border-top: 1px solid rgba(0, 0, 0, .1) } .algolia-autocomplete .ds-suggestion .algolia-docsearch-suggestion--subcategory-column { display: block; padding: .1rem 1rem; margin-bottom: 0.1; font-size: 1.0em; font-weight: 400 /* display: none */ } .algolia-autocomplete .algolia-docsearch-suggestion--title { display: block; padding: .25rem 1rem; margin-bottom: 0; font-size: 0.9em; font-weight: 400 } .algolia-autocomplete .algolia-docsearch-suggestion--text { padding: 0 1rem .5rem; margin-top: -.25rem; font-size: 0.8em; font-weight: 400; line-height: 1.25 } .algolia-autocomplete .algolia-docsearch-footer { width: 110px; height: 20px; z-index: 3; margin-top: 10.66667px; float: right; font-size: 0; line-height: 0; } .algolia-autocomplete .algolia-docsearch-footer--logo { background-image: url("data:image/svg+xml;utf8,"); background-repeat: no-repeat; background-position: 50%; background-size: 100%; overflow: hidden; text-indent: -9000px; width: 100%; height: 100%; display: block; transform: translate(-8px); } .algolia-autocomplete .algolia-docsearch-suggestion--highlight { color: #FF8C00; background: rgba(232, 189, 54, 0.1) } .algolia-autocomplete .algolia-docsearch-suggestion--text .algolia-docsearch-suggestion--highlight { box-shadow: inset 0 -2px 0 0 rgba(105, 105, 105, .5) } .algolia-autocomplete .ds-suggestion.ds-cursor .algolia-docsearch-suggestion--content { background-color: rgba(192, 192, 192, .15) } ================================================ FILE: docs/docsearch.js ================================================ $(function() { // register a handler to move the focus to the search bar // upon pressing shift + "/" (i.e. "?") $(document).on('keydown', function(e) { if (e.shiftKey && e.keyCode == 191) { e.preventDefault(); $("#search-input").focus(); } }); $(document).ready(function() { // do keyword highlighting /* modified from https://jsfiddle.net/julmot/bL6bb5oo/ */ var mark = function() { var referrer = document.URL ; var paramKey = "q" ; if (referrer.indexOf("?") !== -1) { var qs = referrer.substr(referrer.indexOf('?') + 1); var qs_noanchor = qs.split('#')[0]; var qsa = qs_noanchor.split('&'); var keyword = ""; for (var i = 0; i < qsa.length; i++) { var currentParam = qsa[i].split('='); if (currentParam.length !== 2) { continue; } if (currentParam[0] == paramKey) { keyword = decodeURIComponent(currentParam[1].replace(/\+/g, "%20")); } } if (keyword !== "") { $(".contents").unmark({ done: function() { $(".contents").mark(keyword); } }); } } }; mark(); }); }); /* Search term highlighting ------------------------------*/ function matchedWords(hit) { var words = []; var hierarchy = hit._highlightResult.hierarchy; // loop to fetch from lvl0, lvl1, etc. for (var idx in hierarchy) { words = words.concat(hierarchy[idx].matchedWords); } var content = hit._highlightResult.content; if (content) { words = words.concat(content.matchedWords); } // return unique words var words_uniq = [...new Set(words)]; return words_uniq; } function updateHitURL(hit) { var words = matchedWords(hit); var url = ""; if (hit.anchor) { url = hit.url_without_anchor + '?q=' + escape(words.join(" ")) + '#' + hit.anchor; } else { url = hit.url + '?q=' + escape(words.join(" ")); } return url; } ================================================ FILE: docs/index.html ================================================ Interact with carbon.js • carbonate

    carbon.js is the easiest way to create beautiful images of your source code.”

    This package uses an R6 api to interact with carbon.js and create directly from the console carbon images.

    Like the image below:

    Installation

    #remotes::install_github('yonicd/carbonate')
    install.packages('carbonate')

    Usage

    Initialize new carbon object

    The default code in the carbon object is taken from the clipboard.

    x <- carbon$new()

    But can also be defined inline. Code can be a character object of any length.

    x <- carbon$new(readLines('DESCRIPTION'))

    The code is kept in the object and can be changed at any time.

    x$code
    #>  [1] "Package: carbonate"                                        
    #>  [2] "Title: Interact with 'carbon.js'"                          
    #>  [3] "Version: 0.2.0"                                            
    #>  [4] "Authors@R: "                                               
    #>  [5] "    person(given = \"Jonathan\","                          
    #>  [6] "           family = \"Sidi\","                             
    #>  [7] "           role = c(\"aut\", \"cre\"),"                    
    #>  [8] "           email = \"yonicd@gmail.com\","                  
    #>  [9] "           comment = c(ORCID = \"0000-0002-4222-1819\"))"  
    #> [10] "Description: Create beautiful images of source code using" 
    #> [11] "    'carbon.js'<https://carbon.now.sh/about>."             
    #> [12] "License: MIT + file LICENSE"                               
    #> [13] "URL: https://github.com/yonicd/carbonate"                  
    #> [14] "BugReports: https://github.com/yonicd/carbonate/issues"    
    #> [15] "Depends: "                                                 
    #> [16] "    R (>= 3.2.0)"                                          
    #> [17] "Imports: "                                                 
    #> [18] "    clipr,"                                                
    #> [19] "    details,"                                              
    #> [20] "    httpuv,"                                               
    #> [21] "    httr,"                                                 
    #> [22] "    magick,"                                               
    #> [23] "    R6,"                                                   
    #> [24] "    reprex,"                                               
    #> [25] "    RSelenium,"                                            
    #> [26] "    rtweet,"                                               
    #> [27] "    utils,"                                                
    #> [28] "    wdman,"                                                
    #> [29] "    jsonlite,"                                             
    #> [30] "    yaml"                                                  
    #> [31] "Suggests: "                                                
    #> [32] "    covr,"                                                 
    #> [33] "    knitr,"                                                
    #> [34] "    rmarkdown,"                                            
    #> [35] "    testthat"                                              
    #> [36] "VignetteBuilder: "                                         
    #> [37] "    knitr"                                                 
    #> [38] "RdMacros: "                                                
    #> [39] "    details"                                               
    #> [40] "Encoding: UTF-8"                                           
    #> [41] "LazyData: true"                                            
    #> [42] "Roxygen: list(markdown = TRUE,old_usage = TRUE,r6 = FALSE)"
    #> [43] "RoxygenNote: 7.2.1"

    The main job of the R6 object is to convert all the options into a uri that is sent to the carbon url page, where it is processed.

    x$uri()
    #> [1] "https://carbon.now.sh/?bg=rgba(171%2C175%2C195%2C0.7)&t=panda-syntax&wt=none&l=r&ds=true&dsyoff=20px&dsblur=68px&wc=true&wa=true&pv=11px&ph=14px&ln=false&fm=Fira%20Code&fs=14px&lh=133%25&si=false&es=1x&wm=false&ts=false&code=Package%253A%2520carbonate%250ATitle%253A%2520Interact%2520with%2520%27carbon.js%27%250AVersion%253A%25200.2.0%250AAuthors%2540R%253A%2520%250A%2520%2520%2520%2520person(given%2520%253D%2520%2522Jonathan%2522%252C%250A%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520family%2520%253D%2520%2522Sidi%2522%252C%250A%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520role%2520%253D%2520c(%2522aut%2522%252C%2520%2522cre%2522)%252C%250A%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520email%2520%253D%2520%2522yonicd%2540gmail.com%2522%252C%250A%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520comment%2520%253D%2520c(ORCID%2520%253D%2520%25220000-0002-4222-1819%2522))%250ADescription%253A%2520Create%2520beautiful%2520images%2520of%2520source%2520code%2520using%250A%2520%2520%2520%2520%27carbon.js%27%253Chttps%253A%252F%252Fcarbon.now.sh%252Fabout%253E.%250ALicense%253A%2520MIT%2520%252B%2520file%2520LICENSE%250AURL%253A%2520https%253A%252F%252Fgithub.com%252Fyonicd%252Fcarbonate%250ABugReports%253A%2520https%253A%252F%252Fgithub.com%252Fyonicd%252Fcarbonate%252Fissues%250ADepends%253A%2520%250A%2520%2520%2520%2520R%2520(%253E%253D%25203.2.0)%250AImports%253A%2520%250A%2520%2520%2520%2520clipr%252C%250A%2520%2520%2520%2520details%252C%250A%2520%2520%2520%2520httpuv%252C%250A%2520%2520%2520%2520httr%252C%250A%2520%2520%2520%2520magick%252C%250A%2520%2520%2520%2520R6%252C%250A%2520%2520%2520%2520reprex%252C%250A%2520%2520%2520%2520RSelenium%252C%250A%2520%2520%2520%2520rtweet%252C%250A%2520%2520%2520%2520utils%252C%250A%2520%2520%2520%2520wdman%252C%250A%2520%2520%2520%2520jsonlite%252C%250A%2520%2520%2520%2520yaml%250ASuggests%253A%2520%250A%2520%2520%2520%2520covr%252C%250A%2520%2520%2520%2520knitr%252C%250A%2520%2520%2520%2520rmarkdown%252C%250A%2520%2520%2520%2520testthat%250AVignetteBuilder%253A%2520%250A%2520%2520%2520%2520knitr%250ARdMacros%253A%2520%250A%2520%2520%2520%2520details%250AEncoding%253A%2520UTF-8%250ALazyData%253A%2520true%250ARoxygen%253A%2520list(markdown%2520%253D%2520TRUE%252Cold_usage%2520%253D%2520TRUE%252Cr6%2520%253D%2520FALSE)%250ARoxygenNote%253A%25207.2.1"

    Click the link to see the URI works.

    Manipulate carbon object

    Aesthetics of the carbon object that can be manipulated

    Carbon Variable Carbonate Variable Description Default
    l language language r
    bg palette layout pallete (vector with c(r,g,b,a) c(r=171,g=184,b=195,a=1)
    t template layout template (listed in get_templates()) ‘seti’
    wc add_window_control add/remove window controls (circles on top left corner) TRUE
    wt window_control_theme change window control themes (listed in get_windows_control_themes()) ‘none’
    ds add_drop_shadow add/remove dropshadow TRUE
    dsyoff drop_shadow_offset_y shadow vertical offset (px) 20
    dsblur drop_shadow_blur_radius shadow blur radius (px) 68
    wa auto_adjust_width auto-audjust output width TRUE
    pv padding_vertical vertical padding (px) 48
    ph padding_horizontal horizontal padding (px) 32
    ln add_line_number add/remove line numbers FALSE
    fm font_family layout font family (listed in get_font_families()) ‘Hack’
    fs font_size font size (px) 14
    lh line_height_percent relative space between lines (percent) 133
    si square_image output image is square FALSE
    es relative_export_size image size in export relative to what is in the preview (1,2 or 4) 1
    wm add_watermark add official carbon.js watermark FALSE
    x$get_templates()
    #>  [1] "3024-night"       "a11y-dark"        "blackboard"      
    #>  [4] "base16-dark"      "base16-light"     "cobalt"          
    #>  [7] "dracula"          "duotone-dark"     "hopscotch"       
    #> [10] "lucario"          "material"         "monokai"         
    #> [13] "night-owl"        "nord"             "oceanic-next"    
    #> [16] "one-light"        "one-dark"         "panda-syntax"    
    #> [19] "paraiso-dark"     "seti"             "shades-of-purple"
    #> [22] "solarized dark"   "solarized light"  "synthwave-84"    
    #> [25] "twilight"         "verminal"         "vscode"          
    #> [28] "yeti"             "zenburn"
    x$get_font_families()
    #>  [1] "Anonymous Pro"       "Cascadia Code"       "Droid Sans Mono"    
    #>  [4] "Fantasque Sans Mono" "Fira Code"           "Hack"               
    #>  [7] "IBM Plex Mono"       "Inconsolata"         "JetBrains Mono"     
    #> [10] "Monoid"              "Source Code Pro"     "Space Mono"         
    #> [13] "Ubuntu Mono"
    x$get_windows_control_themes()
    #> [1] "none"  "sharp" "bw"

    Personal Configuration

    Users can use a file called carbon.yml and place it in their home directory (~) to override the packages defaults in order to create a session peristent carbon template they like. The config file controls all the public carbon object fields. The following is an example of such a configuration file.

    These fields will set

    • The palette (rgba) g and a fields to 175 and 0.7 respectively
    • The template will be set to panda-syntax
    • The font to Fira Code
    • The padding around the output will be made tighter than the system defaults 11px and 14px.
    palette:
    - g: 175.0
    - a: 0.7
    template: panda-syntax
    font_family: Fira Code
    padding_vertical: 11
    padding_horizontal: 14

    Open carbon code in browser

    x$browse()

    Set the download directory

    x$download_path <- file.path('README_files/download')

    Carbonate code directly to file

    This function depends on RSelenium

    x$carbonate(file = 'myfile.png')

    x$template <-'cobalt'
    x$carbonate(file = 'new_template.png')

    x$font_family <-'IBM Plex Mono'
    x$carbonate(file = 'new_font.png')

    Carbonate code directly to file in specific directory

    Closing Browsers

    Closing all instances of open browsers used by RSelenium.

    x$stop_all()

    Sharing

    Tinyurl

    You can also put a tinyurl link as a watermark on the image produced that will open to the carbon.now.sh page that has the code in the image.

    x$add_tinyurl <- TRUE
    x$carbonate(file = 'tiny_url.png')

    If you just want the tinyurl link without the image to use in a tweet you can create it using

    x$tiny()
    #> [1] "https://tinyurl.com/2kvjyzlx"

    Or you can put the link directly on your clipboard

    x$tiny(clip = TRUE)
    #> [1] "https://tinyurl.com/2kvjyzlx"
    clipr::read_clip()
    #> [1] "https://tinyurl.com/2kvjyzlx"
    Twitter
    Direct

    You can also directly tweet the image. An automatic status is created with two options

    • Default
      • Created in R using the Carbonate 📦
    • When add_tinyurl <- TRUE
    • Manual
      • Using tweet_status you can write your own status.
    x <- carbonate::carbon$new()
    x$tweet <- TRUE
    x$carbonate()
    Post process (Batch)

    If you have images stored in x$carbons you can post them also in a tweet using.

    # for multiple png attachments
    x$rtweet(x$carbons,media_type = 'png') #using default status
    
    # subsets of images
    x$rtweet(status='These are images',x$carbons[c(1,3)],media_type = 'png')
    
    # for gifs
    x$rtweet(status='This is a gif', x$carbons,media_type = 'gif')

    Post image processing

    All carbon outputs are collected and saved in the list x$carbons

    Combining
    x$carbons%>%
      magick::image_scale('300')%>%
      magick::image_append()

    
    x$carbons%>%
      magick::image_scale('300')%>%
      magick::image_append(stack = TRUE)

    GIFs
    x$carbons%>%
      magick::image_animate(fps = 1)

    Site built with pkgdown 2.0.6.

    ================================================ FILE: docs/pkgdown.css ================================================ /* Sticky footer */ /** * Basic idea: https://philipwalton.github.io/solved-by-flexbox/demos/sticky-footer/ * Details: https://github.com/philipwalton/solved-by-flexbox/blob/master/assets/css/components/site.css * * .Site -> body > .container * .Site-content -> body > .container .row * .footer -> footer * * Key idea seems to be to ensure that .container and __all its parents__ * have height set to 100% * */ html, body { height: 100%; } body { position: relative; } body > .container { display: flex; height: 100%; flex-direction: column; } body > .container .row { flex: 1 0 auto; } footer { margin-top: 45px; padding: 35px 0 36px; border-top: 1px solid #e5e5e5; color: #666; display: flex; flex-shrink: 0; } footer p { margin-bottom: 0; } footer div { flex: 1; } footer .pkgdown { text-align: right; } footer p { margin-bottom: 0; } img.icon { float: right; } /* Ensure in-page images don't run outside their container */ .contents img { max-width: 100%; height: auto; } /* Fix bug in bootstrap (only seen in firefox) */ summary { display: list-item; } /* Typographic tweaking ---------------------------------*/ .contents .page-header { margin-top: calc(-60px + 1em); } dd { margin-left: 3em; } /* Section anchors ---------------------------------*/ a.anchor { display: none; margin-left: 5px; width: 20px; height: 20px; background-image: url(./link.svg); background-repeat: no-repeat; background-size: 20px 20px; background-position: center center; } h1:hover .anchor, h2:hover .anchor, h3:hover .anchor, h4:hover .anchor, h5:hover .anchor, h6:hover .anchor { display: inline-block; } /* Fixes for fixed navbar --------------------------*/ .contents h1, .contents h2, .contents h3, .contents h4 { padding-top: 60px; margin-top: -40px; } /* Navbar submenu --------------------------*/ .dropdown-submenu { position: relative; } .dropdown-submenu>.dropdown-menu { top: 0; left: 100%; margin-top: -6px; margin-left: -1px; border-radius: 0 6px 6px 6px; } .dropdown-submenu:hover>.dropdown-menu { display: block; } .dropdown-submenu>a:after { display: block; content: " "; float: right; width: 0; height: 0; border-color: transparent; border-style: solid; border-width: 5px 0 5px 5px; border-left-color: #cccccc; margin-top: 5px; margin-right: -10px; } .dropdown-submenu:hover>a:after { border-left-color: #ffffff; } .dropdown-submenu.pull-left { float: none; } .dropdown-submenu.pull-left>.dropdown-menu { left: -100%; margin-left: 10px; border-radius: 6px 0 6px 6px; } /* Sidebar --------------------------*/ #pkgdown-sidebar { margin-top: 30px; position: -webkit-sticky; position: sticky; top: 70px; } #pkgdown-sidebar h2 { font-size: 1.5em; margin-top: 1em; } #pkgdown-sidebar h2:first-child { margin-top: 0; } #pkgdown-sidebar .list-unstyled li { margin-bottom: 0.5em; } /* bootstrap-toc tweaks ------------------------------------------------------*/ /* All levels of nav */ nav[data-toggle='toc'] .nav > li > a { padding: 4px 20px 4px 6px; font-size: 1.5rem; font-weight: 400; color: inherit; } nav[data-toggle='toc'] .nav > li > a:hover, nav[data-toggle='toc'] .nav > li > a:focus { padding-left: 5px; color: inherit; border-left: 1px solid #878787; } nav[data-toggle='toc'] .nav > .active > a, nav[data-toggle='toc'] .nav > .active:hover > a, nav[data-toggle='toc'] .nav > .active:focus > a { padding-left: 5px; font-size: 1.5rem; font-weight: 400; color: inherit; border-left: 2px solid #878787; } /* Nav: second level (shown on .active) */ nav[data-toggle='toc'] .nav .nav { display: none; /* Hide by default, but at >768px, show it */ padding-bottom: 10px; } nav[data-toggle='toc'] .nav .nav > li > a { padding-left: 16px; font-size: 1.35rem; } nav[data-toggle='toc'] .nav .nav > li > a:hover, nav[data-toggle='toc'] .nav .nav > li > a:focus { padding-left: 15px; } nav[data-toggle='toc'] .nav .nav > .active > a, nav[data-toggle='toc'] .nav .nav > .active:hover > a, nav[data-toggle='toc'] .nav .nav > .active:focus > a { padding-left: 15px; font-weight: 500; font-size: 1.35rem; } /* orcid ------------------------------------------------------------------- */ .orcid { font-size: 16px; color: #A6CE39; /* margins are required by official ORCID trademark and display guidelines */ margin-left:4px; margin-right:4px; vertical-align: middle; } /* Reference index & topics ----------------------------------------------- */ .ref-index th {font-weight: normal;} .ref-index td {vertical-align: top; min-width: 100px} .ref-index .icon {width: 40px;} .ref-index .alias {width: 40%;} .ref-index-icons .alias {width: calc(40% - 40px);} .ref-index .title {width: 60%;} .ref-arguments th {text-align: right; padding-right: 10px;} .ref-arguments th, .ref-arguments td {vertical-align: top; min-width: 100px} .ref-arguments .name {width: 20%;} .ref-arguments .desc {width: 80%;} /* Nice scrolling for wide elements --------------------------------------- */ table { display: block; overflow: auto; } /* Syntax highlighting ---------------------------------------------------- */ pre, code, pre code { background-color: #f8f8f8; color: #333; } pre, pre code { white-space: pre-wrap; word-break: break-all; overflow-wrap: break-word; } pre { border: 1px solid #eee; } pre .img, pre .r-plt { margin: 5px 0; } pre .img img, pre .r-plt img { background-color: #fff; } code a, pre a { color: #375f84; } a.sourceLine:hover { text-decoration: none; } .fl {color: #1514b5;} .fu {color: #000000;} /* function */ .ch,.st {color: #036a07;} /* string */ .kw {color: #264D66;} /* keyword */ .co {color: #888888;} /* comment */ .error {font-weight: bolder;} .warning {font-weight: bolder;} /* Clipboard --------------------------*/ .hasCopyButton { position: relative; } .btn-copy-ex { position: absolute; right: 0; top: 0; visibility: hidden; } .hasCopyButton:hover button.btn-copy-ex { visibility: visible; } /* headroom.js ------------------------ */ .headroom { will-change: transform; transition: transform 200ms linear; } .headroom--pinned { transform: translateY(0%); } .headroom--unpinned { transform: translateY(-100%); } /* mark.js ----------------------------*/ mark { background-color: rgba(255, 255, 51, 0.5); border-bottom: 2px solid rgba(255, 153, 51, 0.3); padding: 1px; } /* vertical spacing after htmlwidgets */ .html-widget { margin-bottom: 10px; } /* fontawesome ------------------------ */ .fab { font-family: "Font Awesome 5 Brands" !important; } /* don't display links in code chunks when printing */ /* source: https://stackoverflow.com/a/10781533 */ @media print { code a:link:after, code a:visited:after { content: ""; } } /* Section anchors --------------------------------- Added in pandoc 2.11: https://github.com/jgm/pandoc-templates/commit/9904bf71 */ div.csl-bib-body { } div.csl-entry { clear: both; } .hanging-indent div.csl-entry { margin-left:2em; text-indent:-2em; } div.csl-left-margin { min-width:2em; float:left; } div.csl-right-inline { margin-left:2em; padding-left:1em; } div.csl-indent { margin-left: 2em; } ================================================ FILE: docs/pkgdown.js ================================================ /* http://gregfranko.com/blog/jquery-best-practices/ */ (function($) { $(function() { $('.navbar-fixed-top').headroom(); $('body').css('padding-top', $('.navbar').height() + 10); $(window).resize(function(){ $('body').css('padding-top', $('.navbar').height() + 10); }); $('[data-toggle="tooltip"]').tooltip(); var cur_path = paths(location.pathname); var links = $("#navbar ul li a"); var max_length = -1; var pos = -1; for (var i = 0; i < links.length; i++) { if (links[i].getAttribute("href") === "#") continue; // Ignore external links if (links[i].host !== location.host) continue; var nav_path = paths(links[i].pathname); var length = prefix_length(nav_path, cur_path); if (length > max_length) { max_length = length; pos = i; } } // Add class to parent
  • , and enclosing
  • if in dropdown if (pos >= 0) { var menu_anchor = $(links[pos]); menu_anchor.parent().addClass("active"); menu_anchor.closest("li.dropdown").addClass("active"); } }); function paths(pathname) { var pieces = pathname.split("/"); pieces.shift(); // always starts with / var end = pieces[pieces.length - 1]; if (end === "index.html" || end === "") pieces.pop(); return(pieces); } // Returns -1 if not found function prefix_length(needle, haystack) { if (needle.length > haystack.length) return(-1); // Special case for length-0 haystack, since for loop won't run if (haystack.length === 0) { return(needle.length === 0 ? 0 : -1); } for (var i = 0; i < haystack.length; i++) { if (needle[i] != haystack[i]) return(i); } return(haystack.length); } /* Clipboard --------------------------*/ function changeTooltipMessage(element, msg) { var tooltipOriginalTitle=element.getAttribute('data-original-title'); element.setAttribute('data-original-title', msg); $(element).tooltip('show'); element.setAttribute('data-original-title', tooltipOriginalTitle); } if(ClipboardJS.isSupported()) { $(document).ready(function() { var copyButton = ""; $("div.sourceCode").addClass("hasCopyButton"); // Insert copy buttons: $(copyButton).prependTo(".hasCopyButton"); // Initialize tooltips: $('.btn-copy-ex').tooltip({container: 'body'}); // Initialize clipboard: var clipboardBtnCopies = new ClipboardJS('[data-clipboard-copy]', { text: function(trigger) { return trigger.parentNode.textContent.replace(/\n#>[^\n]*/g, ""); } }); clipboardBtnCopies.on('success', function(e) { changeTooltipMessage(e.trigger, 'Copied!'); e.clearSelection(); }); clipboardBtnCopies.on('error', function() { changeTooltipMessage(e.trigger,'Press Ctrl+C or Command+C to copy'); }); }); } })(window.jQuery || window.$) ================================================ FILE: docs/pkgdown.yml ================================================ pandoc: '2.18' pkgdown: 2.0.6 pkgdown_sha: ~ articles: tests_and_coverage: tests_and_coverage.html last_built: 2022-08-22T01:06Z ================================================ FILE: docs/reference/browse.html ================================================ open $uri to in browser window — .browse • carbonate

    opens the uri address in $uri in the browser window.

    .browse(self, private)

    Arguments

    self

    carbon self object

    private

    carbon private object

    See also

    Examples

    x <- carbon$new('x <- 1')
    #> Set via '~/carbon.yml'
    #> palette:
    #> - 171.0
    #> - 175.0
    #> - 195.0
    #> - 0.7
    #> template: panda-syntax
    #> font_family: Fira Code
    #> padding_vertical: 11
    #> padding_horizontal: 14
    #> language: r
    if(interactive())
     x$browse()
    
    

    Site built with pkgdown 2.0.6.

    ================================================ FILE: docs/reference/carbon.html ================================================ Carbon R6 class — carbon • carbonate

    The Carbon generator creates a new Carbon-object, which is the class containing all the app logic. The class is based on the R6 OO-system and is thus reference-based with methods and data attached to each object, in contrast to the more well known S3 and S4 systems.

    Initialization

    A new 'Carbon'-object is initialized using the new() method on the generator:

    x <- carbon$new(code = clipr::read_clip())

    Fields


    Public Fields

    Description of fields of the R6 object that can be set by the user can be found in the following page.

    Methods


    Interacting with Browser

    $carbonateUsing RSelenium fetch the carbon image output
    $browseopen $uri in the browser


    Aesthetics

    $set_templateset $template
    $get_templatesget a list of possible templates
    $set_window_control_themeset $windows_control_theme
    $get_windows_control_themesget a list of possible window control themes
    $set_font_familyset $font_family
    $get_font_familiesget a list of possible fonts


    URI Building

    $uriconstruct valid carbon.js uri
    $optionsreturn all current carbon options
    $encodeURL encode a string for the $uri
    $tinyCreate tinyurl from $uri
    $rtweetSend tweets containing media generated from carbon


    Webdriver Settings

    $chromeOptionsconstruct a chromeOptions object
    $chrome_startstart a chrome session
    $chrome_stopstop a chrome session
    $startstart a RSelenium session
    $stopstop a RSelenium session
    $stop_allstop all active RSelenium sessions
    $get_portGet active port
    $set_portSet new port

    Site built with pkgdown 2.0.6.

    ================================================ FILE: docs/reference/carbon_chrome.html ================================================ chrome webdriver functions — .chromeOptions • carbonate

    Functions to open,close,set chrome webdriver

    .chromeOptions(self, private)

    Arguments

    self

    carbon self object

    private

    carbon private object

    See also

    Site built with pkgdown 2.0.6.

    ================================================ FILE: docs/reference/carbon_fields.html ================================================ Carbon object fields — carbon_fields • carbonate

    Fields that can be changed in the Carbon object

    Arguments

    code

    character, script to embbed, Default: NULL

    palette

    numeric, layout pallete, Default: c(r=171,g=184,b=195,a=1)

    template

    character, layout template, Default: 'seti'

    add_window_control

    boolean, add/remove window controls (circles on top left corner), Default: TRUE

    window_control_theme

    character, change window control themes, Default: 'none'

    language

    character, language, Default: 'r'

    add_drop_shadow

    boolean, add/remove dropshadow, Default: TRUE

    drop_shadow_offset_y

    numeric, shadow vertical offset (px), Default: 20

    drop_shadow_blur_radius

    numeric, shadow blur radius (px), Default: 68

    auto_adjust_width

    boolean, auto-audjust output width, Default: TRUE

    padding_vertical

    numeric, vertical padding (px), Default: 48

    padding_horizontal

    numeric, horizontal padding (px), Default: 32

    add_line_number

    boolean, add/remove line numbers, Default: FALSE

    font_family

    character, layout font family, Default: 'Hack'

    font_size

    numeric, font size (px), Default: 14

    line_height_percent

    numeric, relative space between lines (percent), Default: 133

    square_image

    boolean, output image is square, Default: FALSE

    relative_export_size

    numeric, image size in export relative to what is in the preview (1,2 or 4), Default: 1

    add_watermark

    boolean, add official carbon.js watermark, Default: FALSE

    add_tinyurl

    boolean, add tinyurl link to image directing to the carbon page that created the image, Default: FALSE

    tinyurl_location

    character, string with gravity value to place the annotate tinyurl address on image, Default: 'southeast'

    tweet

    boolean, tweet out the image using post_tweet

    tweet_status

    character, status to add to the tweet. If add_tinyurl is TRUE then a link to the url will be appended to the status automatically, Default: 'Created in R using the Carbonate (Package Icon)'

    add_timestamp

    boolean, add timestamp to output filename, Default: FALSE

    carbons

    list, storage of rendered carbon images, Default: NULL

    download_path

    character, path to download the images, Default: tempdir()

    chrome_args

    character, arguments passed to chrome browser, Default: c('--disable-gpu', '--window-size=1280,800')

    chrome_pref

    list, preferences passed to chrome browser, Default: list("profile.default_content_settings.popups" = 0L,"download.prompt_for_download" = FALSE,"download.default_directory" = tempdir())

    rD

    RSelenium Driver object

    cDrv

    Chrome Driver object from wdman

    See also

    Site built with pkgdown 2.0.6.

    ================================================ FILE: docs/reference/carbon_gecko.html ================================================ gecko webdriver functions — .firefoxOptions • carbonate

    Functions to open,close,set gecko webdriver

    .firefoxOptions(self, private)

    Arguments

    self

    carbon self object

    private

    carbon private object

    See also

    Site built with pkgdown 2.0.6.

    ================================================ FILE: docs/reference/carbon_selenium.html ================================================ RSelenium webdriver functions — .start • carbonate

    Functions to open,stop, stop_all RSelenium sessions

    .start(self, private, eCap, driver = c("firefox", "chrome"))
    
    .driver_start(self, private, driver = c("chrome", "firefox"))
    
    .driver_stop(self, private)
    
    .stop(self, private)
    
    .stop_all(self, private)
    
    .set_port(self, private, port = NULL)
    
    .get_port(self, private)

    Arguments

    self

    carbon self object

    private

    carbon private object

    eCap

    chromeOptions passed into rsDriver

    driver

    character, select either 'firefox' or 'chrome' driver

    port

    integer, port for the rsDriver to use, if NULL then a random port is selected

    See also

    Site built with pkgdown 2.0.6.

    ================================================ FILE: docs/reference/carbonate.html ================================================ Carbonate script lines to a carbon image — .carbonate • carbonate

    Main function of the package that invokes RSelenium to open a browser to the carbon.js uri, create an image and download the file.

    .carbonate(self, private, file, path, code, rD, driver)

    Arguments

    self

    carbon self object

    private

    carbon private object

    file

    character, name of file to save image as

    path

    character, path to save the image

    code

    character, lines of script to make carbon image from

    rD

    RSelenium driver

    driver

    character, select either 'firefox' or 'chrome' driver

    Value

    image object

    Details

    Script is passed to https://carbon.now.sh/ is downloaded to the tempdir() and appended to the list $carbons using RSelenium and Chrome.

    See also

    Examples

    if(interactive()){
     x <- carbon$new('x <- 1')
     x$carbonate()
     }
    

    Site built with pkgdown 2.0.6.

    ================================================ FILE: docs/reference/encode.html ================================================ encode uri for carbon.js — .encode • carbonate

    encode uri string for carbon.js. Augmented version of than URLencode

    .encode(self, private, URL, reserved, repeated)

    Arguments

    self

    carbon self object

    private

    carbon private object

    URL

    character, uri string to url encode

    reserved

    boolean, should ‘reserved’ characters be encoded?

    repeated

    boolean, should apparently already-encoded URLs be encoded again?

    Value

    character

    See also

    Site built with pkgdown 2.0.6.

    ================================================ FILE: docs/reference/get_carbon.html ================================================ carbon get functions — .get_windows_control_themes • carbonate

    function that gets the available list of aesthetic values of fields

    .get_windows_control_themes(self, private)
    
    .get_font_families(self, private)
    
    .get_templates(self, private)

    Arguments

    self

    carbon self object

    private

    carbon private object

    See also

    Site built with pkgdown 2.0.6.

    ================================================ FILE: docs/reference/index.html ================================================ Function reference • carbonate

    All functions

    .browse()

    open $uri to in browser window

    carbon

    Carbon R6 class

    .chromeOptions()

    chrome webdriver functions

    carbon_fields carbon-fields

    Carbon object fields

    .firefoxOptions()

    gecko webdriver functions

    .start() .driver_start() .driver_stop() .stop() .stop_all() .set_port() .get_port()

    RSelenium webdriver functions

    .carbonate()

    Carbonate script lines to a carbon image

    .encode()

    encode uri for carbon.js

    .get_windows_control_themes() .get_font_families() .get_templates()

    carbon get functions

    .options()

    concatenate the carbon options to a string

    reprex_to_carbon_browser() reprex_to_carbon_download()

    Creates a Reprex of selected code (or from input) renders it and opens or downloads the Carbon

    .rtweet()

    send tweets using carbonate outputs

    .set_template() .set_window_control_theme() .set_font_family()

    carbon set functions

    .tiny()

    convert carbon uri to tinyurl

    tinyurl()

    convert uri to tinyurl

    .uri()

    URI constructor

    Site built with pkgdown 2.0.6.

    ================================================ FILE: docs/reference/options.html ================================================ concatenate the carbon options to a string — .options • carbonate

    combine all the carbon options into a carbon.js valid string

    .options(self, private, code)

    Arguments

    self

    carbon self object

    private

    carbon private object

    code

    character, script to embbed into the uri

    Value

    OUTPUT_DESCRIPTION

    See also

    Site built with pkgdown 2.0.6.

    ================================================ FILE: docs/reference/reprex_to_carbon_browser.html ================================================ Creates a Reprex of selected code (or from input) renders it and opens or downloads the Carbon — reprex_to_carbon_browser • carbonate

    Creates a Reprex of selected code (or from input) renders it and opens or downloads the Carbon

    reprex_to_carbon_browser(..., html_preview = FALSE, style = TRUE,
      url_only = FALSE)
    
    reprex_to_carbon_download(..., file = "carbon_reprex.png",
      html_preview = FALSE, style = TRUE, url_only = FALSE)

    Arguments

    ...

    arguments passed to reprex::reprex

    html_preview

    show also reprex html result? Default is false

    style

    should the code be styled? Default is True

    url_only

    if only the URL should be returned without opening the browser

    Value

    the URL to the Carbon (invisible) or the filename (invisible)

    Functions

    • reprex_to_carbon_download(): downloads the picture

    Examples

    if (FALSE) {
    reprex_to_carbon_browser(input = c("   x=1:  10", "   x"))
    # copy the following code using STRG + C or similar:
      a <- 1:10
      b <- rnorm(10)
      cbind(a, b)
      plot(a, b)
    
    # Then run this
    reprex_to_carbon_browser()
    }
    

    Site built with pkgdown 2.0.6.

    ================================================ FILE: docs/reference/rtweet.html ================================================ send tweets using carbonate outputs — .rtweet • carbonate

    wrapper for post_tweet to send tweets with media created using carbonate.

    .rtweet(self, private, media, status = self$tweet_status,
      media_format = c("png", "gif"), ...)

    Arguments

    self

    carbon self object

    private

    carbon private object

    media

    magick-image object or path to image

    status

    character, status to attach to post, Default: self$tweet_status

    media_format

    character, type of media to tweet, Default: c('png','gif')

    ...

    arguments to pass to post_tweet

    Value

    outcome from rtweet

    Details

    If multiple images are passed they can be either converted to a gif by setting media_format to 'gif' or attached each one to the post.

    Examples

    if (FALSE) {
    x <- carbonate::carbon$new()
    x$carbonate(code = readLines(system.file('DESCRIPTION',package='carbonate')))
    x$carbonate(code = 'x+2')
    
    # using default status value (x$tweet_status)
    x$rtweet(system.file('figures/hex_black_small.png',package='carbonate'))
    
    x$rtweet(status = 'these are two pngs',media = x$carbons,media_format='png')
    x$rtweet(status = 'this is a gif', media = x$carbons,media_format='gif')
    
    }
    

    Site built with pkgdown 2.0.6.

    ================================================ FILE: docs/reference/set_carbon.html ================================================ carbon set functions — .set_template • carbonate

    function that set the aesthetics of the carbon image output

    .set_template(self, private, template)
    
    .set_window_control_theme(self, private, theme)
    
    .set_font_family(self, private, family)

    Arguments

    self

    carbon self object

    private

    carbon private object

    template

    character, name of template to set $template to

    theme

    character, theme to set $theme to

    family

    character, font family to set $font_family to

    See also

    Site built with pkgdown 2.0.6.

    ================================================ FILE: docs/reference/tiny.html ================================================ convert carbon uri to tinyurl — .tiny • carbonate

    convert carbon uri to tinyurl with option to attach to clipboard.

    .tiny(self, private, clip = FALSE)

    Arguments

    self

    carbon self object

    private

    carbon private object

    clip

    boolean, write tinyurl to clipboard, Default: FALSE

    Value

    character

    Details

    If clip is set to TRUE write_clip will put the tinyurl on the clipboard.

    Site built with pkgdown 2.0.6.

    ================================================ FILE: docs/reference/tinyurl.html ================================================ convert uri to tinyurl — tinyurl • carbonate

    convert uri to tinyurl.

    tinyurl(uri)

    Arguments

    uri

    character, the uri to convert

    Value

    character

    Site built with pkgdown 2.0.6.

    ================================================ FILE: docs/reference/uri.html ================================================ URI constructor — .uri • carbonate

    Function that is called in a carbon object to construct valid uri to send to browser

    .uri(self, private, code)

    Arguments

    self

    carbon self object

    private

    carbon private object

    code

    character, script to embbed into the uri

    See also

    Examples

    if(interactive()){
    
    x <- carbon$new('x <- 1')
    
    # populate from self$code
    x$uri()
    
    # enter manually
    x$uri(code = 'x <- y + 3')
    
    }
    

    Site built with pkgdown 2.0.6.

    ================================================ FILE: docs/sitemap.xml ================================================ /404.html /LICENSE-text.html /PULL_REQUEST_TEMPLATE.html /articles/index.html /articles/tests_and_coverage.html /authors.html /index.html /reference/browse.html /reference/carbon.html /reference/carbon_chrome.html /reference/carbon_fields.html /reference/carbon_gecko.html /reference/carbon_selenium.html /reference/carbonate.html /reference/encode.html /reference/get_carbon.html /reference/index.html /reference/options.html /reference/reprex_to_carbon_browser.html /reference/rtweet.html /reference/set_carbon.html /reference/tiny.html /reference/tinyurl.html /reference/uri.html ================================================ FILE: hextools/create_hex.R ================================================ library(progress) f <- function (r = 1, ...) { user <- par("usr") pin <- par("pin") sy <- user[4] - user[3] sx <- user[2] - user[1] ry <- r * sy/sx * pin[1]/pin[2] shape::getellipse(r, ry, c(0, 0), angle = 0, dr = 0.01, from = -pi, to = pi) } x <- f() library(magrittr) p <- as.data.frame(x)%>% dplyr::mutate(id = 1:n())%>% dplyr::group_by(id)%>% dplyr::mutate(n = norm(as.matrix(c(V1,V2)),type = 'F'))%>% dplyr::ungroup()%>% ggplot2::ggplot(ggplot2::aes(x=V1,y=V2,colour = n)) + ggplot2::geom_point() + viridis::scale_color_viridis(option = 'A') p1 <- ggplot2::ggplot_build(p) colors <- p1$data[[1]]$colour imgurl <- 'https://www.mouthhealthy.org/~/media/MouthHealthy/Images/Articles/article_sparkling_water.jpg?h=307&la=en&w=460&hash=C5B22EB96AB5D4C5BFBDF360A745D108E2AF053F' hex_f <- function(id,hex,imgurl){ pb$tick() hexSticker::sticker(imgurl, package="carbonate", p_size=8, s_x=1, s_y=.75, s_width=.6, p_color = hex, h_color = hex, h_fill = '#FFFFFF', filename=sprintf("misc/hex/hex_%03d.png",id)) } pb <- progress_bar$new(total = length(colors)) purrr::walk2(as.list(seq_along(colors)), as.list(colors), .f=hex_f,imgurl = imgurl) x <- list.files('misc/hex',full.names = TRUE) idx <- c(1:200,sort(sample(200:550,200,replace = FALSE)),550:630) imgs <- magick::image_read(x[idx])%>%magick::image_scale('150') magick::image_animate(imgs,fps = 5, dispose = "previous") junk <- sapply(list.files(tempdir(),pattern = 'jpeg$',full.names = TRUE),unlink,force = TRUE) file.copy(file.path(tempdir(),'preview.gif'),'tools/temp/hex.gif',overwrite = TRUE) library(magick) magick::image_read(imgurl)%>%image_negate()%>%image_oilpaint()%>% magick::image_write('misc/carbonate_black.png') hexSticker::sticker('misc/carbonate_black.png', package="carbonate", p_size=8, s_x=1, s_y=.75, s_width=.6, p_color = "white", h_color = "white", h_fill = 'black',filename="misc/hex_black.png") slickR::slickR( obj = x[idx], slickOpts = list( initialSlide = 0, slidesToShow = 10, slidesToScroll = 10, focusOnSelect = TRUE, dots = FALSE ), height=100,width='100%') ================================================ FILE: inst/rstudio/addins.dcf ================================================ Name: Browse carbonated Reprex Description: Opens the browser for the current reprex in Carbon Binding: reprex_to_carbon_browser Interactive: true Name: Download carbonated Reprex Description: Downloads the current reprex in Carbon Binding: reprex_to_carbon_download Interactive: true ================================================ FILE: man/browse.Rd ================================================ % Generated by roxygen2: do not edit by hand % Please edit documentation in R/uri_functions.R \name{.browse} \alias{.browse} \alias{carbon-browse} \title{open $uri to in browser window} \usage{ .browse(self, private) } \arguments{ \item{self}{carbon self object} \item{private}{carbon private object} } \description{ opens the uri address in \link[=carbon-uri]{$uri} in the browser window. } \examples{ x <- carbon$new('x <- 1') if(interactive()) x$browse() } \seealso{ \link[=carbon]{carbon} } ================================================ FILE: man/carbon.Rd ================================================ % Generated by roxygen2: do not edit by hand % Please edit documentation in R/carbon.R \name{carbon} \alias{carbon} \title{Carbon R6 class} \description{ The Carbon generator creates a new \code{Carbon}-object, which is the class containing all the app logic. The class is based on the \link[R6:R6Class]{R6} OO-system and is thus reference-based with methods and data attached to each object, in contrast to the more well known S3 and S4 systems. } \section{Initialization}{ A new 'Carbon'-object is initialized using the \code{new()} method on the generator: \tabular{l}{ \code{x <- carbon$new(code = clipr::read_clip())} } } \section{Fields}{ \foldstart{Public Fields} Description of fields of the R6 object that can be set by the user can be found in the following \link[=carbon-fields]{page}. \foldend } \section{Methods}{ \foldstart{Interacting with Browser} \tabular{ll}{ \link[=carbon-carbonate]{$carbonate} \tab Using RSelenium fetch the carbon image output \cr \link[=.browse]{$browse} \tab open \link[=carbon-uri]{$uri} in the browser } \foldend \foldstart{ Aesthetics } \tabular{ll}{ \link[=carbon-set-fields]{$set_template} \tab set $template \cr \link[=carbon-get-fields]{$get_templates} \tab get a list of possible templates \cr \link[=carbon-set-fields]{$set_window_control_theme} \tab set $windows_control_theme \cr \link[=carbon-get-fields]{$get_windows_control_themes} \tab get a list of possible window control themes\cr \link[=carbon-set-fields]{$set_font_family} \tab set $font_family\cr \link[=carbon-get-fields]{$get_font_families} \tab get a list of possible fonts } \foldend \foldstart{ URI Building } \tabular{ll}{ \link[=carbon-uri]{$uri} \tab construct valid carbon.js uri \cr \link[=carbon-options]{$options} \tab return all current carbon options\cr \link[=carbon-encode]{$encode} \tab URL encode a string for the $uri \cr \link[=carbon-tinyurl]{$tiny} \tab Create tinyurl from \link[=carbon-uri]{$uri} \cr \link[=carbon-rtweet]{$rtweet} \tab Send tweets containing media generated from carbon } \foldend \foldstart{ Webdriver Settings } \tabular{ll}{ \link[=carbon-chrome]{$chromeOptions} \tab construct a chromeOptions object \cr \link[=carbon-chrome]{$chrome_start} \tab start a chrome session \cr \link[=carbon-chrome]{$chrome_stop} \tab stop a chrome session \cr \link[=carbon-selenium]{$start} \tab start a RSelenium session \cr \link[=carbon-selenium]{$stop} \tab stop a RSelenium session \cr \link[=carbon-selenium]{$stop_all} \tab stop all active RSelenium sessions \cr \link[=carbon-selenium]{$get_port} \tab Get active port \cr \link[=carbon-selenium]{$set_port} \tab Set new port } \foldend } ================================================ FILE: man/carbon_chrome.Rd ================================================ % Generated by roxygen2: do not edit by hand % Please edit documentation in R/selenium_functions.R \name{.chromeOptions} \alias{.chromeOptions} \alias{carbon-chrome} \title{chrome webdriver functions} \usage{ .chromeOptions(self, private) } \arguments{ \item{self}{carbon self object} \item{private}{carbon private object} } \description{ Functions to open,close,set chrome webdriver } \seealso{ \link[=carbon]{carbon}, \link[wdman:chrome]{chrome} } ================================================ FILE: man/carbon_fields.Rd ================================================ % Generated by roxygen2: do not edit by hand % Please edit documentation in R/carbon_fields.R \name{carbon_fields} \alias{carbon_fields} \alias{carbon-fields} \title{Carbon object fields} \arguments{ \item{code}{character, script to embbed, Default: NULL} \item{palette}{numeric, layout pallete, Default: c(r=171,g=184,b=195,a=1)} \item{template}{character, layout template, Default: 'seti'} \item{add_window_control}{boolean, add/remove window controls (circles on top left corner), Default: TRUE} \item{window_control_theme}{character, change window control themes, Default: 'none'} \item{language}{character, language, Default: 'r'} \item{add_drop_shadow}{boolean, add/remove dropshadow, Default: TRUE} \item{drop_shadow_offset_y}{numeric, shadow vertical offset (px), Default: 20} \item{drop_shadow_blur_radius}{numeric, shadow blur radius (px), Default: 68} \item{auto_adjust_width}{boolean, auto-audjust output width, Default: TRUE} \item{padding_vertical}{numeric, vertical padding (px), Default: 48} \item{padding_horizontal}{numeric, horizontal padding (px), Default: 32} \item{add_line_number}{boolean, add/remove line numbers, Default: FALSE} \item{font_family}{character, layout font family, Default: 'Hack'} \item{font_size}{numeric, font size (px), Default: 14} \item{line_height_percent}{numeric, relative space between lines (percent), Default: 133} \item{square_image}{boolean, output image is square, Default: FALSE} \item{relative_export_size}{numeric, image size in export relative to what is in the preview (1,2 or 4), Default: 1} \item{add_watermark}{boolean, add official carbon.js watermark, Default: FALSE} \item{add_tinyurl}{boolean, add tinyurl link to image directing to the carbon page that created the image, Default: FALSE} \item{tinyurl_location}{character, string with \link[magick:options]{gravity} value to place the annotate tinyurl address on image, Default: 'southeast'} \item{tweet}{boolean, tweet out the image using \link[rtweet:post_tweet]{post_tweet}} \item{tweet_status}{character, status to add to the tweet. If add_tinyurl is TRUE then a link to the url will be appended to the status automatically, Default: 'Created in R using the Carbonate (Package Icon)'} \item{add_timestamp}{boolean, add timestamp to output filename, Default: FALSE} \item{carbons}{list, storage of rendered carbon images, Default: NULL} \item{download_path}{character, path to download the images, Default: tempdir()} \item{chrome_args}{character, arguments passed to chrome browser, Default: c('--disable-gpu', '--window-size=1280,800')} \item{chrome_pref}{list, preferences passed to chrome browser, Default: list("profile.default_content_settings.popups" = 0L,"download.prompt_for_download" = FALSE,"download.default_directory" = tempdir())} \item{rD}{RSelenium Driver object} \item{cDrv}{Chrome Driver object from wdman} } \description{ Fields that can be changed in the \link[=carbon]{Carbon} object } \seealso{ \link[=carbon]{carbon} } ================================================ FILE: man/carbon_gecko.Rd ================================================ % Generated by roxygen2: do not edit by hand % Please edit documentation in R/selenium_functions.R \name{.firefoxOptions} \alias{.firefoxOptions} \alias{carbon-gecko} \title{gecko webdriver functions} \usage{ .firefoxOptions(self, private) } \arguments{ \item{self}{carbon self object} \item{private}{carbon private object} } \description{ Functions to open,close,set gecko webdriver } \seealso{ \link[=carbon]{carbon}, \link[wdman:gecko]{gecko} } ================================================ FILE: man/carbon_selenium.Rd ================================================ % Generated by roxygen2: do not edit by hand % Please edit documentation in R/selenium_functions.R \name{.start} \alias{.start} \alias{carbon-selenium} \alias{.driver_start} \alias{.driver_stop} \alias{.stop} \alias{.stop_all} \alias{.set_port} \alias{.get_port} \title{RSelenium webdriver functions} \usage{ .start(self, private, eCap, driver = c("firefox", "chrome")) .driver_start(self, private, driver = c("chrome", "firefox")) .driver_stop(self, private) .stop(self, private) .stop_all(self, private) .set_port(self, private, port = NULL) .get_port(self, private) } \arguments{ \item{self}{carbon self object} \item{private}{carbon private object} \item{eCap}{chromeOptions passed into \link[RSelenium:rsDriver]{rsDriver}} \item{driver}{character, select either 'firefox' or 'chrome' driver} \item{port}{integer, port for the \link[RSelenium:rsDriver]{rsDriver} to use, if NULL then a random port is selected} } \description{ Functions to open,stop, stop_all RSelenium sessions } \seealso{ \link[=carbon]{carbon} } ================================================ FILE: man/carbonate.Rd ================================================ % Generated by roxygen2: do not edit by hand % Please edit documentation in R/carbonate.R \name{.carbonate} \alias{.carbonate} \alias{carbon-carbonate} \alias{carbonate} \title{Carbonate script lines to a carbon image} \usage{ .carbonate(self, private, file, path, code, rD, driver) } \arguments{ \item{self}{carbon self object} \item{private}{carbon private object} \item{file}{character, name of file to save image as} \item{path}{character, path to save the image} \item{code}{character, lines of script to make carbon image from} \item{rD}{RSelenium driver} \item{driver}{character, select either 'firefox' or 'chrome' driver} } \value{ image object } \description{ Main function of the package that invokes RSelenium to open a browser to the carbon.js uri, create an image and download the file. } \details{ Script is passed to \url{https://carbon.now.sh/} is downloaded to the \code{tempdir()} and appended to the list \link[=carbon-fields]{$carbons} using RSelenium and Chrome. } \examples{ if(interactive()){ x <- carbon$new('x <- 1') x$carbonate() } } \seealso{ \link[=carbon]{carbon}, \link[RSelenium:rsDriver]{rsDriver} } ================================================ FILE: man/encode.Rd ================================================ % Generated by roxygen2: do not edit by hand % Please edit documentation in R/uri_functions.R \name{.encode} \alias{.encode} \alias{carbon-encode} \title{encode uri for carbon.js} \usage{ .encode(self, private, URL, reserved, repeated) } \arguments{ \item{self}{carbon self object} \item{private}{carbon private object} \item{URL}{character, uri string to url encode} \item{reserved}{boolean, should ‘reserved’ characters be encoded?} \item{repeated}{boolean, should apparently already-encoded URLs be encoded again?} } \value{ character } \description{ encode uri string for carbon.js. Augmented version of than \link[utils:URLencode]{URLencode} } \seealso{ \link[utils:URLencode]{URLencode}, \link[=carbon]{carbon} } ================================================ FILE: man/get_carbon.Rd ================================================ % Generated by roxygen2: do not edit by hand % Please edit documentation in R/set_get_functions.R \name{.get_windows_control_themes} \alias{.get_windows_control_themes} \alias{carbon-get-fields} \alias{.get_font_families} \alias{.get_templates} \title{carbon get functions} \usage{ .get_windows_control_themes(self, private) .get_font_families(self, private) .get_templates(self, private) } \arguments{ \item{self}{carbon self object} \item{private}{carbon private object} } \description{ function that gets the available list of aesthetic values of fields } \seealso{ \link[=carbon]{carbon} } ================================================ FILE: man/options.Rd ================================================ % Generated by roxygen2: do not edit by hand % Please edit documentation in R/uri_functions.R \name{.options} \alias{.options} \alias{carbon-options} \title{concatenate the carbon options to a string} \usage{ .options(self, private, code) } \arguments{ \item{self}{carbon self object} \item{private}{carbon private object} \item{code}{character, script to embbed into the uri} } \value{ OUTPUT_DESCRIPTION } \description{ combine all the carbon options into a carbon.js valid string } \seealso{ \link[=carbon]{carbon} } ================================================ FILE: man/rtweet.Rd ================================================ % Generated by roxygen2: do not edit by hand % Please edit documentation in R/uri_functions.R \name{.rtweet} \alias{.rtweet} \alias{carbon-rtweet} \title{send tweets using carbonate outputs} \usage{ .rtweet(self, private, media, status = self$tweet_status, media_format = c("png", "gif"), ...) } \arguments{ \item{self}{carbon self object} \item{private}{carbon private object} \item{media}{magick-image object or path to image} \item{status}{character, status to attach to post, Default: self$tweet_status} \item{media_format}{character, type of media to tweet, Default: c('png','gif')} \item{\dots}{arguments to pass to \link[rtweet:post_tweet]{post_tweet}} } \value{ outcome from rtweet } \description{ wrapper for \link[rtweet:post_tweet]{post_tweet} to send tweets with media created using carbonate. } \details{ If multiple images are passed they can be either converted to a gif by setting media_format to 'gif' or attached each one to the post. } \examples{ \dontrun{ x <- carbonate::carbon$new() x$carbonate(code = readLines(system.file('DESCRIPTION',package='carbonate'))) x$carbonate(code = 'x+2') # using default status value (x$tweet_status) x$rtweet(system.file('figures/hex_black_small.png',package='carbonate')) x$rtweet(status = 'these are two pngs',media = x$carbons,media_format='png') x$rtweet(status = 'this is a gif', media = x$carbons,media_format='gif') } } \seealso{ \link[magick:editing]{image_write} \link[rtweet:post_tweet]{post_tweet} } ================================================ FILE: man/set_carbon.Rd ================================================ % Generated by roxygen2: do not edit by hand % Please edit documentation in R/set_get_functions.R \name{.set_template} \alias{.set_template} \alias{carbon-set-fields} \alias{.set_window_control_theme} \alias{.set_font_family} \title{carbon set functions} \usage{ .set_template(self, private, template) .set_window_control_theme(self, private, theme) .set_font_family(self, private, family) } \arguments{ \item{self}{carbon self object} \item{private}{carbon private object} \item{template}{character, name of template to set \link[=carbon-fields]{$template} to} \item{theme}{character, theme to set \link[=carbon-fields]{$theme} to} \item{family}{character, font family to set \link[=carbon-fields]{$font_family} to} } \description{ function that set the aesthetics of the carbon image output } \seealso{ \link[=carbon]{carbon} } ================================================ FILE: man/tiny.Rd ================================================ % Generated by roxygen2: do not edit by hand % Please edit documentation in R/uri_functions.R \name{.tiny} \alias{.tiny} \alias{carbon-tinyurl} \title{convert carbon uri to tinyurl} \usage{ .tiny(self, private, clip = FALSE) } \arguments{ \item{self}{carbon self object} \item{private}{carbon private object} \item{clip}{boolean, write tinyurl to clipboard, Default: FALSE} } \value{ character } \description{ convert carbon uri to tinyurl with option to attach to clipboard. } \details{ If clip is set to TRUE \link[clipr:write_clip]{write_clip} will put the tinyurl on the clipboard. } ================================================ FILE: man/tinyurl.Rd ================================================ % Generated by roxygen2: do not edit by hand % Please edit documentation in R/uri_functions.R \name{tinyurl} \alias{tinyurl} \title{convert uri to tinyurl} \usage{ tinyurl(uri) } \arguments{ \item{uri}{character, the uri to convert} } \value{ character } \description{ convert uri to tinyurl. } ================================================ FILE: man/uri.Rd ================================================ % Generated by roxygen2: do not edit by hand % Please edit documentation in R/uri_functions.R \name{.uri} \alias{.uri} \alias{carbon-uri} \title{URI constructor} \usage{ .uri(self, private, code) } \arguments{ \item{self}{carbon self object} \item{private}{carbon private object} \item{code}{character, script to embbed into the uri} } \description{ Function that is called in a carbon object to construct valid uri to send to browser } \examples{ if(interactive()){ x <- carbon$new('x <- 1') # populate from self$code x$uri() # enter manually x$uri(code = 'x <- y + 3') } } \seealso{ \link[=carbon]{carbon} } ================================================ FILE: tests/README.md ================================================ Tests and Coverage ================ 25 August, 2022 20:24:56 - Coverage - Unit Tests This output is created by [covrpage](https://github.com/yonicd/covrpage). ## Coverage Coverage summary is created using the [covr](https://github.com/r-lib/covr) package. | Object | Coverage (%) | |:----------------------------------------------------|:------------:| | carbonate | 51.46 | | [R/carbonate.R](../R/carbonate.R) | 0.00 | | [R/selenium_functions.R](../R/selenium_functions.R) | 20.00 | | [R/uri_functions.R](../R/uri_functions.R) | 38.60 | | [R/carbon.R](../R/carbon.R) | 60.61 | | [R/helpers.R](../R/helpers.R) | 76.64 | | [R/set_get_functions.R](../R/set_get_functions.R) | 100.00 |
    ## Unit Tests Unit Test summary is created using the [testthat](https://github.com/r-lib/testthat) package. | file | n | time | error | failed | skipped | warning | icon | |:------------------------------------|----:|------:|------:|-------:|--------:|--------:|:-----| | [test-port.R](testthat/test-port.R) | 3 | 0.024 | 0 | 0 | 0 | 0 | | | [test-set.R](testthat/test-set.R) | 3 | 0.893 | 0 | 0 | 0 | 0 | | | [test-uri.R](testthat/test-uri.R) | 8 | 1.342 | 0 | 0 | 2 | 0 | 🔶 | | [test-yml.R](testthat/test-yml.R) | 6 | 2.351 | 0 | 0 | 0 | 0 | |
    Show Detailed Test Results | file | context | test | status | n | time | icon | |:----------------------------------------|:--------|:-----------------------------------------|:--------|----:|------:|:-----| | [test-port.R](testthat/test-port.R#L9) | port | port: init | PASS | 1 | 0.011 | | | [test-port.R](testthat/test-port.R#L14) | port | port: reset | PASS | 1 | 0.011 | | | [test-port.R](testthat/test-port.R#L19) | port | port: manual | PASS | 1 | 0.002 | | | [test-set.R](testthat/test-set.R#L8) | set\_ | set functions: set_template | PASS | 1 | 0.529 | | | [test-set.R](testthat/test-set.R#L13) | set\_ | set functions: set_font_family | PASS | 1 | 0.363 | | | [test-set.R](testthat/test-set.R#L18) | set\_ | set functions: set_windows_control_theme | PASS | 1 | 0.001 | | | [test-uri.R](testthat/test-uri.R#L9) | uri | options: benchmark | PASS | 1 | 0.325 | | | [test-uri.R](testthat/test-uri.R#L17) | uri | uri: benchmark | PASS | 1 | 0.235 | | | [test-uri.R](testthat/test-uri.R#L21) | uri | uri: 200 | PASS | 1 | 0.528 | | | [test-uri.R](testthat/test-uri.R#L27) | uri | encode: encode character | PASS | 1 | 0.002 | | | [test-uri.R](testthat/test-uri.R#L31) | uri | encode: no encode character | PASS | 1 | 0.001 | | | [test-uri.R](testthat/test-uri.R#L37) | uri | tiny: valid tiny | SKIPPED | 1 | 0.001 | 🔶 | | [test-uri.R](testthat/test-uri.R#L43) | uri | tiny: clipboard | SKIPPED | 1 | 0.002 | 🔶 | | [test-uri.R](testthat/test-uri.R#) | uri | bad template: error uri | PASS | 1 | 0.248 | | | [test-yml.R](testthat/test-yml.R#L24) | yml | yaml fields: rgba | PASS | 1 | 0.525 | | | [test-yml.R](testthat/test-yml.R#L29) | yml | yaml fields: template | PASS | 1 | 0.432 | | | [test-yml.R](testthat/test-yml.R#L34) | yml | yaml fields: bad font family | PASS | 1 | 0.439 | | | [test-yml.R](testthat/test-yml.R#L39) | yml | yaml fields: pv | PASS | 1 | 0.522 | | | [test-yml.R](testthat/test-yml.R#L44) | yml | yaml fields: ph | PASS | 1 | 0.431 | | | [test-yml.R](testthat/test-yml.R#L59) | yml | namesless palette: fill in palette | PASS | 1 | 0.002 | | | Failed | Warning | Skipped | |:-------|:--------|:--------| | 🛑 | ⚠️ | 🔶 |
    Session Info | Field | Value | |:---------|:---------------------------------| | Version | R version 4.2.1 (2022-06-23) | | Platform | x86_64-apple-darwin17.0 (64-bit) | | Running | macOS Big Sur 11.6 | | Language | en_US | | Timezone | America/New_York | | Package | Version | |:---------|:--------| | testthat | 3.1.4 | | covr | 3.5.1 | | covrpage | 0.1 |
    ================================================ FILE: tests/testthat/helpers.R ================================================ # taken from https://github.com/tidyverse/reprex/blob/master/tests/testthat/helper.R ## used to make clipboard unavailable locally # Sys.setenv("CLIPBOARD_AVAILABLE" = TRUE) # Sys.setenv("CLIPBOARD_AVAILABLE" = FALSE) NOT_CRAN <- Sys.getenv("NOT_CRAN", unset = "") ON_CRAN <- identical(NOT_CRAN, "") || identical(tolower(NOT_CRAN), "false") if (ON_CRAN) { Sys.setenv("CLIPBOARD_AVAILABLE" = FALSE) } clipboard_available <- function() { if (Sys.getenv("CLIPBOARD_AVAILABLE", unset = TRUE)) { return(clipr::clipr_available()) } FALSE } skip_if_no_clipboard <- function() { if (!clipboard_available()) { testthat::skip("System clipboard is not available - skipping test.") } return(invisible(TRUE)) } ================================================ FILE: tests/testthat/test-port.R ================================================ testthat::context("port") carb <- carbonate::carbon$new(code='123') p <- carb$get_port() testthat::describe("port", { it('init',{ testthat::expect_true(inherits(carb$get_port(),'integer')) }) it('reset',{ carb$set_port() testthat::expect_false(p==carb$get_port()) }) it('manual',{ carb$set_port(1234) testthat::expect_equal(carb$get_port(),1234L) }) }) ================================================ FILE: tests/testthat/test-set.R ================================================ testthat::context("set_") x <- carbonate::carbon$new(code = "abc", yml = NULL) testthat::describe("set functions", { it("set_template", { x$set_template(x$get_templates()[1]) testthat::expect_equal(x$template, x$get_templates()[1]) }) it("set_font_family", { x$set_font_family(x$get_font_families()[1]) testthat::expect_equal(x$font_family, x$get_font_families()[1]) }) it("set_windows_control_theme", { x$set_window_control_theme(x$get_windows_control_themes()[1]) testthat::expect_equal(x$window_control_theme, x$get_windows_control_themes()[1]) }) }) ================================================ FILE: tests/testthat/test-uri.R ================================================ testthat::context("uri") x <- carbonate::carbon$new(code = "abc", yml = NULL) testthat::describe("options", { bench <- "bg=rgba(171%2C184%2C195%2C1)&t=seti&wt=none&l=r&ds=true&dsyoff=20px&dsblur=68px&wc=true&wa=true&pv=48px&ph=32px&ln=false&fm=Hack&fs=14px&lh=133%25&si=false&es=1x&wm=false&ts=false&code=abc" it("benchmark", { testthat::expect_equal(bench, x$options()) }) }) testthat::describe("uri", { bench <- "https://carbon.now.sh/?bg=rgba(171%2C184%2C195%2C1)&t=seti&wt=none&l=r&ds=true&dsyoff=20px&dsblur=68px&wc=true&wa=true&pv=48px&ph=32px&ln=false&fm=Hack&fs=14px&lh=133%25&si=false&es=1x&wm=false&ts=false&code=abc" it("benchmark", { testthat::expect_equal(bench, x$uri()) }) it("200", { testthat::expect_false(httr::http_error(x$uri())) }) }) testthat::describe("encode", { it("encode character", { testthat::expect_equal("%2523%2540%2524%2525%27", x$encode(URL = "#@$%'")) }) it("no encode character", { testthat::expect_equal("!();?._~-", x$encode(URL = "!();?._~-")) }) }) testthat::describe("tiny", { it("valid tiny", { testthat::skip_on_cran() testthat::expect_false(httr::http_error(x$tiny())) }) it("clipboard", { testthat::skip_on_travis() skip_if_no_clipboard() cl <- x$tiny(clip = TRUE) testthat::expect_equal(cl, clipr::read_clip()) }) }) testthat::describe("bad template", { x$template <- "xxx" it("error uri", testthat::expect_error(x$uri(), "template not valid: xxx")) }) ================================================ FILE: tests/testthat/test-yml.R ================================================ testthat::context("yml") this <- "palette:\n- g: 175.0\n- a: 0.7\ntemplate: panda-syntax\nfont_family: Fira Cod\npadding_vertical: 11\npadding_horizontal: 14" this_noname <- "palette:\n- 175.0\n- 0.7\ntemplate: panda-syntax\nfont_family: Fira Cod\npadding_vertical: 11\npadding_horizontal: 14" reset <- function(this) { tf <- tempfile(fileext = ".yml") cat(this, file = tf, sep = "\n") carbonate::carbon$new(code = "abc", yml = tf, silent_yml = TRUE) } reset_verbose <- function(this) { tf <- tempfile(fileext = ".yml") cat(this, file = tf, sep = "\n") carbonate::carbon$new(code = "abc", yml = tf, silent_yml = FALSE) } testthat::describe("yaml fields", { it("rgba", { x <- reset(this) expect_equal(c(r = 171, g = 175, b = 195, a = 0.7), x$palette) }) it("template", { x <- reset(this) expect_equal("panda-syntax", x$template) }) it("bad font family", { x <- reset(this) expect_equal("Hack", x$font_family) }) it("pv", { x <- reset(this) expect_equal(11, x$padding_vertical) }) it("ph", { x <- reset(this) expect_equal(14, x$padding_horizontal) }) }) testthat::describe("yaml verbose", { out <- "palette:\n- 171.0\n- 175.0\n- 195.0\n- 0.7\ntemplate: panda-syntax\npadding_vertical: 11\npadding_horizontal: 14" x <- testthat::expect_message(object = reset_verbose(this), regexp = "invalid value") x <- testthat::expect_output(object = reset_verbose(this), regexp = out) }) testthat::describe("namesless palette", { x <- reset(this_noname) it("fill in palette", { testthat::expect_equal(x$palette, c(r = 175, g = 0.7, b = 195, a = 1)) }) }) ================================================ FILE: tests/testthat.R ================================================ library(testthat) library(carbonate) test_check("carbonate") ================================================ FILE: vignettes/.gitignore ================================================ *.html *.R ================================================ FILE: vignettes/tests_and_coverage.Rmd ================================================ --- title: "Tests and Coverage" date: "`r format(Sys.time(), '%d %B, %Y %H:%M:%S')`" output: rmarkdown::html_vignette vignette: > %\VignetteIndexEntry{Tests and Coverage} %\VignetteEngine{knitr::rmarkdown} %\VignetteEncoding{UTF-8} --- ```{r setup, include = FALSE} knitr::opts_chunk$set( collapse = TRUE, comment = "#>", eval = FALSE ) ``` - Coverage - Unit Tests This output is created by [covrpage](https://github.com/yonicd/covrpage). ## Coverage Coverage summary is created using the [covr](https://github.com/r-lib/covr) package. | Object | Coverage (%) | |:----------------------------------------------------|:------------:| | carbonate | 51.46 | | [R/carbonate.R](https://github.com/yonicd/carbonate/blob/cran_update/R/carbonate.R) | 0.00 | | [R/selenium_functions.R](https://github.com/yonicd/carbonate/blob/cran_update/R/selenium_functions.R) | 20.00 | | [R/uri_functions.R](https://github.com/yonicd/carbonate/blob/cran_update/R/uri_functions.R) | 38.60 | | [R/carbon.R](https://github.com/yonicd/carbonate/blob/cran_update/R/carbon.R) | 60.61 | | [R/helpers.R](https://github.com/yonicd/carbonate/blob/cran_update/R/helpers.R) | 76.64 | | [R/set_get_functions.R](https://github.com/yonicd/carbonate/blob/cran_update/R/set_get_functions.R) | 100.00 |
    ## Unit Tests Unit Test summary is created using the [testthat](https://github.com/r-lib/testthat) package. | file | n | time | error | failed | skipped | warning | icon | |:------------------------------------|----:|------:|------:|-------:|--------:|--------:|:-----| | [test-port.R](https://github.com/yonicd/carbonate/blob/cran_update/tests/testthat/test-port.R) | 3 | 0.116 | 0 | 0 | 0 | 0 | | | [test-set.R](https://github.com/yonicd/carbonate/blob/cran_update/tests/testthat/test-set.R) | 3 | 0.812 | 0 | 0 | 0 | 0 | | | [test-uri.R](https://github.com/yonicd/carbonate/blob/cran_update/tests/testthat/test-uri.R) | 8 | 1.257 | 0 | 0 | 2 | 0 | 🔶 | | [test-yml.R](https://github.com/yonicd/carbonate/blob/cran_update/tests/testthat/test-yml.R) | 6 | 2.591 | 0 | 0 | 0 | 0 | |
    Show Detailed Test Results | file | context | test | status | n | time | icon | |:----------------------------------------|:--------|:-----------------------------------------|:--------|----:|------:|:-----| | [test-port.R](https://github.com/yonicd/carbonate/blob/cran_update/tests/testthat/test-port.R#L9) | port | port: init | PASS | 1 | 0.105 | | | [test-port.R](https://github.com/yonicd/carbonate/blob/cran_update/tests/testthat/test-port.R#L14) | port | port: reset | PASS | 1 | 0.008 | | | [test-port.R](https://github.com/yonicd/carbonate/blob/cran_update/tests/testthat/test-port.R#L19) | port | port: manual | PASS | 1 | 0.003 | | | [test-set.R](https://github.com/yonicd/carbonate/blob/cran_update/tests/testthat/test-set.R#L8) | set\_ | set functions: set_template | PASS | 1 | 0.464 | | | [test-set.R](https://github.com/yonicd/carbonate/blob/cran_update/tests/testthat/test-set.R#L13) | set\_ | set functions: set_font_family | PASS | 1 | 0.346 | | | [test-set.R](https://github.com/yonicd/carbonate/blob/cran_update/tests/testthat/test-set.R#L18) | set\_ | set functions: set_windows_control_theme | PASS | 1 | 0.002 | | | [test-uri.R](https://github.com/yonicd/carbonate/blob/cran_update/tests/testthat/test-uri.R#L9) | uri | options: benchmark | PASS | 1 | 0.248 | | | [test-uri.R](https://github.com/yonicd/carbonate/blob/cran_update/tests/testthat/test-uri.R#L17) | uri | uri: benchmark | PASS | 1 | 0.234 | | | [test-uri.R](https://github.com/yonicd/carbonate/blob/cran_update/tests/testthat/test-uri.R#L21) | uri | uri: 200 | PASS | 1 | 0.416 | | | [test-uri.R](https://github.com/yonicd/carbonate/blob/cran_update/tests/testthat/test-uri.R#L27) | uri | encode: encode character | PASS | 1 | 0.002 | | | [test-uri.R](https://github.com/yonicd/carbonate/blob/cran_update/tests/testthat/test-uri.R#L31) | uri | encode: no encode character | PASS | 1 | 0.002 | | | [test-uri.R](https://github.com/yonicd/carbonate/blob/cran_update/tests/testthat/test-uri.R#L37) | uri | tiny: valid tiny | SKIPPED | 1 | 0.002 | 🔶 | | [test-uri.R](https://github.com/yonicd/carbonate/blob/cran_update/tests/testthat/test-uri.R#L43) | uri | tiny: clipboard | SKIPPED | 1 | 0.014 | 🔶 | | [test-uri.R](https://github.com/yonicd/carbonate/blob/cran_update/tests/testthat/test-uri.R#) | uri | bad template: error uri | PASS | 1 | 0.339 | | | [test-yml.R](https://github.com/yonicd/carbonate/blob/cran_update/tests/testthat/test-yml.R#L24) | yml | yaml fields: rgba | PASS | 1 | 0.515 | | | [test-yml.R](https://github.com/yonicd/carbonate/blob/cran_update/tests/testthat/test-yml.R#L29) | yml | yaml fields: template | PASS | 1 | 0.457 | | | [test-yml.R](https://github.com/yonicd/carbonate/blob/cran_update/tests/testthat/test-yml.R#L34) | yml | yaml fields: bad font family | PASS | 1 | 0.428 | | | [test-yml.R](https://github.com/yonicd/carbonate/blob/cran_update/tests/testthat/test-yml.R#L39) | yml | yaml fields: pv | PASS | 1 | 0.592 | | | [test-yml.R](https://github.com/yonicd/carbonate/blob/cran_update/tests/testthat/test-yml.R#L44) | yml | yaml fields: ph | PASS | 1 | 0.597 | | | [test-yml.R](https://github.com/yonicd/carbonate/blob/cran_update/tests/testthat/test-yml.R#L59) | yml | namesless palette: fill in palette | PASS | 1 | 0.002 | | | Failed | Warning | Skipped | |:-------|:--------|:--------| | 🛑 | ⚠️ | 🔶 |
    Session Info | Field | Value | |:---------|:---------------------------------| | Version | R version 4.2.1 (2022-06-23) | | Platform | x86_64-apple-darwin17.0 (64-bit) | | Running | macOS Big Sur 11.6 | | Language | en_US | | Timezone | America/New_York | | Package | Version | |:---------|:--------| | testthat | 3.1.4 | | covr | 3.5.1 | | covrpage | 0.1 |