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

Draft of a help function for method documentation similar to reference classes #20

Closed
wants to merge 1 commit into from

Conversation

paulstaab
Copy link

Related to #2, I was looking for ways to document methods. The code in this pull request mimics the documentation system of reference classes, where each methods can optionally be documented with a string, given as first line of its body:

TC <- R6Class("test_class",
              public = list(getx = function() { 'Gets x'; private$x },
                            setx = function(x) { 'Sets x'; self$x <- x },
                            one = function() 1,
                            help = R6_help),
              private = list(x = 1)
)
T <- TC$new()
T$help('setx')
# test_class$setx: Sets x
T$help('getx')
# test_class$getx: Gets x
T$help('one')
# test_class$one: No documentation available.

The help function could be automatically added to all objects. Would you be interested in including something like this in R6? If there is interest on your side, I will happily improve the code until it is fit for being included.

@wch
Copy link
Member

wch commented Aug 12, 2014

Hm, I'm not sure yet that this is the way to go. I do like that it's optional, and that the class author would have to explicitly opt-in. It would be nice if T$help() listed all the methods, and possibly public fields.

I'm leaning toward making it easier to create real .Rd documentation, though. @hadley tells me that, for reference classes, roxygen2 has support for pulling out doc strings and putting them into man pages. It would need some tweaking to work with R6, though.

@paulstaab
Copy link
Author

Yes, real .Rd documentation is definitely better. Guess the user would than call something like ?test_class$setx to view the page?

@paulstaab
Copy link
Author

Documentation as in suggested in #3 works for me. I'm closing this PR.

@paulstaab paulstaab closed this Jan 15, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants