Documentation directives
Crystal also provides several directives that inform the documentation generator how it should treat documentation for a specific feature. These include the following:
:ditto:
:nodoc:
:inherit:
Let's take a closer look at what they do.
Ditto
The :ditto:
directive can be used to copy the documentation from the previous definition, like so:
# Returns the number of items within this collection. def size; end # :ditto: def length; end # :ditto: # # Some information specific to this method. def count; end
When the documentation is generated, #length
would have the same sentence as #size
. #count
would also have this sentence, in addition to another sentence that's specific to that method. This can help reduce duplication for a series of related methods.
Nodoc
Documentation is only generated for the public API. This means that private and protected features are hidden by default. However, in some cases, a type...