ruby-lsp-doclinks 0.1.2 → 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +6 -0
- data/README.md +2 -0
- data/lib/ruby_lsp/doclinks/addon.rb +6 -14
- data/lib/ruby_lsp/doclinks/version.rb +1 -1
- data/sorbet/rbi/todo.rbi +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6cb2415735db78487975413f1f294cd3a85c8fcc43475b37f233c3a58576a408
|
4
|
+
data.tar.gz: ac50c6f6bd6c1b6ee9ca39ff61cfe3277b4569e26fa952ca0b0de74a7911fd8e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bbeb3f968b46875007ef2e8feaf9a95384c310ae79b6b7cc608e8407ab3661ece83f338502cbe9753037569ac29fb5a5b851b1f56839478c95375900a73d18d7
|
7
|
+
data.tar.gz: c7f1e318db94512e7c86e133fa0fee91ac59070901010a2453a517545e1164b6b3f73b587f1f8459144bb6186df3a7223eab64f049b9e961e19d3eb2001a006a
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -45,6 +45,8 @@ If you'd like to use a yard server or something custom, you can customize the do
|
|
45
45
|
|
46
46
|
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
47
47
|
|
48
|
+
Note: The `Gemfile.lock` is included in version control for development purposes only. It helps ensure consistent development dependencies across different environments. This file is not part of the gem package and is not updated during gem releases.
|
49
|
+
|
48
50
|
You can point your project to a path based version of the gem with an entry in your Gemfile like:
|
49
51
|
```
|
50
52
|
gem "ruby-lsp-doclinks", path: "~/myprojects/ruby-lsp-doclinks"
|
@@ -1,4 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
+
# typed: true
|
3
|
+
|
2
4
|
|
3
5
|
require "ruby_lsp/addon"
|
4
6
|
require "ruby_lsp/requests/support/common"
|
@@ -37,7 +39,7 @@ module RubyLsp
|
|
37
39
|
end
|
38
40
|
|
39
41
|
def version
|
40
|
-
|
42
|
+
RubyLsp::Doclinks::VERSION
|
41
43
|
end
|
42
44
|
|
43
45
|
def create_hover_listener(response_builder, node_context, dispatcher)
|
@@ -60,44 +62,36 @@ module RubyLsp
|
|
60
62
|
end
|
61
63
|
|
62
64
|
def on_constant_read_node_enter(node)
|
63
|
-
# $stderr.puts "#{name} addon handling on_constant_read_node_enter: #{node.inspect} slice=#{node&.slice&.inspect}"
|
64
65
|
constant = node.slice
|
65
66
|
handle_constant(constant)
|
66
67
|
end
|
67
68
|
|
68
69
|
def on_constant_path_node_enter(node)
|
69
|
-
# $stderr.puts "#{name} addon handling on_constant_path_node_enter: #{node.inspect} slice=#{node&.slice&.inspect}"
|
70
70
|
# Handle nested constants like Foo::Bar
|
71
71
|
constant = node.slice
|
72
72
|
handle_constant(constant)
|
73
73
|
end
|
74
74
|
|
75
75
|
def on_call_node_enter(node)
|
76
|
-
# $stderr.puts "#{name} addon handling on_call_node_enter: #{node.name} receiver_slice=#{node&.receiver&.slice&.inspect}"
|
77
76
|
# Handle method calls
|
78
77
|
constant = node.receiver&.slice
|
79
78
|
method = node.name
|
80
|
-
# $stderr.puts "#{name} addon constant=#{constant} method=#{method} node=#{node.inspect}"
|
81
79
|
handle_constant(constant, method)
|
82
80
|
end
|
83
81
|
|
84
82
|
private
|
85
83
|
|
86
84
|
def handle_constant(constant, method_name = nil)
|
87
|
-
# $stderr.puts "#{name} addon handling: #{constant}#{method_name ? "##{method_name}" : ""}"
|
88
85
|
return unless constant && !constant.empty?
|
89
86
|
|
90
87
|
# Check if the word is a gem constant
|
91
88
|
gem_info = find_gem_for_constant(constant)
|
92
|
-
# $stderr.puts "#{name} addon gem_info: #{gem_info.inspect}"
|
93
89
|
return unless gem_info
|
94
90
|
|
95
91
|
# Generate documentation link based on configuration
|
96
92
|
doc_link = generate_doc_link(gem_info, constant, method_name)
|
97
|
-
# $stderr.puts "#{name} addon doc_link: #{doc_link}"
|
98
93
|
return unless doc_link
|
99
94
|
|
100
|
-
# $stderr.puts "#{name} addon adding hover response"
|
101
95
|
display_name = method_name ? "#{constant}##{method_name}" : constant
|
102
96
|
content = "\n[View documentation for #{display_name}](#{doc_link})"
|
103
97
|
@response_builder.push(content, category: :documentation)
|
@@ -121,16 +115,14 @@ module RubyLsp
|
|
121
115
|
next if path.nil? || path.empty?
|
122
116
|
|
123
117
|
Dir.glob("#{path}/**/*.rb").any? do |file|
|
124
|
-
next if file.nil?
|
125
|
-
|
126
118
|
begin
|
127
119
|
content = File.read(file)
|
128
|
-
next if content.
|
120
|
+
next if content.empty?
|
129
121
|
|
130
122
|
# Look for class/module definitions with the exact constant name
|
131
123
|
content.match?(/\b(?:class|module)\s+#{Regexp.escape(constant_name)}\b/)
|
132
124
|
rescue => e
|
133
|
-
$stderr.puts "
|
125
|
+
# $stderr.puts "Doclinks error reading file #{file}: #{e.message}"
|
134
126
|
false
|
135
127
|
end
|
136
128
|
end
|
@@ -157,7 +149,7 @@ module RubyLsp
|
|
157
149
|
constant: constant.gsub("::", "/"),
|
158
150
|
method: "#{method_name}#{method_type}"
|
159
151
|
}
|
160
|
-
$stderr.puts "
|
152
|
+
# $stderr.puts "Doclinks addon doc_url for source=#{source}: #{doc_url}"
|
161
153
|
|
162
154
|
doc_url
|
163
155
|
end
|
data/sorbet/rbi/todo.rbi
CHANGED
@@ -11,5 +11,5 @@ module ActiveSupport::Multibyte::Chars; end
|
|
11
11
|
module ActiveSupport::SafeBuffer; end
|
12
12
|
module ActiveSupport::StringInquirer; end
|
13
13
|
module ActiveSupport::TimeZone; end
|
14
|
-
|
14
|
+
class RubyLsp::Addon; end
|
15
15
|
module RubyLsp::Doclinks::Hover::Requests::Support::Common; end
|