-
-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
improve format_expression
#159
Comments
@chlebowa is this still relevant? There is no more format_expression in this package and not in teal.data |
I guess if the answer to "do we need it" is yes, then we should give it some thought. Who knows, maybe even bring back |
format_expression <- function(code) {
paste(unlist(teal.code:::lang2calls(code)), collapse = "\n")
}
format_expression_trimws <- function(code) {
trimws(paste(unlist(teal.code:::lang2calls(code)), collapse = "\n"))
}
format_expression_styler <- function(code) {
paste(styler::style_text(teal.code:::lang2calls(code)), collapse = "\n")
}
char4 <- "
while (FALSE) {
i <- iris
m <- mtcars
}
"
format_expression(char4)
#> [1] "\n while (FALSE) {\n i <- iris\n m <- mtcars\n }\n"
format_expression_trimws(char4)
#> [1] "while (FALSE) {\n i <- iris\n m <- mtcars\n }"
format_expression_styler(char4)
#> [1] "while (FALSE) {\n i <- iris\n m <- mtcars\n}" ps. ignore this if there is a downstream formatting I'm missing |
There is, actually:
|
I think we should improve
format_expression
a little.Consider:
Currently
unlist
separates character vectortrimws
removes some excess white spaceQuestion is: do we really need it? This is an internal function and I'm not sure if there are constrains on the input. Then again we may want to use it in another place (there's a PR in
teal.data
that does).The text was updated successfully, but these errors were encountered: