etiennebacher / altdoc

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

Show error messages from quarto even if `verbose = FALSE` #272

Closed etiennebacher closed 4 months ago

etiennebacher commented 4 months ago

https://github.com/etiennebacher/altdoc/issues/270#issuecomment-2038185857

We already install evaluate anyway since it's one of the foundations of quarto/R Markdown:

pak::pkg_deps_explain("altdoc", "evaluate")
#> ℹ Loading metadata database✔ Loading metadata database ... done
#> altdoc -> quarto -> rmarkdown -> evaluate
#> altdoc -> quarto -> rmarkdown -> knitr -> evaluate

Demo

On a small test R package with 2 man pages, one of which has an error.

Before

> altdoc::render_docs(verbose = FALSE)

── Basic files ───────────────────────────────────────────────────────────────────────────────────────────────────────────────────
✔ README imported.

── Man pages ─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
ℹ Found 2 man pages to convert.
✔ Converting function reference 1/2: hello_base [2.3s]
✔ Converting function reference 2/2: hello_r6 [897ms]

✖ The conversion failed for the following man page:
  • hello_base

── Vignettes ─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
ℹ Found 2 vignettes to convert.
✔ Converting vignette 1/2: altdoc.pdf [41ms]
✔ Converting vignette 2/2: test.Rmd [1.9s]
Error in `altdoc::render_docs()`:
! There were some failures when rendering man pages.
Run `rlang::last_trace()` to see where the error occurred.

After

Note that if there are no error (man page number 2), then there are no quarto messages at all:

> altdoc::render_docs(verbose = FALSE)

── Basic files ───────────────────────────────────────────────────────────────────────────────────────────────────────────────────
✔ README imported.

── Man pages ─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
ℹ Found 2 man pages to convert.
⠙ Converting function reference 1/2: hello_base

processing file: hello_base.qmd
  |...................................                 |  67% [unnamed-chunk-1]

Quitting from lines 40-44 [unnamed-chunk-1] (hello_base.qmd)
Error in `log()`:
! non-numeric argument to mathematical function

Execution halted
✔ Converting function reference 1/2: hello_base [2.3s]
✔ Converting function reference 2/2: hello_r6 [887ms]

✖ The conversion failed for the following man page:
  • hello_base

── Vignettes ─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
ℹ Found 2 vignettes to convert.
✔ Converting vignette 1/2: altdoc.pdf [32ms]
✔ Converting vignette 2/2: test.Rmd [1.9s]
Error in `altdoc::render_docs()`:
! There were some failures when rendering man pages.
Run `rlang::last_trace()` to see where the error occurred.
vincentarelbundock commented 4 months ago

I've never used evaluate, so I have a hard time imagining corner cases and such. But the cost in terms of dependency is null, the implementation is straightforward, and the error messages are a clear improvement.

Well done!

etiennebacher commented 4 months ago

I'm also unsure about corner cases, I can try later with polars.

etiennebacher commented 4 months ago

I don't see a problem with polars and it works in parallel too