Skip to content

Commit

Permalink
Improve ordering
Browse files Browse the repository at this point in the history
  • Loading branch information
krlmlr committed Jan 4, 2024
1 parent adee2a7 commit e9a7286
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 12 deletions.
7 changes: 5 additions & 2 deletions R/rd-family.R
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,15 @@ topics_process_family <- function(topics, env) {
if (length(others) < 1)
next

by_file <- map_chr(aliases[others], function(x) {
other_aliases <- aliases[others]
other_aliases_order <- map_chr(other_aliases, function(x) escape(x[1]))

by_file <- map_chr(other_aliases[order_c(other_aliases_order)], function(x) {
obj <- find_object(x[1], env)
suffix <- if (is.function(obj$value)) "()" else ""
paste0("\\code{\\link{", escape(x[1]), "}", suffix, "}")
})
links <- paste(sort_c(by_file), collapse = ",\n")
links <- paste(by_file, collapse = ",\n")
seealso <- topics_process_family_prefix(family)

topic$add(rd_section("seealso", paste0(seealso, "\n", links)))
Expand Down
8 changes: 7 additions & 1 deletion R/util-locale.R
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,10 @@ with_collate <- function(locale, code) {
force(code)
}

sort_c <- function(x, ...) with_collate("C", sort(x, ...))
sort_c <- function(x, ...) {
with_collate("C", sort(x, ...))
}

order_c <- function(x, ...) {
with_collate("C", order(x, ...))
}
2 changes: 1 addition & 1 deletion man/tags-index-crossref.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions man/tags-reuse.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 6 additions & 6 deletions tests/testthat/_snaps/rd-family.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
\seealso{
Other a:
\code{\link{Foofun3}()},
\code{\link{foofun2}()},
\code{\link{foofun}()}
\code{\link{foofun}()},
\code{\link{foofun2}()}
}
\concept{a}
Expand All @@ -38,8 +38,8 @@
\seealso{
Other a:
\code{\link{Foofun3}()},
\code{\link{foofun1}()},
\code{\link{foofun}()}
\code{\link{foofun}()},
\code{\link{foofun1}()}
}
\concept{a}
Expand All @@ -57,9 +57,9 @@
}
\seealso{
Other a:
\code{\link{foofun}()},
\code{\link{foofun1}()},
\code{\link{foofun2}()},
\code{\link{foofun}()}
\code{\link{foofun2}()}
}
\concept{a}
Expand Down

0 comments on commit e9a7286

Please sign in to comment.