Skip to content
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
4 changes: 2 additions & 2 deletions lib/ruby_lsp/listeners/hover.rb
Original file line number Diff line number Diff line change
Expand Up @@ -283,10 +283,10 @@ def handle_keyword_documentation(keyword)
content = KEYWORD_DOCS[keyword]
return unless content

doc_path = File.join(STATIC_DOCS_PATH, "#{keyword}.md")
doc_uri = URI::Generic.from_path(path: File.join(STATIC_DOCS_PATH, "#{keyword}.md"))

@response_builder.push("```ruby\n#{keyword}\n```", category: :title)
@response_builder.push("[Read more](#{doc_path})", category: :links)
@response_builder.push("[Read more](#{doc_uri})", category: :links)
@response_builder.push(content, category: :documentation)
end

Expand Down
4 changes: 2 additions & 2 deletions lib/ruby_lsp/requests/completion_resolve.rb
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ def keyword_resolve(item)
content = KEYWORD_DOCS[keyword]

if content
doc_path = File.join(STATIC_DOCS_PATH, "#{keyword}.md")
doc_uri = URI::Generic.from_path(path: File.join(STATIC_DOCS_PATH, "#{keyword}.md"))

@item[:documentation] = Interface::MarkupContent.new(
kind: "markdown",
Expand All @@ -93,7 +93,7 @@ def keyword_resolve(item)
#{keyword}
```

[Read more](#{doc_path})
[Read more](#{doc_uri})

#{content}
MARKDOWN
Expand Down
3 changes: 2 additions & 1 deletion test/requests/completion_resolve_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,8 @@ def foo
RubyLsp::KEYWORD_DOCS["yield"], #: as !nil
contents,
)
assert_match("[Read more](#{RubyLsp::STATIC_DOCS_PATH}/yield.md)", contents)
expected_uri = URI::Generic.from_path(path: File.join(RubyLsp::STATIC_DOCS_PATH, "yield.md"))
assert_match("[Read more](#{expected_uri})", contents)
end
end
end
4 changes: 3 additions & 1 deletion test/requests/hover_expectations_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -965,7 +965,9 @@ def foo
RubyLsp::KEYWORD_DOCS[keyword] || "No documentation found for #{keyword}",
contents,
)
assert_match("[Read more](#{RubyLsp::STATIC_DOCS_PATH}/#{keyword}.md)", contents)

expected_uri = URI::Generic.from_path(path: File.join(RubyLsp::STATIC_DOCS_PATH, "#{keyword}.md"))
assert_match("[Read more](#{expected_uri})", contents)
end
end
end
Expand Down