Skip to content

Cannot Document Two s3 Methods Together #848

@billdenney

Description

@billdenney

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 
Details

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugan unexpected problem or unintended behavior

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions