yard 0.7.5 → 0.8.0
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.
- data/.yardopts +10 -2
- data/ChangeLog +1263 -38
- data/LEGAL +5 -5
- data/LICENSE +1 -1
- data/README.md +91 -82
- data/Rakefile +6 -6
- data/benchmarks/builtins_vs_eval.rb +1 -1
- data/benchmarks/erb_vs_erubis.rb +4 -4
- data/benchmarks/generation.rb +5 -5
- data/benchmarks/parsing.rb +2 -2
- data/benchmarks/registry_store_types.rb +48 -0
- data/bin/yard +9 -1
- data/bin/yardoc +9 -1
- data/bin/yri +10 -2
- data/docs/CodeObjects.md +10 -10
- data/docs/GettingStarted.md +85 -83
- data/docs/Handlers.md +21 -21
- data/docs/Overview.md +7 -7
- data/docs/Parser.md +30 -30
- data/docs/Tags.md +250 -554
- data/docs/TagsArch.md +123 -0
- data/docs/Templates.md +58 -80
- data/docs/WhatsNew.md +378 -133
- data/docs/templates/default/fulldoc/html/full_list_tag.erb +7 -0
- data/docs/templates/default/fulldoc/html/setup.rb +6 -0
- data/docs/templates/default/layout/html/setup.rb +8 -0
- data/docs/templates/default/layout/html/tag_list.erb +11 -0
- data/docs/templates/default/yard_tags/html/list.erb +18 -0
- data/docs/templates/default/yard_tags/html/setup.rb +27 -0
- data/docs/templates/plugin.rb +65 -0
- data/lib/yard.rb +1 -10
- data/lib/yard/autoload.rb +75 -27
- data/lib/yard/cli/command.rb +5 -2
- data/lib/yard/cli/command_parser.rb +3 -2
- data/lib/yard/cli/diff.rb +1 -1
- data/lib/yard/cli/i18n.rb +69 -0
- data/lib/yard/cli/list.rb +1 -1
- data/lib/yard/cli/server.rb +30 -7
- data/lib/yard/cli/stats.rb +5 -6
- data/lib/yard/cli/yardoc.rb +95 -45
- data/lib/yard/cli/yri.rb +24 -3
- data/lib/yard/code_objects/base.rb +35 -4
- data/lib/yard/code_objects/extra_file_object.rb +1 -1
- data/lib/yard/code_objects/macro_object.rb +56 -99
- data/lib/yard/code_objects/method_object.rb +44 -6
- data/lib/yard/config.rb +18 -8
- data/lib/yard/core_ext/symbol_hash.rb +1 -1
- data/lib/yard/docstring.rb +45 -85
- data/lib/yard/docstring_parser.rb +269 -0
- data/lib/yard/handlers/base.rb +129 -118
- data/lib/yard/handlers/c/alias_handler.rb +15 -0
- data/lib/yard/handlers/c/attribute_handler.rb +13 -0
- data/lib/yard/handlers/c/base.rb +110 -0
- data/lib/yard/handlers/c/class_handler.rb +26 -0
- data/lib/yard/handlers/c/constant_handler.rb +12 -0
- data/lib/yard/handlers/c/handler_methods.rb +165 -0
- data/lib/yard/handlers/c/init_handler.rb +16 -0
- data/lib/yard/handlers/c/method_handler.rb +35 -0
- data/lib/yard/handlers/c/mixin_handler.rb +13 -0
- data/lib/yard/handlers/c/module_handler.rb +16 -0
- data/lib/yard/handlers/c/override_comment_handler.rb +22 -0
- data/lib/yard/handlers/c/path_handler.rb +10 -0
- data/lib/yard/handlers/c/struct_handler.rb +12 -0
- data/lib/yard/handlers/c/symbol_handler.rb +7 -0
- data/lib/yard/handlers/processor.rb +41 -30
- data/lib/yard/handlers/ruby/alias_handler.rb +0 -2
- data/lib/yard/handlers/ruby/attribute_handler.rb +16 -17
- data/lib/yard/handlers/ruby/base.rb +10 -6
- data/lib/yard/handlers/ruby/comment_handler.rb +9 -0
- data/lib/yard/handlers/ruby/dsl_handler.rb +14 -0
- data/lib/yard/handlers/ruby/dsl_handler_methods.rb +71 -0
- data/lib/yard/handlers/ruby/legacy/alias_handler.rb +0 -3
- data/lib/yard/handlers/ruby/legacy/attribute_handler.rb +16 -17
- data/lib/yard/handlers/ruby/legacy/base.rb +28 -6
- data/lib/yard/handlers/ruby/legacy/comment_handler.rb +9 -0
- data/lib/yard/handlers/ruby/legacy/dsl_handler.rb +16 -0
- data/lib/yard/handlers/ruby/legacy/method_handler.rb +0 -2
- data/lib/yard/handlers/ruby/legacy/mixin_handler.rb +1 -1
- data/lib/yard/handlers/ruby/legacy/module_function_handler.rb +18 -0
- data/lib/yard/handlers/ruby/method_handler.rb +10 -15
- data/lib/yard/handlers/ruby/mixin_handler.rb +1 -1
- data/lib/yard/handlers/ruby/module_function_handler.rb +26 -0
- data/lib/yard/handlers/ruby/struct_handler_methods.rb +3 -2
- data/lib/yard/i18n/pot_generator.rb +281 -0
- data/lib/yard/i18n/text.rb +72 -0
- data/lib/yard/logging.rb +3 -7
- data/lib/yard/options.rb +216 -0
- data/lib/yard/parser/c/c_parser.rb +225 -0
- data/lib/yard/parser/c/comment_parser.rb +131 -0
- data/lib/yard/parser/c/statement.rb +63 -0
- data/lib/yard/parser/ruby/ast_node.rb +91 -1
- data/lib/yard/parser/ruby/legacy/ruby_parser.rb +1 -0
- data/lib/yard/parser/ruby/legacy/statement.rb +7 -2
- data/lib/yard/parser/ruby/legacy/statement_list.rb +13 -22
- data/lib/yard/parser/ruby/ruby_parser.rb +87 -26
- data/lib/yard/parser/source_parser.rb +89 -88
- data/lib/yard/rake/yardoc_task.rb +1 -1
- data/lib/yard/registry.rb +21 -10
- data/lib/yard/registry_store.rb +48 -0
- data/lib/yard/serializers/file_system_serializer.rb +18 -20
- data/lib/yard/serializers/yardoc_serializer.rb +1 -0
- data/lib/yard/server/adapter.rb +2 -2
- data/lib/yard/server/commands/base.rb +1 -1
- data/lib/yard/server/commands/display_object_command.rb +13 -6
- data/lib/yard/server/commands/frames_command.rb +4 -21
- data/lib/yard/server/commands/library_command.rb +57 -11
- data/lib/yard/server/commands/list_command.rb +10 -34
- data/lib/yard/server/commands/search_command.rb +8 -2
- data/lib/yard/server/doc_server_helper.rb +34 -0
- data/lib/yard/server/rack_adapter.rb +5 -1
- data/lib/yard/server/router.rb +4 -10
- data/lib/yard/server/static_caching.rb +2 -2
- data/lib/yard/server/templates/default/fulldoc/html/css/custom.css +2 -2
- data/lib/yard/server/templates/default/fulldoc/html/js/live.js +0 -15
- data/lib/yard/server/templates/default/layout/html/breadcrumb.erb +3 -3
- data/lib/yard/server/templates/default/layout/html/script_setup.erb +8 -0
- data/lib/yard/server/templates/doc_server/processing/html/processing.erb +1 -1
- data/lib/yard/server/templates/doc_server/search/html/setup.rb +1 -1
- data/lib/yard/tags/default_factory.rb +31 -4
- data/lib/yard/tags/directives.rb +593 -0
- data/lib/yard/tags/library.rb +437 -35
- data/lib/yard/templates/engine.rb +17 -12
- data/lib/yard/templates/helpers/base_helper.rb +8 -2
- data/lib/yard/templates/helpers/html_helper.rb +57 -14
- data/lib/yard/templates/helpers/markup/rdoc_markup.rb +1 -1
- data/lib/yard/templates/helpers/markup_helper.rb +9 -9
- data/lib/yard/templates/helpers/text_helper.rb +2 -2
- data/lib/yard/templates/template.rb +42 -13
- data/lib/yard/templates/template_options.rb +81 -0
- data/spec/cli/command_parser_spec.rb +4 -4
- data/spec/cli/command_spec.rb +3 -3
- data/spec/cli/config_spec.rb +13 -13
- data/spec/cli/diff_spec.rb +13 -10
- data/spec/cli/gems_spec.rb +12 -12
- data/spec/cli/help_spec.rb +2 -2
- data/spec/cli/i18n_spec.rb +111 -0
- data/spec/cli/server_spec.rb +66 -18
- data/spec/cli/stats_spec.rb +15 -15
- data/spec/cli/yardoc_spec.rb +124 -97
- data/spec/cli/yri_spec.rb +14 -12
- data/spec/code_objects/base_spec.rb +104 -46
- data/spec/code_objects/class_object_spec.rb +33 -33
- data/spec/code_objects/code_object_list_spec.rb +5 -5
- data/spec/code_objects/constants_spec.rb +4 -3
- data/spec/code_objects/extra_file_object_spec.rb +19 -19
- data/spec/code_objects/macro_object_spec.rb +31 -37
- data/spec/code_objects/method_object_spec.rb +46 -23
- data/spec/code_objects/module_object_spec.rb +16 -16
- data/spec/code_objects/namespace_object_spec.rb +6 -6
- data/spec/code_objects/proxy_spec.rb +19 -19
- data/spec/config_spec.rb +33 -24
- data/spec/core_ext/array_spec.rb +1 -1
- data/spec/core_ext/file_spec.rb +8 -8
- data/spec/core_ext/hash_spec.rb +1 -1
- data/spec/core_ext/insertion_spec.rb +3 -3
- data/spec/core_ext/module_spec.rb +1 -1
- data/spec/core_ext/string_spec.rb +6 -6
- data/spec/core_ext/symbol_hash_spec.rb +11 -11
- data/spec/docstring_parser_spec.rb +207 -0
- data/spec/docstring_spec.rb +33 -146
- data/spec/handlers/alias_handler_spec.rb +14 -14
- data/spec/handlers/attribute_handler_spec.rb +20 -20
- data/spec/handlers/base_spec.rb +16 -16
- data/spec/handlers/c/alias_handler_spec.rb +33 -0
- data/spec/handlers/c/attribute_handler_spec.rb +40 -0
- data/spec/handlers/c/class_handler_spec.rb +64 -0
- data/spec/handlers/c/constant_handler_spec.rb +68 -0
- data/spec/handlers/c/init_handler_spec.rb +36 -0
- data/spec/handlers/c/method_handler_spec.rb +228 -0
- data/spec/handlers/c/mixin_handler_spec.rb +27 -0
- data/spec/handlers/c/module_handler_spec.rb +38 -0
- data/spec/handlers/c/override_comment_handler_spec.rb +43 -0
- data/spec/handlers/c/path_handler_spec.rb +35 -0
- data/spec/handlers/c/spec_helper.rb +11 -0
- data/spec/handlers/c/struct_handler_spec.rb +15 -0
- data/spec/handlers/class_condition_handler_spec.rb +10 -10
- data/spec/handlers/class_handler_spec.rb +38 -38
- data/spec/handlers/class_variable_handler_spec.rb +1 -1
- data/spec/handlers/constant_handler_spec.rb +7 -7
- data/spec/handlers/{macro_handler_spec.rb → dsl_handler_spec.rb} +72 -53
- data/spec/handlers/examples/alias_handler_001.rb.txt +5 -5
- data/spec/handlers/examples/class_condition_handler_001.rb.txt +9 -9
- data/spec/handlers/examples/class_handler_001.rb.txt +1 -1
- data/spec/handlers/examples/dsl_handler_001.rb.txt +110 -0
- data/spec/handlers/examples/exception_handler_001.rb.txt +14 -14
- data/spec/handlers/examples/method_condition_handler_001.rb.txt +2 -2
- data/spec/handlers/examples/method_handler_001.rb.txt +16 -16
- data/spec/handlers/examples/mixin_handler_001.rb.txt +8 -4
- data/spec/handlers/examples/private_constant_handler_001.rb.txt +1 -1
- data/spec/handlers/examples/visibility_handler_001.rb.txt +3 -3
- data/spec/handlers/examples/yield_handler_001.rb.txt +13 -14
- data/spec/handlers/exception_handler_spec.rb +9 -9
- data/spec/handlers/extend_handler_spec.rb +2 -2
- data/spec/handlers/legacy_base_spec.rb +34 -34
- data/spec/handlers/method_condition_handler_spec.rb +2 -2
- data/spec/handlers/method_handler_spec.rb +33 -33
- data/spec/handlers/mixin_handler_spec.rb +13 -9
- data/spec/handlers/module_function_handler_spec.rb +82 -0
- data/spec/handlers/module_handler_spec.rb +6 -6
- data/spec/handlers/private_constant_handler_spec.rb +3 -3
- data/spec/handlers/processor_spec.rb +5 -5
- data/spec/handlers/ruby/base_spec.rb +10 -6
- data/spec/handlers/ruby/legacy/base_spec.rb +11 -7
- data/spec/handlers/spec_helper.rb +2 -3
- data/spec/handlers/visibility_handler_spec.rb +6 -6
- data/spec/handlers/yield_handler_spec.rb +8 -8
- data/spec/i18n/pot_generator_spec.rb +244 -0
- data/spec/i18n/text_spec.rb +69 -0
- data/spec/options_spec.rb +160 -0
- data/spec/parser/base_spec.rb +3 -3
- data/spec/parser/c_parser_spec.rb +31 -257
- data/spec/parser/examples/array.c.txt +187 -187
- data/spec/parser/examples/extrafile.c.txt +1 -1
- data/spec/parser/examples/override.c.txt +1 -1
- data/spec/parser/ruby/ast_node_spec.rb +1 -1
- data/spec/parser/ruby/legacy/statement_list_spec.rb +24 -24
- data/spec/parser/ruby/legacy/token_list_spec.rb +7 -7
- data/spec/parser/ruby/ruby_parser_spec.rb +56 -34
- data/spec/parser/source_parser_spec.rb +125 -65
- data/spec/parser/tag_parsing_spec.rb +4 -4
- data/spec/rake/yardoc_task_spec.rb +10 -8
- data/spec/registry_spec.rb +65 -36
- data/spec/registry_store_spec.rb +90 -40
- data/spec/serializers/file_system_serializer_spec.rb +12 -12
- data/spec/serializers/yardoc_serializer_spec.rb +2 -2
- data/spec/server/adapter_spec.rb +3 -3
- data/spec/server/commands/base_spec.rb +8 -8
- data/spec/server/commands/library_command_spec.rb +3 -3
- data/spec/server/commands/static_file_command_spec.rb +7 -7
- data/spec/server/doc_server_helper_spec.rb +1 -1
- data/spec/server/doc_server_serializer_spec.rb +6 -6
- data/spec/server/rack_adapter_spec.rb +3 -3
- data/spec/server/router_spec.rb +19 -19
- data/spec/server/static_caching_spec.rb +4 -4
- data/spec/spec_helper.rb +7 -7
- data/spec/tags/default_factory_spec.rb +24 -16
- data/spec/tags/directives_spec.rb +422 -0
- data/spec/tags/library_spec.rb +15 -4
- data/spec/tags/overload_tag_spec.rb +6 -6
- data/spec/tags/ref_tag_list_spec.rb +8 -8
- data/spec/templates/class_spec.rb +7 -7
- data/spec/templates/constant_spec.rb +7 -7
- data/spec/templates/engine_spec.rb +28 -36
- data/spec/templates/examples/class001.html +108 -108
- data/spec/templates/examples/class002.html +17 -17
- data/spec/templates/examples/constant001.txt +1 -1
- data/spec/templates/examples/method001.html +45 -45
- data/spec/templates/examples/method002.html +25 -25
- data/spec/templates/examples/method003.html +60 -60
- data/spec/templates/examples/method004.html +7 -7
- data/spec/templates/examples/method005.html +28 -28
- data/spec/templates/examples/module001.html +321 -321
- data/spec/templates/examples/module001.txt +1 -1
- data/spec/templates/examples/module002.html +130 -130
- data/spec/templates/examples/module003.html +74 -74
- data/spec/templates/examples/module004.html +388 -0
- data/spec/templates/helpers/base_helper_spec.rb +32 -32
- data/spec/templates/helpers/html_helper_spec.rb +87 -68
- data/spec/templates/helpers/html_syntax_highlight_helper_spec.rb +9 -9
- data/spec/templates/helpers/markup/rdoc_markup_spec.rb +16 -16
- data/spec/templates/helpers/markup_helper_spec.rb +31 -28
- data/spec/templates/helpers/method_helper_spec.rb +7 -7
- data/spec/templates/helpers/shared_signature_examples.rb +9 -7
- data/spec/templates/helpers/text_helper_spec.rb +3 -3
- data/spec/templates/method_spec.rb +13 -13
- data/spec/templates/module_spec.rb +70 -24
- data/spec/templates/onefile_spec.rb +32 -15
- data/spec/templates/section_spec.rb +23 -23
- data/spec/templates/spec_helper.rb +31 -1
- data/spec/templates/tag_spec.rb +5 -5
- data/spec/templates/template_spec.rb +54 -46
- data/spec/verifier_spec.rb +5 -5
- data/templates/default/class/setup.rb +2 -2
- data/templates/default/docstring/html/abstract.erb +1 -1
- data/templates/default/docstring/html/note.erb +1 -1
- data/templates/default/docstring/html/private.erb +1 -1
- data/templates/default/docstring/html/todo.erb +1 -1
- data/templates/default/docstring/setup.rb +2 -2
- data/templates/default/fulldoc/html/css/full_list.css +4 -2
- data/templates/default/fulldoc/html/css/style.css +50 -44
- data/templates/default/fulldoc/html/frames.erb +21 -6
- data/templates/default/fulldoc/html/full_list.erb +5 -3
- data/templates/default/fulldoc/html/{full_list_files.erb → full_list_file.erb} +0 -0
- data/templates/default/fulldoc/html/js/app.js +29 -26
- data/templates/default/fulldoc/html/js/full_list.js +9 -9
- data/templates/default/fulldoc/html/js/jquery.js +4 -16
- data/templates/default/fulldoc/html/setup.rb +42 -38
- data/templates/default/layout/dot/header.erb +1 -1
- data/templates/default/layout/html/breadcrumb.erb +6 -6
- data/templates/default/layout/html/files.erb +1 -1
- data/templates/default/layout/html/footer.erb +1 -1
- data/templates/default/layout/html/headers.erb +3 -6
- data/templates/default/layout/html/index.erb +1 -1
- data/templates/default/layout/html/layout.erb +3 -7
- data/templates/default/layout/html/objects.erb +1 -1
- data/templates/default/layout/html/script_setup.erb +5 -0
- data/templates/default/layout/html/search.erb +4 -1
- data/templates/default/layout/html/setup.rb +8 -8
- data/templates/default/method_details/html/method_signature.erb +10 -3
- data/templates/default/method_details/setup.rb +1 -0
- data/templates/default/module/dot/info.erb +1 -1
- data/templates/default/module/dot/setup.rb +2 -2
- data/templates/default/module/html/attribute_details.erb +1 -1
- data/templates/default/module/html/children.erb +1 -1
- data/templates/default/module/html/defines.erb +1 -1
- data/templates/default/module/html/inherited_methods.erb +5 -4
- data/templates/default/module/html/item_summary.erb +15 -5
- data/templates/default/module/html/method_details_list.erb +2 -2
- data/templates/default/module/setup.rb +25 -12
- data/templates/default/module/text/setup.rb +1 -1
- data/templates/default/onefile/html/layout.erb +1 -1
- data/templates/default/onefile/html/setup.rb +2 -2
- data/templates/default/tags/html/example.erb +4 -2
- data/templates/default/tags/html/option.erb +1 -1
- data/templates/default/tags/html/overload.erb +1 -1
- data/templates/default/tags/html/see.erb +1 -1
- data/templates/default/tags/html/tag.erb +1 -1
- data/templates/default/tags/setup.rb +4 -3
- data/templates/guide/fulldoc/html/css/style.css +8 -8
- data/templates/guide/fulldoc/html/js/app.js +6 -6
- data/templates/guide/fulldoc/html/setup.rb +12 -12
- data/templates/guide/layout/html/layout.erb +11 -11
- data/templates/guide/layout/html/setup.rb +9 -9
- data/templates/guide/method/html/header.erb +2 -2
- data/templates/guide/method/html/setup.rb +1 -1
- metadata +68 -18
- data/bin/yard-graph +0 -4
- data/bin/yard-server +0 -4
- data/docs/Glossary.md +0 -12
- data/lib/yard/handlers/ruby/legacy/macro_handler.rb +0 -39
- data/lib/yard/handlers/ruby/macro_handler.rb +0 -40
- data/lib/yard/handlers/ruby/macro_handler_methods.rb +0 -131
- data/lib/yard/parser/c_parser.rb +0 -497
- data/lib/yard/server/templates/default/layout/html/headers.erb +0 -16
- data/lib/yard/server/templates/doc_server/frames/html/frames.erb +0 -13
- data/lib/yard/server/templates/doc_server/frames/html/setup.rb +0 -3
- data/lib/yard/server/templates/doc_server/full_list/html/full_list.erb +0 -34
- data/lib/yard/server/templates/doc_server/full_list/html/setup.rb +0 -20
- data/spec/handlers/examples/macro_handler_001.rb.txt +0 -83
data/spec/docstring_spec.rb
CHANGED
@@ -2,19 +2,19 @@ require File.dirname(__FILE__) + '/spec_helper'
|
|
2
2
|
|
3
3
|
describe YARD::Docstring do
|
4
4
|
before { YARD::Registry.clear }
|
5
|
-
|
5
|
+
|
6
6
|
describe '#initialize' do
|
7
7
|
it "should handle docstrings with empty newlines" do
|
8
8
|
Docstring.new("\n\n").should == ""
|
9
9
|
end
|
10
10
|
end
|
11
|
-
|
11
|
+
|
12
12
|
describe '#+' do
|
13
13
|
it "should add another Docstring" do
|
14
14
|
d = Docstring.new("FOO") + Docstring.new("BAR")
|
15
15
|
d.should == "FOO\nBAR"
|
16
16
|
end
|
17
|
-
|
17
|
+
|
18
18
|
it "should copy over tags" do
|
19
19
|
d1 = Docstring.new("FOO\n@api private\n")
|
20
20
|
d2 = Docstring.new("BAR\n@param foo descr")
|
@@ -22,31 +22,31 @@ describe YARD::Docstring do
|
|
22
22
|
d.should have_tag(:api)
|
23
23
|
d.should have_tag(:param)
|
24
24
|
end
|
25
|
-
|
25
|
+
|
26
26
|
it "should add a String" do
|
27
27
|
d = Docstring.new("FOO") + "BAR"
|
28
28
|
d.should == "FOOBAR"
|
29
29
|
end
|
30
30
|
end
|
31
|
-
|
31
|
+
|
32
32
|
describe '#line' do
|
33
33
|
it "should return nil if #line_range is not set" do
|
34
34
|
Docstring.new('foo').line.should be_nil
|
35
35
|
end
|
36
|
-
|
36
|
+
|
37
37
|
it "should return line_range.first if #line_range is set" do
|
38
38
|
doc = Docstring.new('foo')
|
39
39
|
doc.line_range = (1..10)
|
40
40
|
doc.line.should == doc.line_range.first
|
41
41
|
end
|
42
42
|
end
|
43
|
-
|
43
|
+
|
44
44
|
describe '#summary' do
|
45
45
|
it "should handle empty docstrings" do
|
46
46
|
o1 = Docstring.new
|
47
47
|
o1.summary.should == ""
|
48
48
|
end
|
49
|
-
|
49
|
+
|
50
50
|
it "should handle multiple calls" do
|
51
51
|
o1 = Docstring.new("Hello. world")
|
52
52
|
5.times { o1.summary.should == "Hello." }
|
@@ -72,26 +72,26 @@ describe YARD::Docstring do
|
|
72
72
|
it "should not double the ending period" do
|
73
73
|
o = Docstring.new("Returns a list of tags specified by +name+ or all tags if +name+ is not specified.\n\nTest")
|
74
74
|
o.summary.should == "Returns a list of tags specified by +name+ or all tags if +name+ is not specified."
|
75
|
-
|
75
|
+
|
76
76
|
doc = Docstring.new(<<-eof)
|
77
|
-
|
77
|
+
|
78
78
|
Returns a list of tags specified by +name+ or all tags if +name+ is not specified.
|
79
|
-
|
79
|
+
|
80
80
|
@param name the tag name to return data for, or nil for all tags
|
81
81
|
@return [Array<Tags::Tag>] the list of tags by the specified tag name
|
82
82
|
eof
|
83
83
|
doc.summary.should == "Returns a list of tags specified by +name+ or all tags if +name+ is not specified."
|
84
84
|
end
|
85
|
-
|
85
|
+
|
86
86
|
it "should handle references embedded in summary" do
|
87
87
|
Docstring.new("Aliasing {Test.test}. Done.").summary.should == "Aliasing {Test.test}."
|
88
88
|
end
|
89
|
-
|
89
|
+
|
90
90
|
it "should only end first sentence when outside parentheses" do
|
91
91
|
Docstring.new("Hello (the best.) world. Foo bar.").summary.should == "Hello (the best.) world."
|
92
92
|
Docstring.new("A[b.]c.").summary.should == "A[b.]c."
|
93
93
|
end
|
94
|
-
|
94
|
+
|
95
95
|
it "should only see '.' as period if whitespace (or eof) follows" do
|
96
96
|
Docstring.new("hello 1.5 times.").summary.should == "hello 1.5 times."
|
97
97
|
Docstring.new("hello... me").summary.should == "hello..."
|
@@ -115,12 +115,12 @@ describe YARD::Docstring do
|
|
115
115
|
doc.ref_tags.first.tag_name.should == "param"
|
116
116
|
doc.ref_tags.first.name.should == "blah"
|
117
117
|
end
|
118
|
-
|
118
|
+
|
119
119
|
it "should fail to parse named reference tag into ref_tags" do
|
120
120
|
doc = Docstring.new("@param blah THIS_BREAKS_REFTAG (see Foo#bar)")
|
121
121
|
doc.ref_tags.size.should == 0
|
122
122
|
end
|
123
|
-
|
123
|
+
|
124
124
|
it "should return all valid reference tags along with #tags" do
|
125
125
|
o = CodeObjects::MethodObject.new(:root, 'Foo#bar')
|
126
126
|
o.docstring.add_tag Tags::Tag.new('return', 'testing')
|
@@ -131,7 +131,7 @@ describe YARD::Docstring do
|
|
131
131
|
tags.first.should be_kind_of(Tags::RefTag)
|
132
132
|
tags.first.owner.should == o
|
133
133
|
end
|
134
|
-
|
134
|
+
|
135
135
|
it "should return all valid named reference tags along with #tags(name)" do
|
136
136
|
o = CodeObjects::MethodObject.new(:root, 'Foo#bar')
|
137
137
|
o.docstring.add_tag Tags::Tag.new('param', 'testing', nil, '*args')
|
@@ -149,14 +149,14 @@ describe YARD::Docstring do
|
|
149
149
|
tags = doc.tags('param')
|
150
150
|
tags.size.should == 0
|
151
151
|
end
|
152
|
-
|
152
|
+
|
153
153
|
it "resolves references to methods in the same class with #methname" do
|
154
154
|
klass = CodeObjects::ClassObject.new(:root, "Foo")
|
155
155
|
o = CodeObjects::MethodObject.new(klass, "bar")
|
156
156
|
ref = CodeObjects::MethodObject.new(klass, "baz")
|
157
157
|
o.docstring.add_tag Tags::Tag.new('param', 'testing', nil, 'arg1')
|
158
158
|
ref.docstring = "@param (see #bar)"
|
159
|
-
|
159
|
+
|
160
160
|
tags = ref.docstring.tags("param")
|
161
161
|
tags.size.should == 1
|
162
162
|
tags.first.text.should == "testing"
|
@@ -164,7 +164,7 @@ describe YARD::Docstring do
|
|
164
164
|
tags.first.owner.should == o
|
165
165
|
end
|
166
166
|
end
|
167
|
-
|
167
|
+
|
168
168
|
describe '#empty?/#blank?' do
|
169
169
|
before(:all) do
|
170
170
|
Tags::Library.define_tag "Invisible", :invisible_tag
|
@@ -194,132 +194,19 @@ describe YARD::Docstring do
|
|
194
194
|
d.should be_empty
|
195
195
|
d.should_not be_blank
|
196
196
|
end
|
197
|
-
|
197
|
+
|
198
198
|
it "should be blank if it has no visible tags" do
|
199
199
|
d = Docstring.new("@invisible_tag value")
|
200
200
|
d.should be_blank
|
201
201
|
end
|
202
|
-
|
202
|
+
|
203
203
|
it "should not be blank if it has invisible tags and only_visible_tags = false" do
|
204
204
|
d = Docstring.new("@invisible_tag value")
|
205
205
|
d.add_tag Tags::Tag.new('invisible_tag', nil, nil)
|
206
206
|
d.blank?(false).should == false
|
207
207
|
end
|
208
208
|
end
|
209
|
-
|
210
|
-
describe '#add_tag' do
|
211
|
-
it "should only parse tags with charset [A-Za-z_]" do
|
212
|
-
doc = Docstring.new
|
213
|
-
valid = %w( @testing @valid @is_a @is_A @__ )
|
214
|
-
invalid = %w( @ @return@ @param, @x.y @x-y )
|
215
|
-
|
216
|
-
log.enter_level(Logger::FATAL) do
|
217
|
-
{valid => 1, invalid => 0}.each do |tags, size|
|
218
|
-
tags.each do |tag|
|
219
|
-
class << doc
|
220
|
-
def create_tag(tag_name, *args)
|
221
|
-
add_tag Tags::Tag.new(tag_name, *args)
|
222
|
-
end
|
223
|
-
end
|
224
|
-
doc.all = tag
|
225
|
-
doc.tags(tag[1..-1]).size.should == size
|
226
|
-
end
|
227
|
-
end
|
228
|
-
end
|
229
|
-
end
|
230
|
-
end
|
231
|
-
|
232
|
-
describe '#parse_comments' do
|
233
|
-
it "should parse comments into tags" do
|
234
|
-
doc = Docstring.new(<<-eof)
|
235
|
-
@param name Hello world
|
236
|
-
how are you?
|
237
|
-
@param name2
|
238
|
-
this is a new line
|
239
|
-
@param name3 and this
|
240
|
-
is a new paragraph:
|
241
|
-
|
242
|
-
right here.
|
243
|
-
eof
|
244
|
-
tags = doc.tags(:param)
|
245
|
-
tags[0].name.should == "name"
|
246
|
-
tags[0].text.should == "Hello world\nhow are you?"
|
247
|
-
tags[1].name.should == "name2"
|
248
|
-
tags[1].text.should == "this is a new line"
|
249
|
-
tags[2].name.should == "name3"
|
250
|
-
tags[2].text.should == "and this\nis a new paragraph:\n\nright here."
|
251
|
-
end
|
252
209
|
|
253
|
-
it "should end parsing a tag on de-dent" do
|
254
|
-
doc = Docstring.new(<<-eof)
|
255
|
-
@note test
|
256
|
-
one two three
|
257
|
-
rest of docstring
|
258
|
-
eof
|
259
|
-
doc.tag(:note).text.should == "test\none two three"
|
260
|
-
doc.should == "rest of docstring"
|
261
|
-
end
|
262
|
-
|
263
|
-
it "should parse examples embedded in doc" do
|
264
|
-
doc = Docstring.new(<<-eof)
|
265
|
-
test string here
|
266
|
-
@example code
|
267
|
-
|
268
|
-
def foo(x, y, z)
|
269
|
-
end
|
270
|
-
|
271
|
-
class A; end
|
272
|
-
|
273
|
-
more stuff
|
274
|
-
eof
|
275
|
-
doc.should == "test string here\nmore stuff"
|
276
|
-
doc.tag(:example).text.should == "\ndef foo(x, y, z)\nend\n\nclass A; end"
|
277
|
-
end
|
278
|
-
|
279
|
-
it "should remove only original indentation from beginning of line in tags" do
|
280
|
-
doc = Docstring.new(<<-eof)
|
281
|
-
@param name
|
282
|
-
some value
|
283
|
-
foo bar
|
284
|
-
baz
|
285
|
-
eof
|
286
|
-
doc.tag(:param).text.should == "some value\nfoo bar\n baz"
|
287
|
-
end
|
288
|
-
|
289
|
-
it "should allow numbers in tags" do
|
290
|
-
Tags::Library.define_tag(nil, :foo1)
|
291
|
-
Tags::Library.define_tag(nil, :foo2)
|
292
|
-
Tags::Library.define_tag(nil, :foo3)
|
293
|
-
doc = Docstring.new(<<-eof)
|
294
|
-
@foo1 bar1
|
295
|
-
@foo2 bar2
|
296
|
-
@foo3 bar3
|
297
|
-
eof
|
298
|
-
doc.tag(:foo1).text.should == "bar1"
|
299
|
-
doc.tag(:foo2).text.should == "bar2"
|
300
|
-
end
|
301
|
-
|
302
|
-
it "should end tag on newline if next line is not indented" do
|
303
|
-
doc = Docstring.new(<<-eof)
|
304
|
-
@author bar1
|
305
|
-
@api bar2
|
306
|
-
Hello world
|
307
|
-
eof
|
308
|
-
doc.tag(:author).text.should == "bar1"
|
309
|
-
doc.tag(:api).text.should == "bar2"
|
310
|
-
end
|
311
|
-
|
312
|
-
it "should warn about unknown tag" do
|
313
|
-
log.should_receive(:warn).with(/Unknown tag @hello$/)
|
314
|
-
Docstring.new("@hello world")
|
315
|
-
end
|
316
|
-
|
317
|
-
it "should not add trailing whitespace to freeform tags" do
|
318
|
-
doc = Docstring.new("@api private \t ")
|
319
|
-
doc.tag(:api).text.should == "private"
|
320
|
-
end
|
321
|
-
end
|
322
|
-
|
323
210
|
describe '#delete_tags' do
|
324
211
|
it "should delete tags by a given tag name" do
|
325
212
|
doc = Docstring.new("@param name x\n@param name2 y\n@return foo")
|
@@ -327,7 +214,7 @@ eof
|
|
327
214
|
doc.tags.size.should == 1
|
328
215
|
end
|
329
216
|
end
|
330
|
-
|
217
|
+
|
331
218
|
describe '#delete_tag_if' do
|
332
219
|
it "should delete tags for a given block" do
|
333
220
|
doc = Docstring.new("@param name x\n@param name2 y\n@return foo")
|
@@ -335,43 +222,43 @@ eof
|
|
335
222
|
doc.tags.size.should == 2
|
336
223
|
end
|
337
224
|
end
|
338
|
-
|
225
|
+
|
339
226
|
describe '#to_raw' do
|
340
227
|
it "should return a clean representation of tags" do
|
341
228
|
doc = Docstring.new("Hello world\n@return [String, X] foobar\n@param name<Array> the name\nBYE!")
|
342
229
|
doc.to_raw.should == "Hello world\nBYE!\n@param [Array] name\n the name\n@return [String, X] foobar"
|
343
230
|
end
|
344
|
-
|
231
|
+
|
345
232
|
it "should handle tags with newlines and indentation" do
|
346
233
|
doc = Docstring.new("@example TITLE\n the \n example\n @foo\n@param [X] name\n the name")
|
347
234
|
doc.to_raw.should == "@example TITLE\n the \n example\n @foo\n@param [X] name\n the name"
|
348
235
|
end
|
349
|
-
|
236
|
+
|
350
237
|
it "should handle deleted tags" do
|
351
238
|
doc = Docstring.new("@example TITLE\n the \n example\n @foo\n@param [X] name\n the name")
|
352
239
|
doc.delete_tags(:param)
|
353
240
|
doc.to_raw.should == "@example TITLE\n the \n example\n @foo"
|
354
241
|
end
|
355
|
-
|
242
|
+
|
356
243
|
it "should handle added tags" do
|
357
244
|
doc = Docstring.new("@example TITLE\n the \n example\n @foo")
|
358
245
|
doc.add_tag(Tags::Tag.new('foo', 'foo'))
|
359
246
|
doc.to_raw.should == "@example TITLE\n the \n example\n @foo\n@foo foo"
|
360
247
|
end
|
361
|
-
|
248
|
+
|
362
249
|
it "should be equal to .all if not modified" do
|
363
250
|
doc = Docstring.new("123\n@param")
|
364
251
|
doc.to_raw.should == doc.all
|
365
252
|
end
|
366
253
|
end
|
367
|
-
|
254
|
+
|
368
255
|
describe '#dup' do
|
369
256
|
it "should duplicate docstring text" do
|
370
257
|
doc = Docstring.new("foo")
|
371
258
|
doc.dup.should == doc
|
372
259
|
doc.dup.all.should == doc
|
373
260
|
end
|
374
|
-
|
261
|
+
|
375
262
|
it "should duplicate tags to new list" do
|
376
263
|
doc = Docstring.new("@param x\n@return y")
|
377
264
|
doc2 = doc.dup
|
@@ -379,18 +266,18 @@ eof
|
|
379
266
|
doc.tags.size.should == 2
|
380
267
|
doc2.tags.size.should == 1
|
381
268
|
end
|
382
|
-
|
269
|
+
|
383
270
|
it "should preserve summary" do
|
384
271
|
doc = Docstring.new("foo. bar")
|
385
272
|
doc.dup.summary.should == doc.summary
|
386
273
|
end
|
387
|
-
|
274
|
+
|
388
275
|
it "should preserve hash_flag" do
|
389
276
|
doc = Docstring.new
|
390
277
|
doc.hash_flag = 'foo'
|
391
278
|
doc.dup.hash_flag.should == doc.hash_flag
|
392
279
|
end
|
393
|
-
|
280
|
+
|
394
281
|
it "should preserve line_range" do
|
395
282
|
doc = Docstring.new
|
396
283
|
doc.line_range = (1..2)
|
@@ -6,40 +6,40 @@ describe "YARD::Handlers::Ruby::#{LEGACY_PARSER ? "Legacy::" : ""}AliasHandler"
|
|
6
6
|
it "should throw alias into namespace object list" do
|
7
7
|
P(:A).aliases[P("A#b")].should == :a
|
8
8
|
end
|
9
|
-
|
9
|
+
|
10
10
|
['c', 'd?', '[]', '[]=', '-@', '%', '*'].each do |a|
|
11
11
|
it "should handle the Ruby 'alias' keyword syntax for method ##{a}" do
|
12
12
|
P('A#' + a).should be_instance_of(CodeObjects::MethodObject)
|
13
13
|
end
|
14
14
|
end
|
15
|
-
|
15
|
+
|
16
16
|
it "should handle keywords as the alias name" do
|
17
17
|
P('A#for').should be_instance_of(CodeObjects::MethodObject)
|
18
18
|
end
|
19
|
-
|
19
|
+
|
20
20
|
it "should allow ConstantNames to be specified as aliases" do
|
21
21
|
P('A#ConstantName').should be_instance_of(CodeObjects::MethodObject)
|
22
22
|
end
|
23
|
-
|
23
|
+
|
24
24
|
it "should create a new method object for the alias" do
|
25
25
|
P("A#b").should be_instance_of(CodeObjects::MethodObject)
|
26
26
|
end
|
27
|
-
|
27
|
+
|
28
28
|
it "should pull the method into the current class if it's from another one" do
|
29
29
|
P(:B).aliases[P("B#q")].should == :x
|
30
30
|
P(:B).aliases[P("B#r?")].should == :x
|
31
31
|
end
|
32
|
-
|
32
|
+
|
33
33
|
it "should gracefully fail to pull a method in if the original method cannot be found" do
|
34
34
|
P(:B).aliases[P("B#s")].should == :to_s
|
35
35
|
end
|
36
|
-
|
36
|
+
|
37
37
|
it "should allow complex Ruby expressions after the alias parameters" do
|
38
38
|
P(:B).aliases[P("B#t")].should == :inspect
|
39
39
|
end
|
40
|
-
|
40
|
+
|
41
41
|
it "should show up in #is_alias? for method" do
|
42
|
-
P("B#t").is_alias?.should == true
|
42
|
+
P("B#t").is_alias?.should == true
|
43
43
|
P('B#r?').is_alias?.should == true
|
44
44
|
end
|
45
45
|
|
@@ -47,31 +47,31 @@ describe "YARD::Handlers::Ruby::#{LEGACY_PARSER ? "Legacy::" : ""}AliasHandler"
|
|
47
47
|
P('B#<<').should be_instance_of(CodeObjects::MethodObject)
|
48
48
|
P('B#for').should be_instance_of(CodeObjects::MethodObject)
|
49
49
|
end
|
50
|
-
|
50
|
+
|
51
51
|
it "should handle keywords in alias names" do
|
52
52
|
P('B#do').is_alias?.should == true
|
53
53
|
P('B#x2').is_alias?.should == true
|
54
54
|
P(:B).aliases[P('B#do')].should == :x
|
55
55
|
P(:B).aliases[P('B#x2')].should == :do
|
56
56
|
end
|
57
|
-
|
57
|
+
|
58
58
|
it "should handle quoted symbols" do
|
59
59
|
foo = Registry.at('A#foo')
|
60
60
|
foo.should_not be_nil
|
61
61
|
foo.should be_is_alias
|
62
62
|
Registry.at('A').aliases[foo].should == :a
|
63
63
|
end
|
64
|
-
|
64
|
+
|
65
65
|
it "should prepend aliases object's docstring to comments" do
|
66
66
|
Registry.at('D#a').tag(:return).types.should == ['Numeric']
|
67
67
|
Registry.at('D#b').tag(:return).types.should == ['String']
|
68
68
|
Registry.at('D#b').docstring.should == "Foo bar"
|
69
69
|
end
|
70
|
-
|
70
|
+
|
71
71
|
it "should raise an UndocumentableError if only one parameter is passed" do
|
72
72
|
undoc_error "alias_method :q"
|
73
73
|
end
|
74
|
-
|
74
|
+
|
75
75
|
it "should raise an UndocumentableError if the parameter is not a Symbol or String" do
|
76
76
|
undoc_error "alias_method CONST, Something"
|
77
77
|
undoc_error "alias_method variable, ClassName"
|
@@ -2,84 +2,84 @@ require File.dirname(__FILE__) + '/spec_helper'
|
|
2
2
|
|
3
3
|
describe "YARD::Handlers::Ruby::#{LEGACY_PARSER ? "Legacy::" : ""}AttributeHandler" do
|
4
4
|
before(:all) { parse_file :attribute_handler_001, __FILE__ }
|
5
|
-
|
5
|
+
|
6
6
|
def read_write(namespace, name, read, write, scope = :instance)
|
7
7
|
rname, wname = namespace.to_s+"#"+name.to_s, namespace.to_s+"#"+name.to_s+"="
|
8
8
|
if read
|
9
|
-
Registry.at(rname).should be_instance_of(CodeObjects::MethodObject)
|
9
|
+
Registry.at(rname).should be_instance_of(CodeObjects::MethodObject)
|
10
10
|
else
|
11
11
|
Registry.at(rname).should == nil
|
12
12
|
end
|
13
|
-
|
13
|
+
|
14
14
|
if write
|
15
|
-
Registry.at(wname).should be_kind_of(CodeObjects::MethodObject)
|
15
|
+
Registry.at(wname).should be_kind_of(CodeObjects::MethodObject)
|
16
16
|
else
|
17
17
|
Registry.at(wname).should == nil
|
18
|
-
end
|
19
|
-
|
18
|
+
end
|
19
|
+
|
20
20
|
attrs = Registry.at(namespace).attributes[scope][name]
|
21
21
|
attrs[:read].should == (read ? Registry.at(rname) : nil)
|
22
22
|
attrs[:write].should == (write ? Registry.at(wname) : nil)
|
23
23
|
end
|
24
|
-
|
24
|
+
|
25
25
|
it "should parse attributes inside modules too" do
|
26
26
|
Registry.at("A#x=").should_not == nil
|
27
27
|
end
|
28
|
-
|
28
|
+
|
29
29
|
it "should parse 'attr'" do
|
30
30
|
read_write(:B, :a, true, true)
|
31
31
|
read_write(:B, :a2, true, false)
|
32
32
|
read_write(:B, "a3", true, false)
|
33
33
|
end
|
34
|
-
|
34
|
+
|
35
35
|
it "should parse 'attr_reader'" do
|
36
36
|
read_write(:B, :b, true, false)
|
37
37
|
end
|
38
|
-
|
38
|
+
|
39
39
|
it "should parse 'attr_writer'" do
|
40
40
|
read_write(:B, :e, false, true)
|
41
41
|
end
|
42
|
-
|
42
|
+
|
43
43
|
it "should parse 'attr_accessor'" do
|
44
44
|
read_write(:B, :f, true, true)
|
45
45
|
end
|
46
|
-
|
46
|
+
|
47
47
|
it "should parse a list of attributes" do
|
48
48
|
read_write(:B, :b, true, false)
|
49
49
|
read_write(:B, :c, true, false)
|
50
50
|
read_write(:B, :d, true, false)
|
51
51
|
end
|
52
|
-
|
52
|
+
|
53
53
|
it "should have a default docstring if one is not supplied" do
|
54
54
|
Registry.at("B#f=").docstring.should_not be_empty
|
55
55
|
end
|
56
|
-
|
56
|
+
|
57
57
|
it "should set the correct docstring if one is supplied" do
|
58
58
|
Registry.at("B#b").docstring.should == "Docstring"
|
59
59
|
Registry.at("B#c").docstring.should == "Docstring"
|
60
60
|
Registry.at("B#d").docstring.should == "Docstring"
|
61
61
|
end
|
62
|
-
|
62
|
+
|
63
63
|
it "should be able to differentiate between class and instance attributes" do
|
64
64
|
P('B').class_attributes[:z][:read].scope.should == :class
|
65
65
|
P('B').instance_attributes[:z][:read].scope.should == :instance
|
66
66
|
end
|
67
|
-
|
67
|
+
|
68
68
|
it "should respond true in method's #is_attribute?" do
|
69
69
|
P('B#a').is_attribute?.should == true
|
70
70
|
P('B#a=').is_attribute?.should == true
|
71
71
|
end
|
72
|
-
|
72
|
+
|
73
73
|
it "should not return true for #is_explicit? in created methods" do
|
74
74
|
Registry.at(:B).meths.each do |meth|
|
75
75
|
meth.is_explicit?.should == false
|
76
76
|
end
|
77
77
|
end
|
78
|
-
|
78
|
+
|
79
79
|
it "should handle attr call with no arguments" do
|
80
80
|
lambda { StubbedSourceParser.parse_string "attr" }.should_not raise_error
|
81
81
|
end
|
82
|
-
|
82
|
+
|
83
83
|
it "should add existing reader method as part of attr_writer combo" do
|
84
84
|
Registry.at('C#foo=').attr_info[:read].should == Registry.at('C#foo')
|
85
85
|
end
|
@@ -87,7 +87,7 @@ describe "YARD::Handlers::Ruby::#{LEGACY_PARSER ? "Legacy::" : ""}AttributeHandl
|
|
87
87
|
it "should add existing writer method as part of attr_reader combo" do
|
88
88
|
Registry.at('C#foo').attr_info[:write].should == Registry.at('C#foo=')
|
89
89
|
end
|
90
|
-
|
90
|
+
|
91
91
|
it "should maintain visibility for attr_reader" do
|
92
92
|
Registry.at('D#parser').visibility.should == :protected
|
93
93
|
end
|