Code Monkey home page Code Monkey logo

desc's Introduction

desc

Parse DESCRIPTION files

Lifecycle: stable R-CMD-check Codecov test coverage CRAN RStudio mirror downloads

Parse, manipulate and reformat DESCRIPTION files. The package provides two APIs, one is object oriented, the other one is procedural and manipulates the files in place.


Installation

# Install the released version from CRAN
install.packages("desc")

# Or the development version from GitHub:
# install.packages("pak")
pak::pak("r-lib/desc")

The object oriented API

library(desc)

Introduction

The object oriented API uses R6 classes.

Loading or creating new DESCRIPTION files

A new description object can be created by reading a DESCRIPTION file form the disk. By default the DESCRIPTION file in the current directory is read:

desc <- description$new()
desc
#> Package: desc
#> Title: Manipulate DESCRIPTION Files
#> Version: 1.0.0
#> Author: Gábor Csárdi
#> Maintainer: Gábor Csárdi <[email protected]>
#> Description: Tools to read, write, create, and manipulate DESCRIPTION
#>     files.  It is intented for packages that create or manipulate other
#>     packages.
#> License: MIT + file LICENSE
#> URL: https://github.com/r-lib/desc
#> BugReports: https://github.com/r-lib/desc/issues
#> Imports:
#>     R6
#> Suggests:
#>     newpackage,
#>     testthat,
#>     whoami
#> Encoding: UTF-8
#> LazyData: true
#> RoxygenNote: 5.0.0

A new object can also be created from scratch:

desc2 <- description$new("!new")
desc2
#> Package: {{ Package }}
#> Title: {{ Title }}
#> Version: 1.0.0
#> Authors@R (parsed):
#>     * Jo Doe <[email protected]> [aut, cre]
#> Maintainer: {{ Maintainer }}
#> Description: {{ Description }}
#> License: {{ License }}
#> URL: {{ URL }}
#> BugReports: {{ BugReports }}
#> Encoding: UTF-8

Normalizing DESCRIPTION files

Most DESCRIPTION fields may be formatted in multiple equivalent ways. desc does not reformat fields, unless they are updated or reformatting is explicitly requested via a call to the normalize() method or using the normalize argument of the write() method.

Querying, changing and removing fields

get() and set() queries or updates a field:

desc$set("Package", "foo")
desc$get("Package")
#> Package 
#>   "foo"

They work with multiple fields as well:

desc$set(Package = "bar", Title = "Bar Package")
desc$get(c("Package", "Title"))
#>       Package         Title 
#>         "bar" "Bar Package"

Dependencies

Package dependencies can be set and updated via an easier API:

desc$get_deps()
#>       type    package version
#> 1 Suggests   testthat       *
#> 2 Suggests     whoami       *
#> 3 Suggests newpackage       *
#> 4  Imports         R6       *
desc$set_dep("mvtnorm")
desc$set_dep("Rcpp", "LinkingTo")
desc$get_deps()
#>        type    package version
#> 1  Suggests   testthat       *
#> 2  Suggests     whoami       *
#> 3  Suggests newpackage       *
#> 4   Imports    mvtnorm       *
#> 5   Imports         R6       *
#> 6 LinkingTo       Rcpp       *
desc
#> Package: bar
#> Title: Bar Package
#> Version: 1.0.0
#> Author: Gábor Csárdi
#> Maintainer: Gábor Csárdi <[email protected]>
#> Description: Tools to read, write, create, and manipulate DESCRIPTION
#>     files.  It is intented for packages that create or manipulate other
#>     packages.
#> License: MIT + file LICENSE
#> URL: https://github.com/r-lib/desc
#> BugReports: https://github.com/r-lib/desc/issues
#> Imports:
#>     mvtnorm,
#>     R6
#> Suggests:
#>     newpackage,
#>     testthat,
#>     whoami
#> LinkingTo:
#>     Rcpp
#> Encoding: UTF-8
#> LazyData: true
#> RoxygenNote: 5.0.0

Collate fields

Collate fields can be queried and set using simple character vectors of file names:

desc$set_collate(list.files("../R"))
#> Warning in idesc_set_collate(self, private, files, match.arg(which)): No files
#> in 'Collate' field
desc$get_collate()
#> character(0)

Authors

Authors information, when specified via the Authors@R field, also has a simplified API:

