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

Return value not documented #283

Closed
barryrowlingson opened this issue Nov 15, 2022 · 1 comment · Fixed by #291
Closed

Return value not documented #283

barryrowlingson opened this issue Nov 15, 2022 · 1 comment · Fixed by #291

Comments

@barryrowlingson
Copy link

The documentation for help(glue::glue) doesn't have a Value section explicitly saying what is returned.

Currently an object of multiple class "glue" and "character" is returned, but I see no documentation on the "glue" class. The only obvious functionality is it makes glued results appear without vector labels or quotation marks:

> gs = glue::glue("{sample(letters)}")
> gs
a
e
o
x
y
[etc]

which is clearly less friendly than printing as characters, as you'd get if paste()-ing chars or as you get when converting glue to character with as.character or unclass, when it all fits on a couple of lines, shows the index position, and shows these things are quoted character strings:

> unclass(gs)
 [1] "a" "e" "o" "x" "y" "i" "j" "c" "s" "h" "q" "k" "r" "f" "l" "n" "z" "m" "u"
[20] "b" "d" "g" "t" "v" "w" "p"
> 

Presentation of the class via print.glue aside, the return value ought to be specified in the help and the class should be documented so people who want to use these classes have an interface they can work with.

@hadley
Copy link
Member

hadley commented Jan 25, 2023

For the print method, one possible option would be to take some of the logic from str_view():

stringr::str_view(letters[1:10])
#>  [1] │ a
#>  [2] │ b
#>  [3] │ c
#>  [4] │ d
#>  [5] │ e
#>  [6] │ f
#>  [7] │ g
#>  [8] │ h
#>  [9] │ i
#> [10] │ j

Created on 2023-01-25 with reprex v2.0.2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants