tidyverse / style

The tidyverse style guide for R code
https://style.tidyverse.org
Other
293 stars 100 forks source link

Moving towards {package} for package naming #180

Open lorenzwalthert opened 2 years ago

lorenzwalthert commented 2 years ago

The current recommendation is to use package on first usage, then just package I believe, or just package (Reference: https://github.com/tidyverse/style/issues/50). A recent trend is that people opt for {package}, .e.g. on Twitter. This notation is deeply rooted in base R, e.g. in help files:

Screenshot 2021-10-28 at 20 14 46

To me, it makes perfect sense because it won't be confused with code_we <- write or pkg::fun(), yet {package} stands out from normal text with a unique visual signature, without conflicting with common usage of italics, bold or "quoted".

Here's a visual comparison:

kellijohnson-NOAA commented 2 years ago

I would add the following suggestion to @lorenzwalthert's. If you delineate a package using the {packagename} convention, one should NOT put the word "package" after the curly braces. All of the suggestions provided by @lorenzwalthert follow this convention but I see lots of examples on the web that look like {packagename} package. I find it redundant and think it would be a good idea, if @lorenzwalthert's suggestion is included in the style guide, to explicitly state

The word package should not be added after the curly braces.

IndrajeetPatil commented 4 months ago

Using this convention also helps {pkgdown} to link to the package website, if one exists and is mentioned in the DESCRIPTION file:

downlit:::autolink_curly("{cli}")
#> [1] "<a href='https://cli.r-lib.org'>cli</a>"

Created on 2024-04-21 with reprex v2.1.0