Giter Club home page Giter Club logo

Comments (2)

statisfactions avatar statisfactions commented on June 1, 2024

That line of code prevents inserting of a usage section for non-function objects (e.g. data or package). If we just remove that line and reinstall the package, we get problems when documenting data or packages:

library(roxygen2)
roc <- rd_roclet()

out <- roc_proc_text(roc, "
    #' Data
    #' @docType data
    x <- 1:10")[[1]]
roxygen2:::get_tag(out, "usage")$values

With the proposed change, we will get x() for usage which will show up in the output Rd file, which is obviously not what we want for data.

So we need another way of distinguishing function from non-function documentation if we want usage sections to come up for functions without parameter (and I agree this is a good thing!). One way to do this is to delete that line and replace it with:

if(!is.null(partitum$docType)) return()

With this change, if the user has used the @docType tag (i.e. package, data, or method/class for S4), which the user needs to pass R CMD check anyway for those kinds of objects, then this doesn't attempt to create usage from the function definition; otherwise it does even if there are no arguments. With that change in the code reinstalled in the package, my example produces NULL for usage and your example produces f().

from roxygen.

yihui avatar yihui commented on June 1, 2024

If there is a way to check whether the object is a function or not, it will be more straightforward to fix this issue. I did not dig deeply enough into roxygen2, so I do not know. Anyway, I believe your fix should work well. I cannot think of other cases that it can possibly fail.

Thanks a lot!

from roxygen.

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.