Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove downlit to use built-in Quarto functionality instead #283

Merged
merged 2 commits into from
Jul 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Type: Package
Package: altdoc
Title: Package Documentation Websites with 'Quarto', 'Docsify', 'Docute', or 'MkDocs'
Version: 0.3.0.9003
Version: 0.3.0.9004
Authors@R:
c(person(given = "Etienne",
family = "Bacher",
Expand All @@ -24,14 +24,14 @@ Imports:
cli,
desc,
evaluate,
downlit,
fs,
quarto,
tools,
utils
Suggests:
covr,
digest,
downlit,
future,
future.apply,
knitr,
Expand Down
2 changes: 1 addition & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
execute:
freeze: auto
```
* `render_docs(autolink = TRUE)` uses the `downlit` package to automatically link function calls to their documentation on the web.
* For Quarto websites, `render_docs()` can use the `downlit` package to automatically link function calls to their documentation on the web. Turn off by modifying the `code-link` line in `altdoc/quarto_website.yml`

### Other changes

Expand Down
28 changes: 0 additions & 28 deletions R/autolink.R

This file was deleted.

8 changes: 1 addition & 7 deletions R/render_docs.R
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
#' @param verbose Logical. Print Rmarkdown or Quarto rendering output.
#' @param parallel Logical. Render man pages and vignettes in parallel using the `future` framework. In addition to setting this argument to TRUE, users must define the parallelism plan in `future`. See the examples section below.
#' @param freeze Logical. If TRUE and a man page or vignette has not changed since the last call to `render_docs()`, that file is skipped. File hashes are stored in `altdoc/freeze.rds`. If that file is deleted, all man pages and vignettes will be rendered anew.
#' @param autolink Logical. TRUE to link function names and calls to web-based documentation. See the Autolink section below for details.
#' @inheritParams setup_docs
#' @export
#'
Expand Down Expand Up @@ -46,7 +45,7 @@
#' render_docs(parallel = TRUE)
#'
#' }
render_docs <- function(path = ".", verbose = FALSE, parallel = FALSE, freeze = FALSE, autolink = FALSE) {
render_docs <- function(path = ".", verbose = FALSE, parallel = FALSE, freeze = FALSE) {

path <- .convert_path(path)
tool <- .doc_type(path)
Expand Down Expand Up @@ -107,11 +106,6 @@ render_docs <- function(path = ".", verbose = FALSE, parallel = FALSE, freeze =
cli::cli_h1("Update HTML")
.import_settings(path = path, tool = tool, verbose = verbose, freeze = freeze)

if (isTRUE(autolink)) {
cli::cli_h1("Auto-Link")
.autolink(path)
}

cli::cli_h1("Complete")
cli::cli_alert_success("Documentation updated.")
}
Expand Down
6 changes: 4 additions & 2 deletions inst/quarto_website/quarto_website.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ project:

website:
title: "$ALTDOC_PACKAGE_NAME"
code-links: true
navbar:
search: true
right:
Expand All @@ -34,7 +35,8 @@ website:
- text: Citation
file: $ALTDOC_CITATION

# format:
# html:
format:
html:
code-link: true
# theme: cosmo
# number-sections: false
11 changes: 5 additions & 6 deletions man-roxygen/altdoc_autolink.R
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
#' @section Auto-link:
#'
#' When the `autolink` argument is `TRUE`, `altdoc` will use the `downlit` package to replace the function names on the package website by links to web-based package documentation. This works for base R libraries and any package published on CRAN.
#' @section Auto-link for Quarto websites:
#'
#' To allow internal links to functions documented by `altdoc`, we need to include links to correct URLs in the `altdoc/pkgdown.yml` file. By default, this file is populated with links to the first URL in the `DESCRIPTION`. When calling `render_docs(autolink=TRUE)`, the `pkgdown.yml` file is moved to the root of the website.
#' When the `code-link` format setting is `true` in `altdoc/quarto_website.yml` and the `downlit` package is installed, `altdoc` will use the `downlit` package to replace the function names on the package website by links to web-based package documentation. This works for base R libraries and any package published on CRAN.
#'
#' Importantly, `downlit` requires the `pkgdown.yml` to be live on the website to create links. This means that links will generally not be updated when making purely local changes. Also, links may not be updated the first time an `altdoc` website is published to the web.
#' To allow internal links to functions documented by `altdoc`, we need to include links to correct URLs in the `altdoc/pkgdown.yml` file. By default, this file is populated with links to the first URL in the `DESCRIPTION`.
#'
#' Importantly, `downlit` requires the `pkgdown.yml` file to be live on the website to create links. This means that links will generally not be updated when making purely local changes. Also, links may not be updated the first time an `altdoc` website is published to the web.
#'
#' Note that the `autolink` argument works best for Quarto-based websites. `mkdocs` appears to ignore `downlit` annotations altogether. `docute` and `docsify` display `downlit` annotations, but CSS styling and code highlighting sometimes suffer.
20 changes: 5 additions & 15 deletions man/render_docs.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions tests/testthat/_snaps/docsify/render_docs.md
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@
[16] "<table>"
[17] "<tr>"
[18] "<td style=\"white-space: nowrap; font-family: monospace; vertical-align: top\">"
[19] "<code id=\"hello_base_:_x\">x</code>"
[19] "<code id=\"x\">x</code>"
[20] "</td>"
[21] "<td>"
[22] "A parameter"
Expand Down Expand Up @@ -359,7 +359,7 @@
[16] "<table>"
[17] "<tr>"
[18] "<td style=\"white-space: nowrap; font-family: monospace; vertical-align: top\">"
[19] "<code id=\"examplesIf_true_:_x\">x</code>"
[19] "<code id=\"x\">x</code>"
[20] "</td>"
[21] "<td>"
[22] "A parameter"
Expand Down Expand Up @@ -405,7 +405,7 @@
[16] "<table>"
[17] "<tr>"
[18] "<td style=\"white-space: nowrap; font-family: monospace; vertical-align: top\">"
[19] "<code id=\"examplesIf_false_:_x\">x</code>"
[19] "<code id=\"x\">x</code>"
[20] "</td>"
[21] "<td>"
[22] "A parameter"
Expand Down
6 changes: 3 additions & 3 deletions tests/testthat/_snaps/docute/render_docs.md
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@
[16] "<table>"
[17] "<tr>"
[18] "<td style=\"white-space: nowrap; font-family: monospace; vertical-align: top\">"
[19] "<code id=\"hello_base_:_x\">x</code>"
[19] "<code id=\"x\">x</code>"
[20] "</td>"
[21] "<td>"
[22] "A parameter"
Expand Down Expand Up @@ -350,7 +350,7 @@
[16] "<table>"
[17] "<tr>"
[18] "<td style=\"white-space: nowrap; font-family: monospace; vertical-align: top\">"
[19] "<code id=\"examplesIf_true_:_x\">x</code>"
[19] "<code id=\"x\">x</code>"
[20] "</td>"
[21] "<td>"
[22] "A parameter"
Expand Down Expand Up @@ -396,7 +396,7 @@
[16] "<table>"
[17] "<tr>"
[18] "<td style=\"white-space: nowrap; font-family: monospace; vertical-align: top\">"
[19] "<code id=\"examplesIf_false_:_x\">x</code>"
[19] "<code id=\"x\">x</code>"
[20] "</td>"
[21] "<td>"
[22] "A parameter"
Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/_snaps/mkdocs/render_docs.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
[16] "<table>"
[17] "<tr>"
[18] "<td style=\"white-space: nowrap; font-family: monospace; vertical-align: top\">"
[19] "<code id=\"hello_base_:_x\">x</code>"
[19] "<code id=\"x\">x</code>"
[20] "</td>"
[21] "<td>"
[22] "A parameter"
Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/test-render_docs.R
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ test_that("quarto: autolink", {
install.packages(".", repos = NULL, type = "source")
fs::file_move("README.Rmd", "README.qmd") # special thing quarto
setup_docs("quarto_website")
expect_no_error(render_docs(verbose = .on_ci(), autolink = TRUE))
expect_no_error(render_docs(verbose = .on_ci()))

tmp <- .readlines("docs/vignettes/test.html")
expect_true(any(grepl("https://rdrr.io/r/base/library.html", tmp, fixed = TRUE)))
Expand Down
Loading