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

Preserve order of @example and @examples #868

Closed
HenrikBengtsson opened this issue May 29, 2019 · 6 comments
Closed

Preserve order of @example and @examples #868

HenrikBengtsson opened this issue May 29, 2019 · 6 comments
Labels
feature a feature request or enhancement rd ✍️
Milestone

Comments

@HenrikBengtsson
Copy link
Contributor

I'd like to propose a new tag @import that takes a file as input. It reads the content of that file and injects it as is.

One use case would be to allow for something like (just a toy example):

#' @examples
#' \dontshow{
#' oopts <- options()
#' }
#' @import incl/my_fcn.R
#' \dontshow{
#' options(oops)
#' }

The above allows you to keep a standalone, syntax-valid file incl/my_fcn.R that can be source():ed while still having additional Rd markup in the example() code.

@gaborcsardi
Copy link
Member

#' @example filename
#' @examples
#' code

almost does that, @examples and the code in filename will be put in the \examples.

@HenrikBengtsson

This comment has been minimized.

@gaborcsardi

This comment has been minimized.

@HenrikBengtsson

This comment has been minimized.

@gaborcsardi
Copy link
Member

gaborcsardi commented May 29, 2019

It is a bit hard to keep the order internally, because roxygen collates all @examples blocks previously, before putting that and the @example files together.

Also, CRAN do not like this, potentially, depending on what you put in the setup and teardown chunks.

@hadley
Copy link
Member

hadley commented Jul 21, 2019

Looking at topic_add_examples(), I don't think it should be too hard to interleave @example and @examples in the order that they're encountered, rather than in individual blocks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature a feature request or enhancement rd ✍️
Projects
None yet
Development

No branches or pull requests

3 participants