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

Add edit parameter to plumb_api() #699

Closed
blairj09 opened this issue Oct 14, 2020 · 0 comments · Fixed by #700
Closed

Add edit parameter to plumb_api() #699

blairj09 opened this issue Oct 14, 2020 · 0 comments · Fixed by #700
Assignees

Comments

@blairj09
Copy link
Collaborator

After an extensive conversation with @schloerke, we've decided to add an edit parameter to the plumb_api() function. This parameter will open the plumber.R or entrypoint.R file associated with a specified Plumber API. This will enable Plumber users to quickly and easily view source code for Plumber APIs that are included in R packages.

The expected behavior of this feature is as follows:

plumb_api("plumber", "01-append", edit = TRUE)
  1. A message is presented to the user specifying the path of the directory containing the source code and a warning that if they want to make persistent changes to the code, they should copy it to a separate file.
  2. The associated plumber.R file is opened for editing
  3. If using RStudio, the files pane is directed to the directory containing the source code

There were a few alternative options discussed that were ultimately rejected:

  • Copying the source directory to a temporary location and opening the files from there
    This idea was based on preventing users from accidentally changing the behavior of API examples included with installed packages. It was ultimately decided that the simplest solution is to just open the original source file and provide the user with a warning about permanently editing the files.

  • Creating a separate pr_view_source() function.
    This idea was based around the private $filename value for Plumber routers. The idea was to capture that filename and to open the source file. This approach was rejected in favor of adding edit to plumb_api() for simplicity sake. Using plumb_api() instead of introducing a new function also restricts this functionality to APIs included in installed packages, which is a desired characteristic.

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

Successfully merging a pull request may close this issue.

1 participant