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

R6 class of local package does not get highlighted (inline) #140

Open
pat-s opened this issue Jun 6, 2022 · 2 comments
Open

R6 class of local package does not get highlighted (inline) #140

pat-s opened this issue Jun 6, 2022 · 2 comments
Labels
reprex needs a minimal reproducible example

Comments

@pat-s
Copy link

pat-s commented Jun 6, 2022

The following works

`<pkg>::<class>$new()`

The following do not

`<class>`
`<class>$new()`

I've played around a bit with downlit::highlight() and found that

downlit::highlight("<class>$new()")

does not include the href part because packages in

https://github.com/r-lib/downlit/blob/main/R/highlight.R#L58

is empty. I've added the following to a fork

  if (is.null(packages)) {
    packages <- loadedNamespaces()
  }

which makes the href part getting added to downlit::highlight("<class>$new()") when executed directly.
However, I still do not get highlighting when building a pkgdown site 🤔 (new session, fresh start with modified {downlit}).

Is there something else I am overlooking which is responsible for highlighting of local packages in {pkgdown}?

@hadley
Copy link
Member

hadley commented Jun 9, 2022

Can you please provide a reprex using a package that's on CRAN?

@hadley hadley added the reprex needs a minimal reproducible example label Jun 9, 2022
@jemus42
Copy link

jemus42 commented Sep 14, 2022

Reprex using mlr3 from CRAN, which I suspect is one of the reasons Patrick encountered this behavior:

library(downlit)
library(mlr3)

# Object in question: mlr3::Task

downlit::highlight("mlr3::Task$new()")
#> [1] "<span><span class='nf'>mlr3</span><span class='nf'>::</span><span class='nv'><a href='https://mlr3.mlr-org.com/reference/Task.html'>Task</a></span><span class='o'>$</span><span class='nf'>new</span><span class='o'>(</span><span class='o'>)</span></span>"

downlit::highlight("mlr3::Task")
#> [1] "<span><span class='nf'>mlr3</span><span class='nf'>::</span><span class='nv'><a href='https://mlr3.mlr-org.com/reference/Task.html'>Task</a></span></span>"

downlit::highlight("Task$new()")
#> [1] "<span><span class='nv'>Task</span><span class='o'>$</span><span class='nf'>new</span><span class='o'>(</span><span class='o'>)</span></span>"

downlit::highlight("Task")
#> [1] "<span><span class='nv'>Task</span></span>"

Created on 2022-09-14 with reprex v2.0.2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
reprex needs a minimal reproducible example
Projects
None yet
Development

No branches or pull requests

3 participants