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

Comments

@HenrikBengtsson
Copy link
Contributor

@HenrikBengtsson HenrikBengtsson commented May 29, 2019

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
Collaborator

@gaborcsardi gaborcsardi commented May 29, 2019

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

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

@HenrikBengtsson

This comment has been hidden.

@gaborcsardi

This comment has been hidden.

@HenrikBengtsson

This comment has been hidden.

@gaborcsardi
Copy link
Collaborator

@gaborcsardi 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 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
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants