docstring
docstring copied to clipboard
Approach to avoid capture.output
Basically inconsequential suggestion, but I was curious how your package worked and I noticed the capture.output(print(fun)) line in read_docstring,
https://github.com/Dasonk/docstring/blob/master/R/read_docstring.R#L17
I had guessed prior that it would be an application of body but that doesn't return the comments. So I dug around to figure out where print is finding the source code and I noticed it's in the function's attributes
as.character(attr(f, "srcref"))
This would avoid ever hitting the output stream. And would also work for function objects with overloaded print methods (not that those are very common).