yard 0.9.21 → 0.9.26
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 +4 -4
- data/.dockerignore +0 -0
- data/.gitattributes +4 -0
- data/.github/FUNDING.yml +3 -0
- data/.github/ISSUE_TEMPLATE.md +6 -6
- data/.github/PULL_REQUEST_TEMPLATE.md +5 -5
- data/.github/workflows/ci.yml +42 -0
- data/.github/workflows/gem.yml +27 -0
- data/.gitignore +0 -0
- data/.rspec +0 -0
- data/.rubocop.yml +37 -24
- data/.travis.yml +0 -3
- data/.yardopts +0 -0
- data/.yardopts_guide +0 -0
- data/.yardopts_i18n +0 -0
- data/CHANGELOG.md +47 -4
- data/CONTRIBUTING.md +2 -2
- data/Gemfile +4 -3
- data/README.md +97 -102
- data/Rakefile +2 -0
- data/lib/yard/cli/diff.rb +4 -1
- data/lib/yard/cli/server.rb +22 -13
- data/lib/yard/code_objects/method_object.rb +1 -1
- data/lib/yard/code_objects/namespace_mapper.rb +30 -3
- data/lib/yard/code_objects/proxy.rb +2 -1
- data/lib/yard/globals.rb +1 -1
- data/lib/yard/handlers/c/base.rb +35 -0
- data/lib/yard/handlers/ruby/mixin_handler.rb +4 -1
- data/lib/yard/parser/ruby/legacy/irb/slex.rb +1 -1
- data/lib/yard/parser/ruby/ruby_parser.rb +6 -4
- data/lib/yard/parser/ruby/token_resolver.rb +3 -1
- data/lib/yard/parser/source_parser.rb +1 -1
- data/lib/yard/registry_resolver.rb +10 -24
- data/lib/yard/registry_store.rb +1 -1
- data/lib/yard/serializers/yardoc_serializer.rb +1 -1
- data/lib/yard/server/commands/base.rb +2 -2
- data/lib/yard/templates/helpers/html_helper.rb +10 -3
- data/lib/yard/templates/helpers/html_syntax_highlight_helper.rb +1 -1
- data/lib/yard/templates/helpers/markup/rdoc_markup.rb +5 -4
- data/lib/yard/templates/section.rb +1 -3
- data/lib/yard/version.rb +1 -1
- data/samus.json +15 -46
- data/tasks/update_error_map.rake +53 -0
- data/templates/default/fulldoc/html/css/style.css +1 -0
- data/templates/default/fulldoc/html/js/jquery.js +4 -2
- data/yard.gemspec +1 -2
- metadata +9 -206
- data/spec/cli/command_parser_spec.rb +0 -43
- data/spec/cli/command_spec.rb +0 -36
- data/spec/cli/config_spec.rb +0 -148
- data/spec/cli/diff_spec.rb +0 -254
- data/spec/cli/display_spec.rb +0 -30
- data/spec/cli/gems_spec.rb +0 -81
- data/spec/cli/graph_spec.rb +0 -18
- data/spec/cli/help_spec.rb +0 -22
- data/spec/cli/i18n_spec.rb +0 -107
- data/spec/cli/list_spec.rb +0 -8
- data/spec/cli/markup_types_spec.rb +0 -22
- data/spec/cli/server_spec.rb +0 -324
- data/spec/cli/stats_spec.rb +0 -96
- data/spec/cli/yard_on_yard_spec.rb +0 -38
- data/spec/cli/yardoc_spec.rb +0 -896
- data/spec/cli/yri_spec.rb +0 -101
- data/spec/code_objects/base_spec.rb +0 -485
- data/spec/code_objects/class_object_spec.rb +0 -226
- data/spec/code_objects/code_object_list_spec.rb +0 -36
- data/spec/code_objects/constants_spec.rb +0 -116
- data/spec/code_objects/extra_file_object_spec.rb +0 -161
- data/spec/code_objects/macro_object_spec.rb +0 -150
- data/spec/code_objects/method_object_spec.rb +0 -184
- data/spec/code_objects/module_object_spec.rb +0 -142
- data/spec/code_objects/namespace_object_spec.rb +0 -171
- data/spec/code_objects/proxy_spec.rb +0 -147
- data/spec/code_objects/spec_helper.rb +0 -3
- data/spec/config_spec.rb +0 -171
- data/spec/core_ext/array_spec.rb +0 -13
- data/spec/core_ext/file_spec.rb +0 -72
- data/spec/core_ext/hash_spec.rb +0 -14
- data/spec/core_ext/insertion_spec.rb +0 -37
- data/spec/core_ext/module_spec.rb +0 -9
- data/spec/core_ext/string_spec.rb +0 -42
- data/spec/core_ext/symbol_hash_spec.rb +0 -89
- data/spec/docstring_parser_spec.rb +0 -280
- data/spec/docstring_spec.rb +0 -373
- data/spec/handlers/alias_handler_spec.rb +0 -82
- data/spec/handlers/attribute_handler_spec.rb +0 -96
- data/spec/handlers/base_spec.rb +0 -216
- data/spec/handlers/c/alias_handler_spec.rb +0 -34
- data/spec/handlers/c/attribute_handler_spec.rb +0 -41
- data/spec/handlers/c/class_handler_spec.rb +0 -78
- data/spec/handlers/c/constant_handler_spec.rb +0 -71
- data/spec/handlers/c/init_handler_spec.rb +0 -48
- data/spec/handlers/c/method_handler_spec.rb +0 -327
- data/spec/handlers/c/mixin_handler_spec.rb +0 -44
- data/spec/handlers/c/module_handler_spec.rb +0 -71
- data/spec/handlers/c/override_comment_handler_spec.rb +0 -47
- data/spec/handlers/c/path_handler_spec.rb +0 -36
- data/spec/handlers/c/spec_helper.rb +0 -23
- data/spec/handlers/c/struct_handler_spec.rb +0 -16
- data/spec/handlers/class_condition_handler_spec.rb +0 -87
- data/spec/handlers/class_handler_spec.rb +0 -247
- data/spec/handlers/class_method_handler_shared_examples.rb +0 -133
- data/spec/handlers/class_variable_handler_spec.rb +0 -12
- data/spec/handlers/constant_handler_spec.rb +0 -112
- data/spec/handlers/decorator_handler_methods_spec.rb +0 -393
- data/spec/handlers/dsl_handler_spec.rb +0 -226
- data/spec/handlers/examples/alias_handler_001.rb.txt +0 -46
- data/spec/handlers/examples/attribute_handler_001.rb.txt +0 -32
- data/spec/handlers/examples/class_condition_handler_001.rb.txt +0 -69
- data/spec/handlers/examples/class_handler_001.rb.txt +0 -120
- data/spec/handlers/examples/class_variable_handler_001.rb.txt +0 -10
- data/spec/handlers/examples/constant_handler_001.rb.txt +0 -35
- data/spec/handlers/examples/dsl_handler_001.rb.txt +0 -156
- data/spec/handlers/examples/exception_handler_001.rb.txt +0 -59
- data/spec/handlers/examples/extend_handler_001.rb.txt +0 -19
- data/spec/handlers/examples/method_condition_handler_001.rb.txt +0 -10
- data/spec/handlers/examples/method_handler_001.rb.txt +0 -128
- data/spec/handlers/examples/mixin_handler_001.rb.txt +0 -40
- data/spec/handlers/examples/module_handler_001.rb.txt +0 -29
- data/spec/handlers/examples/private_constant_handler_001.rb.txt +0 -8
- data/spec/handlers/examples/process_handler_001.rb.txt +0 -11
- data/spec/handlers/examples/visibility_handler_001.rb.txt +0 -36
- data/spec/handlers/examples/yield_handler_001.rb.txt +0 -54
- data/spec/handlers/exception_handler_spec.rb +0 -49
- data/spec/handlers/extend_handler_spec.rb +0 -28
- data/spec/handlers/legacy_base_spec.rb +0 -128
- data/spec/handlers/method_condition_handler_spec.rb +0 -15
- data/spec/handlers/method_handler_spec.rb +0 -214
- data/spec/handlers/mixin_handler_spec.rb +0 -60
- data/spec/handlers/module_function_handler_spec.rb +0 -106
- data/spec/handlers/module_handler_spec.rb +0 -35
- data/spec/handlers/private_class_method_handler_spec.rb +0 -11
- data/spec/handlers/private_constant_handler_spec.rb +0 -25
- data/spec/handlers/processor_spec.rb +0 -35
- data/spec/handlers/public_class_method_handler_spec.rb +0 -11
- data/spec/handlers/ruby/base_spec.rb +0 -95
- data/spec/handlers/ruby/legacy/base_spec.rb +0 -84
- data/spec/handlers/spec_helper.rb +0 -33
- data/spec/handlers/visibility_handler_spec.rb +0 -44
- data/spec/handlers/yield_handler_spec.rb +0 -52
- data/spec/i18n/locale_spec.rb +0 -81
- data/spec/i18n/message_spec.rb +0 -52
- data/spec/i18n/messages_spec.rb +0 -67
- data/spec/i18n/pot_generator_spec.rb +0 -295
- data/spec/i18n/text_spec.rb +0 -184
- data/spec/logging_spec.rb +0 -44
- data/spec/options_spec.rb +0 -171
- data/spec/parser/base_spec.rb +0 -24
- data/spec/parser/c_parser_spec.rb +0 -236
- data/spec/parser/examples/array.c.txt +0 -6267
- data/spec/parser/examples/example1.rb.txt +0 -8
- data/spec/parser/examples/extrafile.c.txt +0 -8
- data/spec/parser/examples/file.c.txt +0 -28
- data/spec/parser/examples/multifile.c.txt +0 -22
- data/spec/parser/examples/namespace.cpp.txt +0 -68
- data/spec/parser/examples/override.c.txt +0 -424
- data/spec/parser/examples/parse_in_order_001.rb.txt +0 -2
- data/spec/parser/examples/parse_in_order_002.rb.txt +0 -2
- data/spec/parser/examples/tag_handler_001.rb.txt +0 -8
- data/spec/parser/ruby/ast_node_spec.rb +0 -33
- data/spec/parser/ruby/legacy/statement_list_spec.rb +0 -299
- data/spec/parser/ruby/legacy/token_list_spec.rb +0 -79
- data/spec/parser/ruby/ruby_parser_spec.rb +0 -508
- data/spec/parser/ruby/token_resolver_spec.rb +0 -165
- data/spec/parser/source_parser_spec.rb +0 -727
- data/spec/parser/tag_parsing_spec.rb +0 -17
- data/spec/rake/yardoc_task_spec.rb +0 -118
- data/spec/registry_spec.rb +0 -463
- data/spec/registry_store_spec.rb +0 -327
- data/spec/rubygems/doc_manager_spec.rb +0 -112
- data/spec/serializers/data/serialized_yardoc/checksums +0 -1
- data/spec/serializers/data/serialized_yardoc/objects/Foo.dat +0 -0
- data/spec/serializers/data/serialized_yardoc/objects/Foo/bar_i.dat +0 -0
- data/spec/serializers/data/serialized_yardoc/objects/Foo/baz_i.dat +0 -0
- data/spec/serializers/data/serialized_yardoc/objects/root.dat +0 -0
- data/spec/serializers/data/serialized_yardoc/proxy_types +0 -2
- data/spec/serializers/file_system_serializer_spec.rb +0 -145
- data/spec/serializers/spec_helper.rb +0 -2
- data/spec/serializers/yardoc_serializer_spec.rb +0 -78
- data/spec/server/adapter_spec.rb +0 -39
- data/spec/server/commands/base_spec.rb +0 -91
- data/spec/server/commands/library_command_spec.rb +0 -39
- data/spec/server/doc_server_helper_spec.rb +0 -72
- data/spec/server/doc_server_serializer_spec.rb +0 -60
- data/spec/server/rack_adapter_spec.rb +0 -21
- data/spec/server/router_spec.rb +0 -123
- data/spec/server/spec_helper.rb +0 -22
- data/spec/server/static_caching_spec.rb +0 -47
- data/spec/server/webrick_servlet_spec.rb +0 -20
- data/spec/server_spec.rb +0 -19
- data/spec/spec_helper.rb +0 -212
- data/spec/tags/default_factory_spec.rb +0 -168
- data/spec/tags/default_tag_spec.rb +0 -11
- data/spec/tags/directives_spec.rb +0 -463
- data/spec/tags/library_spec.rb +0 -48
- data/spec/tags/overload_tag_spec.rb +0 -53
- data/spec/tags/ref_tag_list_spec.rb +0 -53
- data/spec/tags/types_explainer_spec.rb +0 -203
- data/spec/templates/class_spec.rb +0 -45
- data/spec/templates/constant_spec.rb +0 -41
- data/spec/templates/engine_spec.rb +0 -131
- data/spec/templates/examples/class001.html +0 -308
- data/spec/templates/examples/class001.txt +0 -36
- data/spec/templates/examples/class002.html +0 -39
- data/spec/templates/examples/constant001.txt +0 -25
- data/spec/templates/examples/constant002.txt +0 -7
- data/spec/templates/examples/constant003.txt +0 -11
- data/spec/templates/examples/method001.html +0 -137
- data/spec/templates/examples/method001.txt +0 -35
- data/spec/templates/examples/method002.html +0 -91
- data/spec/templates/examples/method002.txt +0 -20
- data/spec/templates/examples/method003.html +0 -165
- data/spec/templates/examples/method003.txt +0 -45
- data/spec/templates/examples/method004.html +0 -48
- data/spec/templates/examples/method004.txt +0 -10
- data/spec/templates/examples/method005.html +0 -105
- data/spec/templates/examples/method005.txt +0 -33
- data/spec/templates/examples/method006.html +0 -108
- data/spec/templates/examples/method006.txt +0 -20
- data/spec/templates/examples/module001.dot +0 -33
- data/spec/templates/examples/module001.html +0 -833
- data/spec/templates/examples/module001.txt +0 -33
- data/spec/templates/examples/module002.html +0 -341
- data/spec/templates/examples/module003.html +0 -202
- data/spec/templates/examples/module004.html +0 -394
- data/spec/templates/examples/module005.html +0 -82
- data/spec/templates/examples/tag001.txt +0 -82
- data/spec/templates/helpers/base_helper_spec.rb +0 -171
- data/spec/templates/helpers/html_helper_spec.rb +0 -687
- data/spec/templates/helpers/html_syntax_highlight_helper_spec.rb +0 -65
- data/spec/templates/helpers/markup/rdoc_markup_spec.rb +0 -84
- data/spec/templates/helpers/markup_helper_spec.rb +0 -136
- data/spec/templates/helpers/method_helper_spec.rb +0 -107
- data/spec/templates/helpers/module_helper_spec.rb +0 -35
- data/spec/templates/helpers/shared_signature_examples.rb +0 -126
- data/spec/templates/helpers/text_helper_spec.rb +0 -65
- data/spec/templates/markup_processor_integrations/asciidoctor_spec.rb +0 -60
- data/spec/templates/markup_processor_integrations/integration_spec_helper.rb +0 -46
- data/spec/templates/markup_processor_integrations/rdoc_markdown_spec.rb +0 -59
- data/spec/templates/markup_processor_integrations/rdoc_spec.rb +0 -39
- data/spec/templates/markup_processor_integrations/redcarpet_spec.rb +0 -59
- data/spec/templates/markup_processor_integrations/redcloth_spec.rb +0 -48
- data/spec/templates/method_spec.rb +0 -118
- data/spec/templates/module_spec.rb +0 -203
- data/spec/templates/onefile_spec.rb +0 -66
- data/spec/templates/section_spec.rb +0 -144
- data/spec/templates/spec_helper.rb +0 -76
- data/spec/templates/tag_spec.rb +0 -52
- data/spec/templates/template_spec.rb +0 -410
- data/spec/verifier_spec.rb +0 -106
data/Rakefile
CHANGED
data/lib/yard/cli/diff.rb
CHANGED
@@ -161,7 +161,10 @@ module YARD
|
|
161
161
|
url = "http://rubygems.org/downloads/#{gemfile}"
|
162
162
|
log.info "Searching for remote gem file #{url}"
|
163
163
|
begin
|
164
|
-
|
164
|
+
# Note: In Ruby 2.4.x, URI.open is a private method. After
|
165
|
+
# 2.5, URI.open behaves much like Kernel#open once you've
|
166
|
+
# required 'open-uri'
|
167
|
+
OpenURI.open_uri(url) {|io| expand_and_parse(gemfile, io) }
|
165
168
|
return true
|
166
169
|
rescue OpenURI::HTTPError
|
167
170
|
nil # noop
|
data/lib/yard/cli/server.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
+
|
2
3
|
module YARD
|
3
4
|
module CLI
|
4
5
|
# A local documentation server
|
@@ -58,11 +59,13 @@ module YARD
|
|
58
59
|
|
59
60
|
def load_template_paths
|
60
61
|
return if YARD::Config.options[:safe_mode]
|
62
|
+
|
61
63
|
Templates::Engine.template_paths |= template_paths
|
62
64
|
end
|
63
65
|
|
64
66
|
def select_adapter
|
65
67
|
return adapter if adapter
|
68
|
+
|
66
69
|
require 'rubygems'
|
67
70
|
require 'rack'
|
68
71
|
self.adapter = YARD::Server::RackAdapter
|
@@ -129,7 +132,8 @@ module YARD
|
|
129
132
|
require 'rubygems'
|
130
133
|
YARD::GemIndex.each do |spec|
|
131
134
|
libraries[spec.name] ||= []
|
132
|
-
libraries[spec.name] |= [YARD::Server::LibraryVersion.new(spec.name, spec.version.to_s,
|
135
|
+
libraries[spec.name] |= [YARD::Server::LibraryVersion.new(spec.name, spec.version.to_s,
|
136
|
+
nil, :gem)]
|
133
137
|
end
|
134
138
|
end
|
135
139
|
|
@@ -139,7 +143,8 @@ module YARD
|
|
139
143
|
if File.exist?("#{gemfile}.lock")
|
140
144
|
Bundler::LockfileParser.new(File.read("#{gemfile}.lock")).specs.each do |spec|
|
141
145
|
libraries[spec.name] ||= []
|
142
|
-
libraries[spec.name] |= [YARD::Server::LibraryVersion.new(spec.name,
|
146
|
+
libraries[spec.name] |= [YARD::Server::LibraryVersion.new(spec.name,
|
147
|
+
spec.version.to_s, nil, :gem)]
|
143
148
|
end
|
144
149
|
else
|
145
150
|
log.warn "Cannot find #{gemfile}.lock, ignoring --gemfile option"
|
@@ -171,7 +176,8 @@ module YARD
|
|
171
176
|
opts.on('-g', '--gems', 'Serves documentation for installed gems') do
|
172
177
|
add_gems
|
173
178
|
end
|
174
|
-
opts.on('-G', '--gemfile [GEMFILE]',
|
179
|
+
opts.on('-G', '--gemfile [GEMFILE]',
|
180
|
+
'Serves documentation for gems from Gemfile') do |gemfile|
|
175
181
|
add_gems_from_gemfile(gemfile)
|
176
182
|
end
|
177
183
|
opts.on('-t', '--template-path PATH',
|
@@ -192,23 +198,26 @@ module YARD
|
|
192
198
|
opts.on('--docroot DOCROOT', 'Uses DOCROOT as document root') do |docroot|
|
193
199
|
server_options[:DocumentRoot] = File.expand_path(docroot)
|
194
200
|
end
|
195
|
-
opts.on('-a', '--adapter ADAPTER',
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
201
|
+
opts.on('-a', '--adapter ADAPTER',
|
202
|
+
'Use the ADAPTER (full Ruby class) for web server') do |adapter|
|
203
|
+
self.adapter = if adapter.casecmp('webrick') == 0
|
204
|
+
YARD::Server::WebrickAdapter
|
205
|
+
elsif adapter.casecmp('rack') == 0
|
206
|
+
YARD::Server::RackAdapter
|
207
|
+
else
|
208
|
+
eval(adapter) # rubocop:disable Security/Eval
|
209
|
+
end
|
203
210
|
end
|
204
|
-
opts.on('-s', '--server TYPE',
|
211
|
+
opts.on('-s', '--server TYPE',
|
212
|
+
'Use a specific server type eg. thin,mongrel,cgi (Rack specific)') do |type|
|
205
213
|
server_options[:server] = type
|
206
214
|
end
|
207
215
|
opts.on('--fork', 'Use process forking when serving requests') do
|
208
216
|
options[:use_fork] = true
|
209
217
|
end
|
210
218
|
common_options(opts)
|
211
|
-
opts.on('-e', '--load FILE',
|
219
|
+
opts.on('-e', '--load FILE',
|
220
|
+
'A Ruby script to load before the source tree is parsed.') do |file|
|
212
221
|
scripts << file
|
213
222
|
end
|
214
223
|
parse_options(opts, args)
|
@@ -145,7 +145,7 @@ module YARD::CodeObjects
|
|
145
145
|
end
|
146
146
|
|
147
147
|
# Returns all alias names of the object
|
148
|
-
# @return [Array<
|
148
|
+
# @return [Array<MethodObject>] the alias names
|
149
149
|
def aliases
|
150
150
|
list = []
|
151
151
|
return list unless namespace.is_a?(NamespaceObject)
|
@@ -11,6 +11,9 @@ module YARD
|
|
11
11
|
# Registers a separator with an optional set of valid types that
|
12
12
|
# must follow the separator lexically.
|
13
13
|
#
|
14
|
+
# Calls all callbacks defined by {NamespaceMapper.on_invalidate} after
|
15
|
+
# the separator is registered.
|
16
|
+
#
|
14
17
|
# @param sep [String] the separator string for the namespace
|
15
18
|
# @param valid_types [Array<Symbol>] a list of object types that
|
16
19
|
# must follow the separator. If the list is empty, any type can
|
@@ -20,6 +23,7 @@ module YARD
|
|
20
23
|
# register_separator "#", :method
|
21
24
|
# # Anything after a "." denotes a method object
|
22
25
|
# register_separator ".", :method
|
26
|
+
# @see .on_invalidate
|
23
27
|
def register_separator(sep, *valid_types)
|
24
28
|
NamespaceMapper.invalidate
|
25
29
|
|
@@ -32,6 +36,19 @@ module YARD
|
|
32
36
|
NamespaceMapper.map[sep] += valid_types
|
33
37
|
end
|
34
38
|
|
39
|
+
# Unregisters a separator by a type.
|
40
|
+
#
|
41
|
+
# @param type [Symbol] the type to unregister
|
42
|
+
# @see #register_separator
|
43
|
+
def unregister_separator_by_type(type)
|
44
|
+
seps = NamespaceMapper.rev_map[type]
|
45
|
+
return unless seps
|
46
|
+
|
47
|
+
seps.each {|s| NamespaceMapper.map.delete(s) }
|
48
|
+
NamespaceMapper.rev_map.delete(type)
|
49
|
+
NamespaceMapper.invalidate
|
50
|
+
end
|
51
|
+
|
35
52
|
# Clears the map of separators.
|
36
53
|
#
|
37
54
|
# @return [void]
|
@@ -50,6 +67,7 @@ module YARD
|
|
50
67
|
# default_separator "::"
|
51
68
|
def default_separator(value = nil)
|
52
69
|
if value
|
70
|
+
NamespaceMapper.invalidate
|
53
71
|
NamespaceMapper.default_separator = Regexp.quote value
|
54
72
|
else
|
55
73
|
NamespaceMapper.default_separator
|
@@ -71,17 +89,25 @@ module YARD
|
|
71
89
|
# @param sep [String] the separator to return types for
|
72
90
|
# @return [Array<Symbol>] a list of types registered to a separator
|
73
91
|
def types_for_separator(sep)
|
74
|
-
NamespaceMapper.map[sep]
|
92
|
+
NamespaceMapper.map[sep] || []
|
75
93
|
end
|
76
94
|
|
77
95
|
# @param type [String] the type to return separators for
|
78
96
|
# @return [Array<Symbol>] a list of separators registered to a type
|
79
97
|
def separators_for_type(type)
|
80
|
-
NamespaceMapper.rev_map[type]
|
98
|
+
NamespaceMapper.rev_map[type] || []
|
81
99
|
end
|
82
100
|
|
83
101
|
# Internal methods to act as a singleton registry
|
84
102
|
class << self
|
103
|
+
# @!group Invalidation callbacks
|
104
|
+
|
105
|
+
# Adds a callback that triggers when a new separator is registered or
|
106
|
+
# the cache is cleared by invalidation.
|
107
|
+
def on_invalidate(&block)
|
108
|
+
(@invalidation_callbacks ||= []).push(block)
|
109
|
+
end
|
110
|
+
|
85
111
|
# @!visibility private
|
86
112
|
|
87
113
|
# @return [Hash] a mapping of types to separators
|
@@ -98,11 +124,12 @@ module YARD
|
|
98
124
|
# @return [void]
|
99
125
|
def invalidate
|
100
126
|
@map_match = nil
|
127
|
+
(@invalidation_callbacks || []).each(&:call)
|
101
128
|
end
|
102
129
|
|
103
130
|
# @return [Regexp] the full list of separators as a regexp match
|
104
131
|
def map_match
|
105
|
-
@map_match ||=
|
132
|
+
@map_match ||= map.keys.map {|k| Regexp.quote k }.join('|')
|
106
133
|
end
|
107
134
|
|
108
135
|
# @return [String] the default separator when no separator can begin
|
@@ -59,7 +59,8 @@ module YARD
|
|
59
59
|
|
60
60
|
if @namespace.is_a?(ConstantObject)
|
61
61
|
unless @namespace.value =~ /\A#{NAMESPACEMATCH}\Z/
|
62
|
-
raise Parser::UndocumentableError, "constant mapping"
|
62
|
+
raise Parser::UndocumentableError, "constant mapping for " +
|
63
|
+
"#{@origname} (type=#{type.inspect})"
|
63
64
|
end
|
64
65
|
|
65
66
|
@origname = nil # forget these for a constant
|
data/lib/yard/globals.rb
CHANGED
@@ -5,7 +5,7 @@
|
|
5
5
|
#
|
6
6
|
# @see YARD::CodeObjects::Proxy
|
7
7
|
# @see YARD::Registry.resolve
|
8
|
-
def P(namespace, name = nil, type = nil) # rubocop:disable
|
8
|
+
def P(namespace, name = nil, type = nil) # rubocop:disable Naming/MethodName
|
9
9
|
if name.nil?
|
10
10
|
name = namespace
|
11
11
|
namespace = nil
|
data/lib/yard/handlers/c/base.rb
CHANGED
@@ -63,6 +63,13 @@ module YARD
|
|
63
63
|
|
64
64
|
def namespace_for_variable(var)
|
65
65
|
return namespaces[var] if namespaces[var]
|
66
|
+
|
67
|
+
# The global variables for Ruby's core error classes does not
|
68
|
+
# represent their Ruby name. So we need to look up these names.
|
69
|
+
name = ERROR_CLASS_NAMES[var]
|
70
|
+
return P(name) if name
|
71
|
+
|
72
|
+
# Otherwise the name is inferred from the C variable name.
|
66
73
|
var = remove_var_prefix(var)
|
67
74
|
var.empty? ? nil : P(var)
|
68
75
|
end
|
@@ -120,6 +127,34 @@ module YARD
|
|
120
127
|
|
121
128
|
private
|
122
129
|
|
130
|
+
# Generated by update_error_map.rb (Copy+past results)
|
131
|
+
ERROR_CLASS_NAMES = {
|
132
|
+
'rb_eArgError' => 'ArgumentError',
|
133
|
+
'rb_eEncodingError' => 'EncodingError',
|
134
|
+
'rb_eException' => 'Exception',
|
135
|
+
'rb_eFatal' => 'fatal',
|
136
|
+
'rb_eFrozenError' => 'FrozenError',
|
137
|
+
'rb_eIndexError' => 'IndexError',
|
138
|
+
'rb_eInterrupt' => 'Interrupt',
|
139
|
+
'rb_eKeyError' => 'KeyError',
|
140
|
+
'rb_eLoadError' => 'LoadError',
|
141
|
+
'rb_eNameError' => 'NameError',
|
142
|
+
'rb_eNoMatchingPatternError' => 'NoMatchingPatternError',
|
143
|
+
'rb_eNoMemError' => 'NoMemoryError',
|
144
|
+
'rb_eNoMethodError' => 'NoMethodError',
|
145
|
+
'rb_eNotImpError' => 'NotImplementedError',
|
146
|
+
'rb_eRangeError' => 'RangeError',
|
147
|
+
'rb_eRuntimeError' => 'RuntimeError',
|
148
|
+
'rb_eScriptError' => 'ScriptError',
|
149
|
+
'rb_eSecurityError' => 'SecurityError',
|
150
|
+
'rb_eSignal' => 'SignalException',
|
151
|
+
'rb_eStandardError' => 'StandardError',
|
152
|
+
'rb_eSyntaxError' => 'SyntaxError',
|
153
|
+
'rb_eSystemCallError' => 'SystemCallError',
|
154
|
+
'rb_eSystemExit' => 'SystemExit',
|
155
|
+
'rb_eTypeError' => 'TypeError',
|
156
|
+
}
|
157
|
+
|
123
158
|
def remove_var_prefix(var)
|
124
159
|
var.gsub(/^rb_[mc]|^[a-z_]+/, '')
|
125
160
|
end
|
@@ -2,6 +2,7 @@
|
|
2
2
|
# Handles the 'include' statement to mixin a module in the instance scope
|
3
3
|
class YARD::Handlers::Ruby::MixinHandler < YARD::Handlers::Ruby::Base
|
4
4
|
handles method_call(:include)
|
5
|
+
handles method_call(:prepend)
|
5
6
|
namespace_only
|
6
7
|
|
7
8
|
process do
|
@@ -34,7 +35,9 @@ class YARD::Handlers::Ruby::MixinHandler < YARD::Handlers::Ruby::Base
|
|
34
35
|
|
35
36
|
rec = recipient(mixin)
|
36
37
|
return if rec.nil? || rec.mixins(scope).include?(obj)
|
37
|
-
|
38
|
+
|
39
|
+
shift = statement.method_name(true) == :include ? :unshift : :push
|
40
|
+
rec.mixins(scope).send(shift, obj)
|
38
41
|
end
|
39
42
|
|
40
43
|
def recipient(mixin)
|
@@ -202,8 +202,7 @@ module YARD
|
|
202
202
|
begin; undef on_#{event}; rescue NameError; end
|
203
203
|
def on_#{event}(tok)
|
204
204
|
unless @last_ns_token == [:kw, "def"] ||
|
205
|
-
(@tokens.last && @tokens.last[0] == :symbeg)
|
206
|
-
(!@newline && %w(if while until unless).include?(tok))
|
205
|
+
(@tokens.last && @tokens.last[0] == :symbeg)
|
207
206
|
(@map[tok] ||= []) << [lineno, charno]
|
208
207
|
end
|
209
208
|
visit_ns_token(:#{event}, tok, true)
|
@@ -412,7 +411,7 @@ module YARD
|
|
412
411
|
end
|
413
412
|
|
414
413
|
def on_dyna_symbol(sym)
|
415
|
-
rng = if sym.source_range.size == 0 # rubocop:disable Style/ZeroLengthPredicate
|
414
|
+
rng = if sym.source_range.to_a.size == 0 # rubocop:disable Style/ZeroLengthPredicate
|
416
415
|
(sym.source_range.begin - 3)...sym.source_range.end
|
417
416
|
else
|
418
417
|
(sym.source_range.begin - 2)..(sym.source_range.end + 1)
|
@@ -442,6 +441,8 @@ module YARD
|
|
442
441
|
module_eval(<<-eof, __FILE__, __LINE__ + 1)
|
443
442
|
begin; undef on_#{kw}; rescue NameError; end
|
444
443
|
def on_#{kw}(*args)
|
444
|
+
mapping = @map[#{kw.to_s.sub(/_mod$/, '').inspect}]
|
445
|
+
mapping.pop if mapping
|
445
446
|
sr = args.last.source_range.first..args.first.source_range.last
|
446
447
|
lr = args.last.line_range.first..args.first.line_range.last
|
447
448
|
#{node_class}.new(:#{kw}, args, :line => lr, :char => sr)
|
@@ -612,7 +613,7 @@ module YARD
|
|
612
613
|
|
613
614
|
def insert_comments
|
614
615
|
root.traverse do |node|
|
615
|
-
next if
|
616
|
+
next if [:comment, :void_stmt, :list].include?(node.type) || node.parent.type != :list
|
616
617
|
|
617
618
|
# never attach comments to if/unless mod nodes
|
618
619
|
if node.type == :if_mod || node.type == :unless_mod
|
@@ -684,6 +685,7 @@ module YARD
|
|
684
685
|
end
|
685
686
|
|
686
687
|
def freeze_tree(node = nil)
|
688
|
+
@tokens = @tokens.sort_by {|t| t.last }
|
687
689
|
nodes = [node || root]
|
688
690
|
until nodes.empty?
|
689
691
|
p_node = nodes.shift
|
@@ -7,6 +7,7 @@ module YARD
|
|
7
7
|
# constant or identifier token.
|
8
8
|
class TokenResolver
|
9
9
|
include Enumerable
|
10
|
+
include CodeObjects::NamespaceMapper
|
10
11
|
|
11
12
|
# Creates a token resolver for given source.
|
12
13
|
#
|
@@ -114,7 +115,8 @@ module YARD
|
|
114
115
|
|
115
116
|
if toktype == :const
|
116
117
|
types.any? do |type|
|
117
|
-
prefix =
|
118
|
+
prefix = type ? type.path : ""
|
119
|
+
prefix += last_sep.to_s if separators.include?(last_sep.to_s)
|
118
120
|
self.object = Registry.resolve(@default_namespace, "#{prefix}#{name}", true)
|
119
121
|
end
|
120
122
|
else # ident
|
@@ -64,7 +64,7 @@ module YARD
|
|
64
64
|
class SourceParser
|
65
65
|
SHEBANG_LINE = /\A\s*#!\S+/
|
66
66
|
ENCODING_LINE = %r{\A(?:\s*#*!.*\r?\n)?\s*(?:#+|/\*+|//+).*coding\s*[:=]{1,2}\s*([a-z\d_\-]+)}i
|
67
|
-
FROZEN_STRING_LINE = /frozen(-|_)string(-|_)literal
|
67
|
+
FROZEN_STRING_LINE = /frozen(-|_)string(-|_)literal:\s+(true|false)/i
|
68
68
|
|
69
69
|
# The default glob of files to be parsed.
|
70
70
|
# @since 0.9.0
|
@@ -16,6 +16,9 @@ module YARD
|
|
16
16
|
def initialize(registry = Registry)
|
17
17
|
@registry = registry
|
18
18
|
@default_sep = nil
|
19
|
+
|
20
|
+
# Preload all code objects for separator declarations
|
21
|
+
YARD::CodeObjects.constants.map {|t| YARD::CodeObjects.const_get(t) }
|
19
22
|
end
|
20
23
|
|
21
24
|
# Performs a lookup on a given path in the registry. Resolution will occur
|
@@ -186,46 +189,29 @@ module YARD
|
|
186
189
|
nss
|
187
190
|
end
|
188
191
|
|
189
|
-
# @see NamespaceMapper#register_separator
|
190
|
-
def register_separator(*)
|
191
|
-
super
|
192
|
-
invalidate_memoized_matchers
|
193
|
-
end
|
194
|
-
|
195
|
-
# @see NamespaceMapper#clear_separators
|
196
|
-
def clear_separators
|
197
|
-
super
|
198
|
-
invalidate_memoized_matchers
|
199
|
-
end
|
200
|
-
|
201
|
-
# @see NamespaceMapper#default_separator
|
202
|
-
def default_separator(value = nil)
|
203
|
-
@starts_with_default_separator_match = nil if value
|
204
|
-
super
|
205
|
-
end
|
206
|
-
|
207
192
|
# @return [Regexp] the regexp match of the default separator
|
208
193
|
def starts_with_default_separator_match
|
209
|
-
|
194
|
+
@@starts_with_default_separator_match ||= /\A#{default_separator}/
|
210
195
|
end
|
211
196
|
|
212
197
|
# @return [Regexp] the regexp that matches strings starting with
|
213
198
|
# a separator
|
214
199
|
def starts_with_separator_match
|
215
|
-
|
200
|
+
@@starts_with_separator_match ||= /\A(#{separators_match})/
|
216
201
|
end
|
217
202
|
|
218
203
|
# @return [Regexp] the regexp that can be used to split a string on all
|
219
204
|
# occurrences of separator tokens
|
220
205
|
def split_on_separators_match
|
221
|
-
|
206
|
+
@@split_on_separators_match ||= /(.+?)(#{separators_match}|$)/
|
222
207
|
end
|
223
208
|
|
224
209
|
# Additional invalidations to done when NamespaceMapper API methods are
|
225
210
|
# called on this class
|
226
|
-
|
227
|
-
|
228
|
-
|
211
|
+
YARD::CodeObjects::NamespaceMapper.on_invalidate do
|
212
|
+
@@starts_with_default_separator_match = nil
|
213
|
+
@@starts_with_separator_match = nil
|
214
|
+
@@split_on_separators_match = nil
|
229
215
|
end
|
230
216
|
end
|
231
217
|
end
|
data/lib/yard/registry_store.rb
CHANGED
@@ -291,7 +291,7 @@ module YARD
|
|
291
291
|
def load_checksums
|
292
292
|
return unless File.file?(checksums_path)
|
293
293
|
lines = File.readlines(checksums_path).map do |line|
|
294
|
-
line.strip.
|
294
|
+
line.strip.rpartition(' ').tap { |p| p.delete_at(1) }
|
295
295
|
end
|
296
296
|
@checksums = Hash[lines]
|
297
297
|
end
|