Skip to content

Commit

Permalink
chore: Keep raw component up to date, use it for assembling the NEWS (
Browse files Browse the repository at this point in the history
  • Loading branch information
krlmlr authored Nov 23, 2024
1 parent 778f0a2 commit a924e0e
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 20 deletions.
4 changes: 3 additions & 1 deletion R/auto.R
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,8 @@ merge_dev_news <- function(fledgeling, new_version) {
unlist(fledgeling[["news"]]$news[seq_len(n_dev)], recursive = FALSE)
)

raw <- format_news_subsections(news, header_level = 2)

new_section <- tibble::tibble(
start = 3,
end = NA,
Expand All @@ -260,7 +262,7 @@ merge_dev_news <- function(fledgeling, new_version) {
date = maybe_date(fledgeling[["news"]]),
nickname = NA,
news = list(news),
raw = "",
raw = raw,
title = "",
section_state = "new"
)
Expand Down
27 changes: 12 additions & 15 deletions R/fledgling.R
Original file line number Diff line number Diff line change
Expand Up @@ -233,24 +233,21 @@ write_news_section <- function(df) {
)
)

# If only uncategorized items for the version, no subheaders
if (length(df$news[[1]]) == 1 && names(df$news[[1]]) == default_type()) {
section_lines <- c(
version_header, "",
paste(df$news[[1]][[1]], collapse = "\n"), ""
)
if (isTRUE(df$h2)) {
header_level <- 3
} else {
if (isTRUE(df$h2)) {
header_level <- 3
} else {
header_level <- 2
}
header_level <- 2
}

section_lines <- c(
version_header, "",
format_news_subsections(df$news[[1]], header_level), ""
)
raw <- df$raw

# If only uncategorized items for the version, no subheaders
if (grepl(paste0("^#+ ", default_type()), raw)) {
raw <- gsub("^#+ [^\n]*\n\n", "", raw)
}

section_lines <- c(version_header, "", raw, "")

paste0(section_lines, collapse = "\n")
}

Expand Down
11 changes: 7 additions & 4 deletions R/update-news.R
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ update_news_impl <- function(commits,
dev_header_present <- isTRUE(
grepl(
"(development version)",
fledgeling[["news"]][["title"]][1]
fledgeling[["news"]]$title[[1]]
)
)

Expand Down Expand Up @@ -62,7 +62,8 @@ update_news_impl <- function(commits,
fledgeling[["news"]]$news[[1]]
)
combined <- purrr::discard(combined, purrr::is_empty)
fledgeling[["news"]]$news[[1]] <- regroup_news(combined)
regrouped <- regroup_news(combined)
fledgeling[["news"]]$raw[[1]] <- format_news_subsections(regrouped, header_level = 2)
fledgeling[["news"]][1, ]$section_state <- "new"
}

Expand Down Expand Up @@ -101,6 +102,8 @@ update_news_impl <- function(commits,
news <- parse_news_md(news_lines)
}

raw <- format_news_subsections(news, header_level = 2)

section_df <- tibble::tibble(
start = 3,
end = NA,
Expand All @@ -109,15 +112,15 @@ update_news_impl <- function(commits,
date = maybe_date(fledgeling[["news"]]),
nickname = NA,
news = list(news),
raw = "",
raw = raw,
title = "",
section_state = "new"
)

if (initializing) {
fledgeling[["news"]] <- section_df
} else {
fledgeling[["news"]] <- rbind(
fledgeling[["news"]] <- vctrs::vec_rbind(
section_df,
fledgeling[["news"]]
)
Expand Down

0 comments on commit a924e0e

Please sign in to comment.