Skip to content

Commit

Permalink
Include @example tags in Pin::Method documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
lekemula committed Jun 9, 2024
1 parent d7a14bf commit 380a3ca
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
5 changes: 5 additions & 0 deletions lib/solargraph/pin/method.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
11 changes: 11 additions & 0 deletions spec/pin/method_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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(%(
Expand Down

0 comments on commit 380a3ca

Please sign in to comment.