desc <- description$new("tools/pkg2")
desc$get_authors()
#> [1] "Hadley Wickham <[email protected]> [aut, cre, cph]"
#> [2] "Peter Danenberg <[email protected]> [aut, cph]"        
#> [3] "Manuel Eugster [aut, cph]"                           
#> [4] "RStudio [cph]"
desc$add_author("Bugs", "Bunny", email = "[email protected]")
desc$add_me()
desc$add_author_gh("jeroen")
desc$get_authors()
#> [1] "Hadley Wickham <[email protected]> [aut, cre, cph]"
#> [2] "Peter Danenberg <[email protected]> [aut, cph]"        
#> [3] "Manuel Eugster [aut, cph]"                           
#> [4] "RStudio [cph]"                                       
#> [5] "Bugs Bunny <[email protected]>"                            
#> [6] "First Last <[email protected]> [ctb]"               
#> [7] "Jeroen Ooms <[email protected]> [ctb]"

If the Author field is specified, it can be changed to a Authors@R field using coerce_authors_at_r(), incorporating the Maintainer information if necessary:

desc <- description$new("!new")
desc$del("Authors@R")
desc$del("Maintainer")
desc$set(Author = "Gábor Csárdi <[email protected]>")
desc$get_authors()
#> Error in ensure_authors_at_r(self): No 'Authors@R' field!
#> You can create one with $add_author.
#> You can also use $coerce_authors_at_r() to change Author fields
desc$coerce_authors_at_r()
desc$get_authors()
#> [1] "Gábor Csárdi <[email protected]> [aut]"

The procedural API

The procedural API is simpler to use for one-off DESCRIPTION manipulation, since it does not require dealing with description objects. Each object oriented method has a procedural counterpart that works on a file, and potentially writes its result back to the same file.

For example, adding a new dependency to DESCRIPTION in the current working directory can be done with

desc_set_dep("newpackage", "Suggests")
#> Package: desc
#> Title: Manipulate DESCRIPTION Files
#> Version: 1.4.2.9000
#> Authors@R (parsed):
#>     * Gábor Csárdi <[email protected]> [aut, cre]
#>     * Kirill Müller [aut]
#>     * Jim Hester <[email protected]> [aut]
#>     * Maëlle Salmon [ctb] (<https://orcid.org/0000-0002-2815-0399>)
#>     * Posit Software, PBC [cph, fnd]
#> Maintainer: Gábor Csárdi <[email protected]>
#> Description: Tools to read, write, create, and manipulate DESCRIPTION
#>     files.  It is intended for packages that create or manipulate other
#>     packages.
#> License: MIT + file LICENSE
#> URL: https://desc.r-lib.org/, https://github.com/r-lib/desc
#> BugReports: https://github.com/r-lib/desc/issues
#> Depends:
#>     R (>= 3.4)
#> Imports:
#>     cli,
#>     R6,
#>     utils
#> Suggests:
#>     callr,
#>     covr,
#>     gh,
#>     newpackage,
#>     spelling,
#>     testthat,
#>     whoami,
#>     withr
#> Config/Needs/website: tidyverse/tidytemplate
#> Config/testthat/edition: 3
#> Encoding: UTF-8
#> Language: en-US
#> Roxygen: list(r6 = FALSE, load = "installed", markdown = TRUE)
#> RoxygenNote: 7.2.3
#> Collate:
#>     'assertions.R'
#>     'authors-at-r.R'
#>     'built.R'
#>     'classes.R'
#>     'collate.R'
#>     'constants.R'
#>     'deps.R'
#>     'desc-package.R'
#>     'description.R'
#>     'encoding.R'
#>     'find-package-root.R'
#>     'latex.R'
#>     'non-oo-api.R'
#>     'package-archives.R'
#>     'read.R'
#>     'remotes.R'
#>     'str.R'
#>     'syntax_checks.R'
#>     'urls.R'
#>     'utils.R'
#>     'validate.R'
#>     'version.R'

This added newpackage to the Suggests field:

desc_get("Suggests")
#>                                                                                                  Suggests 
#> "\n    callr,\n    covr,\n    gh,\n    newpackage,\n    spelling,\n    testthat,\n    whoami,\n    withr"

So the full list of dependencies are now

desc_get_deps()
#>        type    package version
#> 1   Depends          R  >= 3.4
#> 2   Imports        cli       *
#> 3   Imports         R6       *
#> 4   Imports      utils       *
#> 5  Suggests      callr       *
#> 6  Suggests       covr       *
#> 7  Suggests         gh       *
#> 8  Suggests newpackage       *
#> 9  Suggests   spelling       *
#> 10 Suggests   testthat       *
#> 11 Suggests     whoami       *
#> 12 Suggests      withr       *

