tomdoc icon indicating copy to clipboard operation
tomdoc copied to clipboard

Description of Examples

Open maasha opened this issue 10 years ago • 1 comments

I would like to add some lines of description to each example in the Examples section, however, that seems to violate the format, and the description becomes an example of its own :o(. One way to deal with this is to include the description as a comment in the example like the return value, but the description is not part of the code - and it makes the HTML less readable.

# Public: Outputs 'Hello World!' to $stdout.
#
# Examples
#
# This is my description.
#
#   hello_world
#   # => 'Hello World!'
#
# Returns nil.

maasha avatar Mar 18 '15 13:03 maasha

Another related question: how do you express that a particular example raises?

# Method that raises if options include any option not in the allowed Array.
#
# options - The Hash with options to be checked.
# allowed - One or more allowed options.
#
# Examples
#
#   options_allowed({foo: "bar"}, :foo)
#   # => nil
#
#   options_allowed({foo: "bar"}, :foobar)
#   # => Raises ???
#
# Returns nothing.
# Raises OptionError on any options not in the allowed Array.

maasha avatar Mar 20 '15 12:03 maasha