Skip to content

Commit

Permalink
Merge branch 'main' into patch-1
Browse files Browse the repository at this point in the history
  • Loading branch information
gaborcsardi authored Jul 31, 2023
2 parents 88cc280 + 525ebbe commit 37781c4
Show file tree
Hide file tree
Showing 81 changed files with 1,009 additions and 148 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 }}
2 changes: 1 addition & 1 deletion 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
4 changes: 4 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# cli (development version)

# 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
13 changes: 8 additions & 5 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 @@ -75,9 +79,8 @@
#' * `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 information about cli
#' hyperlinks.
#' * `strong` for strong importance.
#' 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.
Expand Down Expand Up @@ -199,7 +202,7 @@
#' ```{asciicast inline-plural}
#' ndirs <- 1
#' nfiles <- 13
#' cli_alert_info("Found {ndirs} diretor{?y/ies} and {nfiles} file{?s}.")
#' cli_alert_info("Found {ndirs} director{?y/ies} and {nfiles} file{?s}.")
#' cli_text("Will install {length(pkgs)} package{?s}: {.pkg {pkgs}}")
#' ```
#'
Expand Down
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 37781c4

Please sign in to comment.