Skip to content
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

Treat Config/Needs/website like Imports? #122

Open
DavisVaughan opened this issue Jan 25, 2022 · 3 comments
Open

Treat Config/Needs/website like Imports? #122

DavisVaughan opened this issue Jan 25, 2022 · 3 comments
Assignees
Labels
feature a feature request or enhancement

Comments

@DavisVaughan
Copy link
Member

DavisVaughan commented Jan 25, 2022

I ran use_tidy_description() on a package with:

Config/Needs/website:
    tidyverse/tidytemplate

and it converted it to:

Config/Needs/website:tidyverse/tidytemplate

Notice that it also removed the space, which seems wrong. At the very least I think it should keep that.

I managed to reproduce this with dev desc. The other weird thing is that if you run use_tidy_description() again on the "tidied" file, then it adds the space back.

tf <- tempfile()

# With Config/Needs/website
text <- "Config/Needs/website:\n\ttidyverse/tidytemplate"
desc <- desc::description$new(text = text)
desc$normalize()
desc$write(file = tf)
readLines(tf)
#> [1] "Config/Needs/website:tidyverse/tidytemplate"


# With Imports
text <- "Imports:\n\trlang"
desc <- desc::description$new(text = text)
desc$normalize()
desc$write(file = tf)
readLines(tf)
#> [1] "Imports:"  "    rlang"


# Notice how it actually adds the space back if you run it again?
text <- "Config/Needs/website:tidyverse/tidytemplate"
desc <- desc::description$new(text = text)
desc$normalize()
desc$write(file = tf)
readLines(tf)
#> [1] "Config/Needs/website: tidyverse/tidytemplate"

Created on 2022-01-25 by the reprex package (v2.0.1)

@DavisVaughan
Copy link
Member Author

I think the removal of that white space happens right here?

postprocess_trailing_ws(tmp, names(private$notws))

@hadley
Copy link
Member

hadley commented Mar 2, 2022

Came here to say the same thing 😄

@gaborcsardi gaborcsardi added the feature a feature request or enhancement label Mar 3, 2022
@averissimo
Copy link

It would be great if it behaves just like Imports/Suggests, namely on package separator.

It doesn't require a lot of custom code to achieve part of it, but it would be great not to have it (or at least an option to enable this identical behavior).

tf <- tempfile()
text <- "Package: test\nImports: tdplyr, tibble\nConfig/Needs/website: tidyverse/tidytemplate, r-lib/desc"

# Single line for Needs
desc <- desc::description$new(text = text)
desc$normalize()
desc$write(file = tf)
readLines(tf) |> paste0(collapse = "\n") |> cat()
#> Package: test
#> Imports: 
#>     tdplyr,
#>     tibble
#> Config/Needs/website: tidyverse/tidytemplate, r-lib/desc

# 
desc <- desc::description$new(text = text)
desc$normalize()
desc_field_name <- "Config/Needs/website"
if (desc$has_fields(desc_field_name)) {
  tmp_list <- desc$get_list(desc_field_name)
  desc$set_list(desc_field_name, tmp_list, sep = ",\n    ")
}
desc$write(file = tf)
readLines(tf) |> paste0(collapse = "\n") |> cat()
#> Package: test
#> Imports: 
#>     tdplyr,
#>     tibble
#> Config/Needs/website: tidyverse/tidytemplate,
#>     r-lib/desc

Created on 2023-10-25 with reprex v2.0.2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature a feature request or enhancement
Projects
Status: Todo
Development

No branches or pull requests

4 participants