-
Notifications
You must be signed in to change notification settings - Fork 15
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
Implementation Suggestion: packages mentioned in document take precedence over packages in user library #61
Comments
thanks for breathing life into the package again. This is indeed a heavier lift and departs a bit from the current logic. The way the package is set up now it is using the parser to figure out function names for the script context. That would have to stay put instead of grepping. the order of the lookup is defined by the searchpath and what is defined in the global environment. you can see that in the pretty_utils happy to discuss further |
Certainly! I'm getting a lot of mileage out of it parsing all of the R code I've written over the last couple years. The experience of using it on such a diversity of code in an iterative fashion has had the side effect of running into all kinds of edge cases and exceptions where things bug out or are difficult to handle properly - so that's the inspiration!
This makes sense. I imagine that the premises for this is that the majority of use cases are going to be people using
Yes, I did notice this. I don't quite yet understand the logic of how the functions from the packages on the I've rolled some supporting functions for extracting the namespaces loaded in Rmd/R docs and then acquiring their respective exported functions in list format similar to what's recommend for I'll see about submitting a PR tomorrow with the custom functions so you can see what I'm talking about here. |
I gave this some more thought since yesterday evening. What do you think about adding a parameter called
The user could re-arrange the arguments as they see fit to determine the order in which namespaces are applied to the document. This could even be structured as a list where they could supply namespace lists like that to It would require some reworking of how namespaces are attributed, but probably wouldn't be too difficult. Thoughts? |
As a follow-up I just opened #63 with those supporting functions I mentioned on a branch entitled |
Hi @yonicd, |
There is a testing branch. I was looking at your PR over the weekend, and they look good. I'll continue going over them in the next few days. Thanks again for all the content. |
I migrated the tests to the master branch. You can add them there now, the GHA CI will pick them up on PRs. thanks |
Ok, thank you! I'll create the tests soon. |
Ok, so looking back over the pull requests, all of the PR's implement changes to user-input features (when Regarding the other PRs: I've searched around and I don't see anything suggesting that it's possible to actually run tests on functions that solicit user inputs. As far as I can tell, I don't think tests can be written for these PRs. |
Hi @yonicd,
As I'm diving deeper into the package and making pull requests for some features that I feel would be helpful, I'm noticing an issue that seems to happen at random and I think it's due to the way
sinew
searches the search list and all possible packages to generate the possible packages.For example, I have an Rmd document that loads a couple of libraries, and uses certain packages via
::
throughout. Randomly,sinew
will select a package that's not used anywhere else in the Rmd:I've been using
sinew
to namespace all of the R documents on my computer, and it does this quite often. There's probably a number of documents and scripts that are no longer going to work and will need debugging as a result.To remedy this issue, I was thinking that it would make more sense for
sinew
to search the documents for all of the following ways in which namespaces are loaded:library
require
attach
loadNamespace
@importFrom
&@import
grep
can be used to identify lines in the document with these functions, the lines can be parsed to calls (for all but roxygen comments), and namespaces can be extracted by identifying the appropriate arguments. Resulting package names are then matched with those in the user library to eliminate the possibility of extraneous arguments to these functions being extracted.roxygen comments can simply be parsed with regex.
Namespaces are then aggregated from all calls using
::
and added to the list of possible packages.If a function is encountered that is not in the namespaces of these packages, then the user library is searched (and asked for verification if
ask = TRUE
).Unlike the other simple feature additions that I've submitted as PRs, making this change will require substantial revisions so I wanted to hear your thoughts on such a change.
Looking forward to your response,
Stephen
The text was updated successfully, but these errors were encountered: