From bb74f38df996279527ea2d65a7c8c1872ffda299 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lek=C3=AB=20Mula?= Date: Sun, 9 Jun 2024 18:55:47 +0200 Subject: [PATCH] Include @example tags in Pin::Method documentation --- lib/solargraph/pin/method.rb | 5 +++++ spec/pin/method_spec.rb | 11 +++++++++++ 2 files changed, 16 insertions(+) diff --git a/lib/solargraph/pin/method.rb b/lib/solargraph/pin/method.rb index f86dbed13..ec693a90d 100644 --- a/lib/solargraph/pin/method.rb +++ b/lib/solargraph/pin/method.rb @@ -130,6 +130,11 @@ def documentation end @documentation += "\n\n" unless @documentation.empty? @documentation += "Visibility: #{visibility}" + example_tags = docstring.tags(:example) + unless example_tags.empty? + @documentation += "\n\nExamples:\n\n" + @documentation += example_tags.map(&:text).join("\n") + end end @documentation.to_s end diff --git a/spec/pin/method_spec.rb b/spec/pin/method_spec.rb index 9fe437956..3851ff1dc 100644 --- a/spec/pin/method_spec.rb +++ b/spec/pin/method_spec.rb @@ -275,6 +275,17 @@ def bar?; end expect(pin.documentation).to include('the foo text string') end + it 'includes @example text in documentation' do + pin = Solargraph::Pin::Method.new( + name: 'foo', + comments: %( +@example + foo + ) + ) + expect(pin.documentation).to include('foo') + end + context 'as attribute' do it "is a kind of attribute/property" do source = Solargraph::Source.load_string(%(