From 8b8893c7f79548aaf2c01526e7cfffe46e523ba4 Mon Sep 17 00:00:00 2001 From: Tomeriko96 Date: Fri, 5 Jan 2024 12:14:07 +0100 Subject: [PATCH] add: helper function to create reference index --- .Rbuildignore | 1 + .../data_reference_index_missing.R | 20 +++++++++++++++++++ 2 files changed, 21 insertions(+) create mode 100644 helperfunctions/data_reference_index_missing.R diff --git a/.Rbuildignore b/.Rbuildignore index 3b2dc4d..6236ded 100644 --- a/.Rbuildignore +++ b/.Rbuildignore @@ -3,6 +3,7 @@ ^LICENSE\.md$ ^build_vvCommander.R ^\.github$ +^helperfunctions$ ^_pkgdown\.yml$ ^docs$ ^pkgdown$ diff --git a/helperfunctions/data_reference_index_missing.R b/helperfunctions/data_reference_index_missing.R new file mode 100644 index 0000000..65db087 --- /dev/null +++ b/helperfunctions/data_reference_index_missing.R @@ -0,0 +1,20 @@ +library(purrr) +data_reference_index_missing <- function(pkg = ".", depth = 1L) { + pkg <- pkgdown:::as_pkgdown(pkg) + + meta <- pkg$meta[["reference"]] %||% pkgdown:::default_reference_index(pkg) + if (length(meta) == 0) { + return(list()) + } + + # Cross-reference complete list of topics vs. topics found in index page + all_topics <- meta %>% + map(~ pkgdown:::select_topics(.$contents, pkg$topics)) %>% + reduce(union) + in_index <- seq_along(pkg$topics$name) %in% all_topics + + missing <- !in_index & !pkg$topics$internal + pkg$topics$name[missing] +} + +data_reference_index_missing()