1

How can I use YUIDoc comments in Ruby? The best I can come up with is this:

  ##*
  # Get Query history
  # @type {Array} Past search query objects
  # @param {int} limit The number of objects to return. Defaults to 10. (Max 100).
  # @param {boolean} only_visible limit the search to visible items. Defaults to true.
  #

And this:

  #/**
  # * Get Query history
  # * @type {Array} Past search query objects
  # * @param {int} limit The number of objects to return. Defaults to 10. (Max 100).
  # * @param {boolean} only_visible limit the search to visible items. Defaults to true.
  # */
toro2k
  • 19,020
  • 7
  • 64
  • 71
Alexandros K
  • 947
  • 1
  • 6
  • 19

1 Answers1

1

You have to embed YUIDoc comments inside a Ruby multiline comment, like this:

=begin
/**
* Get Query history
* @type {Array} Past search query objects
* @param {int} limit The number of objects to return. Defaults to 10. (Max 100).
* @param {boolean} only_visible limit the search to visible items. Defaults to true.
*/
=end

The = character before begin and end must be on the first column of the line.

toro2k
  • 19,020
  • 7
  • 64
  • 71
  • Interesting. Is that considered OK style? Please let me state that I am a javascript developer with very little rails experience. It almost looks like a CDATA block or something. By the way.. what does the =begin and =end actually do?? – Alexandros K May 28 '13 at 20:46
  • @AlexKessaris `=begin` and `=end` are delimiters for multiline comments, similar to `/*` and `*/` in JavaScript. They are quite uncommon in Ruby code but in this case they are the only choice. – toro2k May 29 '13 at 07:08
  • Cool! Thank you for your help in this matter. Incidentally, I would be interested to know more options on commenting in Ruby. I'll look it up online, but your thoughts are also very welcome! – Alexandros K May 29 '13 at 13:06
  • In the end I guess the outcome of this question has been to adopt YARD-style comments. Thank you very much for your help @toro2k – Alexandros K Jun 05 '13 at 16:18