mojombo / tomdoc

A flexible code documentation specification with human readers in mind.
333 stars 47 forks source link

Description of Examples #53

Open maasha opened 9 years ago

maasha commented 9 years ago

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 commented 9 years ago

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.