yard 0.9.16 → 0.9.21
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of yard might be problematic. Click here for more details.
- checksums.yaml +5 -5
- data/.dockerignore +2 -0
- data/.github/ISSUE_TEMPLATE.md +33 -0
- data/.github/PULL_REQUEST_TEMPLATE.md +12 -0
- data/.gitignore +14 -0
- data/.rspec +2 -0
- data/.rubocop.yml +99 -0
- data/.travis.yml +52 -0
- data/.yardopts +0 -0
- data/.yardopts_guide +19 -0
- data/.yardopts_i18n +23 -0
- data/CHANGELOG.md +41 -1
- data/CODE_OF_CONDUCT.md +15 -0
- data/CONTRIBUTING.md +140 -0
- data/Dockerfile.samus +28 -0
- data/Gemfile +32 -0
- data/README.md +3 -1
- data/Rakefile +7 -17
- data/SECURITY.md +26 -0
- data/bin/yard +0 -0
- data/bin/yardoc +0 -0
- data/bin/yri +0 -0
- data/docs/GettingStarted.md +1 -1
- data/lib/yard/autoload.rb +5 -0
- data/lib/yard/cli/i18n.rb +1 -1
- data/lib/yard/cli/stats.rb +1 -1
- data/lib/yard/cli/yardoc.rb +4 -3
- data/lib/yard/code_objects/base.rb +14 -2
- data/lib/yard/code_objects/extra_file_object.rb +7 -4
- data/lib/yard/code_objects/proxy.rb +4 -0
- data/lib/yard/core_ext/module.rb +0 -9
- data/lib/yard/docstring.rb +10 -2
- data/lib/yard/handlers/c/handler_methods.rb +2 -1
- data/lib/yard/handlers/c/method_handler.rb +9 -0
- data/lib/yard/handlers/common/method_handler.rb +19 -0
- data/lib/yard/handlers/ruby/alias_handler.rb +5 -4
- data/lib/yard/handlers/ruby/attribute_handler.rb +1 -1
- data/lib/yard/handlers/ruby/constant_handler.rb +1 -5
- data/lib/yard/handlers/ruby/dsl_handler_methods.rb +6 -5
- data/lib/yard/handlers/ruby/method_handler.rb +3 -17
- data/lib/yard/handlers/ruby/mixin_handler.rb +13 -1
- data/lib/yard/parser/c/statement.rb +2 -0
- data/lib/yard/parser/ruby/ast_node.rb +11 -0
- data/lib/yard/parser/ruby/legacy/irb/slex.rb +276 -0
- data/lib/yard/parser/ruby/legacy/ruby_lex.rb +3 -12
- data/lib/yard/parser/ruby/legacy/statement.rb +2 -0
- data/lib/yard/parser/ruby/ruby_parser.rb +14 -2
- data/lib/yard/parser/source_parser.rb +1 -1
- data/lib/yard/registry_resolver.rb +47 -5
- data/lib/yard/registry_store.rb +6 -1
- data/lib/yard/server/commands/display_file_command.rb +1 -1
- data/lib/yard/server/commands/static_file_helpers.rb +0 -1
- data/lib/yard/templates/helpers/html_helper.rb +25 -4
- data/lib/yard/version.rb +6 -4
- data/po/ja.po +31108 -0
- data/samus.json +80 -0
- data/spec/cli/yardoc_spec.rb +48 -1
- data/spec/code_objects/base_spec.rb +25 -0
- data/spec/code_objects/extra_file_object_spec.rb +4 -3
- data/spec/code_objects/proxy_spec.rb +6 -0
- data/spec/core_ext/module_spec.rb +0 -6
- data/spec/docstring_parser_spec.rb +18 -0
- data/spec/docstring_spec.rb +9 -0
- data/spec/handlers/c/method_handler_spec.rb +2 -0
- data/spec/handlers/constant_handler_spec.rb +1 -1
- data/spec/handlers/dsl_handler_spec.rb +7 -0
- data/spec/handlers/examples/dsl_handler_001.rb.txt +2 -0
- data/spec/handlers/examples/extend_handler_001.rb.txt +4 -1
- data/spec/handlers/examples/mixin_handler_001.rb.txt +3 -0
- data/spec/handlers/extend_handler_spec.rb +4 -0
- data/spec/handlers/method_handler_spec.rb +24 -0
- data/spec/handlers/mixin_handler_spec.rb +4 -0
- data/spec/parser/c_parser_spec.rb +13 -0
- data/spec/parser/examples/file.c.txt +28 -0
- data/spec/registry_store_spec.rb +11 -0
- data/spec/templates/examples/module001.html +3 -3
- data/spec/templates/examples/module002.html +1 -1
- data/spec/templates/examples/module003.html +1 -1
- data/spec/templates/helpers/html_helper_spec.rb +34 -0
- data/spec/templates/helpers/method_helper_spec.rb +2 -2
- data/spec/templates/markup_processor_integrations/asciidoctor_spec.rb +60 -0
- data/spec/templates/markup_processor_integrations/integration_spec_helper.rb +46 -0
- data/spec/templates/markup_processor_integrations/rdoc_markdown_spec.rb +59 -0
- data/spec/templates/markup_processor_integrations/rdoc_spec.rb +39 -0
- data/spec/templates/markup_processor_integrations/redcarpet_spec.rb +59 -0
- data/spec/templates/markup_processor_integrations/redcloth_spec.rb +48 -0
- data/spec/templates/method_spec.rb +2 -2
- data/templates/default/docstring/setup.rb +1 -1
- data/templates/default/fulldoc/html/css/style.css +2 -2
- data/templates/default/fulldoc/html/frames.erb +1 -1
- data/templates/default/fulldoc/html/full_list.erb +1 -1
- data/templates/default/fulldoc/html/js/app.js +25 -3
- data/templates/default/fulldoc/html/js/jquery.js +2 -4
- data/templates/default/layout/html/headers.erb +1 -1
- data/templates/default/layout/html/script_setup.erb +1 -1
- data/templates/default/onefile/html/headers.erb +1 -1
- data/templates/default/onefile/html/setup.rb +1 -1
- data/templates/default/tags/html/tag.erb +1 -1
- data/templates/guide/layout/html/layout.erb +1 -1
- data/yard.gemspec +1 -20
- metadata +29 -22
- data/spec/examples.txt +0 -1874
@@ -7,8 +7,9 @@ module YARD
|
|
7
7
|
include Parser
|
8
8
|
|
9
9
|
IGNORE_METHODS = Hash[*%w(alias alias_method autoload attr attr_accessor
|
10
|
-
attr_reader attr_writer extend include public private
|
11
|
-
private_constant
|
10
|
+
attr_reader attr_writer extend include module_function public private
|
11
|
+
protected private_constant private_class_method public_class_method).
|
12
|
+
map {|n| [n, true] }.flatten]
|
12
13
|
|
13
14
|
def handle_comments
|
14
15
|
return if IGNORE_METHODS[caller_method]
|
@@ -39,9 +40,9 @@ module YARD
|
|
39
40
|
return register_docstring(nil)
|
40
41
|
end
|
41
42
|
|
42
|
-
|
43
|
-
|
44
|
-
|
43
|
+
register MethodObject.new(namespace, method_name, scope) do |o|
|
44
|
+
o.signature = method_signature
|
45
|
+
end
|
45
46
|
end
|
46
47
|
|
47
48
|
def register_docstring(object, docstring = @docstring, stmt = statement)
|
@@ -1,6 +1,8 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
# Handles a method definition
|
3
3
|
class YARD::Handlers::Ruby::MethodHandler < YARD::Handlers::Ruby::Base
|
4
|
+
include YARD::Handlers::Common::MethodHandler
|
5
|
+
|
4
6
|
handles :def, :defs
|
5
7
|
|
6
8
|
process do
|
@@ -19,7 +21,6 @@ class YARD::Handlers::Ruby::MethodHandler < YARD::Handlers::Ruby::Base
|
|
19
21
|
|
20
22
|
nobj = P(namespace, nobj.value) while nobj.type == :constant
|
21
23
|
obj = register MethodObject.new(nobj, meth, mscope) do |o|
|
22
|
-
o.signature = method_signature
|
23
24
|
o.explicit = true
|
24
25
|
o.parameters = args
|
25
26
|
end
|
@@ -39,13 +40,7 @@ class YARD::Handlers::Ruby::MethodHandler < YARD::Handlers::Ruby::Base
|
|
39
40
|
extended method_added method_removed method_undefined).include?(meth)
|
40
41
|
obj.add_tag(YARD::Tags::Tag.new(:private, nil))
|
41
42
|
elsif meth.to_s =~ /\?$/
|
42
|
-
|
43
|
-
obj.tag(:return).types = ['Boolean']
|
44
|
-
elsif obj.tag(:return).nil?
|
45
|
-
unless obj.tags(:overload).any? {|overload| overload.tag(:return) }
|
46
|
-
obj.add_tag(YARD::Tags::Tag.new(:return, "", "Boolean"))
|
47
|
-
end
|
48
|
-
end
|
43
|
+
add_predicate_return_tag(obj)
|
49
44
|
end
|
50
45
|
|
51
46
|
if obj.has_tag?(:option)
|
@@ -106,13 +101,4 @@ class YARD::Handlers::Ruby::MethodHandler < YARD::Handlers::Ruby::Base
|
|
106
101
|
|
107
102
|
params
|
108
103
|
end
|
109
|
-
|
110
|
-
def method_signature
|
111
|
-
method_name = statement.method_name(true)
|
112
|
-
if statement.parameters.any? {|e| e }
|
113
|
-
"def #{method_name}(#{statement.parameters.source})"
|
114
|
-
else
|
115
|
-
"def #{method_name}"
|
116
|
-
end
|
117
|
-
end
|
118
104
|
end
|
@@ -32,6 +32,18 @@ class YARD::Handlers::Ruby::MixinHandler < YARD::Handlers::Ruby::Base
|
|
32
32
|
obj = Proxy.new(namespace, mixin.source, :module)
|
33
33
|
end
|
34
34
|
|
35
|
-
|
35
|
+
rec = recipient(mixin)
|
36
|
+
return if rec.nil? || rec.mixins(scope).include?(obj)
|
37
|
+
rec.mixins(scope).unshift(obj)
|
38
|
+
end
|
39
|
+
|
40
|
+
def recipient(mixin)
|
41
|
+
if statement[0].type == :var_ref && statement[0][0] != s(:kw, "self")
|
42
|
+
statement[0][0].type == :const ?
|
43
|
+
Proxy.new(namespace, statement.namespace.source) :
|
44
|
+
nil
|
45
|
+
else
|
46
|
+
namespace
|
47
|
+
end
|
36
48
|
end
|
37
49
|
end
|
@@ -485,6 +485,17 @@ module YARD
|
|
485
485
|
include_block_param ? params : params[0...-1]
|
486
486
|
end
|
487
487
|
|
488
|
+
def signature
|
489
|
+
params_src = ''
|
490
|
+
params = self[1 + index_adjust]
|
491
|
+
if params.first
|
492
|
+
params_src = params.type == :paren ? '' : ' '
|
493
|
+
params_src += params.source.gsub(/\s+(\s|\))/m, '\1')
|
494
|
+
end
|
495
|
+
|
496
|
+
"def #{method_name(true)}#{params_src}"
|
497
|
+
end
|
498
|
+
|
488
499
|
alias block last
|
489
500
|
|
490
501
|
private
|
@@ -0,0 +1,276 @@
|
|
1
|
+
# frozen_string_literal: false
|
2
|
+
#
|
3
|
+
# irb/slex.rb - simple lex analyzer
|
4
|
+
# $Release Version: 0.9.6$
|
5
|
+
# $Revision$
|
6
|
+
# by Keiju ISHITSUKA(keiju@ruby-lang.org)
|
7
|
+
#
|
8
|
+
# --
|
9
|
+
#
|
10
|
+
#
|
11
|
+
#
|
12
|
+
|
13
|
+
require "irb/notifier"
|
14
|
+
|
15
|
+
# :stopdoc:
|
16
|
+
module IRB
|
17
|
+
class SLex
|
18
|
+
DOUT = Notifier::def_notifier("SLex::")
|
19
|
+
D_WARN = DOUT::def_notifier(1, "Warn: ")
|
20
|
+
D_DEBUG = DOUT::def_notifier(2, "Debug: ")
|
21
|
+
D_DETAIL = DOUT::def_notifier(4, "Detail: ")
|
22
|
+
|
23
|
+
DOUT.level = Notifier::D_NOMSG
|
24
|
+
|
25
|
+
def initialize
|
26
|
+
@head = Node.new("")
|
27
|
+
end
|
28
|
+
|
29
|
+
def def_rule(token, preproc = nil, postproc = nil, &block)
|
30
|
+
D_DETAIL.pp token
|
31
|
+
|
32
|
+
postproc = block if block_given?
|
33
|
+
create(token, preproc, postproc)
|
34
|
+
end
|
35
|
+
|
36
|
+
def def_rules(*tokens, &block)
|
37
|
+
if block_given?
|
38
|
+
p = block
|
39
|
+
end
|
40
|
+
for token in tokens
|
41
|
+
def_rule(token, nil, p)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
def preproc(token, proc)
|
46
|
+
node = search(token)
|
47
|
+
node.preproc=proc
|
48
|
+
end
|
49
|
+
|
50
|
+
# need a check?
|
51
|
+
def postproc(token)
|
52
|
+
node = search(token, proc)
|
53
|
+
node.postproc=proc
|
54
|
+
end
|
55
|
+
|
56
|
+
def search(token)
|
57
|
+
@head.search(token.split(//))
|
58
|
+
end
|
59
|
+
|
60
|
+
def create(token, preproc = nil, postproc = nil)
|
61
|
+
@head.create_subnode(token.split(//), preproc, postproc)
|
62
|
+
end
|
63
|
+
|
64
|
+
def match(token)
|
65
|
+
case token
|
66
|
+
when Array
|
67
|
+
when String
|
68
|
+
return match(token.split(//))
|
69
|
+
else
|
70
|
+
return @head.match_io(token)
|
71
|
+
end
|
72
|
+
ret = @head.match(token)
|
73
|
+
D_DETAIL.exec_if{D_DETAIL.printf "match end: %s:%s\n", ret, token.inspect}
|
74
|
+
ret
|
75
|
+
end
|
76
|
+
|
77
|
+
def inspect
|
78
|
+
format("<SLex: @head = %s>", @head.inspect)
|
79
|
+
end
|
80
|
+
|
81
|
+
#----------------------------------------------------------------------
|
82
|
+
#
|
83
|
+
# class Node -
|
84
|
+
#
|
85
|
+
#----------------------------------------------------------------------
|
86
|
+
class Node
|
87
|
+
# if postproc is nil, this node is an abstract node.
|
88
|
+
# if postproc is non-nil, this node is a real node.
|
89
|
+
def initialize(preproc = nil, postproc = nil)
|
90
|
+
@Tree = {}
|
91
|
+
@preproc = preproc
|
92
|
+
@postproc = postproc
|
93
|
+
end
|
94
|
+
|
95
|
+
attr_accessor :preproc
|
96
|
+
attr_accessor :postproc
|
97
|
+
|
98
|
+
def search(chrs, opt = nil)
|
99
|
+
return self if chrs.empty?
|
100
|
+
ch = chrs.shift
|
101
|
+
if node = @Tree[ch]
|
102
|
+
node.search(chrs, opt)
|
103
|
+
else
|
104
|
+
if opt
|
105
|
+
chrs.unshift ch
|
106
|
+
self.create_subnode(chrs)
|
107
|
+
else
|
108
|
+
raise "node nothing"
|
109
|
+
end
|
110
|
+
end
|
111
|
+
end
|
112
|
+
|
113
|
+
def create_subnode(chrs, preproc = nil, postproc = nil)
|
114
|
+
if chrs.empty?
|
115
|
+
if @postproc
|
116
|
+
D_DETAIL.pp node
|
117
|
+
raise "node already exists"
|
118
|
+
else
|
119
|
+
D_DEBUG.puts "change abstract node to real node."
|
120
|
+
@preproc = preproc
|
121
|
+
@postproc = postproc
|
122
|
+
end
|
123
|
+
return self
|
124
|
+
end
|
125
|
+
|
126
|
+
ch = chrs.shift
|
127
|
+
if node = @Tree[ch]
|
128
|
+
if chrs.empty?
|
129
|
+
if node.postproc
|
130
|
+
DebugLogger.pp node
|
131
|
+
DebugLogger.pp self
|
132
|
+
DebugLogger.pp ch
|
133
|
+
DebugLogger.pp chrs
|
134
|
+
raise "node already exists"
|
135
|
+
else
|
136
|
+
D_WARN.puts "change abstract node to real node"
|
137
|
+
node.preproc = preproc
|
138
|
+
node.postproc = postproc
|
139
|
+
end
|
140
|
+
else
|
141
|
+
node.create_subnode(chrs, preproc, postproc)
|
142
|
+
end
|
143
|
+
else
|
144
|
+
if chrs.empty?
|
145
|
+
node = Node.new(preproc, postproc)
|
146
|
+
else
|
147
|
+
node = Node.new
|
148
|
+
node.create_subnode(chrs, preproc, postproc)
|
149
|
+
end
|
150
|
+
@Tree[ch] = node
|
151
|
+
end
|
152
|
+
node
|
153
|
+
end
|
154
|
+
|
155
|
+
#
|
156
|
+
# chrs: String
|
157
|
+
# character array
|
158
|
+
# io must have getc()/ungetc(); and ungetc() must be
|
159
|
+
# able to be called arbitrary number of times.
|
160
|
+
#
|
161
|
+
def match(chrs, op = "")
|
162
|
+
D_DETAIL.print "match>: ", chrs, "op:", op, "\n"
|
163
|
+
if chrs.empty?
|
164
|
+
if @preproc.nil? || @preproc.call(op, chrs)
|
165
|
+
DOUT.printf(D_DETAIL, "op1: %s\n", op)
|
166
|
+
@postproc.call(op, chrs)
|
167
|
+
else
|
168
|
+
nil
|
169
|
+
end
|
170
|
+
else
|
171
|
+
ch = chrs.shift
|
172
|
+
if node = @Tree[ch]
|
173
|
+
if ret = node.match(chrs, op+ch)
|
174
|
+
return ret
|
175
|
+
else
|
176
|
+
chrs.unshift ch
|
177
|
+
if @postproc and @preproc.nil? || @preproc.call(op, chrs)
|
178
|
+
DOUT.printf(D_DETAIL, "op2: %s\n", op.inspect)
|
179
|
+
ret = @postproc.call(op, chrs)
|
180
|
+
return ret
|
181
|
+
else
|
182
|
+
return nil
|
183
|
+
end
|
184
|
+
end
|
185
|
+
else
|
186
|
+
chrs.unshift ch
|
187
|
+
if @postproc and @preproc.nil? || @preproc.call(op, chrs)
|
188
|
+
DOUT.printf(D_DETAIL, "op3: %s\n", op)
|
189
|
+
@postproc.call(op, chrs)
|
190
|
+
return ""
|
191
|
+
else
|
192
|
+
return nil
|
193
|
+
end
|
194
|
+
end
|
195
|
+
end
|
196
|
+
end
|
197
|
+
|
198
|
+
def match_io(io, op = "")
|
199
|
+
if op == ""
|
200
|
+
ch = io.getc
|
201
|
+
if ch == nil
|
202
|
+
return nil
|
203
|
+
end
|
204
|
+
else
|
205
|
+
ch = io.getc_of_rests
|
206
|
+
end
|
207
|
+
if ch.nil?
|
208
|
+
if @preproc.nil? || @preproc.call(op, io)
|
209
|
+
D_DETAIL.printf("op1: %s\n", op)
|
210
|
+
@postproc.call(op, io)
|
211
|
+
else
|
212
|
+
nil
|
213
|
+
end
|
214
|
+
else
|
215
|
+
if node = @Tree[ch]
|
216
|
+
if ret = node.match_io(io, op+ch)
|
217
|
+
ret
|
218
|
+
else
|
219
|
+
io.ungetc ch
|
220
|
+
if @postproc and @preproc.nil? || @preproc.call(op, io)
|
221
|
+
DOUT.exec_if{D_DETAIL.printf "op2: %s\n", op.inspect}
|
222
|
+
@postproc.call(op, io)
|
223
|
+
else
|
224
|
+
nil
|
225
|
+
end
|
226
|
+
end
|
227
|
+
else
|
228
|
+
io.ungetc ch
|
229
|
+
if @postproc and @preproc.nil? || @preproc.call(op, io)
|
230
|
+
D_DETAIL.printf("op3: %s\n", op)
|
231
|
+
@postproc.call(op, io)
|
232
|
+
else
|
233
|
+
nil
|
234
|
+
end
|
235
|
+
end
|
236
|
+
end
|
237
|
+
end
|
238
|
+
end
|
239
|
+
end
|
240
|
+
end
|
241
|
+
# :startdoc:
|
242
|
+
|
243
|
+
if $0 == __FILE__
|
244
|
+
case $1
|
245
|
+
when "1"
|
246
|
+
tr = SLex.new
|
247
|
+
print "0: ", tr.inspect, "\n"
|
248
|
+
tr.def_rule("=") {print "=\n"}
|
249
|
+
print "1: ", tr.inspect, "\n"
|
250
|
+
tr.def_rule("==") {print "==\n"}
|
251
|
+
print "2: ", tr.inspect, "\n"
|
252
|
+
|
253
|
+
print "case 1:\n"
|
254
|
+
print tr.match("="), "\n"
|
255
|
+
print "case 2:\n"
|
256
|
+
print tr.match("=="), "\n"
|
257
|
+
print "case 3:\n"
|
258
|
+
print tr.match("=>"), "\n"
|
259
|
+
|
260
|
+
when "2"
|
261
|
+
tr = SLex.new
|
262
|
+
print "0: ", tr.inspect, "\n"
|
263
|
+
tr.def_rule("=") {print "=\n"}
|
264
|
+
print "1: ", tr.inspect, "\n"
|
265
|
+
tr.def_rule("==", proc{false}) {print "==\n"}
|
266
|
+
print "2: ", tr.inspect, "\n"
|
267
|
+
|
268
|
+
print "case 1:\n"
|
269
|
+
print tr.match("="), "\n"
|
270
|
+
print "case 2:\n"
|
271
|
+
print tr.match("=="), "\n"
|
272
|
+
print "case 3:\n"
|
273
|
+
print tr.match("=>"), "\n"
|
274
|
+
end
|
275
|
+
exit
|
276
|
+
end
|
@@ -1,5 +1,4 @@
|
|
1
|
-
|
2
|
-
require "irb/slex"
|
1
|
+
require_relative 'irb/slex'
|
3
2
|
|
4
3
|
module YARD
|
5
4
|
module Parser::Ruby::Legacy
|
@@ -129,7 +128,7 @@ module YARD
|
|
129
128
|
when String, Symbol
|
130
129
|
source = token.is_a?(String) ? TkReading2Token : TkSymbol2Token
|
131
130
|
if (tk = source[token]).nil?
|
132
|
-
|
131
|
+
raise "no key #{token}"
|
133
132
|
end
|
134
133
|
tk = Token(tk[0], value)
|
135
134
|
else
|
@@ -285,7 +284,7 @@ module YARD
|
|
285
284
|
|
286
285
|
if reading
|
287
286
|
if TkReading2Token[reading]
|
288
|
-
|
287
|
+
raise "duplicate #{token_n} #{reading}"
|
289
288
|
end
|
290
289
|
if opts.empty?
|
291
290
|
TkReading2Token[reading] = [token_c]
|
@@ -425,14 +424,6 @@ module YARD
|
|
425
424
|
|
426
425
|
# end of nested class BufferedReader
|
427
426
|
|
428
|
-
extend Exception2MessageMapper
|
429
|
-
def_exception(:AlreadyDefinedToken, "Already defined token(%s)")
|
430
|
-
def_exception(:TkReading2TokenNoKey, "key nothing(key='%s')")
|
431
|
-
def_exception(:TkSymbol2TokenNoKey, "key nothing(key='%s')")
|
432
|
-
def_exception(:TkReading2TokenDuplicateError,
|
433
|
-
"key duplicate(token_n='%s', key='%s')")
|
434
|
-
def_exception(:SyntaxError, "%s")
|
435
|
-
|
436
427
|
include RubyToken
|
437
428
|
include IRB
|
438
429
|
|
@@ -333,6 +333,7 @@ module YARD
|
|
333
333
|
undef on_bodystmt
|
334
334
|
undef on_top_const_ref
|
335
335
|
undef on_const_path_ref
|
336
|
+
undef on_dyna_symbol
|
336
337
|
|
337
338
|
def on_program(*args)
|
338
339
|
args.first
|
@@ -410,6 +411,16 @@ module YARD
|
|
410
411
|
visit_ns_token(:rbracket, tok, false)
|
411
412
|
end
|
412
413
|
|
414
|
+
def on_dyna_symbol(sym)
|
415
|
+
rng = if sym.source_range.size == 0 # rubocop:disable Style/ZeroLengthPredicate
|
416
|
+
(sym.source_range.begin - 3)...sym.source_range.end
|
417
|
+
else
|
418
|
+
(sym.source_range.begin - 2)..(sym.source_range.end + 1)
|
419
|
+
end
|
420
|
+
AstNode.new(:dyna_symbol, [sym], :line => lineno..lineno,
|
421
|
+
:listline => lineno..lineno, :listchar => rng, :char => rng)
|
422
|
+
end
|
423
|
+
|
413
424
|
def on_top_const_ref(*args)
|
414
425
|
type = :top_const_ref
|
415
426
|
node = AstNode.node_class_for(type).new(type, args)
|
@@ -481,7 +492,8 @@ module YARD
|
|
481
492
|
end
|
482
493
|
|
483
494
|
def on_string_content(*args)
|
484
|
-
|
495
|
+
chr_rng = args.empty? ? charno...charno : charno..charno
|
496
|
+
AstNode.new(:string_content, args, :listline => lineno..lineno, :listchar => chr_rng)
|
485
497
|
end
|
486
498
|
|
487
499
|
def on_rescue(exc, *args)
|
@@ -600,7 +612,7 @@ module YARD
|
|
600
612
|
|
601
613
|
def insert_comments
|
602
614
|
root.traverse do |node|
|
603
|
-
next if
|
615
|
+
next if %i{comment void_stmt list}.include?(node.type) || node.parent.type != :list
|
604
616
|
|
605
617
|
# never attach comments to if/unless mod nodes
|
606
618
|
if node.type == :if_mod || node.type == :unless_mod
|