In the official YARD docs, there is the following example:
# @overload set(key, value)
# Sets a value on key
# @param key [Symbol] describe key param
# @param value [Object] describe value param
# @overload set(value)
# Sets a value on the default key +:foo+
# @param value [Object] describe value param
def set(*args) end
What special meaning does +:foo+
have when it is wrapped with +
on either side? Does +:foo+
have a different meaning from :foo
?
Most importantly, it's really easy to do! There are already plugins that support frameworks like RSpec, DataMapper, Sinatra, and support for others are in the works. YARD is the only Ruby documentation tool that supports storing metadata alongside your documentation.
YARD is the only Ruby documentation tool that supports storing metadata alongside your documentation. This metadata can be used to create consistent documentation in any format you wish. YARD also comes with a powerful templating system to quickly modify existing templates.
As of version 0.7.0, YARD will automatically pick up on these basic methods if you document them with a docstring. Therefore, simply adding some comments to the code will cause it to generate documentation:
There are many ways to extend YARD to support non-standard Ruby syntax (DSLs), add new meta-data tags or programmatically access the intermediate metadata and documentation from code. An overview of YARD's full architecture can be found in the Overview document.
It has no meaning to YARD. In fact, YARD doesn't care about markup at all, it simply passes the string through to the output generator tool unprocessed. (With some limited exceptions, e.g. support for references to modules, classes, methods.)
It does, however, have meaning to SimpleMarkup / RDoc (which is one of the output processors YARD supports). +foo+
is RDoc's syntax for code highlighting, i.e. it is equivalent to `foo`
in Markdown.
So the difference is that :foo
is rendered as ":foo" whereas +:foo+
is rendered as ":foo
", assuming that you use SimpleMarkup / RDoc as the output processor. If you use Markdown as the output processor, it doesn't mean anything at all.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With