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

build_reference(): a function cannot share the package's name #1414

Closed
Rmomal opened this issue Sep 25, 2020 · 8 comments
Closed

build_reference(): a function cannot share the package's name #1414

Rmomal opened this issue Sep 25, 2020 · 8 comments

Comments

@Rmomal
Copy link

Rmomal commented Sep 25, 2020

The build_reference() function gives an error I did not have before a recent update:
Error: Failed to parse Rd in myfunction.Rd ℹ values must be length 1, but FUN(X[[1]]) result is length 2
I wasn't able to fully understand the error, but finally figured that it was due to my function having the same name as my package. Changing it did the trick, however I guess it is not a weird name and it should be allowed. Is there a way to do so ?

Here is the traceback:

> traceback()
17: stop(fallback)
16: signal_abort(cnd)
15: abort(msg, parent = err)
14: h(simpleError(msg, call))
13: .handleSimpleError(function (err) 
    {
        msg <- c(paste0("Failed to parse Rd in ", topic$file_in), 
            i = err$message)
        abort(msg, parent = err)
    }, "values must be length 1,\n but FUN(X[[1]]) result is length 2", 
        base::quote(vapply(.x, .f, ..., FUN.VALUE = character(1), 
            USE.NAMES = FALSE)))
12: vapply(.x, .f, ..., FUN.VALUE = character(1), USE.NAMES = FALSE)
11: map_chr(text[fun], href_topic_local)
10: token_href(out$token, out$text)
9: downlit::highlight(text, classes = downlit::classes_pandoc())
8: highlight_text(text)
7: as_data.tag_usage(tags$tag_usage[[1]])
6: as_data(tags$tag_usage[[1]])
5: data_reference_topic(topic, pkg, examples = examples, run_dont_run = run_dont_run)
4: withCallingHandlers(data_reference_topic(topic, pkg, examples = examples, 
       run_dont_run = run_dont_run), error = function(err) {
       msg <- c(paste0("Failed to parse Rd in ", topic$file_in), 
           i = err$message)
       abort(msg, parent = err)
   })
3: .f(.x[[i]], ...)
2: purrr::map(topics, build_reference_topic, pkg = pkg, lazy = lazy, 
       examples = examples, run_dont_run = run_dont_run)
1: pkgdown::build_reference()
@maelle
Copy link
Collaborator

maelle commented Sep 29, 2020

I can reproduce this with the desc package (that has a function called desc()) if I add a package man page (otherwise, it works fine). Both desc.Rd and desc-package.Rd share the alias "desc". I wonder whether this is something that should be solved in roxygen2, should the @PACKAGE tag not add the alias if there's another man page with the alias? 🤔

@maelle
Copy link
Collaborator

maelle commented Sep 29, 2020

Especially as R CMD check warns about duplicate aliases (so downlit doesn't expect find_rdname() to return two Rd names).

@alexpghayes
Copy link

Just ran into this as well and followed Davis' advice at tidymodels/hardhat#130 (comment) for a temporary workaround in https://github.com/RoheLab/vsp.

Attempted fix: RoheLab/vsp@cdd1799

@hadley
Copy link
Member

hadley commented Nov 3, 2020

This seems more like a roxygen2 issue than a downlit one, given the R CMD check warning.

@maelle
Copy link
Collaborator

maelle commented Nov 4, 2020

There is even already an issue there r-lib/roxygen2#1160

@rhijmans
Copy link

rhijmans commented Apr 9, 2021

I encountered this error because I had the same alias for a method twice in the same Rd file (I do not use roxygen). It was not the same as the package name; and R CMD check apparently does not not catch that. It was difficult to find what caused it because the duplication was not in the Rd file where the pkdown compilation broke. The compilation broke in another Rd that used the offending method in the example. It would have been very helpful to get an error message telling me which value had length 2.

@maelle
Copy link
Collaborator

maelle commented Apr 30, 2021

@rhijmans Thank you! This has been fixed by 1fe9140 so no need for a new error message now. 😁

@maelle
Copy link
Collaborator

maelle commented Apr 30, 2021

unless I misunderstood your comment, in which case it'll be easier to open a new issue I think.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants