In Ruby YARD docs, what it mean to wrap a word +example+ with + (plus sign)?
Asked Answered
B

1

7

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?

Borras answered 25/11, 2017 at 22:1 Comment(0)
C
8

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.

Chenoweth answered 26/11, 2017 at 0:19 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.