cache_make_key: Make a key for 'R.cache'

Description Usage Arguments Details Experiments Examples

View source: R/utils-cache.R

Description

This is used to determine if caching already corresponds to a style guide.

Usage

1
cache_make_key(text, transformers)

Arguments

text

Code to create a cache for. This should be styled text, as the approach used by styler does not cache input, but styled code.

transformers

A list of transformer functions, because we can only know if text is already correct if we know which transformer function it should be styled with.

Details

We need to compare:

Experiments

There is unexplainable behavior in conjunction with hashing and environments:

Examples

1
2
3
4
5
6
7
8
add <- function(x, y) {
  x + y
}
add1 <- purrr::partial(add, x = 1)
add2 <- purrr::partial(add, x = 1)
identical(add1, add2)
identical(digest::digest(add1), digest::digest(add2))
identical(digest::digest(styler::tidyverse_style()), digest::digest(styler::tidyverse_style()))

krlmlr/styler documentation built on Oct. 25, 2020, 8:13 a.m.