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

Re-exporting non-function object (?) breaks build_site() #666

Closed
gaborcsardi opened this issue May 15, 2018 · 3 comments
Closed

Re-exporting non-function object (?) breaks build_site() #666

gaborcsardi opened this issue May 15, 2018 · 3 comments

Comments

@gaborcsardi
Copy link
Contributor

@gaborcsardi gaborcsardi commented May 15, 2018

This is callr, which now re-exports process from processx. If I remove the export(process) from NAMESPACE then it works fine.

❯ pkgdown::build_site()
══ Building pkgdown site ═══════════════════════════════════════════════════════
Reading from: '/Users/gaborcsardi/works/callr'
Writing to:   '/Users/gaborcsardi/works/callr/docs'
── Initialising site ───────────────────────────────────────────────────────────
Writing 'sitemap.xml'
── Building home ───────────────────────────────────────────────────────────────
Writing 'index.html'
── Building function reference ─────────────────────────────────────────────────
Warning: Topics missing from index: callr
Loading callr
Reading 'man/callr.Rd'
Reading 'man/convert_and_check_my_args.Rd'
Reading 'man/get_result.Rd'
Reading 'man/make_error.Rd'
Reading 'man/r.Rd'
Reading 'man/r_bg.Rd'
Error in asNamespace(ns) : not a namespace

❯ traceback()
28: stop("not a namespace")
27: asNamespace(ns)
26: getNamespaceName(pkg)
25: unname(getNamespaceName(pkg))
24: ns_env_name(get_env(obj))
23: href_topic_local(in_braces)
22: as_html.tag_link(.x[[i]], ...)
21: .f(.x[[i]], ...)
20: .Call(map_impl, environment(), ".x", ".f", "character")
19: purrr::map_chr(x, as_html, ...)
18: flatten_para(text, ...)
17: as_data.tag_value(.x[[i]], ...)
16: .f(.x[[i]], ...)
15: .Call(map_impl, environment(), ".x", ".f", "list")
14: purrr::map(., as_data)
13: function_list[[i]](value)
12: freduce(value, `_function_list`)
11: `_fseq`(`_lhs`)
10: eval(quote(`_fseq`(`_lhs`)), env, env)
9: eval(quote(`_fseq`(`_lhs`)), env, env)
8: withVisible(eval(quote(`_fseq`(`_lhs`)), env, env))
7: sections %>% purrr::map(as_data) %>% purrr::map(add_slug)
6: data_reference_topic(topic, pkg, examples = examples, run_dont_run = run_dont_run,
       mathjax = mathjax)
5: .f(.x[[i]], ...)
4: .Call(map_impl, environment(), ".x", ".f", "list")
3: purrr::map(topics, build_reference_topic, pkg = pkg, lazy = lazy,
       examples = examples, run_dont_run = run_dont_run, mathjax = mathjax)
2: build_reference(pkg, lazy = lazy, examples = examples, run_dont_run = run_dont_run,
       mathjax = mathjax, seed = seed, override = override, preview = FALSE)
1: pkgdown::build_site()
@gaborcsardi gaborcsardi changed the title Re-exporting non-function object (?) breaks build_ Re-exporting non-function object (?) breaks build_site() May 15, 2018
@gaborcsardi
Copy link
Contributor Author

@gaborcsardi gaborcsardi commented May 15, 2018

The problem is here:

package <- ns_env_name(get_env(obj))

This assumes that we are re-exporting a function, but in my case it is an object... the solution is to find where the object was imported from. This is not always easy, because we might import a whole package.... but it is not bad at least for importFrom. For that we can just look over the imports in the namespace env.

gaborcsardi added a commit that referenced this issue May 15, 2018
We cannot take the package name from the
environment of the function in this case,
but need to look at the import env of the package.

Fixes #666.
gaborcsardi added a commit that referenced this issue May 15, 2018
We cannot take the package name from the
environment of the function in this case,
but need to look at the import env of the package.

Fixes #666.
gaborcsardi added a commit that referenced this issue May 15, 2018
We cannot take the package name from the
environment of the function in this case,
but need to look at the import env of the package.

Fixes #666.
gaborcsardi added a commit that referenced this issue May 15, 2018
We cannot take the package name from the
environment of the function in this case,
but need to look at the import env of the package.

Fixes #666.
@hadley hadley closed this in #669 May 15, 2018
hadley added a commit that referenced this issue May 15, 2018
We cannot take the package name from the
environment of the function in this case,
but need to look at the import env of the package.

Fixes #666.
@mjsteinbaugh
Copy link

@mjsteinbaugh mjsteinbaugh commented Mar 22, 2019

I'm hitting this documentation issue with reexported functions in a couple of my packages. Is there a way to improve the error message to potentially tell you which line contains the offender? This is currently difficult to diagnose for long vignettes and/or package NEWS files.

Seems like it might be this code, correct?
find_reexport_source()

Here's an example:

Error in asNamespace(ns) : not a namespace
Calls: build_articles ... ns_env_name -> unname -> getNamespaceName -> asNamespace
Backtrace:
     █
  1. └─global::build_articles()
  2.   └─pkgdown::build_articles(...)
  3.     └─purrr::walk(...)
  4.       └─purrr::map(.x, .f, ...)
  5.         └─pkgdown:::.f(.x[[i]], ...)
  6.           └─pkgdown:::render_rmarkdown(...)
  7.             └─pkgdown:::update_html(path, tweak_rmarkdown_html, input_path = path_dir(input_path))
  8.               └─pkgdown:::tweak(html, ...)
  9.                 └─pkgdown:::tweak_code(html)
 10.                   └─`%>%`(...)
 11.                     ├─base::withVisible(eval(quote(`_fseq`(`_lhs`)), env, env))
 12.                     └─base::eval(quote(`_fseq`(`_lhs`)), env, env)
 13.                       └─base::eval(quote(`_fseq`(`_lhs`)), env, env)
 14.                         └─pkgdown:::`_fseq`(`_lhs`)
 15.                           └─magrittr::freduce(value, `_function_list`)
 16.                             ├─base::withVisible(function_list[[k]](value))
 17.                             └─function_list[[k]](value)
 18.                               └─purrr::map(., tweak_pre_node)
 19.                                 └─pkgdown:::.f(.x[[i]], ...)
 20.                                   └─purrr::map_chr(text[!has_pkg], href_topic_local)
 21.                                     └─pkgdown:::.f(.x[[i]], ...)
 22.                                       └─pkgdown:::find_reexport_source(obj, ns, topic)
 23.                                         └─rlang::ns_env_name(get_env(obj))
 24.                                           ├─base::unname(getNamespaceName(pkg))
 25.                                           └─base::getNamespaceName(pkg)
 26.                                             └─base::asNamespace(ns)

@gaborcsardi can we reopen this or should I start a new issue?

@mjsteinbaugh
Copy link

@mjsteinbaugh mjsteinbaugh commented Mar 22, 2019

Alternatively, is there a way to disable automatic function links when building a pkgdown site?

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

Successfully merging a pull request may close this issue.

None yet
2 participants