Skip to content

Commit

Permalink
Merge commit 'deac35040916b02b6af9daa84310ca2a7f8903e1'
Browse files Browse the repository at this point in the history
  • Loading branch information
gaborcsardi committed Sep 13, 2023
2 parents 1abc22e + deac350 commit a23714a
Show file tree
Hide file tree
Showing 93 changed files with 1,115 additions and 206 deletions.
7 changes: 6 additions & 1 deletion .github/workflows/pkgdown.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ jobs:
group: pkgdown-${{ github.event_name != 'pull_request' || github.run_id }}
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
R_CLI_NUM_COLORS: 256
steps:
- uses: actions/checkout@v3

Expand All @@ -37,8 +38,12 @@ jobs:
needs: website

- name: Build site
run: pkgdown::build_site_github_pages(new_process = FALSE, install = FALSE)
run: |
rmarkdown::render("README.Rmd")
pkgdown::build_site_github_pages(new_process = FALSE, install = FALSE)
shell: Rscript {0}
env:
IN_PKGDOWN: true

- name: Deploy to GitHub pages 🚀
if: github.event_name != 'pull_request'
Expand Down
72 changes: 72 additions & 0 deletions .github/workflows/rhub.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
# R-hub's genetic GitHub Actions workflow file. It's canonical location is at
# https://github.com/r-hub/rhub2/blob/v1/inst/workflow/rhub.yaml
# You can update this file to a newer version using the rhub2 package:
#
# rhub2::rhub_setup()
#
# It is unlikely that you need to modify this file manually.

name: R-hub

on:
workflow_dispatch:
inputs:
config:
description: 'A comma separated list of R-hub platforms to use.'
type: string
default: 'linux,windows,macos'

jobs:

setup:
runs-on: ubuntu-latest
outputs:
containers: ${{ steps.rhub-setup.outputs.containers }}
platforms: ${{ steps.rhub-setup.outputs.platforms }}

steps:
# NO NEED TO CHECKOUT HERE
- uses: r-hub/rhub2/actions/rhub-setup@v1
with:
config: ${{ github.event.inputs.config }}
id: rhub-setup

linux-containers:
needs: setup
if: ${{ needs.setup.outputs.containers != '[]' }}
runs-on: ubuntu-latest
name: ${{ matrix.config.label }}
strategy:
fail-fast: false
matrix:
config: ${{ fromJson(needs.setup.outputs.containers) }}
container:
image: ${{ matrix.config.container }}

steps:
- uses: actions/checkout@v3
- uses: r-hub/rhub2/actions/rhub-check@v1
with:
token: ${{ secrets.RHUB_TOKEN }}
job-config: ${{ matrix.config.job-config }}

other-platforms:
needs: setup
if: ${{ needs.setup.outputs.platforms != '[]' }}
runs-on: ${{ matrix.config.os }}
name: ${{ matrix.config.label }}
strategy:
fail-fast: false
matrix:
config: ${{ fromJson(needs.setup.outputs.platforms) }}

steps:
- uses: actions/checkout@v3
- uses: r-hub/rhub2/actions/rhub-setup-r@v1
with:
job-config: ${{ matrix.config.job-config }}
token: ${{ secrets.RHUB_TOKEN }}
- uses: r-hub/rhub2/actions/rhub-check@v1
with:
job-config: ${{ matrix.config.job-config }}
token: ${{ secrets.RHUB_TOKEN }}
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: cli
Title: Helpers for Developing Command Line Interfaces
Version: 3.6.0.9000
Version: 3.6.1.9000
Authors@R: c(
person("Gábor", "Csárdi", , "[email protected]", role = c("aut", "cre")),
person("Hadley", "Wickham", role = "ctb"),
Expand Down Expand Up @@ -57,4 +57,4 @@ Config/Needs/website:
vctrs
Config/testthat/edition: 3
Encoding: UTF-8
RoxygenNote: 7.2.1.9000
RoxygenNote: 7.2.3
4 changes: 4 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
* `ansi_collapse(x, trunc = 1, style = "head")` now indeed show one element
if `length(x) == 2`, as documented (@salim-b, #572).

# cli 3.6.1

* ANSI hyperlinks are now turned off on the RStudio render plane (#581).

# cli 3.6.0

* The progressr progress handler now reports progress correctly
Expand Down
2 changes: 1 addition & 1 deletion R/aab-rstudio-detect.R
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ rstudio <- local({
ansi_tty = FALSE,
ansi_color = FALSE,
num_colors = 1L,
hyperlink = data$envs[["RSTUDIO_CLI_HYPERLINKS"]] != "",
hyperlink = FALSE,
has_canonical_mode = FALSE
)
}
Expand Down
12 changes: 1 addition & 11 deletions R/ansi-hyperlink.R
Original file line number Diff line number Diff line change
Expand Up @@ -327,17 +327,7 @@ ansi_has_hyperlink_support <- function() {
if (isTRUE(as.logical(enabled))){ return(TRUE) }

## If ANSI support is off, then this is off as well
opt <- as.integer(getOption("cli.num_colors", NULL))[1]
if (!is.na(opt) && opt == 1) return(FALSE)
env <- as.integer(Sys.getenv("R_CLI_NUM_COLORS", ""))[1]
if (!is.na(env) && env == 1) return(FALSE)
cray_opt <- as.logical(getOption("crayon.enabled", NULL))[1]
if (!is.na(cray_opt) && !cray_opt) return(FALSE)
if (!is.na(Sys.getenv("NO_COLOR", NA_character_))) return(FALSE)

## environment variable used by RStudio
enabled <- Sys.getenv("RSTUDIO_CLI_HYPERLINKS", "")
if (isTRUE(as.logical(enabled))){ return(TRUE) }
if (num_ansi_colors() == 1) return(FALSE)

## Are we in RStudio?
rstudio <- rstudio_detect()
Expand Down
4 changes: 4 additions & 0 deletions R/bullets.R
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@
#' @param class Optional additional class(es) for the `div.bullets` element.
#' @param .envir Environment to evaluate the glue expressions in.
#'
#' @seealso This function supports [inline markup][inline-markup].
#' @family functions supporting inline markup
#' @export

cli_bullets <- function(text, id = NULL, class = NULL,
Expand Down Expand Up @@ -75,7 +77,9 @@ cli_bullets <- function(text, id = NULL, class = NULL,
#' @param id Optional id of the `div.bullets` element, can be used in themes.
#' @param class Optional additional class(es) for the `div.bullets` element.
#'
#' @seealso These functions support [inline markup][inline-markup].
#' @seealso See [cli_bullets()] for examples.
#' @family functions supporting inline markup
#' @export

cli_bullets_raw <- function(text, id = NULL, class = NULL) {
Expand Down
23 changes: 22 additions & 1 deletion R/cli.R
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,8 @@ cli_fmt <- function(expr, collapse = FALSE, strip_newline = FALSE) {
#' and form feeds) as is in the input.
#' @return Character scalar, the formatted string.
#'
#' @seealso This function supports [inline markup][inline-markup].
#' @family functions supporting inline markup
#' @export
#' @examples
#' format_inline("A message for {.emph later}, thanks {.fn format_inline}.")
Expand Down Expand Up @@ -199,6 +201,8 @@ format_inline <- function(..., .envir = parent.frame(), collapse = TRUE,
#' concatenated into a single string. Newlines are _not_ preserved.
#' @param .envir Environment to evaluate the glue expressions in.
#'
#' @seealso This function supports [inline markup][inline-markup].
#' @family functions supporting inline markup
#' @export

cli_text <- function(..., .envir = parent.frame()) {
Expand Down Expand Up @@ -266,6 +270,8 @@ cli_verbatim <- function(..., .envir = parent.frame()) {
#' themes.
#' @param .envir Environment to evaluate the glue expressions in.
#'
#' @seealso These functions supports [inline markup][inline-markup].
#' @family functions supporting inline markup
#' @export

cli_h1 <- function(text, id = NULL, class = NULL, .envir = parent.frame()) {
Expand Down Expand Up @@ -490,6 +496,8 @@ cli_end <- function(id = NULL) {
#' @inheritParams cli_div
#' @return The id of the new container element, invisibly.
#'
#' @seealso This function supports [inline markup][inline-markup].
#' @family functions supporting inline markup
#' @export


Expand Down Expand Up @@ -555,6 +563,8 @@ cli_ul <- function(items = NULL, id = NULL, class = NULL,
#' @inheritParams cli_ul
#' @return The id of the new container element, invisibly.
#'
#' @seealso This function supports [inline markup][inline-markup].
#' @family functions supporting inline markup
#' @export

cli_ol <- function(items = NULL, id = NULL, class = NULL,
Expand Down Expand Up @@ -605,6 +615,8 @@ cli_ol <- function(items = NULL, id = NULL, class = NULL,
#' @inheritParams cli_ul
#' @return The id of the new container element, invisibly.
#'
#' @seealso This function supports [inline markup][inline-markup].
#' @family functions supporting inline markup
#' @export

cli_dl <- function(items = NULL, labels = names(items), id = NULL,
Expand Down Expand Up @@ -658,6 +670,8 @@ cli_dl <- function(items = NULL, labels = names(items), id = NULL,
#' @inheritParams cli_div
#' @return The id of the new container element, invisibly.
#'
#' @seealso This function supports [inline markup][inline-markup].
#' @family functions supporting inline markup
#' @export

cli_li <- function(items = NULL, labels = names(items), id = NULL,
Expand Down Expand Up @@ -725,6 +739,8 @@ cli_li <- function(items = NULL, labels = names(items), id = NULL,
#' @param wrap Whether to auto-wrap the text of the alert.
#' @param .envir Environment to evaluate the glue expressions in.
#'
#' @seealso These functions supports [inline markup][inline-markup].
#' @family functions supporting inline markup
#' @export

cli_alert <- function(text, id = NULL, class = NULL, wrap = FALSE,
Expand Down Expand Up @@ -840,6 +856,8 @@ cli_alert_info <- function(text, id = NULL, class = NULL, wrap = FALSE,
#' @inheritParams rule
#' @inheritParams cli_div
#'
#' @seealso This function supports [inline markup][inline-markup].
#' @family functions supporting inline markup
#' @export

cli_rule <- function(left = "", center = "", right = "", id = NULL,
Expand All @@ -865,11 +883,14 @@ cli_rule <- function(left = "", center = "", right = "", id = NULL,
#' cli_blockquote(evil, citation = "Donald Ervin Knuth")
#' ```
#'
#' @export
#' @param quote Text of the quotation.
#' @param citation Source of the quotation, typically a link or the name
#' of a person.
#' @inheritParams cli_div
#'
#' @seealso This function supports [inline markup][inline-markup].
#' @family functions supporting inline markup
#' @export

cli_blockquote <- function(quote, citation = NULL, id = NULL,
class = NULL, .envir = parent.frame()) {
Expand Down
40 changes: 25 additions & 15 deletions R/cliapp-docs.R
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@

#' About inline markup in the semantic cli
#' @title About inline markup in the semantic cli
#'
#' @description
#' To learn how to use cli’s semantic markup, start with the ‘Building
#' a semantic CLI’ article at <https://cli.r-lib.org>.
#'
#' @section Command substitution:
#'
Expand Down Expand Up @@ -46,26 +50,26 @@
#' * `email` for an email address.
#' If the terminal supports ANSI hyperlinks (e.g. RStudio, iTerm2, etc.),
#' then cli creates a clickable link.
#' See [links] for more about cli hyperlinks.
#' See [links] for more information about cli hyperlinks.
#' * `emph` for emphasized text.
#' * `envvar` for the name of an environment variable.
#' * `field` for a generic field, e.g. in a named list.
#' * `file` for a file name. If the terminal supports ANSI hyperlinks (e.g.
#' RStudio, iTerm2, etc.), then cli creates a clickable link that opens
#' the file in RStudio or with the default app for the file type.
#' See [links] for more about cli hyperlinks.
#' See [links] for more information about cli hyperlinks.
#' * `fun` for a function name. If it is in the `package::function_name`
#' form, and the terminal supports ANSI hyperlinks (e.g. RStudio,
#' iTerm2, etc.), then cli creates a clickable link.
#' See [links] for more about cli hyperlinks.
#' See [links] for more information about cli hyperlinks.
#' * `help` is a help page of a _function_.
#' If the terminal supports ANSI hyperlinks to help pages (e.g. RStudio),
#' then cli creates a clickable link. It supports link text.
#' See [links] for more about cli hyperlinks.
#' See [links] for more information about cli hyperlinks.
#' * `href` creates a hyperlink, potentially with a link text.
#' If the terminal supports ANSI hyperlinks (e.g. RStudio, iTerm2, etc.),
#' then cli creates a clickable link.
#' See [links] for more about cli hyperlinks.
#' See [links] for more information about cli hyperlinks.
#' * `key` for a keyboard key.
#' * `obj_type_friendly` formats the type of an R object in a readable way,
#' and it should be used with `{}`, see an example below.
Expand All @@ -75,23 +79,23 @@
#' * `pkg` for a package name.
#' * `run` is an R expression, that is potentially clickable if the terminal
#' supports ANSI hyperlinks to runnable code (e.g. RStudio).
#' It supports link text. See [links] for more about cli hyperlinks.
#' * `strong` for strong importance.
#' * `topic` is a help page of a _ropic_.
#' It supports link text. See [links] for more information about cli hyperlinks.
#' * `str` for a double quoted string escaped by [base::encodeString()].#' * `strong` for strong importance.
#' * `topic` is a help page of a _topic_.
#' If the terminal supports ANSI hyperlinks to help pages (e.g. RStudio),
#' then cli creates a clickable link. It supports link text.
#' See [links] for more about cli hyperlinks.
#' See [links] for more information about cli hyperlinks.
#' * `type` formats the type of an R object in a readable way, and it
#' should be used with `{}`, see an example below.
#' * `url` for a URL. If the terminal supports ANSI hyperlinks (e.g.
#' RStudio, iTerm2, etc.), then cli creates a clickable link.
#' See [links] for more about cli hyperlinks.
#' See [links] for more information about cli hyperlinks.
#' * `var` for a variable name.
#' * `val` for a generic "value".
#' * `vignette` is a vignette.
#' If the terminal supports ANSI hyperlinks to help pages (e.g. RStudio),
#' then cli creates a clickable link. It supports link text.
#' See [links] for more about cli hyperlinks.
#' See [links] for more information about cli hyperlinks.
#'
#' ```{asciicast inline-examples}
#' ul <- cli_ul()
Expand Down Expand Up @@ -198,7 +202,8 @@
#' ```{asciicast inline-plural}
#' ndirs <- 1
#' nfiles <- 13
#' cli_alert_info("Found {ndirs} diretor{?y/ies} and {nfiles} file{?s}.")
#' pkgs <- c("pkg1", "pkg2", "pkg3")
#' cli_alert_info("Found {ndirs} director{?y/ies} and {nfiles} file{?s}.")
#' cli_text("Will install {length(pkgs)} package{?s}: {.pkg {pkgs}}")
#' ```
#'
Expand Down Expand Up @@ -612,7 +617,7 @@ NULL
#' To link to a help topic that is not a function, use `.topic`:
#'
#' ```{asciicast links-topic}
#' cli::cli_text("... the tibble options at {.help tibble::tibble_options}.")
#' cli::cli_text("... the tibble options at {.topic tibble::tibble_options}.")
#' ```
#'
#' `.topic` support link text.
Expand Down Expand Up @@ -650,13 +655,18 @@ NULL
#'
#' ## Security considerations
#'
#' To make `.run` hyperlinks more secure, RStudio with not run code
#' To make `.run` hyperlinks more secure, RStudio will not run code
#'
#' * that is not in the `pkg::fun(args)` form,
#' * if `args` contains `(`, `)` or `;`,
#' * if it calls a core package (base, stats, etc.),
#' * if it calls a package that is not loaded, and it is not one of
#' testthat, devtools, usethis, or rlang, which are explicitly allowed.
#'
#' When RStudio does not run a `.run` hyperlink, then it shows the code
#' and the user can copy and paste it to the console, if they consider
#' it safe to run.
#'
#' Note that depending on your version of RStudio, the behavior can change.
#' @name links
NULL
2 changes: 1 addition & 1 deletion R/diff.R
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ get_diff_chunks <- function(lcs, context = 3L) {

# chunk starts at operation number sum(length) before it, plus 1, but
# at the end we change this to include the context chunks are well
chunks$op_begin <- c(0, cumsum(runs$length))[which(runs$values)] + 1
chunks$op_begin <- c(0, cumsum(runs$lengths))[which(runs$values)] + 1
chunks$op_length <- runs$lengths[runs$values]

# `old` positions are from `old_off`, but need to fix the boundaries
Expand Down
Loading

0 comments on commit a23714a

Please sign in to comment.