From 95a6610c9a9669ef64bfb91cfff352c3200aab67 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kirill=20M=C3=BCller?= Date: Sat, 23 Dec 2023 07:27:15 +0100 Subject: [PATCH] Improve ordering --- R/rd-family.R | 7 +++++-- R/util-locale.R | 8 +++++++- tests/testthat/_snaps/rd-family.md | 8 ++++---- 3 files changed, 16 insertions(+), 7 deletions(-) diff --git a/R/rd-family.R b/R/rd-family.R index 3b93013a2..df0365443 100644 --- a/R/rd-family.R +++ b/R/rd-family.R @@ -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))) diff --git a/R/util-locale.R b/R/util-locale.R index fa324ce8f..7360aabfb 100644 --- a/R/util-locale.R +++ b/R/util-locale.R @@ -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, ...)) +} diff --git a/tests/testthat/_snaps/rd-family.md b/tests/testthat/_snaps/rd-family.md index f35fc261f..a90e403ad 100644 --- a/tests/testthat/_snaps/rd-family.md +++ b/tests/testthat/_snaps/rd-family.md @@ -17,8 +17,8 @@ } \seealso{ Other a: - \code{\link{foo2}()}, - \code{\link{foo}()} + \code{\link{foo}()}, + \code{\link{foo2}()} } \concept{a} @@ -36,8 +36,8 @@ } \seealso{ Other a: - \code{\link{foo1}()}, - \code{\link{foo}()} + \code{\link{foo}()}, + \code{\link{foo1}()} } \concept{a}