File: venues.R

package info (click to toggle)
r-cran-reprex 1.0.0-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, sid
  • size: 1,584 kB
  • sloc: sh: 13; makefile: 2
file content (62 lines) | stat: -rw-r--r-- 1,557 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# nocov start

#' Venue-specific shortcuts
#'
#' These are thin wrappers around `reprex()` that incorporate the target `venue`
#' as a suffix in the function name, for easier access via auto-completion.
#'
#' @param ... Passed along to [reprex()].
#'
#' @name reprex_venue
NULL

#' @export
#' @rdname reprex_venue
reprex_html <- function(...) reprex(..., venue = "html")

#' @export
#' @rdname reprex_venue
reprex_r <- function(...) reprex(..., venue = "r")

#' @export
#' @rdname reprex_venue
reprex_rtf <- function(...) reprex(..., venue = "rtf")

#' @export
#' @rdname reprex_venue
reprex_slack <- function(...) reprex(..., venue = "slack")

# these should exist for completeness, but I predict they'd never get used and
# they just clutter the auto-complete landscape
# reprex_gh <- function(...) reprex(..., venue = "gh")
# reprex_so <- function(...) reprex(..., venue = "so")
# reprex_ds <- function(...) reprex(..., venue = "ds")

# nocov ends

normalize_venue <- function(venue) {
  venue <- ds_is_gh(venue)
  venue <- so_is_gh(venue)
  venue <- rtf_requires_highlight(venue)
  venue
}

ds_is_gh <- function(venue) {
  if (venue == "ds") {
    reprex_info('
      The Discourse venue "ds" is an alias for the default GitHub venue "gh".
      There is no need to specify the venue.')
    venue <- "gh"
  }
  venue
}

so_is_gh <- function(venue) {
  if (venue == "so") {
    reprex_info('
      The Stack Overflow venue "so" is an alias for the default GitHub venue
      "gh". There is no need to specify the venue.')
    venue <- "gh"
  }
  venue
}