Code of Conduct

Please note that the desc project is released with a Contributor Code of Conduct. By contributing to this project, you agree to abide by its terms.

desc's People

Contributors

ateucher avatar dpastoor avatar dpprdan avatar gaborcsardi avatar hadley avatar jennybc avatar jeroen avatar jimhester avatar krlmlr avatar llrs avatar lorenzwalthert avatar lwjohnst86 avatar maelle avatar malcolmbarrett avatar muschellij2 avatar mvkorpel avatar niceume avatar richfitz avatar salim-b avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

desc's Issues

Error on missing file

desc::desc("foo")
#> Error: File file does not exist
desc::desc_get("Package", "foo")
#> Error: File file does not exist

I would have expected something like

Error: File 'foo' does not exist

Non-OO API

So that one can add a dependency without having to create an object, etc.

Whitespace noise

Hello,

The write() method adds unwanted whitespace, which creates commit noise.

description-whitespace

This happens to all fields whose first element is on a new line.

Alias desc to description$new()

So you can do desc::desc(path) (which is what I try and do every time I use the package)

Would be even nicer to make it

desc <- function(path, name = "DESCRIPTION") { 
  description$new(file.path(path, name))
}

Or since it's just a helper and won't be needed for testing, just provide the path.

get_one helper?

Something like:

get_one <- function(key) {
  fields <- self$get(key)
  if (length(fields)  != 1) {
   stop(length(fields), " fields, not one", call. = FALSE)
  }

  fields[[1]]
}

Maybe get_value()? Or get_single()?

Use internal tar

Helps consistency on Windows. According to ?untar the only reliable way to achieve this is to call untar() with a connection.

Reference: r-lib/rcmdcheck#55.

Validation (again)

So, the thing is, some fields are hard to validate. Take the License field as an example. In https://github.com/wch/r-source/blob/trunk/src/library/tools/R/license.R ~800 lines of code deal with this.

So I am unsure what to do. Options are:

  1. Do not validate fields properly, just do some simple syntax checks. R CMD check will catch the rest.
  2. Copy over the code from tools. :/
  3. Call the (non-exported) functions in tools
  4. Reimplement the checks that are in tools.
  5. Ask CRAN (Kurt) to export some of these functions from tools.

1-4 are all bad options, for various reasons. 5 is unlikely to be successful. Right now I am leaning towards 3.

@hadley what do you think?

Automatic forwarding to implementations

