Skip to content

Commit 4963b4f

Browse files
committed
update
1 parent 2fd9e6d commit 4963b4f

File tree

4 files changed

+27
-23
lines changed

4 files changed

+27
-23
lines changed

R/rstd-GEN.R

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# DO NOT EDIT THIS FILE BY HAND! Instead edit the R Markdown source file `Rmd/rstd.Rmd` and run `pkgpurl::purl_rmd()`.
2-
# See `README.md#literate-programming` for more information on the literature programming approach used applying the R Markdown format.
2+
# See `README.md#r-markdown-format` for more information on the literature programming approach used applying the R Markdown format.
33

44
utils::globalVariables(names = c(".",
55
"Key",
@@ -33,7 +33,7 @@ is_uptodate <- function(stable = TRUE,
3333
#' @param pro `TRUE` for the proprietary RStudio (Server) Pro edition and `FALSE` for the open-source RStudio (Server) edition.
3434
#' @param os The OS _codename_ for which the RStudio version was built. If `NULL`, it will be auto-detected for the current system.
3535
#'
36-
#' @return `r pkgsnippets::return_label("version_nr")`
36+
#' @return `r pkgsnip::return_label("version_nr")`
3737
#' @export
3838
#'
3939
#' @examples
@@ -93,10 +93,10 @@ latest_version <- function(type = c("desktop", "server"),
9393
#' [RStudio Server](https://rstudio.com/products/rstudio/#rstudio-server) release metadata.
9494
#' @param stable Set to `FALSE` to retrieve release metadata of [RStudio preview builds](https://rstudio.com/products/rstudio/download/preview/) instead of
9595
#' [stable builds](https://rstudio.com/products/rstudio/download/).
96-
#' @param use_cache `r pkgsnippets::param_label("use_cache")`
97-
#' @param cache_lifespan `r pkgsnippets::param_label("cache_lifespan")` Defaults to 1 day (24 hours).
96+
#' @param use_cache `r pkgsnip::param_label("use_cache")`
97+
#' @param cache_lifespan `r pkgsnip::param_label("cache_lifespan")` Defaults to 1 day (24 hours).
9898
#'
99-
#' @return `r pkgsnippets::return_label("data")`
99+
#' @return `r pkgsnip::return_label("data")`
100100
#' @export
101101
#'
102102
#' @examples
@@ -167,7 +167,7 @@ get_releases <- function(type,
167167

168168
#' Determine version of Pandoc bundled with RStudio
169169
#'
170-
#' @return `r pkgsnippets::return_label("version_nr")`
170+
#' @return `r pkgsnip::return_label("version_nr")`
171171
#' @export
172172
bundled_pandoc_version <- function() {
173173

README.Rmd

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,17 @@ output: pal::gitlab_document
77
`r pal::desc_value("Description")`
88

99
## Installation
10-
```{r, install-snippet-dev, child = pkgsnippets::snippet_path("installation-notice_dev-version_gitlab.Rmd")}
10+
```{r, install-snippet-dev, child = pkgsnip::snip_path("installation-notice_dev-version_gitlab.Rmd")}
1111
```
1212

1313
## Development
1414

15-
### Literate Programming
16-
```{r, literate-programming-snippet, child = pkgsnippets::snippet_path("literate-programming-notice.Rmd")}
15+
### R Markdown format
16+
```{r, rmd-pkg-snippet, child = pkgsnip::snip_path("rmd-package-notice.Rmd")}
1717
```
1818

19-
### Coding Style
20-
```{r, coding-style-snippet, child = pkgsnippets::snippet_path("coding-style-notice.Rmd")}
19+
### Coding style
20+
```{r, coding-style-snippet, child = pkgsnip::snip_path("coding-style-notice.Rmd")}
2121
```
2222

2323
## See also

README.md

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,19 +17,21 @@ remotes::install_gitlab(repo = "salim_b/r/pkgs/rstd")
1717

1818
## Development
1919

20-
### Literate Programming
20+
### R Markdown format
2121

22-
This package is written using a [literate programming](https://en.wikipedia.org/wiki/Literate_programming) approach [originally proposed by Yihui Xie](https://yihui.name/rlp/). All the `-GEN.R` suffixed R source code found under [`R/`](R/) is generated from their respective [R Markdown](https://rmarkdown.rstudio.com/) counterparts using [`pkgpurl::purl_rmd()`](https://gitlab.com/salim_b/r/pkgs/pkgpurl/). Always make changes only to the `.Rmd` files – not the `.R` files – and then run `pkgpurl::purl_rmd()` to regenerate the R source code.
22+
This package’s source code is written in the [R Markdown](https://rmarkdown.rstudio.com/) file format to facilitate practices commonly referred to as [*literate programming*](https://en.wikipedia.org/wiki/Literate_programming). It allows the actual code to be freely mixed with explanatory and supplementary information in expressive Markdown format instead of having to rely on [`#` comments](https://cran.r-project.org/doc/manuals/r-release/R-lang.html#Comments) only.
2323

24-
### Coding Style
24+
All the `-GEN.R` suffixed R source code found under [`R/`](R/) is generated from the respective R Markdown counterparts under [`Rmd/`](Rmd/) using [`pkgpurl::purl_rmd()`](https://gitlab.com/salim_b/r/pkgs/pkgpurl/)[^1]. Always make changes only to the `.Rmd` files – never the `.R` files – and then run `pkgpurl::purl_rmd()` to regenerate the R source files.
25+
26+
### Coding style
2527

2628
This package borrows a lot of the [Tidyverse](https://www.tidyverse.org/) design philosophies. The R code adheres to the principles specified in the [Tidyverse Design Guide](https://principles.tidyverse.org/) wherever possible and is formatted according to the [Tidyverse Style Guide](https://style.tidyverse.org/) (TSG) with the following exceptions:
2729

2830
- Line width is limited to **160 characters**, double the [limit proposed by the TSG](https://style.tidyverse.org/syntax.html#long-lines) (80 characters is ridiculously little given today’s high-resolution wide screen monitors).
2931

30-
- Usage of [magrittr’s compound assignment pipe-operator `%<>%`](https://magrittr.tidyverse.org/reference/compound.html) is desirable[^1].
32+
- Usage of [magrittr’s compound assignment pipe-operator `%<>%`](https://magrittr.tidyverse.org/reference/compound.html) is desirable[^2].
3133

32-
- Usage of [R’s right-hand assignment operator `->`](https://rdrr.io/r/base/assignOps.html) is not allowed[^2].
34+
- Usage of [R’s right-hand assignment operator `->`](https://rdrr.io/r/base/assignOps.html) is not allowed[^3].
3335

3436
As far as possible, these deviations from the TSG plus some additional restrictions are formally specified in the [lintr configuration file](https://github.com/jimhester/lintr#project-configuration) [`.lintr`](.lintr), so lintr can be used right away to check for formatting issues:
3537

@@ -41,6 +43,8 @@ pkgpurl::lint_rmd()
4143

4244
- The official [**rstudioapi**](https://rstudio.github.io/rstudioapi/) R package containing a handful of useful wrapper functions to access the [RStudio API](https://rstudio.github.io/rstudio-extensions/rstudioapi.html).
4345

44-
[^1]: The TSG [explicitly instructs to avoid this operator](https://style.tidyverse.org/pipes.html#assignment-1) – presumably because it’s relatively unknown and therefore might be confused with the forward pipe operator `%>%` when skimming code only briefly. I don’t consider this to be an actual issue since there aren’t many sensible usage patterns of `%>%` at the beginning of a pipe sequence inside a function – I can only think of creating side effects and relying on [R’s implicit return of the last evaluated expression](https://rdrr.io/r/base/function.html). Therefore – and because I really like the `%<>%` operator – it’s usage is welcome.
46+
[^1]: This naming convention as well as the very idea to leverage the R Markdown format to author R packages was originally proposed by Yihui Xie. See his excellent [blog post](https://yihui.name/rlp/) for more detailed information about the benefits of literate programming techniques and some practical examples. Note that using `pkgpurl::purl_rmd()` is a less cumbersome alternative to the Makefile approach outlined by him.
47+
48+
[^2]: The TSG [explicitly instructs to avoid this operator](https://style.tidyverse.org/pipes.html#assignment-1) – presumably because it’s relatively unknown and therefore might be confused with the forward pipe operator `%>%` when skimming code only briefly. I don’t consider this to be an actual issue since there aren’t many sensible usage patterns of `%>%` at the beginning of a pipe sequence inside a function – I can only think of creating side effects and relying on [R’s implicit return of the last evaluated expression](https://rdrr.io/r/base/function.html). Therefore – and because I really like the `%<>%` operator – it’s usage is welcome.
4549

46-
[^2]: The TSG [explicitly accepts `->` for assignments at the end of a pipe sequence](https://style.tidyverse.org/pipes.html#assignment-1) while Google’s R Style Guide [considers this bad practice](https://google.github.io/styleguide/Rguide.html#right-hand-assignment) because it “makes it harder to see in code where an object is defined”. I second the latter.
50+
[^3]: The TSG [explicitly accepts `->` for assignments at the end of a pipe sequence](https://style.tidyverse.org/pipes.html#assignment-1) while Google’s R Style Guide [considers this bad practice](https://google.github.io/styleguide/Rguide.html#right-hand-assignment) because it “makes it harder to see in code where an object is defined”. I second the latter.

Rmd/rstd.Rmd

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ is_uptodate <- function(stable = TRUE,
7979
#' @param pro `TRUE` for the proprietary RStudio (Server) Pro edition and `FALSE` for the open-source RStudio (Server) edition.
8080
#' @param os The OS _codename_ for which the RStudio version was built. If `NULL`, it will be auto-detected for the current system.
8181
#'
82-
#' @return `r pkgsnippets::return_label("version_nr")`
82+
#' @return `r pkgsnip::return_label("version_nr")`
8383
#' @export
8484
#'
8585
#' @examples
@@ -162,10 +162,10 @@ TODO:
162162
#' [RStudio Server](https://rstudio.com/products/rstudio/#rstudio-server) release metadata.
163163
#' @param stable Set to `FALSE` to retrieve release metadata of [RStudio preview builds](https://rstudio.com/products/rstudio/download/preview/) instead of
164164
#' [stable builds](https://rstudio.com/products/rstudio/download/).
165-
#' @param use_cache `r pkgsnippets::param_label("use_cache")`
166-
#' @param cache_lifespan `r pkgsnippets::param_label("cache_lifespan")` Defaults to 1 day (24 hours).
165+
#' @param use_cache `r pkgsnip::param_label("use_cache")`
166+
#' @param cache_lifespan `r pkgsnip::param_label("cache_lifespan")` Defaults to 1 day (24 hours).
167167
#'
168-
#' @return `r pkgsnippets::return_label("data")`
168+
#' @return `r pkgsnip::return_label("data")`
169169
#' @export
170170
#'
171171
#' @examples
@@ -240,7 +240,7 @@ get_releases <- function(type,
240240
```{r}
241241
#' Determine version of Pandoc bundled with RStudio
242242
#'
243-
#' @return `r pkgsnippets::return_label("version_nr")`
243+
#' @return `r pkgsnip::return_label("version_nr")`
244244
#' @export
245245
bundled_pandoc_version <- function() {
246246

0 commit comments

Comments
 (0)