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

Include @example tags in Pin::Method documentation #718

Open
wants to merge 1 commit into
base: master
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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