Skip to content

Commit

Permalink
Remove unwanted linebreaks from parsing DESCRIPTION (#2247)
Browse files Browse the repository at this point in the history
  • Loading branch information
salim-b authored May 12, 2023
1 parent 44c92aa commit 39083f3
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 8 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ Imports:
bslib (>= 0.3.1),
callr (>= 3.7.3),
cli,
desc,
desc (>= 1.4.0),
digest,
downlit (>= 0.4.0),
fs (>= 1.4.0),
Expand Down
1 change: 1 addition & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# pkgdown (development version)

* Avoid unwanted linebreaks from parsing `DESCRIPTION` (@salim-b, #2247).
* Remove redundant entries in the documentation index when multiple explicit `@usage` tags are provided (@klmr, #2302)
* The article index now sorts vignettes and non-vignette articles alphabetically by their filename (literally, their `basename()`), by default (@jennybc, #2253).

Expand Down
4 changes: 3 additions & 1 deletion R/build-home-citation.R
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ create_citation_meta <- function(path) {
meta$Encoding <- "UTF-8"
}

if (!is.null(meta$Title)) meta$Title <- str_squish(meta$Title)

meta
}

Expand Down Expand Up @@ -45,7 +47,6 @@ data_citations <- function(pkg = ".") {
}

citation_auto(pkg)

}

citation_provided <- function(src_path) {
Expand All @@ -70,6 +71,7 @@ citation_auto <- function(pkg) {
lib.loc = path_dir(pkg$src_path)
)
cit_info$`Date/Publication` <- cit_info$`Date/Publication` %||% Sys.time()
if (!is.null(cit_info$Title)) cit_info$Title <- str_squish(cit_info$Title)

cit <- utils::citation(auto = cit_info)
list(
Expand Down
6 changes: 3 additions & 3 deletions R/build-home-index.R
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ build_home_index <- function(pkg = ".", quiet = TRUE) {
data <- data_home(pkg)

if (is.null(src_path)) {
data$index <- linkify(pkg$desc$get("Description")[[1]])
data$index <- linkify(pkg$desc$get_field("Description", ""))
} else {
local_options_link(pkg, depth = 0L)
data$index <- markdown_body(src_path)
Expand Down Expand Up @@ -45,10 +45,10 @@ data_home <- function(pkg = ".") {

print_yaml(list(
pagetitle = pkg$meta$home[["title"]] %||%
cran_unquote(pkg$desc$get("Title")[[1]]),
cran_unquote(pkg$desc$get_field("Title", "")),
sidebar = data_home_sidebar(pkg),
opengraph = list(description = pkg$meta$home[["description"]] %||%
cran_unquote(pkg$desc$get("Description")[[1]])),
cran_unquote(pkg$desc$get_field("Description", ""))),
has_trailingslash = pkg$meta$template$trailing_slash_redirect %||% FALSE
))
}
Expand Down
2 changes: 1 addition & 1 deletion R/build-home-license.R
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ build_home_license <- function(pkg) {
data_home_sidebar_license <- function(pkg = ".") {
pkg <- as_pkgdown(pkg)

link <- autolink_license(pkg$desc$get("License")[[1]])
link <- autolink_license(pkg$desc$get_field("License", ""))

license_md <- path_first_existing(pkg$src_path, c("LICENSE.md", "LICENCE.md"))
if (!is.null(license_md)) {
Expand Down
4 changes: 2 additions & 2 deletions R/package.R
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ as_pkgdown <- function(pkg = ".", override = list()) {
meta[["url"]] <- sub("/$", "", meta[["url"]])
}

package <- desc$get("Package")[[1]]
package <- desc$get_field("Package")
version <- desc$get_field("Version")

bs_version <- check_bootstrap_version(meta$template$bootstrap, pkg)
Expand Down Expand Up @@ -199,7 +199,7 @@ extract_title <- function(x) {
x %>%
purrr::detect(inherits, "tag_title") %>%
flatten_text(auto_link = FALSE) %>%
str_trim()
str_squish()
}

extract_source <- function(x) {
Expand Down
2 changes: 2 additions & 0 deletions R/utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ is_syntactic <- function(x) x == make.names(x)

str_trim <- function(x) gsub("^\\s+|\\s+$", "", x)

str_squish <- function(x) str_trim(gsub("\\s+", " ", x))

# devtools metadata -------------------------------------------------------

system_file <- function(..., package) {
Expand Down

0 comments on commit 39083f3

Please sign in to comment.