From e2d4f18f9c98228818ba5ae590ebe2adcd517ca3 Mon Sep 17 00:00:00 2001 From: Fred Snyder Date: Sun, 9 Apr 2023 19:34:10 -0400 Subject: [PATCH 1/2] Add a yieldself tag --- lib/yard/tags/library.rb | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/lib/yard/tags/library.rb b/lib/yard/tags/library.rb index 807962608..22ae7eff1 100644 --- a/lib/yard/tags/library.rb +++ b/lib/yard/tags/library.rb @@ -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 From 6190207c52e3afc1add8cc991c86e0b882dd8db5 Mon Sep 17 00:00:00 2001 From: Fred Snyder Date: Mon, 10 Apr 2023 00:26:06 -0400 Subject: [PATCH 2/2] Spec --- lib/yard/tags/library.rb | 2 +- spec/templates/examples/tag001.txt | 5 +++++ spec/templates/tag_spec.rb | 1 + 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/yard/tags/library.rb b/lib/yard/tags/library.rb index 22ae7eff1..5da805800 100644 --- a/lib/yard/tags/library.rb +++ b/lib/yard/tags/library.rb @@ -632,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] diff --git a/spec/templates/examples/tag001.txt b/spec/templates/examples/tag001.txt index 77aeacef3..084da1262 100644 --- a/spec/templates/examples/tag001.txt +++ b/spec/templates/examples/tag001.txt @@ -42,6 +42,11 @@ Yield Parameters: (String) a - a value +Yield Self: +----------- + + (Object) - an object + Yield Returns: -------------- diff --git a/spec/templates/tag_spec.rb b/spec/templates/tag_spec.rb index 5fcf3ed93..3f127dad1 100644 --- a/spec/templates/tag_spec.rb +++ b/spec/templates/tag_spec.rb @@ -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