How to YARD document a method that returns nothing
Asked Answered
V

1

12

I have a method like this

def self.import(file_name, opts = {})

which I'm trying to document with YARD. However this is a method which is 100% side effect (I know, I know, side effects, urgh!). But for users of this method there is effectively no returned object of any type, however YARD generates a signature like this:

+ (Object) import(file_name, opts = {})

Is there any way to tell yard that the import method returns nothing?

I can tell it to return nil, but that's not really the same thing

Vacuity answered 7/9, 2014 at 22:49 Comment(4)
should the method be public? it seems like as a 'side-effect' only other methods might call on it therefore it doesn't need to be a public method...Baumgartner
Since Ruby methods usually return the return value of the latest expression, I am kind of interested how your method looks likes like.Ptolemy
Yes this method should be public as it is the only user accessible entry point into a class (the ruby runs from within a container program and this class imports user-specified data into that program)Vacuity
@Ptolemy - the method actually does return nil ... but I want the documentation to indicate that the method is not intended for returning a value (rather for performing the side effect)Vacuity
A
13

All methods return something, the void key word might be what you are looking for.

# @return [void]
def method_returning_unknown_object
end

void return rendering

Amatol answered 16/9, 2014 at 11:31 Comment(2)
i'm away from my windows machine atm ... what sort of signature does that generate?Vacuity
Link to the documentation instead of a screenshot: rubydoc.info/gems/yard/file/docs/Tags.md#literalsBiddie

© 2022 - 2024 — McMap. All rights reserved.