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

Use sort_c after ls, so RC methods have consistent order #1132

Merged
merged 3 commits into from
Apr 17, 2021

Conversation

d-sci
Copy link
Contributor

@d-sci d-sci commented Jul 3, 2020

Completes #1077, also for Reference Classes. There was the exact same issue, but it was less obvious because it was due to ls rather than sort.

Concrete minimal example (when I originally prepared this I thought it was an RStudio build pane quirk, until I saw #1077):

#' @title Case Sensitivity Test
#' @description
#' When you run [devtools::document()] in the R console, the ordering of RC
#' methods is case insensitive. When you run documentation in the build pane
#' (e.g. via `Ctrl+Shift+D`), the ordering is case sensitive.
#' @export CaseSensitivity
#' @export
CaseSensitivity <- setRefClass("CaseSensitivity",
  methods = list(
    aa = function(){
      'If case insensitive, aa will come before AZ'
      return("insensitive")
    },
    AZ = function(){
      'If case sensitive, AZ will come before aa'
      return("sensitive")
    }
  ))

would lead to:
image

@@ -24,7 +24,7 @@ rc_methods <- function(obj) {
parent_methods <- unlist(lapply(parents, function(x) {
methods::getRefClass(x)$methods()
}))
method_names <- setdiff(ls(envir = obj@refMethods), parent_methods)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about just using sort_c() here? That makes it very clear that the results are sorted.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense! Updated

@d-sci d-sci changed the title Use ls_c, analagous to sort_c Use sort_c after ls, so RC methods have consistent order Apr 17, 2021
@hadley hadley merged commit 2326172 into r-lib:master Apr 17, 2021
@hadley
Copy link
Member

hadley commented Apr 17, 2021

Thanks!

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 this pull request may close these issues.

2 participants