r-lib / devtools

Tools to make an R developer's life easier
https://devtools.r-lib.org
Other
2.37k stars 755 forks source link

Add dev_example() to documentation for run_examples() #2545

Open orgadish opened 7 months ago

orgadish commented 7 months ago

Is your feature request related to a problem? Please describe. When developing my package examples, I often want to test only one file's examples. Using run_examples(start="my_file") is insufficient, since I have little control over what comes after so I have to scroll up to see what I actually want.

It looks like this was implemented at some point (#108), but I can't find it anymore (at least in version 2.4.5). If there is a way to do this with run_examples(), I recommend highlighting that in the help documentation.

Describe the solution you'd like A function like run_example() which runs one file's example.

Update 01/21/2024

Such a function exists! It's just in the pkgload package, which is not where I would have expected to look for it, since a) run_examples() is in devtools and b) run_example() doesn't have to do with "simulating the process of installing and loading a package" in my mind.

Given that the function(s) already exist, but are perhaps not easy to find, this request is to do one or both of the following:

  1. Reference dev_example() / run_example() in the docs for devtools::run_examples()
  2. Move dev_example() / run_example() to devtools.
orgadish commented 7 months ago

Looks like this exists as pkgload::dev_example(), so the ask is to add this to the run_examples documentation and/or export dev_example() as part of devtools.

pawelru commented 5 months ago

I was having a similar issue and I have found out pkgload::run_example(). Does that help?

orgadish commented 5 months ago

@pawelru I think the better alternative for me is pkgload::dev_example() which allows you pass in the topic/name rather than the full path.

Since this function already exists, I think the need is just to reference this function in the devtools::run_examples() documentation so that we even know this exists (since most of us use devtools to do most of our package building, rather than dealing with the separate underlying packages. I will update the request title and description accordingly.