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

Cannot Document Two s3 Methods Together #848

Closed
billdenney opened this issue Mar 5, 2019 · 2 comments
Closed

Cannot Document Two s3 Methods Together #848

billdenney opened this issue Mar 5, 2019 · 2 comments
Labels
bug an unexpected problem or unintended behavior

Comments

@billdenney
Copy link
Contributor

billdenney commented Mar 5, 2019

When I tried to document two s3 methods together, I get the following error:

> devtools::document()
Updating formulops documentation
Loading formulops
Writing NAMESPACE
Warning: substituting_formula.R:75: Don't know how to describe function in s3method
Writing NAMESPACE
Warning message:
as.formula.substituting_formula.Rd is missing name/title. Skipping 

The documentation in question is:

#' Convert a substituting_formula object into a regular formula.
#' 
#' @param x,object the substituting_formula object
#' @param ... Ignored
#' @param env The environment for the resulting formula
#' @return A formula with values substituted.
#' @export
formula.substituting_formula <- function(x, ...) {
  ret <- x$base
  for (i in seq_along(x$substitutions)) {
    ret <-
      modify_formula(
        formula=ret,
        find=get_lhs(x$substitutions[[i]]),
        replace=get_rhs(x$substitutions[[i]])
      )
  }
  ret
}

#' @describeIn formula.substituting_formula as.formula.substituting_formula Add the environment
#' @export
as.formula.substituting_formula <- function(object, env=parent.frame()) {
  ret <- formula.substituting_formula(object)
  environment(ret) <- env
  ret
}

I could work around it with this, but I'm curious if there is a way to make the initial attempt work.

#' Convert a substituting_formula object into a regular formula.
#' 
#' @param x,object the substituting_formula object
#' @param ... Ignored
#' @param env The environment for the resulting formula
#' @return A formula with values substituted.
#' @name formula_substituting_formula
NULL

#' @rdname formula_substituting_formula
#' @export
formula.substituting_formula <- function(x, ...) {
  ret <- x$base
  for (i in seq_along(x$substitutions)) {
    ret <-
      modify_formula(
        formula=ret,
        find=get_lhs(x$substitutions[[i]]),
        replace=get_rhs(x$substitutions[[i]])
      )
  }
  ret
}

#' @rdname formula_substituting_formula
#' @export
as.formula.substituting_formula <- function(object, env=parent.frame()) {
  ret <- formula.substituting_formula(object)
  environment(ret) <- env
  ret
}

I think that this is related to #346.

@hadley hadley added the bug an unexpected problem or unintended behavior label Jul 20, 2019
@hadley
Copy link
Member

hadley commented Sep 11, 2019

Minimal reprex:

library(roxygen2)

out <- roc_proc_text(rd_roclet(), "
  foo <- function(x) UseMethod('foo')
  
  #' Character
  #' 
  #' @param x x
  foo.character <- function(x) {
  }
  
  #' @describeIn foo.character character method
  foo.integer <- function(x) {
  }
")[[1]]
#> Warning: file4299116ab870:11: Don't know how to describe s3method in
#> s3method
#> Warning: foo.integer.Rd is missing name/title. Skipping

Created on 2019-09-11 by the reprex package (v0.3.0)

@hadley hadley closed this as completed in 805a7ad Sep 12, 2019
@billdenney
Copy link
Contributor Author

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug an unexpected problem or unintended behavior
Projects
None yet
Development

No branches or pull requests

2 participants