From ba79f0de6a18e1b50acd364e2f63b0f1a30b48ca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ma=C3=ABlle=20Salmon?= Date: Tue, 24 Sep 2024 11:06:19 +0200 Subject: [PATCH 1/2] docs: lifecycle table --- DESCRIPTION | 2 +- vignettes/articles/current-deprecations.Rmd | 114 ++++++++++++++++++++ 2 files changed, 115 insertions(+), 1 deletion(-) create mode 100644 vignettes/articles/current-deprecations.Rmd diff --git a/DESCRIPTION b/DESCRIPTION index b2917a7af7b..a2ad24877b8 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -65,7 +65,7 @@ VignetteBuilder: knitr Config/Needs/build: roxygen2, devtools, irlba, pkgconfig, igraph/igraph.r2cdocs, moodymudskipper/devtag Config/Needs/coverage: covr -Config/Needs/website: readr +Config/Needs/website: here, readr, tibble, xmlparsedata, xml2 Config/testthat/edition: 3 Config/testthat/parallel: true Config/testthat/start-first: vs-es, scan, vs-operators, weakref, diff --git a/vignettes/articles/current-deprecations.Rmd b/vignettes/articles/current-deprecations.Rmd new file mode 100644 index 00000000000..b6cc738bb09 --- /dev/null +++ b/vignettes/articles/current-deprecations.Rmd @@ -0,0 +1,114 @@ +--- +title: "Improving igraph interface: current deprecations" +--- + +```{r, include = FALSE} +knitr::opts_chunk$set( + collapse = TRUE, + comment = "#>" +) +``` + + +To provide a more consistent interface, part of igraph functions or arguments are slowly but consistently being deprecated. +You can follow along the current level of deprecations in the table below. + +Please update your codebases as soon as you can, be they packages or scripts. +To do that, run your code in a session where you installed the latest igraph version, possibly even the development version that you can install from R-universe: + +```r +options( + repos = c( + igraph = 'https://igraph.r-universe.dev', + CRAN = 'https://cloud.r-project.org' + ) +) +install.packages('igraph') +``` + +And pay attention to any message emitted through the lifecycle package. + + +Thank you for your cooperation! +Direct any question to us in the [igraph issue tracker](https://github.com/igraph/rigraph/issues). + + +```{r, echo=FALSE} +clean_arg <- function(arg) { + arg <- sub("^'", "", arg) + arg <- sub("'$", "", arg) + arg <- sub('^"', '', arg) + arg <- sub('"$', '', arg) + arg +} + +link_new <- function(new) { + # downlit can't link something like "igraph::assortativity(values =)" + new_str <- sub("\\(.*", "", new) + url <- downlit::autolink_url(sprintf("igraph::%s", new_str)) + if (is.na(url)) { + new + } else { + sprintf('%s', url, new) + } +} + +parse_lifecycle_call <- function(symbol_function_call) { + level <- sub("deprecate_", "", xml2::xml_text(symbol_function_call)) + level <- switch( + level, + soft = "1 -- soft", + warn = "2 -- warn", + stop = "3 -- stop" + ) + + args <- purrr::keep( + xml2::xml_siblings(xml2::xml_parent(symbol_function_call)), + \(x) xml2::xml_name(x) == "expr" + ) + version <- xml2::xml_text(args[[1]]) + old <- xml2::xml_text(args[[2]]) + new <- if (length(args) > 2) xml2::xml_text(args[[3]]) else "" + + new_text <- link_new(clean_arg(new)) + + if (!grepl(" + parse(keep.source = TRUE) |> + xmlparsedata::xml_parse_data(pretty = TRUE) |> + xml2::read_xml() |> + xml2::xml_find_all( + ".//SYMBOL_FUNCTION_CALL[contains(text(), 'deprecate_')]" + ) + + if (length(lifecycle_calls) == 0) return(NULL) + + lifecycle_calls_info <- purrr::map(lifecycle_calls, parse_lifecycle_call) + + do.call(rbind, lifecycle_calls_info) +} + +scripts <- fs::dir_ls(here::here("R"), glob = "*.R") + +table <- do.call( + rbind, + purrr::map(scripts, parse_script), + args = list(make.row.names = FALSE) +) + +knitr::table(table) + +``` From 18817bdde7323ca37f71783389f030aee2519657 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ma=C3=ABlle=20Salmon?= Date: Mon, 24 Feb 2025 09:31:19 +0100 Subject: [PATCH 2/2] tweaks --- vignettes/articles/current-deprecations.Rmd | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/vignettes/articles/current-deprecations.Rmd b/vignettes/articles/current-deprecations.Rmd index b6cc738bb09..96fee9a2914 100644 --- a/vignettes/articles/current-deprecations.Rmd +++ b/vignettes/articles/current-deprecations.Rmd @@ -85,6 +85,7 @@ parse_lifecycle_call <- function(symbol_function_call) { new = new_text ) } + parse_script <- function(path) { lifecycle_calls <- path |> parse(keep.source = TRUE) |> @@ -102,13 +103,13 @@ parse_script <- function(path) { } scripts <- fs::dir_ls(here::here("R"), glob = "*.R") +scripts <- scripts[fs::path_file(scripts) != "zzz.R"] table <- do.call( rbind, - purrr::map(scripts, parse_script), - args = list(make.row.names = FALSE) + purrr::map(scripts, parse_script) ) -knitr::table(table) +knitr::kable(table) ```