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

match canonical ordering of roxygen #67

Merged
merged 6 commits into from
Oct 13, 2024
Merged

Conversation

MichaelChirico
Copy link
Collaborator

@MichaelChirico MichaelChirico commented Oct 13, 2024

Again towards shrinking the diff in #61 & making it easier to spot inconsistencies.

Didn't change anything in the R/ version, it's just busywork at this point I reckon

A programmatic approach:

non_sections = c("item", "code", "emph", "itemize", "dontshow", "verb", "method", "subsection", "if", "strong", "tabular")
section_names = function(l) {
  l |>
    grep(pattern = "^[\\][a-zA-Z0-9_]+[{]", value=TRUE) |>
    gsub(pattern = "^[\\]|\\{.*", replacement = "") |>
    setdiff(non_sections)
}

section_ordering_in_branch = function(branch) {
  system2("git", c("checkout", branch))
  rd = Sys.glob("man/*.Rd")
  rdl = lapply(rd, readLines)
  names(rdl) = rd
  
  lapply(rdl, section_names)
}

old = section_ordering_in_branch("master")
new = section_ordering_in_branch("roxygen")

# all.equal() might be nice but there are other differences between the branches still
for (rd in names(new)) {
  o = old[[rd]]
  n = new[[rd]]
  old[[rd]] = o[o %in% n]
  new[[rd]] = n[n %in% o]
}

for (rd in names(new)) if (!isTRUE(all.equal(old[[rd]], new[[rd]]))) {
  message(rd)
  print(cbind(old[[rd]], new[[rd]]))
}

@MichaelChirico MichaelChirico merged commit d783d63 into master Oct 13, 2024
8 checks passed
@MichaelChirico MichaelChirico deleted the description-ordering branch October 13, 2024 20:07
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.

1 participant