Skip to content

Commit

Permalink
Format example code
Browse files Browse the repository at this point in the history
  • Loading branch information
castwide committed Jan 19, 2025
1 parent 5b45ef6 commit 7f276ca
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 6 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
## 0.51.1
- Format example code

## 0.51.0 - January 19, 2025
- Resolve self in yieldself tags
- Include absolute paths in config (#674)
Expand Down
18 changes: 13 additions & 5 deletions lib/solargraph/pin/method.rb
Original file line number Diff line number Diff line change
Expand Up @@ -130,11 +130,7 @@ 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
concat_example_tags
end
@documentation.to_s
end
Expand Down Expand Up @@ -335,6 +331,18 @@ def parse_overload_param(name)
[name, :arg]
end
end

def concat_example_tags
example_tags = docstring.tags(:example)
return if example_tags.empty?
@documentation += "\n\nExamples:\n\n```ruby\n"
@documentation += example_tags.map do |tag|
(tag.name ? "# #{tag.name}\n" : '') +
"#{tag.text}\n"
end
.join("\n")
.concat("```\n")
end
end
end
end
2 changes: 1 addition & 1 deletion lib/solargraph/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# frozen_string_literal: true

module Solargraph
VERSION = '0.51.0'
VERSION = '0.51.1'
end

0 comments on commit 7f276ca

Please sign in to comment.