description <- R6Class("description",
  public = list(

    ## Either from a file, or from a character vector
    initialize = forward_to_impl(idesc_create),

    write = forward_to_impl(idesc_write),

    ....

Motivation: 0f89b50.

Downside: Implementations need to be defined before the class.

Implementation: Similar to https://github.com/krlmlr/hms/blob/master/R/aaa-tools.R.

Interested?

OTOH, one might argue that this really belongs in R6:

description <- R6Class("description",
  public = list(

    ## Either from a file, or from a character vector
    initialize = idesc_create,

    write = idesc_write,

    ....

Helper for licenses?

Not entirely sure if this would be useful. But I need to parse for pkgdown so I can automatically add links to licenses. If it looks like what I implement will be general, I can move the code here. (But currently I'm guessing it'll be some hacky search & replace of license names with links)

Return NULL instead of NA when field does not exist

In R NA is the presence of an absence, NULL the absence of a presence (ancient Hadley proverb).

It'd make more sense to return NULL when a field is not existing. Also it'd prevent weird code. For testing absent fields we'd have:

note <- desc$get("myfield")

if (is.null(note))

instead of

if (identical(note, c(myfield = NA_character_)))

Trailing whitespace behavior when moving dependencies to multiple lines

desc tries very hard to preserve trailing whitespace, however there is one place maybe we should be removing it.

If you have a dependency on the first line, and desc reformats the fields so they are on multiple lines, the trailing whitespace on the first line is preserved.

Depends: pkg1, pkg2, pkg3
Depends: <- space here
  pkg1,
  pkg2
  pkg3

While the current behavior is technically correct (there was a space after the :) I think it is generally not what is desired in this case. Either the behavior could be tweaked when splitting dependencies across lines or perhaps a function to strip all trailing whitespace could be added?

First observed at r-lib/usethis#49

Depends after Imports?

Is there a specific reason why "Depends" is listed after "Imports" in dep_types? Also, why is "VignetteBuilder" not included?

An attempt to change this breaks tests, so I thought I'd ask before PRing ;-)

Only one Author

Using pkgdown::build_site, it calls desc and returns the error:

Error in ensure_authors_at_r(self) : No 'Authors@R' field!
You can create one with $add_author

if there is an Author: field but not a Authors@R: field. I simply made the field (deleting Author) and it went well.

Just wondering if you support simple, single author fields.

Multiple comments per author returns with error

What

I'm trying to add the ORCID component to the comment argument in the person function. While R CMD check works fine with comment fields that have more than one element per person (vectors), desc::desc_normalize() and desc::add_author fail when passing comments with more than one element:

descr <- desc::desc(find.package("desc"))
descr$add_author(given = "Nice",
                 family = "Developer",
                 comment = c(ORCID = "orcid_number", what="he did it"))
descr$write("DESCRIPTION")

Returns with

Error: comment must be a string or NULL

Session info

Session info --------------------------------------------------------------------------------------------------------------------------
 setting  value                       
 version  R version 3.4.4 (2018-03-15)
 system   x86_64, linux-gnu           
 ui       RStudio (1.1.419)           
 language en_US                       
 collate  en_US.UTF-8                 
 tz       America/Los_Angeles         
 date     2018-05-24                  

Packages ------------------------------------------------------------------------------------------------------------------------------
 package    * version    date       source                             
 assertthat   0.2.0      2017-04-11 CRAN (R 3.4.0)                     
 backports    1.1.2      2017-12-13 cran (@1.1.2)                      
 base       * 3.4.4      2018-03-16 local                              
 clisymbols   1.2.0      2017-05-21 cran (@1.2.0)                      
 compiler     3.4.4      2018-03-16 local                              
 crayon       1.3.4      2017-09-16 CRAN (R 3.4.1)                     
 datasets   * 3.4.4      2018-03-16 local                              
 desc         1.2.0      2018-05-01 CRAN (R 3.4.4)                     
 devtools     1.13.5     2018-02-18 CRAN (R 3.4.3)                     
 digest       0.6.15     2018-01-28 cran (@0.6.15)                     
 graphics   * 3.4.4      2018-03-16 local                              
 grDevices  * 3.4.4      2018-03-16 local                              
 grid         3.4.4      2018-03-16 local                              
 highlight    0.4.7.2    2017-10-04 cran (@0.4.7.2)                    
 lattice      0.20-35    2017-03-25 CRAN (R 3.3.3)                     
 Matrix       1.2-14     2018-04-09 CRAN (R 3.4.4)                     
 memoise      1.1.0      2017-04-21 CRAN (R 3.4.0)                     
 methods    * 3.4.4      2018-03-16 local                              
 R6           2.2.2      2017-06-17 CRAN (R 3.4.0)                     
 rprojroot    1.3-2      2018-01-03 cran (@1.3-2)                      
 rstudioapi   0.7.0-9000 2018-05-24 Github (rstudio/rstudioapi@12870f8)
 stats      * 3.4.4      2018-03-16 local                              
 tools        3.4.4      2018-03-16 local                              
 usethis      1.3.0      2018-02-24 CRAN (R 3.4.3)                     
 utils      * 3.4.4      2018-03-16 local                              
 withr        2.1.2      2018-03-15 cran (@2.1.2)                      
 yaml         2.1.19     2018-05-01 CRAN (R 3.4.4)    

Classes for fields

For syntax only, probably, no semantics. I.e. we do not check that the packages listed in Imports are available from CRAN, but we check that they are valid package names.

desc_add_url etc

Would be useful if desc_add_url() did not add duplicates, and returned TRUE/FALSE.

Expose version incrementing logic

Would you be receptive to a PR that moves version incrementation into an exported helper?

It would be nice to use in, e.g., usethis. Basically present and preview the versions that would result from incrementing major, minor, patch and dev.

Right now desc's logic is locked into the method that actually does the incrementing.

desc/R/version.R

Lines 13 to 50 in 1565190

idesc_bump_version <- function(self, private, which) {
assert_that(is_version_component(which))
if (is.character(which)) {
which <- match(which, c("major", "minor", "patch", "dev"))
}
ver_str <- self$get_version()
ver <- get_version_components(ver_str)
## Special dev version
inc <- if (which == 4 && length(ver) < 4) 9000 else 1
## Missing components are equivalent to zero
if (which > length(ver)) ver <- c(ver, rep(0, which - length(ver)))
## Bump selected component
ver[which] <- ver[which] + inc
## Zero out everything after
if (which < length(ver)) ver[(which+1):length(ver)] <- 0
## Keep at most three components if they are zero
if (length(ver) > 3 && all(ver[4:length(ver)] == 0)) {
ver <- ver[1:3]
}
## Set the new version
new_ver <- package_version(paste(ver, collapse = "."))
self$set_version(new_ver)
## Give a message
message(
"Package version bumped from ", sQuote(ver_str),
" to ", sQuote(new_ver)
)
invisible(self)
}

Depend on rprojroot?

desc would seem to be a natural home to replace the functionality previously found in devtools::as.package(), i.e. returning a DESCRIPTION file, looking in parent directories as necessary. Maybe desc::package_desc()?

Alternatively, you could always call rprojroot, when given a directory as file.

FR: Standardized order of entries

Makes a difference both in the printed manual, and also helps when editing the DESCRIPTION. Should be an option for writing, or a transformation of a description object

First draft:

  1. Title
  2. Description
  3. Authors@R
  4. Date
  5. Version
  6. License
  7. BugReports, URL
  8. Dependencies
  9. LazyData, RoxygenNote, Encoding, etc.
  10. Collate

Which fields have I missed?

backports dependency?

trying to install from github and ran into this error:

* installing *source* package 'desc' ...
** R
** inst
** tests
** preparing package for lazy loading
Error in loadNamespace(i, c(lib.loc, .libPaths()), versionCheck = vI[[i]]) : 
  there is no package called 'backports'
ERROR: lazy loading failed for package 'desc'
* removing 'C:/Program Files/R/R-3.3.2/library/desc'
* restoring previous 'C:/Program Files/R/R-3.3.2/library/desc'
Error: Command failed (1)

I looked for a backports import somewhere in the package and didn't see any so didn't know where the dependency was causing the failure.

Running

install.packages("backports")

resolved the issue.

Think about encoding

Follow-up to r-lib/devtools#932 (comment).

If you want an accurate representation of the semantics of the DESCRIPTION file in your class, I think there's no way around decoding on input and encoding on output. Looks like this is what R does, too. This will be mostly relevant for author names, though.

Need to rename

Because R CMD INSTALL fails to install the package on case-insensitive file systems. It is an R bug, you effective cannot have a package called description.

I'll rename it to desc or pkgdesc.

desc_has_dep ?

Verify against type if supplied, ignore version (as I can't see how you'd handle it)

ORCID

One can now add ORCID for authors of a package on CRAN and it's shown with a nice icon in the CRAN page of a package e.g. https://cran.r-project.org/web/packages/fasterize/index.html

I'm wondering how to use desc to add an ORCID for an author. Should this be a separate argument of authors helpers, although the ORCID information is supposed to live in comment (as per https://cran.r-project.org/web/packages/submission_checklist.html "For persons with an ORCID identifier (see https://orcid.org/ for more information, provide the identifier via an element named "ORCID" in the comment argument of person(). Example: person("Achim", "Zeileis", comment = c(ORCID = "0000-0003-0918-3766")). ")?

Currently when trying to add the ORCID via comment I used this workflow

descr <- desc::desc(find.package("desc"))
descr$add_author(given = "Nice",
                 family = "Developer",
                 comment = c(ORCID = "orcid_number"))
descr$write("DESCRIPTION")

Maybe this is not the right way to save DESCRIPTION? If it is, when using this in the file comment becomes "comment = structure("orcid_number", .Names = "ORCID"))" which I'm not sure would be parsed by CRAN (but I haven't tried).

"version" column in get_deps() and set_deps()

Tried to add a dependency with NA value in version column, the results were... interesting:

# devtools::install_github("krlmlr/tibble")
d$get_deps() %>% tibble::add_row(type = "Imports", package = "DBI") %>% d$set_deps()

It works as expected when I say version = "*", though.

Will there be an add_dep() or even a remove_dep() function?

get_field()

I realise now the semantics I actually wanted with get_or_fail() and a better name.

desc$get_field("invalid")
#> Error: Field 'invalid' not found

desc$get_field("invalid", default = NULL)
#> NULL

Author field problems

  • Authors@R messed up by normalize()
  • message suggests using to_authors_at_r() function which doesn't seem to exist
  • description::description$new("!new")$get_author() returns NULL but shouldn't

In 6dfb24e.

NB: Have you tried as.person.character() for parsing Author and Maintainer fields?

Need to translate DESCRIPTION if the specified `Encoding` is not the same as the system encoding.

For instance trying to read the DESCRIPTION file from the RArcInfo package, which has a declared encoding of latin1 while the session encoding is UTF-8.

desc::desc("RArcInfo/DESCRIPTION.txt")
Warning in grepl(re_maint, x$value) :
  input string 1 is invalid in this locale
Error in gsub(st$close, st$open, text, fixed = TRUE) :
  input string 1 is invalid in this locale

Relevant lines from packageDescription would seem to address this issue.

https://github.com/wch/r-source/blob/93b33adbcecd4a2577e1d5b873bef9a52fd734b8/src/library/utils/R/indices.R#L76-L106

Unparsed authors representation?

library(desc)
d <- desc(text = c(
  "Package: foobar", 
  "Authors@R: person('Hadley', 'Wickham', role = c('cre', 'aut'))"
))
cat(d$str())
#> Package: foobar
#> Authors@R:
#>     person(given = "Hadley",
#>            family = "Wickham",
#>            role = c("cre", "aut"))

How can I avoid mangling the authors string?

(This is in the context of usethis::use_description() where I'm creating a description from scratch, not modifying an existing DESCRIPTION)

Collate has trailing space

When the collate field is being written, it is saving a space at the end of the line "Collate: ".

Could this be changed to "Collate:"?

Thank you,
Barret

Better error if file doesn't exist

> desc::description$new("asfsd")
 Error in if (is_dir(file)) file <- file.path(file, "DESCRIPTION") : 
  missing value where TRUE/FALSE needed 

desc_get_urls() doesn't account for some real-world phenomena

Perhaps desc_get_urls() should filter its results for matches against some URL regex? And trim whitespace before it parses. I see two main problems:

  • Leading newline, before any URL data
  • Leading and trailing descriptors, such as "Mailing list:" or "(devel)" or "S-plus original at"

I was looking at the URL fields for all the packages I've installed from CRAN and quite a few feature some weird stuff, which desc_get_urls() dutifully returns. Here are some examples.

library(tidyverse)
library(desc)
#> 
#> Attaching package: 'desc'
#> The following object is masked from 'package:dplyr':
#> 
#>     desc
weird <- c("ade4", "ade4TkGUI", "adegraphics", "BB", "CircStats", "commonmark",
           "curl", "dfoptim", "dynamicTreeCut", "fitdistrplus", "hunspell",
           "memisc", "multcomp", "pdftools", "RMySQL", "sodium")
df <- tibble(
  Package = weird,
  dpath = map_chr(Package, ~ system.file("DESCRIPTION", package = .x)),
  URL = map(dpath, desc_get_urls)
) %>% 
  select(-dpath) %>% 
  unnest() %>% 
  print(n = Inf)
#> # A tibble: 60 x 2
#>    Package        URL                                                     
#>    <chr>          <chr>                                                   
#>  1 ade4           http://pbil.univ-lyon1.fr/ADE-4                         
#>  2 ade4           Mailing                                                 
#>  3 ade4           list:                                                   
#>  4 ade4           http://listes.univ-lyon1.fr/wws/info/adelist            
#>  5 ade4TkGUI      http://pbil.univ-lyon1.fr/ade4TkGUI                     
#>  6 ade4TkGUI      Mailing                                                 
#>  7 ade4TkGUI      list:                                                   
#>  8 ade4TkGUI      http://listes.univ-lyon1.fr/wws/info/adelist            
#>  9 adegraphics    http://pbil.univ-lyon1.fr/ADE-4                         
#> 10 adegraphics    Mailing                                                 
#> 11 adegraphics    list:                                                   
#> 12 adegraphics    http://listes.univ-lyon1.fr/wws/info/adelist            
#> 13 BB             ""                                                      
#> 14 BB             http://www.jhsph.edu/agingandhealth/People/Faculty_pers…
#> 15 CircStats      S-plus                                                  
#> 16 CircStats      original                                                
#> 17 CircStats      at                                                      
#> 18 CircStats      http://statweb.calpoly.edu/lund/                        
#> 19 commonmark     http://github.com/jeroen/commonmark                     
#> 20 commonmark     (devel)                                                 
#> 21 commonmark     https://github.github.com/gfm/                          
#> 22 commonmark     (spec)                                                  
#> 23 curl           https://github.com/jeroen/curl#readme                   
#> 24 curl           (devel)                                                 
#> 25 curl           https://curl.haxx.se/libcurl/                           
#> 26 curl           (upstream)                                              
#> 27 dfoptim        ""                                                      
#> 28 dfoptim        http://www.jhsph.edu/agingandhealth/People/Faculty_pers…
#> 29 dynamicTreeCut ""                                                      
#> 30 dynamicTreeCut http://www.genetics.ucla.edu/labs/horvath/CoexpressionN…
#> 31 fitdistrplus   MailingList:                                            
#> 32 fitdistrplus   http://listes.univ-lyon1.fr/wws/info/fitdist-users;     
#> 33 fitdistrplus   https://lbbe.univ-lyon1.fr/fitdistrplus.html            
#> 34 fitdistrplus   http://riskassessment.r-forge.r-project.org             
#> 35 hunspell       https://github.com/ropensci/hunspell#readme             
#> 36 hunspell       (devel)                                                 
#> 37 hunspell       https://hunspell.github.io                              
#> 38 hunspell       (upstream)                                              
#> 39 memisc         ""                                                      
#> 40 memisc         http://www.elff.eu/software/memisc/                     
#> 41 memisc         http://github.com/melff/memisc/                         
#> 42 multcomp       http://multcomp.R-forge.R-project.org                   
#> 43 multcomp       The                                                     
#> 44 multcomp       publishers                                              
#> 45 multcomp       web                                                     
#> 46 multcomp       page                                                    
#> 47 multcomp       is                                                      
#> 48 multcomp       http://www.crcpress.com/product/isbn/9781584885740      
#> 49 pdftools       https://ropensci.org/blog/2016/03/01/pdftools-and-jeroen
#> 50 pdftools       (blog)                                                  
#> 51 pdftools       https://github.com/ropensci/pdftools#readme             
#> 52 pdftools       (devel)                                                 
#> 53 pdftools       https://poppler.freedesktop.org                         
#> 54 pdftools       (upstream)                                              
#> 55 RMySQL         https://downloads.mariadb.org/connector-c/              
#> 56 RMySQL         (upstream)                                              
#> 57 sodium         https://github.com/jeroen/sodium#readme                 
#> 58 sodium         (devel)                                                 
#> 59 sodium         https://download.libsodium.org/doc/                     
#> 60 sodium         (upstream)

Created on 2018-01-01 by the reprex package (v0.1.1.9000).

helper function to convert to packageDescription

I need to use a description object generated by utils::packageDescription in a citation call (see below).

I have a description object generated by desc::desc(), but there doesn't seem to be a wrapper in this package to go from a description to a packageDescription.

Would a helper function that converts a description to a packageDescription be useful in this package? Happy to submit a PR.

Related to r-lib/pkgdown#493

library(desc)

desc_base <- utils::packageDescription("stats")
class(desc_base)
#> [1] "packageDescription"

citation("stats", auto = desc_base)
#> 
#> The 'stats' package is part of R.  To cite R in publications use:
#> 
#>   R Core Team (2017). R: A language and environment for
#>   statistical computing. R Foundation for Statistical Computing,
#>   Vienna, Austria. URL https://www.R-project.org/.
#> 
#> A BibTeX entry for LaTeX users is
#> 
#>   @Manual{,
#>     title = {R: A Language and Environment for Statistical Computing},
#>     author = {{R Core Team}},
#>     organization = {R Foundation for Statistical Computing},
#>     address = {Vienna, Austria},
#>     year = {2017},
#>     url = {https://www.R-project.org/},
#>   }
#> 
#> We have invested a lot of time and effort in creating R, please
#> cite it when using it for data analysis. See also
#> 'citation("pkgname")' for citing R packages.

desc_desc <- desc::desc(package = "stats")
class(desc_desc)
#> [1] "description" "R6"

citation("stats", auto = desc_desc)
#> Error in !auto: invalid argument type

# need this:
# desc_new <- desc::to_packageDescription(desc_desc)
# and then this should work:
# citation("stats", auto = desc_new)

Created on 2018-01-23 by the reprex package (v0.1.1.9000).

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.