Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a yieldself tag #1491

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 9 additions & 1 deletion lib/yard/tags/library.rb
Expand Up @@ -593,6 +593,14 @@ def directive_create(tag_name, tag_buf, parser)
# @see tag:return
define_tag "Yield Returns", :yieldreturn, :with_types

# Documents the type of context in which the block is expected
# to run.
#
# @example
# # @yieldself [Array] An array will evaluate the block
# def add5_block(&block) [].instance_eval(&block) end
define_tag "Yield Self", :yieldself, :with_types

# @yard.signature [r | w | rw] attribute_name
# Indented attribute docstring
define_directive :attribute, :with_types_and_title, AttributeDirective
Expand Down Expand Up @@ -624,7 +632,7 @@ def directive_create(tag_name, tag_buf, parser)
define_directive :visibility, VisibilityDirective

self.visible_tags = [:abstract, :deprecated, :note, :todo, :example, :overload,
:param, :option, :yield, :yieldparam, :yieldreturn, :return, :raise,
:param, :option, :yield, :yieldparam, :yieldself, :yieldreturn, :return, :raise,
:see, :author, :since, :version]

self.transitive_tags = [:since, :api]
Expand Down
5 changes: 5 additions & 0 deletions spec/templates/examples/tag001.txt
Expand Up @@ -42,6 +42,11 @@ Yield Parameters:

(String) a - a value

Yield Self:
-----------

(Object) - an object

Yield Returns:
--------------

Expand Down
1 change: 1 addition & 0 deletions spec/templates/tag_spec.rb
Expand Up @@ -23,6 +23,7 @@
# @version 1.0
# @yield a block
# @yieldparam [String] a a value
# @yieldself [Object] an object
# @yieldreturn [Hash] a hash
# @example Wash your car
# car.wash
Expand Down