|
1 | | -# ensure that numbered list in each section is in sequence |
2 | | -check_section_numbering = function(news) { |
3 | | - if (!grepl("NEWS", news)) return(invisible()) |
4 | | - news = readLines(news) |
5 | | - # plain '#' catches some examples; 'd' for 'data.table' |
6 | | - sections = grep("^#+ [A-Zd]", news) |
7 | | - entries = grep("^[0-9]+[.]", news) |
8 | | - entry_value = as.integer(gsub("^([0-9]+)[.].*", "\\1", news[entries])) |
9 | | - section_id = findInterval(entries, sections) |
10 | | - |
11 | | - any_mismatch = FALSE |
12 | | - for (id in unique(section_id)) { |
13 | | - section_entries = entry_value[section_id == id] |
14 | | - intended_value = seq_along(section_entries) |
15 | | - matched = section_entries == intended_value |
16 | | - if (all(matched)) next |
17 | | - any_mismatch = TRUE |
18 | | - section_header = news[sections[id]] |
19 | | - cat(sprintf( |
20 | | - "In section '%s' (line %d), bad numbering:\n%s\n", |
21 | | - section_header, sections[id], |
22 | | - paste0(" [", section_entries[!matched], " --> ", intended_value[!matched], "]", collapse="\n") |
23 | | - )) |
24 | | - } |
25 | | - stopifnot("Please fix the NEWS issues above" = !any_mismatch) |
26 | | -} |
27 | | - |
28 | 1 | # ensure that GitHub link text & URL actually agree |
29 | | -check_gh_links = function(news) { |
| 2 | +news_github_link_mismatch_linter = function(news) { |
| 3 | + if (!grepl("NEWS", news)) return(invisible()) |
30 | 4 | news = readLines(news) |
31 | 5 | gh_links_info = gregexpr( |
32 | 6 | "\\[#(?<md_number>[0-9]+)\\]\\(https://github.com/Rdatatable/data.table/(?<link_type>[^/]+)/(?<link_number>[0-9]+)\\)", |
|
0 commit comments