Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wrapping usage #265

Closed
schloerke opened this issue Aug 3, 2014 · 3 comments
Closed

wrapping usage #265

schloerke opened this issue Aug 3, 2014 · 3 comments

Comments

@schloerke
Copy link

Hello,

I ran into a case where the usage section does not wrap when an argument is defaulted to "\"'".

I've included a gist that shows this issue: https://gist.github.com/schloerke/ed2fc2947e97480b4946

Thanks,
Barret

@hadley hadley closed this as completed in f4c8c55 Aug 29, 2014
hadley added a commit that referenced this issue Aug 29, 2014
@hadley
Copy link
Member

hadley commented Aug 29, 2014

Test case if I try again in the future.

test_that("breaking works after escapes (#265)", {

  out <- roc_proc_text(rd_roclet(), "
    #' Long args
    f <- function(
      xxxxxxxxxxxxxxxxxx1,
      xxxxxxxxxxxxxxxxxx2,
      xxxxxxxxxxxxxxxxxx3,
      x = \"\\\"'\",
      xxxxxxxxxxxxxxxxxx4,
      xxxxxxxxxxxxxxxxxx5,
      xxxxxxxxxxxxxxxxxx6,
      xxxxxxxxxxxxxxxxxx7
  ){}")[[1]]
  usage <- format(get_tag(out, "usage"))
  expect_equal(str_count(usage, "\n"), 5)
})

@hadley hadley reopened this Aug 29, 2014
@hadley
Copy link
Member

hadley commented Oct 6, 2015

This seems ok to me now:

x <- "xxxxxxxxxxxxxxxxxx1,\nxxxxxxxxxxxxxxxxxx2,\nxxxxxxxxxxxxxxxxxx3,\nx = \"\\\"'\",\nxxxxxxxxxxxxxxxxxx4,\nxxxxxxxxxxxxxxxxxx5,\nxxxxxxxxxxxxxxxxxx6,\nxxxxxxxxxxxxxxxxxx7"
width <- function(x) nchar(strsplit(x, "\n")[[1]])
width(wrapString(x))
#> [1] 73 64 21

@hadley hadley closed this as completed Oct 6, 2015
@hadley
Copy link
Member

hadley commented Oct 6, 2015

Ooops, no it's not:

out <- roc_proc_text(rd_roclet(), "\n  #' Long args\n    f <- function(\n    xxxxxxxxxxxxxxxxxx1,\n    xxxxxxxxxxxxxxxxxx2,\n    xxxxxxxxxxxxxxxxxx3,\n    x = \"\\\"'\",\n    xxxxxxxxxxxxxxxxxx4,\n    xxxxxxxxxxxxxxxxxx5,\n    xxxxxxxxxxxxxxxxxx6,\n    xxxxxxxxxxxxxxxxxx7\n    ){}")[[1]]
usage <- format(get_tag(out, "usage"))
cat(usage)
#> \usage{
#> f(xxxxxxxxxxxxxxxxxx1, xxxxxxxxxxxxxxxxxx2, xxxxxxxxxxxxxxxxxx3,
#>   x = "\\"'", xxxxxxxxxxxxxxxxxx4, xxxxxxxxxxxxxxxxxx5, xxxxxxxxxxxxxxxxxx6, xxxxxxxxxxxxxxxxxx7)
#> }

@hadley hadley reopened this Oct 6, 2015
@hadley hadley closed this as completed in 612dae1 Oct 6, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants