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

@inherit Doesn't inherit description if not inheriting title #629

Closed
ssokolen opened this issue May 12, 2017 · 2 comments
Closed

@inherit Doesn't inherit description if not inheriting title #629

ssokolen opened this issue May 12, 2017 · 2 comments

Comments

@ssokolen
Copy link

@ssokolen ssokolen commented May 12, 2017

This might be a feature rather than a bug, but the following doesn't seem to work as expected. Unless I include @inherit title, @inherit description doesn't work.

Original function:

#' This is title
#' 
#' This is description
#'
#' @param x x
#' @param y y
#'
#' @return numeric vector
f1 <- function(x, y) x + y

Function that will inherit f1:

#' Different title
#'
#' @inherit f1 description 
#'
#' @inheritParams f1
#' @param z z
#'
#' @inherit f1 return
f2 <-function(x, y, z) x + y + z

This results in \description{} of f2 to be: "Different title". If I modify the title to @inherit f1 title, the \description{} of f2 is correctly inherited as "This is description"

@hadley
Copy link
Member

@hadley hadley commented Aug 17, 2017

Minimal reprex:

out <- roc_proc_text(rd_roclet(), "
  #' T1
  #' 
  #' D1
  f1 <- function() 1
  
  #' T2
  #' @inherit f1 description 
  f2 <-function() 2
")

out[[1]]$get_field("description")$values
out[[2]]$get_field("description")$values

@hadley
Copy link
Member

@hadley hadley commented Aug 17, 2017

It happens because the repetition of title into description happens when the block is parsed. That means the inheritance code sees that a description already exists and skips the inheritance. To fix this, we'll need to move the insertion of the default description much later in the process - presumably just before the Rd file is written.

@hadley hadley closed this in 827b9f8 Aug 17, 2017
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
2 participants