golem icon indicating copy to clipboard operation
golem copied to clipboard

allow golem::fill_desc to use `person` vector

Open VincentGuyader opened this issue 5 years ago • 6 comments

IE :

golem::fill_desc(
  pkg_name = "mapit", # The Name of the package containing the App 
  pkg_title = "ttt", # The Title of the package containing the App 
  pkg_description = "xxx ", # The Description of the package containing the App 
  authors = c(person(given = "Vincent",
                     family = "Guyader",
                     role = c("cre", "aut"),
                     email = "[email protected]",
                     comment = c(ORCID = "0000-0003-0671-9270")),
              person(given = "Colin",
                     family = "Fay",
                     role = "aut",
                     email = "[email protected]",
                     comment = c(ORCID = "0000-0001-7343-1846")),
              person(given = "Sébastien",
                     family = "Rochette",
                     role = "aut",
                     email = "[email protected]",
                     comment = c(ORCID = "0000-0002-1565-9313")),
              person(given = "Cervan",
                     family = "Girard",
                     role = "aut",
                     email = "[email protected]",
                     comment = c(ORCID = "0000-0002-4816-4624")),
              person(given = "Novica",
                     family = "Nakov",
                     role = "ctb",
                     email = "[email protected]"),
              person(given = "ThinkR",
                     role = "cph")) , 
  repo_url = NULL # The (optional) URL of the GitHub Repo
)     ```

VincentGuyader avatar Oct 29 '19 10:10 VincentGuyader

I think this is related to {desc} who can't take this vector.

Maybe the PR should be done in {desc} instead of in {golem}?

For now we can :

dd <- desc::description$new()

lapply(
  c(person(given = "Vincent",
           family = "Guyader",
           role = c("cre", "aut"),
           email = "[email protected]",
           comment = c(ORCID = "0000-0003-0671-9270")),
    person(given = "Colin",
           family = "Fay",
           role = "aut",
           email = "[email protected]",
           comment = c(ORCID = "0000-0001-7343-1846"))), 
  function(x){
    dd$add_author(as.character(x))
  }
)

ColinFay avatar Nov 01 '19 21:11 ColinFay

Pinging @gaborcsardi here.

Do you think this should be a feature supported by {desc}?

ColinFay avatar Nov 01 '19 21:11 ColinFay

Well, I guess, especially if you create a PR. :) But you can also just use $set(), maybe?

gaborcsardi avatar Nov 01 '19 21:11 gaborcsardi

Leaving a comment here after @jennahamlin issue #609, so that it pops on top of the issue board

ColinFay avatar Feb 12 '21 08:02 ColinFay

This is already the case in fusen. https://github.com/ThinkR-open/fusen/blob/main/R/fill_description.R

ALanguillaume avatar Nov 05 '21 16:11 ALanguillaume

Hello, I just would like to ask if you have made any advances in repairing this issue.

I also work with a team on my package and based on your previous answers I was able to work around this problem. In my opinion would be natural to be able to add other authors in the function fill_desc(), also with other functions that function persons() offers. I think that this should be included in your package and it shouldn't be necessary for me to look up for workarounds.

In my solution, I create at first a dummy author, then add real authors with additional attributes and then remove the dummy author and at the end the desc file is overwrite with a new values. Here is my solution for others:

golem::fill_desc(
  pkg_name = "package ", # The Name of the package containing the App
  pkg_title = "package ", # The Title of the package containing the App
  pkg_description = "Description of the package", # The Description of the package containing the App
  author_first_name = "X", # Your First Name
  author_last_name = "X", # Your Last Name
  author_email = "X", # Your Email
  repo_url = NULL # The URL of the GitHub Repo (optional)
)
description <- desc::description$new()
lapply(
  c(person(given = "Vincent",
           family = "Guyader",
           role = c("cre", "aut"),
           email = "[email protected]",
           comment = c(ORCID = "0000-0003-0671-9270")),
    person(given = "Colin",
           family = "Fay",
           role = "aut",
           email = "[email protected]",
           comment = c(ORCID = "0000-0001-7343-1846"))),
  function(x){
    description$add_author(as.character(x))
  }
)
description$del_author("X")
description$write(file = "DESCRIPTION")

Kyoshido avatar Jul 19 '22 13:07 Kyoshido

@Kyoshido That seems to be an unnecessarily complicated way to assign the authors.

Is it not just easier to use one of the desc functions. E.g. desc_set_authors() as below.

p <- c(person(given = "Name1",
           family = "Surname",
           role = c("cre", "aut"),
           email = "[email protected]",
           comment = c(ORCID = "9999-7777-9999-9999")),
    person(given = "The",
           family = "Supervisor",
           role = c("dgs", "ctb"),
           email = "[email protected]",
           comment = c(ORCID = "9999-7777-9999-7777")))

desc::desc_set_authors(p)

jmeyer2482 avatar Nov 05 '22 09:11 jmeyer2482

@jmeyer2482 Thanks for the correction. Your solution is better.

Kyoshido avatar Nov 18 '22 12:11 Kyoshido

@Kyoshido Glad it worked. I was actually using your solution until I did some more investigating. It would be nice to have it clearer in the golem package though.

jmeyer2482 avatar Nov 18 '22 12:11 jmeyer2482

closed via #1037

ColinFay avatar May 25 '23 08:05 ColinFay