yard 0.9.23 → 0.9.27
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 +30 -0
- data/.github/workflows/gem.yml +19 -0
- data/.gitignore +0 -0
- data/.rspec +0 -0
- data/.rubocop.yml +37 -24
- data/.yardopts +0 -0
- data/.yardopts_guide +0 -0
- data/.yardopts_i18n +0 -0
- data/CHANGELOG.md +50 -4
- data/CONTRIBUTING.md +2 -2
- data/Gemfile +5 -3
- data/README.md +97 -102
- data/Rakefile +2 -3
- data/lib/yard/cli/diff.rb +4 -1
- data/lib/yard/cli/server.rb +22 -13
- data/lib/yard/cli/stats.rb +2 -0
- data/lib/yard/cli/yardoc.rb +2 -1
- 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/method_handler.rb +1 -1
- data/lib/yard/handlers/ruby/mixin_handler.rb +7 -2
- data/lib/yard/handlers/ruby/module_function_handler.rb +15 -3
- data/lib/yard/parser/ruby/ast_node.rb +2 -2
- data/lib/yard/parser/ruby/ruby_parser.rb +7 -5
- 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/server/commands/library_command.rb +1 -1
- data/lib/yard/tags/directives.rb +10 -1
- data/lib/yard/templates/helpers/html_helper.rb +15 -5
- data/lib/yard/templates/helpers/markup/rdoc_markup.rb +5 -4
- data/lib/yard/templates/helpers/markup_helper.rb +2 -1
- data/lib/yard/templates/section.rb +1 -3
- data/lib/yard/version.rb +1 -1
- data/lib/yard.rb +3 -0
- data/samus.json +15 -46
- data/tasks/prepare_tag.rake +45 -0
- data/tasks/update_error_map.rake +53 -0
- data/templates/default/fulldoc/html/css/style.css +1 -0
- data/yard.gemspec +3 -2
- metadata +23 -207
- data/.travis.yml +0 -52
- 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/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/Foo.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
@@ -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,11 +35,15 @@ 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)
|
41
|
-
if statement[0].type == :
|
44
|
+
if statement[0].type == :const_path_ref
|
45
|
+
Proxy.new(namespace, statement[0].source)
|
46
|
+
elsif statement[0].type == :var_ref && statement[0][0] != s(:kw, "self")
|
42
47
|
statement[0][0].type == :const ?
|
43
48
|
Proxy.new(namespace, statement.namespace.source) :
|
44
49
|
nil
|
@@ -2,6 +2,8 @@
|
|
2
2
|
# Handles module_function calls to turn methods into public class methods.
|
3
3
|
# Also creates a private instance copy of the method.
|
4
4
|
class YARD::Handlers::Ruby::ModuleFunctionHandler < YARD::Handlers::Ruby::Base
|
5
|
+
include YARD::Handlers::Ruby::DecoratorHandlerMethods
|
6
|
+
|
5
7
|
handles method_call(:module_function)
|
6
8
|
namespace_only
|
7
9
|
|
@@ -13,15 +15,25 @@ class YARD::Handlers::Ruby::ModuleFunctionHandler < YARD::Handlers::Ruby::Base
|
|
13
15
|
when :fcall, :command
|
14
16
|
statement[1].traverse do |node|
|
15
17
|
case node.type
|
18
|
+
when :def
|
19
|
+
process_decorator do |instance_method|
|
20
|
+
make_module_function(instance_method, namespace)
|
21
|
+
end
|
22
|
+
break
|
16
23
|
when :symbol; name = node.first.source
|
17
24
|
when :string_content; name = node.source
|
18
25
|
else next
|
19
26
|
end
|
27
|
+
|
20
28
|
instance_method = MethodObject.new(namespace, name)
|
21
|
-
|
22
|
-
instance_method.copy_to(class_method)
|
23
|
-
class_method.visibility = :public
|
29
|
+
make_module_function(instance_method, namespace)
|
24
30
|
end
|
25
31
|
end
|
26
32
|
end
|
33
|
+
|
34
|
+
def make_module_function(instance_method, namespace)
|
35
|
+
class_method = MethodObject.new(namespace, instance_method.name, :module)
|
36
|
+
instance_method.copy_to(class_method)
|
37
|
+
class_method.visibility = :public
|
38
|
+
end
|
27
39
|
end
|
@@ -480,7 +480,7 @@ module YARD
|
|
480
480
|
end
|
481
481
|
|
482
482
|
def parameters(include_block_param = true)
|
483
|
-
params = self[1 + index_adjust]
|
483
|
+
return unless params = self[1 + index_adjust]
|
484
484
|
params = params[0] if params.type == :paren
|
485
485
|
include_block_param ? params : params[0...-1]
|
486
486
|
end
|
@@ -488,7 +488,7 @@ module YARD
|
|
488
488
|
def signature
|
489
489
|
params_src = ''
|
490
490
|
params = self[1 + index_adjust]
|
491
|
-
if params.first
|
491
|
+
if params and params.first
|
492
492
|
params_src = params.type == :paren ? '' : ' '
|
493
493
|
params_src += params.source.gsub(/\s+(\s|\))/m, '\1')
|
494
494
|
end
|
@@ -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)
|
@@ -371,7 +370,7 @@ module YARD
|
|
371
370
|
|
372
371
|
def on_aref(*args)
|
373
372
|
@map[:lbracket].pop
|
374
|
-
ll, lc = *@map[:aref].
|
373
|
+
ll, lc = *@map[:aref].shift
|
375
374
|
sr = args.first.source_range.first..lc
|
376
375
|
lr = args.first.line_range.first..ll
|
377
376
|
AstNode.new(:aref, args, :char => sr, :line => lr)
|
@@ -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
|
@@ -183,7 +183,7 @@ module YARD
|
|
183
183
|
self.body = "Not found: #{request.path}"
|
184
184
|
headers['Content-Type'] = 'text/plain'
|
185
185
|
headers['X-Cascade'] = 'pass'
|
186
|
-
headers
|
186
|
+
headers['Cache-Control'] = 'nocache'
|
187
187
|
end
|
188
188
|
|
189
189
|
# Sets the headers and status code for a redirection to a given URL
|
@@ -201,7 +201,7 @@ module YARD
|
|
201
201
|
# requests served with "?1234567890" style timestamp query strings.
|
202
202
|
def add_cache_control
|
203
203
|
return if request.query_string.to_i == 0
|
204
|
-
headers['Cache-Control']
|
204
|
+
headers['Cache-Control'] ||= 'public, max-age=300'
|
205
205
|
end
|
206
206
|
end
|
207
207
|
end
|
data/lib/yard/tags/directives.rb
CHANGED
@@ -74,6 +74,13 @@ module YARD
|
|
74
74
|
def after_parse; end
|
75
75
|
|
76
76
|
protected :parser
|
77
|
+
|
78
|
+
protected
|
79
|
+
|
80
|
+
def inside_directive?
|
81
|
+
return true if parser.state.inside_directive
|
82
|
+
parser.directives.any? { |d| d.is_a?(MethodDirective) && d.tag.text.empty? }
|
83
|
+
end
|
77
84
|
end
|
78
85
|
|
79
86
|
# Ends a group listing definition. Group definition automatically end
|
@@ -574,6 +581,8 @@ module YARD
|
|
574
581
|
if %w(class instance module).include?(tag.text)
|
575
582
|
if object.is_a?(CodeObjects::MethodObject)
|
576
583
|
object.scope = tag.text.to_sym
|
584
|
+
elsif handler && !inside_directive?
|
585
|
+
handler.scope = tag.text.to_sym
|
577
586
|
else
|
578
587
|
parser.state.scope = tag.text.to_sym
|
579
588
|
end
|
@@ -604,7 +613,7 @@ module YARD
|
|
604
613
|
if %w(public protected private).include?(tag.text)
|
605
614
|
if object.is_a?(CodeObjects::Base)
|
606
615
|
object.visibility = tag.text.to_sym
|
607
|
-
elsif handler && !
|
616
|
+
elsif handler && !inside_directive?
|
608
617
|
handler.visibility = tag.text.to_sym
|
609
618
|
else
|
610
619
|
parser.state.visibility = tag.text.to_sym
|
@@ -78,12 +78,19 @@ module YARD
|
|
78
78
|
def html_markup_markdown(text)
|
79
79
|
# TODO: other libraries might be more complex
|
80
80
|
provider = markup_class(:markdown)
|
81
|
-
|
81
|
+
case provider.to_s
|
82
|
+
when 'RDiscount'
|
82
83
|
provider.new(text, :autolink).to_html
|
83
|
-
|
84
|
-
provider.new(text, :
|
85
|
-
:fenced_code,
|
86
|
-
:
|
84
|
+
when 'RedcarpetCompat'
|
85
|
+
provider.new(text, :autolink,
|
86
|
+
:fenced_code,
|
87
|
+
:gh_blockcode,
|
88
|
+
:lax_spacing,
|
89
|
+
:tables,
|
90
|
+
:with_toc_data,
|
91
|
+
:no_intraemphasis).to_html
|
92
|
+
when 'CommonMarker'
|
93
|
+
CommonMarker.render_html(text, %i[DEFAULT GITHUB_PRE_LANG], %i[autolink])
|
87
94
|
else
|
88
95
|
provider.new(text).to_html
|
89
96
|
end
|
@@ -316,6 +323,9 @@ module YARD
|
|
316
323
|
link = url_for(obj, anchor, relative)
|
317
324
|
link = link ? link_url(link, title, :title => h("#{obj.title} (#{obj.type})")) : title
|
318
325
|
"<span class='object_link'>" + link + "</span>"
|
326
|
+
rescue Parser::UndocumentableError
|
327
|
+
log.warn "The namespace of link #{obj.inspect} is a constant or invalid."
|
328
|
+
title || obj.to_s
|
319
329
|
end
|
320
330
|
|
321
331
|
# (see BaseHelper#link_url)
|
@@ -34,16 +34,17 @@ module YARD
|
|
34
34
|
class RDocMarkup
|
35
35
|
attr_accessor :from_path
|
36
36
|
|
37
|
+
@@mutex = Mutex.new
|
37
38
|
@@formatter = nil
|
38
39
|
@@markup = nil
|
39
|
-
@@mutex = nil
|
40
40
|
|
41
41
|
def initialize(text)
|
42
42
|
@text = text
|
43
43
|
|
44
|
-
@@
|
45
|
-
|
46
|
-
|
44
|
+
@@mutex.synchronize do
|
45
|
+
@@formatter ||= RDocMarkupToHtml.new
|
46
|
+
@@markup ||= MARKUP.new
|
47
|
+
end
|
47
48
|
end
|
48
49
|
|
49
50
|
def to_html
|
@@ -29,7 +29,8 @@ module YARD
|
|
29
29
|
{:lib => :bluecloth, :const => 'BlueCloth'},
|
30
30
|
{:lib => :maruku, :const => 'Maruku'},
|
31
31
|
{:lib => :'rpeg-markdown', :const => 'PEGMarkdown'},
|
32
|
-
{:lib => :rdoc, :const => 'YARD::Templates::Helpers::Markup::RDocMarkdown'}
|
32
|
+
{:lib => :rdoc, :const => 'YARD::Templates::Helpers::Markup::RDocMarkdown'},
|
33
|
+
{:lib => :commonmarker, :const => 'CommonMarker'}
|
33
34
|
],
|
34
35
|
:textile => [
|
35
36
|
{:lib => :redcloth, :const => 'RedCloth'}
|
data/lib/yard/version.rb
CHANGED
data/lib/yard.rb
CHANGED
@@ -48,6 +48,9 @@ module YARD
|
|
48
48
|
|
49
49
|
# @return [Boolean] whether YARD is being run in Ruby 2.0
|
50
50
|
def self.ruby2?; @ruby2 ||= (RUBY_VERSION >= '2.0.0') end
|
51
|
+
|
52
|
+
# @return [Boolean] whether YARD is being run in Ruby 3.0
|
53
|
+
def self.ruby3?; @ruby3 ||= (RUBY_VERSION >= '3.0.0') end
|
51
54
|
end
|
52
55
|
|
53
56
|
# Keep track of Ruby version for compatibility code
|
data/samus.json
CHANGED
@@ -2,7 +2,9 @@
|
|
2
2
|
"actions": [
|
3
3
|
{
|
4
4
|
"action": "fs-sedfiles",
|
5
|
-
"files": [
|
5
|
+
"files": [
|
6
|
+
"lib/*/version.rb"
|
7
|
+
],
|
6
8
|
"arguments": {
|
7
9
|
"search": "VERSION = ['\"](.+?)['\"]",
|
8
10
|
"replace": "VERSION = '$version'"
|
@@ -10,23 +12,31 @@
|
|
10
12
|
},
|
11
13
|
{
|
12
14
|
"action": "chmod-files",
|
13
|
-
"files": [
|
15
|
+
"files": [
|
16
|
+
"**/*,644",
|
17
|
+
"bin/*,755"
|
18
|
+
]
|
14
19
|
},
|
15
20
|
{
|
16
21
|
"action": "changelog-rotate",
|
17
|
-
"files": [
|
22
|
+
"files": [
|
23
|
+
"CHANGELOG.md"
|
24
|
+
],
|
18
25
|
"arguments": {
|
19
26
|
"title_format": "$version - %B %-d$day_nth, %Y"
|
20
27
|
}
|
21
28
|
},
|
22
29
|
{
|
23
30
|
"action": "git-commit",
|
24
|
-
"files": [
|
31
|
+
"files": [
|
32
|
+
"CHANGELOG.md",
|
33
|
+
"lib/*/version.rb"
|
34
|
+
]
|
25
35
|
},
|
26
36
|
{
|
27
37
|
"action": "git-merge",
|
28
38
|
"arguments": {
|
29
|
-
"branch": "
|
39
|
+
"branch": "main"
|
30
40
|
}
|
31
41
|
},
|
32
42
|
{
|
@@ -34,47 +44,6 @@
|
|
34
44
|
},
|
35
45
|
{
|
36
46
|
"action": "rake-task"
|
37
|
-
},
|
38
|
-
{
|
39
|
-
"action": "archive-git-full",
|
40
|
-
"files": ["git.tgz"],
|
41
|
-
"publish": [
|
42
|
-
{
|
43
|
-
"action": "git-push",
|
44
|
-
"credentials": "lsegal.github.ssh",
|
45
|
-
"arguments": {
|
46
|
-
"remotes": "origin",
|
47
|
-
"refs": "master v$version"
|
48
|
-
}
|
49
|
-
}
|
50
|
-
]
|
51
|
-
},
|
52
|
-
{
|
53
|
-
"action": "gem-build",
|
54
|
-
"files": ["*.gemspec"],
|
55
|
-
"publish": [
|
56
|
-
{
|
57
|
-
"action": "gem-push",
|
58
|
-
"files": ["*.gem"],
|
59
|
-
"credentials": "lsegal.rubygems"
|
60
|
-
}
|
61
|
-
]
|
62
|
-
},
|
63
|
-
{
|
64
|
-
"action": "changelog-parse",
|
65
|
-
"files": ["CHANGELOG.md"],
|
66
|
-
"publish": [
|
67
|
-
{
|
68
|
-
"action": "github-release",
|
69
|
-
"credentials": "lsegal.github",
|
70
|
-
"files": [],
|
71
|
-
"arguments": {
|
72
|
-
"repository": "lsegal/yard",
|
73
|
-
"tag": "v$version",
|
74
|
-
"changelog": "CHANGELOG.md"
|
75
|
-
}
|
76
|
-
}
|
77
|
-
]
|
78
47
|
}
|
79
48
|
]
|
80
49
|
}
|
@@ -0,0 +1,45 @@
|
|
1
|
+
require 'json'
|
2
|
+
require 'tempfile'
|
3
|
+
|
4
|
+
namespace :release do
|
5
|
+
desc 'Updates repository and tags VERSION=X.Y.Z'
|
6
|
+
task :tag do
|
7
|
+
restore_file = Tempfile.new
|
8
|
+
restore_file.close
|
9
|
+
at_exit { restore_file.unlink }
|
10
|
+
|
11
|
+
version = ENV['VERSION']
|
12
|
+
build_path = File.expand_path(File.join(`gem which samus`.strip, '..', '..', 'commands', 'build'))
|
13
|
+
samus_contents = File.read(File.join(__dir__, '..', 'samus.json'))
|
14
|
+
samus_json = JSON.parse(samus_contents.gsub('$version', version))
|
15
|
+
|
16
|
+
samus_json['actions'].each do |action|
|
17
|
+
env = {
|
18
|
+
'_VERSION' => version,
|
19
|
+
'__ORIG_BRANCH' => `git rev-parse --abbrev-ref HEAD`.strip,
|
20
|
+
'__RESTORE_FILE' => restore_file.path,
|
21
|
+
}
|
22
|
+
(action['arguments'] || {}).each {|k, v| env["_#{k.upcase}"] = v }
|
23
|
+
cmd = [File.join(build_path, action['action']), *action['files']]
|
24
|
+
puts "[C] #{action['action']} #{(action['files'] || []).join(' ')}"
|
25
|
+
output = ""
|
26
|
+
IO.popen(env, cmd) {|io| output = io.read }
|
27
|
+
status = $?
|
28
|
+
unless status.success?
|
29
|
+
puts "[F] Last command failed with: #{status.to_i}"
|
30
|
+
puts output
|
31
|
+
exit(status.to_i)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
puts ""
|
36
|
+
puts "Tag v#{version} created. To publish, type the following:"
|
37
|
+
puts ""
|
38
|
+
puts " bundle exec rake release:push VERSION=#{version}"
|
39
|
+
end
|
40
|
+
|
41
|
+
desc 'Pushes the main branch and tag for VERSION=X.Y.Z'
|
42
|
+
task :push do
|
43
|
+
sh "git push main v#{ENV['VERSION']}"
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Script to generate the Error class name map in:
|
4
|
+
# lib/yard/handlers/c/base.rb
|
5
|
+
|
6
|
+
require 'open-uri'
|
7
|
+
require 'stringio'
|
8
|
+
|
9
|
+
desc 'Update the error class names map'
|
10
|
+
task :update_error_map do
|
11
|
+
|
12
|
+
ERROR_C_URL = 'https://raw.githubusercontent.com/ruby/ruby/master/error.c'
|
13
|
+
|
14
|
+
INIT_MATCH = /void\s+Init_Exception\(void\)\s*\{(.+?)^\}/m
|
15
|
+
NAME_MATCH = /(\w+)\s*=\s*rb_define_class\("([^"]+)"/
|
16
|
+
|
17
|
+
$stderr.puts "Downloading #{ERROR_C_URL} ..."
|
18
|
+
content = open(ERROR_C_URL) { |io| io.read }
|
19
|
+
|
20
|
+
$stderr.puts "Extracting class names ..."
|
21
|
+
init_source = content.match(INIT_MATCH).captures.first
|
22
|
+
map = init_source.scan(NAME_MATCH).sort_by { |key, value| key }
|
23
|
+
|
24
|
+
$stderr.puts "Generating new lookup table ..."
|
25
|
+
indent = ' ' * 4
|
26
|
+
source = StringIO.new
|
27
|
+
source.puts "#{indent}ERROR_CLASS_NAMES = {"
|
28
|
+
map.each do |variable, name|
|
29
|
+
source.puts "#{indent} '#{variable}' => '#{name}',"
|
30
|
+
end
|
31
|
+
source.puts "#{indent}}"
|
32
|
+
|
33
|
+
$stderr.puts source.string
|
34
|
+
|
35
|
+
$stderr.puts "Patching 'lib/yard/handlers/c/base.rb' ..."
|
36
|
+
CLASS_NAME_MAP_MATCH = /^\s+ERROR_CLASS_NAMES = {[^}]+}/
|
37
|
+
|
38
|
+
PROJECT_PATH = File.expand_path('..', __dir__)
|
39
|
+
C_BASE_HANDLER = File.join(PROJECT_PATH, 'lib/yard/handlers/c/base.rb')
|
40
|
+
|
41
|
+
File.open(C_BASE_HANDLER, 'r+') { |file|
|
42
|
+
content = file.read
|
43
|
+
# .rstrip is added to avoid adding new empty lines due to the new lines
|
44
|
+
# added by `.puts` when building the string.
|
45
|
+
content.gsub!(CLASS_NAME_MAP_MATCH, source.string.rstrip)
|
46
|
+
file.rewind
|
47
|
+
file.truncate(0)
|
48
|
+
file.write(content)
|
49
|
+
}
|
50
|
+
|
51
|
+
$stderr.puts "Done!"
|
52
|
+
|
53
|
+
end
|
data/yard.gemspec
CHANGED
@@ -11,14 +11,15 @@ Gem::Specification.new do |s|
|
|
11
11
|
custom Ruby constructs such as custom class level definitions.
|
12
12
|
eof
|
13
13
|
s.version = YARD::VERSION
|
14
|
-
s.date = Time.now.strftime('%Y-%m-%d')
|
15
14
|
s.author = "Loren Segal"
|
16
15
|
s.email = "lsegal@soen.ca"
|
17
16
|
s.homepage = "http://yardoc.org"
|
18
17
|
s.platform = Gem::Platform::RUBY
|
19
|
-
s.files = `git ls-files`.strip.split(/\s+/)
|
18
|
+
s.files = `git ls-files`.strip.split(/\s+/).reject {|f| f.match(%r{^spec/}) }
|
20
19
|
s.require_paths = ['lib']
|
21
20
|
s.executables = ['yard', 'yardoc', 'yri']
|
22
21
|
s.license = 'MIT' if s.respond_to?(:license=)
|
23
22
|
s.metadata['yard.run'] = 'yri'
|
23
|
+
|
24
|
+
s.add_runtime_dependency 'webrick', '~> 1.7.0'
|
24
25
|
end
|