r-lib / desc

Manipulate DESCRIPTION files
https://desc.r-lib.org/
Other
122 stars 27 forks source link

Maintainer not returned as author from DESCRIPTION with classic fields #114

Closed dpprdan closed 2 years ago

dpprdan commented 3 years ago

When reading description files with ‘Author’ and ‘Maintainer’ fields (but without ‘Authors\@R’) and with roles specified in brackets, the maintainer/author is not returned as an author by get_author(s)().

Example from WRE (again without ‘Authors\@R’):

library(desc)

d <- desc(text =
            "Package: pkgname
Version: 0.5-1
Date: 2015-01-01
Title: My First Collection of Functions
Author: Joe Developer [aut, cre],
  Pat Developer [aut],
  A. User [ctb]
Maintainer: Joe Developer <Joe.Developer@some.domain.net>
Depends: R (>= 3.1.0), nlme
Suggests: MASS
Description: A (one paragraph) description of what
  the package does and why it may be useful.
License: GPL (>= 2)
URL: https://www.r-project.org, http://www.another.url
BugReports: https://pkgname.bugtracker.url"
)

d$coerce_authors_at_r()

‘Joe Developer [aut, cre]’ is returned as a maintainer

d$get_author("cre")
#> [1] "Joe Developer <Joe.Developer@some.domain.net> [cre]"

But not as an author

d$get_author("aut")
#> [1] "Pat Developer [aut]" "A. User [aut]"

get_authors() also returns him as a maintainer only, i.e. the aut tag is missing

str(d$get_authors())
#> List of 3
#>  $ :Class 'person'  hidden list of 1
#>   ..$ :List of 5
#>   .. ..$ given  : chr "Joe"
#>   .. ..$ family : chr "Developer"
#>   .. ..$ role   : chr "cre"
#>   .. ..$ email  : chr "Joe.Developer@some.domain.net"
#>   .. ..$ comment: NULL
#>  $ :Class 'person'  hidden list of 1
#>   ..$ :List of 5
#>   .. ..$ given  : chr "Pat"
#>   .. ..$ family : chr "Developer"
#>   .. ..$ role   : chr "aut"
#>   .. ..$ email  : NULL
#>   .. ..$ comment: NULL
#>  $ :Class 'person'  hidden list of 1
#>   ..$ :List of 5
#>   .. ..$ given  : chr "A."
#>   .. ..$ family : chr "User"
#>   .. ..$ role   : chr "aut"
#>   .. ..$ email  : NULL
#>   .. ..$ comment: NULL
#>  - attr(*, "class")= chr "person"
Session info ``` r sessioninfo::session_info() #> - Session info --------------------------------------------------------------- #> setting value #> version R version 4.0.5 (2021-03-31) #> os Windows 10 x64 #> system x86_64, mingw32 #> ui RTerm #> language EN #> collate German_Germany.1252 #> ctype German_Germany.1252 #> tz Europe/Berlin #> date 2021-10-05 #> #> - Packages ------------------------------------------------------------------- #> package * version date lib source #> cli 3.0.1 2021-07-17 [1] standard (@3.0.1) #> crayon 1.4.1 2021-02-08 [1] CRAN (R 4.0.4) #> desc * 1.4.0 2021-09-28 [1] standard (@1.4.0) #> digest 0.6.28 2021-09-23 [1] standard (@0.6.28) #> evaluate 0.14 2019-05-28 [1] CRAN (R 4.0.4) #> fastmap 1.1.0 2021-01-25 [1] CRAN (R 4.0.4) #> fs 1.5.0 2020-07-31 [1] CRAN (R 4.0.4) #> glue 1.4.2 2020-08-27 [1] CRAN (R 4.0.4) #> highr 0.9 2021-04-16 [1] standard (@0.9) #> htmltools 0.5.2 2021-08-25 [1] standard (@0.5.2) #> knitr 1.36 2021-09-29 [1] standard (@1.36) #> magrittr 2.0.1 2020-11-17 [1] CRAN (R 4.0.4) #> R6 2.5.1 2021-08-19 [1] standard (@2.5.1) #> reprex 2.0.1 2021-08-05 [1] standard (@2.0.1) #> rlang 0.4.11 2021-04-30 [1] standard (@0.4.11) #> rmarkdown 2.11 2021-09-14 [1] standard (@2.11) #> rprojroot 2.0.2 2020-11-15 [1] CRAN (R 4.0.4) #> rstudioapi 0.13 2020-11-12 [1] CRAN (R 4.0.4) #> sessioninfo 1.1.1 2018-11-05 [1] CRAN (R 4.0.4) #> stringi 1.7.5 2021-10-04 [1] standard (@1.7.5) #> stringr 1.4.0 2019-02-10 [1] CRAN (R 4.0.4) #> withr 2.4.2 2021-04-18 [1] standard (@2.4.2) #> xfun 0.26 2021-09-14 [1] standard (@0.26) #> yaml 2.2.1 2020-02-01 [1] CRAN (R 4.0.3) #> #> [1] D:/Users/Daniel/Documents/R/win-library/4.0 #> [2] C:/Program Files/R/R-4.0.5/library ```
gaborcsardi commented 3 years ago

Seems like a bug in $coerce_authors_at_r() to me.

dpprdan commented 3 years ago

It is, but it seems intentional?! Not entirely sure why, though (added in PR #46).

https://github.com/r-lib/desc/blob/daece0e5816e17a461969489bfdda2d50b4f5fe5/R/authors-at-r.R#L399-L406

There is another issue that I only saw now: A. User is returned as author, but should be returned as a contributor.

dpprdan commented 3 years ago

Not entirely sure why, though

I get it now, the idea is to get the maintainer info (e.g. email) from the maintainer field and then concatenate these two person lists (maintainer & author).

The main problem is that the current code works under the assumption that the Author field does not contain information about the roles (i.e. no [aut, cre], [ctb], etc.) and therefore overwrites these when they are present.

I could try to make a PR, but cannot get devtools::load_all(".") to work:

> devtools::load_all(".")
i Loading desc
Error in create_ns_env(path) : Namespace for desc already exists.

Any idea what I am doing wrong?

gaborcsardi commented 3 years ago

desc does not work with load_all(), it is a bug in pkgload.

gaborcsardi commented 3 years ago

So Authors is a free-form field, e.g. https://cran.r-project.org/web/packages/igraph/DESCRIPTION. I am not sure if it is worth putting effort into parsing it, TBH.

Maybe we could advise the user better about this, though.

dpprdan commented 3 years ago

it is a bug in pkgload

Seems to be fixed in GitHub version

Authors is a free-form field

It will never be perfect of course, but maybe a tad better than now.