ldoc icon indicating copy to clipboard operation
ldoc copied to clipboard

A way to document alternative return values

Open agladysh opened this issue 12 years ago • 3 comments

Currently two @return tags yield text that can be read as mutltiple return values documentation (i.e. and).

Functions that can return different things depending on the situation are not that rare. Is there a way to document alternative return values (i.e. or)?

There should probably be a special syntax (and, maybe, a template in the output) for a set of nil, error_message alternatives, but non-error alternative returns should be supported as well.

For example I've recently written a function that returns an object if it is found, false if it is not and nil, error_message on error.

agladysh avatar Aug 20 '13 07:08 agladysh

This is a good point. I'm open to suggestions on how to indicate 'or' rather than 'and'. (Dynamic languages are such fun to document!)

stevedonovan avatar Aug 20 '13 07:08 stevedonovan

Do we need and as default?

Would this be too hard to do?

@return 
  @nil
  @string error message

(OTOH, backwards compatibility...)

agladysh avatar Aug 20 '13 07:08 agladysh

This is not fixed yet, I'm open to suggestions or PRs!

alerque avatar May 03 '23 08:05 alerque