etiennebacher / altdoc

Alternative to pkgdown to document R packages
https://altdoc.etiennebacher.com
Other
67 stars 9 forks source link

`render_docs(parallel = TRUE)` doesn't show counter #112

Closed etiennebacher closed 11 months ago

etiennebacher commented 11 months ago

Not sure how hard this would be to implement but I think there are some progress bar functionalities in future so there must be a way to share the count between processes

Also testthat can run in parallel and still counts the tests

etiennebacher commented 11 months ago

That seems quite hard to do and it looks like it's not arriving in future any time soon: https://github.com/HenrikBengtsson/future.apply/issues/111

If I put cli::cli_progress_step() and cli::cli_progress_update() in future_sapply() then all messages arrive at the same time when the function has finished running, which is useless. This sounds like a lot of effort for little added value, showing which man page failed to render afterwards is probably more useful.


Some code I tried, just in case:

i <- 0
conversion_worked <- vector(length = n)

if (isTRUE(parallel)) {
  .assert_dependency("future.apply", install = TRUE)
  conversion_worked <- future.apply::future_sapply(
    seq_along(man_source),
    function(x) {
      cli::cli_progress_step("Converting function reference {i}/{n}: {basename(man_source[i])}", spinner = TRUE)
      conversion_worked[x] <<- render_one_man(man_source[x])
      cli::cli_progress_update(inc = 1)
    },
    future.seed = NULL,
    future.conditions = "message"
  )
} else {
  cli::cli_progress_step("Converting function reference {i}/{n}: {basename(man_source[i])}", spinner = TRUE)
  for (i in seq_along(man_source)) {
    conversion_worked[i] <- render_one_man(man_source[i])
    cli::cli_progress_update(inc = 1)
  }
}