From 7014fb1fde5a477f6b969fbd03ff022c08882753 Mon Sep 17 00:00:00 2001 From: Hadley Wickham Date: Tue, 30 Apr 2024 14:39:51 +1200 Subject: [PATCH 1/6] WIP: Display `inst/AUTHORS` info in authors.html --- R/build-home-authors.R | 22 ++++++++----------- R/build-home-citation.R | 5 +++-- R/render.R | 3 ++- .../templates/content-citation-authors.html | 2 +- .../templates/content-citation-authors.html | 13 ++++++++--- tests/testthat/test-build-home-authors.R | 11 ---------- 6 files changed, 25 insertions(+), 31 deletions(-) diff --git a/R/build-home-authors.R b/R/build-home-authors.R index 87fef29a7..8405573c1 100644 --- a/R/build-home-authors.R +++ b/R/build-home-authors.R @@ -2,6 +2,13 @@ data_authors <- function(pkg = ".", roles = default_roles()) { pkg <- as_pkgdown(pkg) author_info <- pkg$meta$authors %||% list() + inst_path <- path(pkg$src_path, "inst", "AUTHORS") + if (file_exists(inst_path)) { + inst <- read_lines(inst_path) + } else { + inst <- NULL + } + all <- pkg %>% pkg_authors() %>% purrr::map(author_list, author_info, pkg = pkg) @@ -22,7 +29,8 @@ data_authors <- function(pkg = ".", roles = default_roles()) { print_yaml(list( all = all, main = main, - needs_page = more_authors || comments + inst = inst, + needs_page = more_authors || comments || !is.null(inst) )) } @@ -72,18 +80,6 @@ data_home_sidebar_authors <- function(pkg = ".") { sidebar_section(tr_("Developers"), bullets) } -data_authors_page <- function(pkg) { - data <- list( - pagetitle = tr_("Authors"), - authors = data_authors(pkg)$all - ) - - data$before <- markdown_text_block(pkg$meta$authors$before) - data$after <- markdown_text_block(pkg$meta$authors$after) - - return(data) -} - author_name <- function(x, authors, pkg) { name <- format_author_name(x$given, x$family) diff --git a/R/build-home-citation.R b/R/build-home-citation.R index e2200bf97..9c35a8ede 100644 --- a/R/build-home-citation.R +++ b/R/build-home-citation.R @@ -89,11 +89,12 @@ build_citation_authors <- function(pkg = ".") { repo_source(pkg, "DESCRIPTION") } + authors <- data_authors(pkg) data <- list( pagetitle = tr_("Authors and Citation"), - citationtitle = tr_("Citation"), citations = data_citations(pkg), - authors = unname(data_authors(pkg)$all), + authors = unname(authors$all), + inst = authors$inst, source = source ) diff --git a/R/render.R b/R/render.R index 00c32b6de..9ec9c95e4 100644 --- a/R/render.R +++ b/R/render.R @@ -95,7 +95,8 @@ data_template <- function(pkg = ".", depth = 0L) { authors = tr_("Authors"), version = tr_("Version"), examples = tr_("Examples"), - citation = tr_("Citation") + citation = tr_("Citation"), + author_details = tr_("Additional details") ) # Components that mostly end up in the diff --git a/inst/BS3/templates/content-citation-authors.html b/inst/BS3/templates/content-citation-authors.html index d71945a8b..5a40700e1 100644 --- a/inst/BS3/templates/content-citation-authors.html +++ b/inst/BS3/templates/content-citation-authors.html @@ -18,7 +18,7 @@

{{pagetitle}}

-

{{citationtitle}}

+

{{#translate}}{{citation}}{{/translate}}

{{#source}}{{{.}}}{{/source}}
diff --git a/inst/BS5/templates/content-citation-authors.html b/inst/BS5/templates/content-citation-authors.html index 97184c64e..5d6db0dac 100644 --- a/inst/BS5/templates/content-citation-authors.html +++ b/inst/BS5/templates/content-citation-authors.html @@ -5,12 +5,12 @@

{{{pagetitle}}}

-
+

{{#translate}}{{authors}}{{/translate}}

{{{before}}}
    {{#authors}} -
  • + <µli>

    {{{name}}}. {{{roles}}}. {{{orcid}}} {{#comment}}
    {{{.}}}{{/comment}}

  • @@ -19,7 +19,7 @@

    {{#translate}}{{authors}}{{/translate}}

    {{{after}}}
-
+

{{#translate}}{{citation}}{{/translate}}

{{#source}}{{{.}}}{{/source}}

@@ -28,6 +28,13 @@

{{#translate}}{{citation}}{{/translate}}

{{{bibtex}}}
{{/citations}}
+ + {{#inst}} +
+

{{#translate}}{{author_details}}{{/translate}}

+
{{.}}
+
+ {{/inst}}