Skip to content

v0.2.0

Compare
Choose a tag to compare
@jennybc jennybc released this 23 Jun 14:06

reprex 0.2.0

reprex has a website: http://reprex.tidyverse.org. It includes a contributed article from @njtierney (#103).

reprex has moved to the tidyverse Organization. It is installed as part of the tidyverse meta-package and is suggested to those seeking help.

reprex() gains several arguments and many arguments can now be controlled via an option, in case a user wants their own defaults.

The new reprex_selection() add-in reprexes the current selection, with venue controlled by the option reprex.venue. It can be handy to bind to a keyboard shortcut (#84 @hadley).

If reprex can't write to the user's clipboard (e.g. on RStudio server or Unix-like systems lacking xclip or xsel), it offers to open the output file for manual copy.

Option-controlled arguments for custom defaults

These look like reprex(..., arg = opt(DEFAULT), ...) in the help file. This is shorthand for arg = getOption("reprex.arg", DEFAULT), i.e. the option reprex.arg is consulted and, if unset, the documented default is used. Allows user to define their own default behaviour (#116).

New arguments to reprex():

  • advertise: toggles inclusion of a footer that describes when and how the reprex was created, e.g., "Created on 2017-11-16 by the reprex package (v0.1.1.9000)". Defaults to TRUE (#121, #69).
  • style: requests code restyling via the newly-Suggested styler package. styler can cope with tidyeval syntactical sugar, e.g. df %>% group_by(!! group_var). Defaults to FALSE (#108, #94).
  • tidyverse_quiet: affords control of the startup message of the tidyverse meta-package. Defaults to TRUE, i.e. suppresses the message (important special case of #70, #100).
  • std_out_err: appends output sent to stdout and stderr by the reprex rendering process. This can be necessary to reveal output if the reprex spawns child processes or has system() calls. Defaults to FALSE (#90, #110).
  • render: determines if the reprex is actually rendered or just returns after producing the templated .R file. For internal testing.

Venues

  • Line wrapping is preserved from source via a Pandoc option (#145 @jimhester, #175).

  • venue = "gh" now targets CommonMark as the standard for GitHub Flavored Markdown (#77).

  • venue = "so" has appropriate whitespace at the start.

  • venue = "ds" is a new value, corresponding to https://www.discourse.org, which is the platform behind community.rstudio.com. This is currently just an alias for the default "gh" GitHub venue, because the formatting appears to be compatible. Adding the "ds" value so Discourse can be documented and to guard against the possibility that some formatting is actually unique.

Other changes

  • The keep.source option is set to TRUE when rendering the reprex, so reprexes involving srcrefs should work (#152).

  • The "undo" functions (reprex_invert(), reprex_clean(), reprex_rescue()) handle input and outfile like reprex() does. The outfile argument is new (#129, #68).

  • The default value for knitr's upload.fun is now set according to the venue. It is knitr::imgur_upload() for all venues except "r", where it is identity (#125).

  • The HTML preview should appear in the RStudio Viewer more consistently, especially on Windows (#75 @yutannihilation).

  • More rigorous use of UTF-8 encoding (#76 @yutannihilation).

  • Expression input handling has been refactored. As a result, formatR is no longer Suggested. Trailing comments -- inline and on their own line -- are also now retained (#89, #91, #114, @jennybc and @jimhester).

  • Custom prompts are now escaped when used in regexes (#98, #99 @jimhester). Embedded newlines are now escaped.