When a page has a Details section and you try to copy it using
#' @inheritSection fun details
you get following error:
Error: is.character(title) is not TRUE
In addition: Warning message:
Can't find section 'details'
Happens with both ''details'' and ''Details''. It's not solved by using the @details
tag specifically in the original document either.
traceback:
> traceback()
16: stop(msg, call. = FALSE, domain = NA)
15: stopifnot(is.character(title), is.character(content))
14: roxy_field_section(new_section$title[selected], new_section$content[selected])
13: topic$add_field(roxy_field_section(new_section$title[selected],
new_section$content[selected]))
12: fun(topic, self, ...)
11: topics$topo_apply(function(x) x$inherits_section_from(), inherit_section)
10: topics_process_inherit(topics, parsed$env)
9: roclet_process.roclet_rd(roc, parsed, base_path)
8: roclet_process(roc, parsed, base_path)
7: FUN(X[[i]], ...)
6: lapply(roclets, roc_out)
5: unlist(lapply(roclets, roc_out))
4: roxygen2::roxygenise(pkg$path, roclets = roclets, load_code = ns_env)
3: force(code)
2: withr::with_envvar(r_env_vars(), roxygen2::roxygenise(pkg$path,
roclets = roclets, load_code = ns_env))
1: devtools::document(pkg = "pkg/xnet", roclets = c("rd", "collate",
"namespace"))
This works for me:
library(roxygen2)
roc_proc_text(rd_roclet(), "
#' Foo
#'
#' @details BLAH
foo <- function() {}
#' Bar
#'
#' @inherit foo details
bar <- function(x){}
")
Can you please try tweaking that reprex to demonstrate the problem you're seeing?
library(roxygen2)
roc_proc_text(rd_roclet(), "
#' Foo
#'
#' @details BLAH
foo <- function() {}
#' Bar
#'
#' @inheritSection foo details
bar <- function(x){}
")
#> Warning: Can't find section 'details'
#> Error in roxy_field_section(new_section$title[selected], new_section$content[selected]): is.character(title) is not TRUE
Created on 2018-06-29 by the reprex package (v0.2.0).
This is the documented use of @inheritSection
per the vignette of roxygen2:
https://cran.r-project.org/web/packages/roxygen2/vignettes/rd.html
Oh hmmmm, that's because "Details" isn't a "Section", it's a "Details".
The error is clearly a problem that needs to be fixed. Otherwise, I think this is a documentation issue — @inheritSection
only works with sections created by @section
.
Thx, the distinction between specific sections and those created by @section
wasn't clear to me. It would be nice if this could be clarified in the docs.
I actually just ran into this too. This was going to be my question:
Are @inherit my_fun return
and @inheritSection my_fun return
supposed to do the same thing? @inherit
works for me but @inheritSection
fails with a Can't find section 'return' in ?my_fun
An RStudio Blog post example doesn't work because of this:
https://blog.rstudio.com/2017/02/01/roxygen2-6-0-0/
"if you’d like to inherit a single section, you can use @inheritSection fun title"
Nope:
Can't find section 'title' in ?my_fun
Tweaked sentence in description; PRs for generally improving this file would be much appreciated.
A thumbs up: I would appreciate a fix which also whould work for @examples
or an own @inheritExamples
tag.
Most helpful comment
I actually just ran into this too. This was going to be my question:
Are
@inherit my_fun return
and@inheritSection my_fun return
supposed to do the same thing?@inherit
works for me but@inheritSection
fails with aCan't find section 'return' in ?my_fun
An RStudio Blog post example doesn't work because of this:
https://blog.rstudio.com/2017/02/01/roxygen2-6-0-0/
"if you’d like to inherit a single section, you can use @inheritSection fun title"
Nope:
Can't find section 'title' in ?my_fun