Giter Club home page Giter Club logo

Comments (3)

daroczig avatar daroczig commented on July 30, 2024

I am reopening this issue now based on @hadley's suggestion on SO.

If I roxygenise the following function:

#' Setter function
#' @param x an R object
#' @param value a character value to set
#' @export
`foo<-` <- function(x, value){
    attr(x, 'foo') <- value
    return(x)
}

I get the following Rd file:

\name{foo<-}
\alias{foo<-}
\title{Setter function}
\usage{
  foo(x, value) <- value
}
\arguments{
  \item{x}{an R object}

  \item{value}{a character value to set}
}
\description{
  Setter function
}

Where the usage tag is not formed correctly.

from roxygen2.

richierocks avatar richierocks commented on July 30, 2024

This update to process.usage fixes the issue (for roxygen2).

process.usage <- function(partitum) {
  if (is.null(partitum$fun) || !partitum$fun) {
    return(new_tag("usage", NULL))
  }

  if (!is.null(partitum$usage)) {
    return(new_tag("usage", partitum$usage))
  }

  fun_name <- if (!is.null(partitum$method)) {
    rd_tag('method', partitum$method[[1]], partitum$method[[2]])
  } else {
    partitum$assignee
  }

  is_setter_fun <- str_detect(fun_name, fixed("<-"))
  if(is_setter_fun) {
    partitum$formals["value"] <- NULL
  }
  args <- usage(partitum$formals)

  if (is_setter_fun) {
    fun_name <- str_replace(fun_name, fixed("<-"), "")
    new_tag("usage", str_c(fun_name, "(", args, ") <- value"))
  } else {
    new_tag("usage", str_c(fun_name, "(", args, ")"))
  }
}

from roxygen2.

hadley avatar hadley commented on July 30, 2024

Fixed in roxygen3 (https://github.com/hadley/roxygen3). This is not yet suitable for use, but it has (I think) a better design, so it's where I'm fixing bugs.

from roxygen2.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.