yard 0.2.2 → 0.2.3

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.

Files changed (204) hide show
  1. data/LICENSE +1 -1
  2. data/README.markdown +200 -0
  3. data/Rakefile +6 -1
  4. data/benchmarks/format_args.rb +46 -0
  5. data/benchmarks/parsing.rb +13 -1
  6. data/benchmarks/rdoc_vs_yardoc.rb +10 -0
  7. data/benchmarks/ripper_parser.rb +12 -0
  8. data/docs/CODE_OBJECTS.markdown +121 -0
  9. data/docs/FAQ.markdown +34 -0
  10. data/docs/GENERATORS.markdown +211 -0
  11. data/docs/GETTING_STARTED.markdown +263 -0
  12. data/docs/GLOSSARY.markdown +13 -0
  13. data/docs/HANDLERS.markdown +158 -0
  14. data/docs/OVERVIEW.markdown +64 -0
  15. data/docs/PARSER.markdown +180 -0
  16. data/docs/TAGS.markdown +181 -0
  17. data/docs/WHATSNEW.markdown +96 -0
  18. data/docs/images/code-objects-class-diagram.png +0 -0
  19. data/docs/images/handlers-class-diagram.png +0 -0
  20. data/docs/images/overview-class-diagram.png +0 -0
  21. data/docs/images/parser-class-diagram.png +0 -0
  22. data/docs/images/tags-class-diagram.png +0 -0
  23. data/lib/yard.rb +4 -1
  24. data/lib/yard/autoload.rb +79 -31
  25. data/lib/yard/cli/yard_graph.rb +8 -2
  26. data/lib/yard/cli/yardoc.rb +61 -8
  27. data/lib/yard/code_objects/base.rb +78 -135
  28. data/lib/yard/code_objects/class_object.rb +9 -8
  29. data/lib/yard/code_objects/constant_object.rb +1 -0
  30. data/lib/yard/code_objects/extended_method_object.rb +9 -0
  31. data/lib/yard/code_objects/method_object.rb +18 -5
  32. data/lib/yard/code_objects/module_object.rb +8 -1
  33. data/lib/yard/code_objects/namespace_object.rb +25 -16
  34. data/lib/yard/code_objects/proxy.rb +22 -22
  35. data/lib/yard/core_ext/file.rb +1 -1
  36. data/lib/yard/core_ext/string.rb +0 -4
  37. data/lib/yard/core_ext/symbol_hash.rb +3 -2
  38. data/lib/yard/docstring.rb +180 -0
  39. data/lib/yard/generators/base.rb +33 -13
  40. data/lib/yard/generators/class_generator.rb +4 -2
  41. data/lib/yard/generators/constants_generator.rb +3 -2
  42. data/lib/yard/generators/full_doc_generator.rb +76 -9
  43. data/lib/yard/generators/helpers/base_helper.rb +18 -1
  44. data/lib/yard/generators/helpers/filter_helper.rb +2 -2
  45. data/lib/yard/generators/helpers/html_helper.rb +94 -39
  46. data/lib/yard/generators/helpers/html_syntax_highlight_helper.rb +49 -0
  47. data/lib/yard/generators/helpers/markup_helper.rb +86 -0
  48. data/lib/yard/generators/helpers/method_helper.rb +23 -7
  49. data/lib/yard/generators/method_generator.rb +15 -3
  50. data/lib/yard/generators/method_listing_generator.rb +3 -3
  51. data/lib/yard/generators/mixins_generator.rb +8 -2
  52. data/lib/yard/generators/module_generator.rb +3 -2
  53. data/lib/yard/generators/overloads_generator.rb +20 -0
  54. data/lib/yard/generators/quick_doc_generator.rb +3 -9
  55. data/lib/yard/generators/root_generator.rb +32 -0
  56. data/lib/yard/generators/source_generator.rb +2 -17
  57. data/lib/yard/generators/tags_generator.rb +34 -6
  58. data/lib/yard/generators/uml_generator.rb +16 -6
  59. data/lib/yard/handlers/base.rb +88 -253
  60. data/lib/yard/handlers/processor.rb +72 -0
  61. data/lib/yard/handlers/ruby/alias_handler.rb +38 -0
  62. data/lib/yard/handlers/ruby/attribute_handler.rb +69 -0
  63. data/lib/yard/handlers/ruby/base.rb +72 -0
  64. data/lib/yard/handlers/ruby/class_condition_handler.rb +70 -0
  65. data/lib/yard/handlers/ruby/class_handler.rb +74 -0
  66. data/lib/yard/handlers/ruby/class_variable_handler.rb +11 -0
  67. data/lib/yard/handlers/ruby/constant_handler.rb +12 -0
  68. data/lib/yard/handlers/ruby/exception_handler.rb +22 -0
  69. data/lib/yard/handlers/ruby/extend_handler.rb +19 -0
  70. data/lib/yard/handlers/{alias_handler.rb → ruby/legacy/alias_handler.rb} +3 -4
  71. data/lib/yard/handlers/{attribute_handler.rb → ruby/legacy/attribute_handler.rb} +2 -2
  72. data/lib/yard/handlers/ruby/legacy/base.rb +198 -0
  73. data/lib/yard/handlers/{class_handler.rb → ruby/legacy/class_handler.rb} +18 -6
  74. data/lib/yard/handlers/{class_variable_handler.rb → ruby/legacy/class_variable_handler.rb} +1 -1
  75. data/lib/yard/handlers/{constant_handler.rb → ruby/legacy/constant_handler.rb} +2 -2
  76. data/lib/yard/handlers/{exception_handler.rb → ruby/legacy/exception_handler.rb} +3 -3
  77. data/lib/yard/handlers/ruby/legacy/extend_handler.rb +18 -0
  78. data/lib/yard/handlers/ruby/legacy/method_handler.rb +31 -0
  79. data/lib/yard/handlers/ruby/legacy/mixin_handler.rb +28 -0
  80. data/lib/yard/handlers/{module_handler.rb → ruby/legacy/module_handler.rb} +1 -1
  81. data/lib/yard/handlers/{visibility_handler.rb → ruby/legacy/visibility_handler.rb} +1 -1
  82. data/lib/yard/handlers/{yield_handler.rb → ruby/legacy/yield_handler.rb} +4 -4
  83. data/lib/yard/handlers/ruby/method_condition_handler.rb +7 -0
  84. data/lib/yard/handlers/ruby/method_handler.rb +48 -0
  85. data/lib/yard/handlers/ruby/mixin_handler.rb +25 -0
  86. data/lib/yard/handlers/ruby/module_handler.rb +9 -0
  87. data/lib/yard/handlers/ruby/visibility_handler.rb +18 -0
  88. data/lib/yard/handlers/ruby/yield_handler.rb +28 -0
  89. data/lib/yard/parser/ruby/ast_node.rb +263 -0
  90. data/lib/yard/parser/{ruby_lex.rb → ruby/legacy/ruby_lex.rb} +258 -259
  91. data/lib/yard/parser/{statement.rb → ruby/legacy/statement.rb} +8 -4
  92. data/lib/yard/parser/ruby/legacy/statement_list.rb +262 -0
  93. data/lib/yard/parser/{token_list.rb → ruby/legacy/token_list.rb} +1 -1
  94. data/lib/yard/parser/ruby/ruby_parser.rb +307 -0
  95. data/lib/yard/parser/source_parser.rb +76 -45
  96. data/lib/yard/rake/yardoc_task.rb +6 -1
  97. data/lib/yard/registry.rb +45 -19
  98. data/lib/yard/serializers/file_system_serializer.rb +8 -3
  99. data/lib/yard/tags/default_factory.rb +70 -10
  100. data/lib/yard/tags/default_tag.rb +12 -0
  101. data/lib/yard/tags/library.rb +65 -26
  102. data/lib/yard/tags/option_tag.rb +12 -0
  103. data/lib/yard/tags/overload_tag.rb +62 -0
  104. data/lib/yard/tags/ref_tag.rb +7 -0
  105. data/lib/yard/tags/ref_tag_list.rb +27 -0
  106. data/lib/yard/tags/tag.rb +1 -0
  107. data/lib/yard/tags/tag_format_error.rb +6 -0
  108. data/spec/cli/yardoc_spec.rb +43 -0
  109. data/spec/code_objects/base_spec.rb +56 -68
  110. data/spec/code_objects/class_object_spec.rb +18 -6
  111. data/spec/code_objects/constants_spec.rb +2 -0
  112. data/spec/code_objects/method_object_spec.rb +33 -5
  113. data/spec/code_objects/module_object_spec.rb +66 -8
  114. data/spec/code_objects/namespace_object_spec.rb +37 -17
  115. data/spec/code_objects/proxy_spec.rb +13 -2
  116. data/spec/core_ext/string_spec.rb +14 -2
  117. data/spec/core_ext/symbol_hash_spec.rb +9 -3
  118. data/spec/docstring_spec.rb +139 -0
  119. data/spec/generators/full_doc_generator_spec.rb +29 -0
  120. data/spec/generators/helpers/html_helper_spec.rb +74 -0
  121. data/spec/generators/helpers/markup_helper_spec.rb +95 -0
  122. data/spec/handlers/alias_handler_spec.rb +16 -3
  123. data/spec/handlers/attribute_handler_spec.rb +1 -1
  124. data/spec/handlers/base_spec.rb +15 -141
  125. data/spec/handlers/class_condition_handler_spec.rb +49 -0
  126. data/spec/handlers/class_handler_spec.rb +44 -3
  127. data/spec/handlers/class_variable_handler_spec.rb +1 -1
  128. data/spec/handlers/constant_handler_spec.rb +1 -1
  129. data/spec/handlers/examples/alias_handler_001.rb.txt +7 -3
  130. data/spec/handlers/examples/class_condition_handler_001.rb.txt +61 -0
  131. data/spec/handlers/examples/class_handler_001.rb.txt +33 -0
  132. data/spec/handlers/examples/exception_handler_001.rb.txt +1 -1
  133. data/spec/handlers/examples/extend_handler_001.rb.txt +8 -0
  134. data/spec/handlers/examples/method_condition_handler_001.rb.txt +10 -0
  135. data/spec/handlers/examples/method_handler_001.rb.txt +16 -4
  136. data/spec/handlers/examples/mixin_handler_001.rb.txt +10 -2
  137. data/spec/handlers/examples/module_handler_001.rb.txt +4 -0
  138. data/spec/handlers/examples/visibility_handler_001.rb.txt +1 -1
  139. data/spec/handlers/exception_handler_spec.rb +2 -2
  140. data/spec/handlers/extend_handler_spec.rb +15 -0
  141. data/spec/handlers/legacy_base_spec.rb +128 -0
  142. data/spec/handlers/method_condition_handler_spec.rb +14 -0
  143. data/spec/handlers/method_handler_spec.rb +38 -5
  144. data/spec/handlers/mixin_handler_spec.rb +15 -7
  145. data/spec/handlers/module_handler_spec.rb +5 -1
  146. data/spec/handlers/processor_spec.rb +19 -0
  147. data/spec/handlers/ruby/base_spec.rb +90 -0
  148. data/spec/handlers/ruby/legacy/base_spec.rb +53 -0
  149. data/spec/handlers/spec_helper.rb +22 -16
  150. data/spec/handlers/visibility_handler_spec.rb +4 -4
  151. data/spec/handlers/yield_handler_spec.rb +1 -1
  152. data/spec/parser/ruby/ast_node_spec.rb +15 -0
  153. data/spec/parser/ruby/legacy/statement_list_spec.rb +145 -0
  154. data/spec/parser/{token_list_spec.rb → ruby/legacy/token_list_spec.rb} +4 -4
  155. data/spec/parser/source_parser_spec.rb +0 -15
  156. data/spec/rake/yardoc_task_spec.rb +48 -0
  157. data/spec/registry_spec.rb +28 -2
  158. data/spec/serializers/file_system_serializer_spec.rb +7 -1
  159. data/spec/spec_helper.rb +1 -1
  160. data/spec/tags/default_factory_spec.rb +135 -0
  161. data/spec/tags/default_tag_spec.rb +11 -0
  162. data/spec/tags/overload_tag_spec.rb +35 -0
  163. data/spec/tags/ref_tag_list_spec.rb +53 -0
  164. data/templates/default/attributes/html/header.erb +17 -5
  165. data/templates/default/attributes/text/header.erb +1 -1
  166. data/templates/default/fulldoc/html/all_files.erb +19 -0
  167. data/templates/default/fulldoc/html/all_methods.erb +8 -7
  168. data/templates/default/fulldoc/html/all_namespaces.erb +4 -1
  169. data/templates/default/fulldoc/html/app.js +1 -1
  170. data/templates/default/fulldoc/html/{readme.erb → file.erb} +2 -2
  171. data/templates/default/fulldoc/html/header.erb +1 -1
  172. data/templates/default/fulldoc/html/index.erb +4 -3
  173. data/templates/default/fulldoc/html/style.css +13 -3
  174. data/templates/default/fulldoc/html/syntax_highlight.css +8 -5
  175. data/templates/default/method/text/header.erb +1 -0
  176. data/templates/default/method/text/title.erb +1 -0
  177. data/templates/default/methodsignature/html/main.erb +10 -8
  178. data/templates/default/methodsignature/text/main.erb +4 -1
  179. data/templates/default/methodsummary/html/summary.erb +8 -4
  180. data/templates/default/methodsummary/text/summary.erb +4 -1
  181. data/templates/default/mixins/html/header.erb +3 -3
  182. data/templates/default/overloads/html/header.erb +8 -0
  183. data/templates/default/overloads/text/header.erb +8 -0
  184. data/templates/default/root/html/header.erb +4 -0
  185. data/templates/default/tags/html/example.erb +20 -0
  186. data/templates/default/tags/html/option.erb +27 -0
  187. data/templates/default/tags/html/param.erb +21 -0
  188. data/templates/default/tags/html/tags.erb +4 -1
  189. data/templates/default/tags/html/todo.erb +8 -0
  190. data/templates/default/tags/text/example.erb +14 -0
  191. data/templates/default/tags/text/header.erb +3 -3
  192. data/templates/default/tags/text/option.erb +5 -0
  193. data/templates/default/tags/text/param.erb +9 -0
  194. data/templates/default/uml/dot/dependencies.erb +1 -1
  195. data/templates/default/uml/dot/info.erb +1 -1
  196. data/templates/default/uml/dot/superclasses.erb +2 -2
  197. data/templates/javadoc/methodsummary/html/summary.erb +2 -2
  198. data/templates/javadoc/mixins/html/header.erb +3 -3
  199. metadata +108 -139
  200. data/README +0 -211
  201. data/lib/yard/handlers/method_handler.rb +0 -27
  202. data/lib/yard/handlers/mixin_handler.rb +0 -16
  203. data/lib/yard/parser/statement_list.rb +0 -167
  204. data/lib/yard/tags/merbdoc_factory.rb +0 -47
@@ -1,9 +1,9 @@
1
- require File.join(File.dirname(__FILE__), '..', 'spec_helper')
1
+ require File.join(File.dirname(__FILE__), '..', '..', '..', 'spec_helper')
2
2
 
3
- include YARD::Parser
4
- include YARD::Parser::RubyToken
3
+ include YARD::Parser::Ruby::Legacy
4
+ include YARD::Parser::Ruby::Legacy::RubyToken
5
5
 
6
- describe YARD::Parser::TokenList, "#initialize / #push" do
6
+ describe YARD::Parser::Ruby::Legacy::TokenList, "#initialize / #push" do
7
7
  it "should accept a tokenlist (via constructor or push)" do
8
8
  lambda { TokenList.new(TokenList.new) }.should_not raise_error(ArgumentError)
9
9
  TokenList.new.push(TokenList.new("x = 2")).size.should == 6
@@ -25,19 +25,4 @@ describe YARD::Parser::SourceParser do
25
25
  Registry.at("Hello::Hi#me").should_not == nil
26
26
  Registry.at("Hello::Hi#me").docstring.should == "Docstring"
27
27
  end
28
-
29
- it "should start with public visibility" do
30
- p = Parser::SourceParser.new
31
- p.visibility.should == :public
32
- end
33
-
34
- it "should start in instance scope" do
35
- p = Parser::SourceParser.new
36
- p.scope.should == :instance
37
- end
38
-
39
- it "should start in root namespace" do
40
- p = Parser::SourceParser.new
41
- p.namespace.should == Registry.root
42
- end
43
28
  end
@@ -0,0 +1,48 @@
1
+ require File.dirname(__FILE__) + '/../spec_helper'
2
+
3
+ describe YARD::Rake::YardocTask do
4
+ before do
5
+ Rake.application.clear
6
+ end
7
+
8
+ def run
9
+ Rake.application.tasks[0].invoke
10
+ end
11
+
12
+ it "should allow separate rake task name to be set" do
13
+ YARD::Rake::YardocTask.new(:notyardoc)
14
+ Rake.application.tasks[0].name.should == "notyardoc"
15
+ end
16
+
17
+ it "should allow files to be set" do
18
+ YARD::CLI::Yardoc.should_receive(:run).with('a', 'b', 'c')
19
+ YARD::Rake::YardocTask.new do |t|
20
+ t.files = ['a', 'b', 'c']
21
+ end
22
+ run
23
+ end
24
+
25
+ it "should allow extra options to be set" do
26
+ YARD::CLI::Yardoc.should_receive(:run).with('--extra', '--opts')
27
+ YARD::Rake::YardocTask.new do |t|
28
+ t.options = ['--extra', '--opts']
29
+ end
30
+ run
31
+ end
32
+
33
+ it "should allow before callback" do
34
+ proc = lambda { }
35
+ proc.should_receive(:call)
36
+ YARD::CLI::Yardoc.should_receive(:run)
37
+ YARD::Rake::YardocTask.new {|t| t.before = proc }
38
+ run
39
+ end
40
+
41
+ it "should allow after callback" do
42
+ proc = lambda { }
43
+ proc.should_receive(:call)
44
+ YARD::CLI::Yardoc.should_receive(:run)
45
+ YARD::Rake::YardocTask.new {|t| t.after = proc }
46
+ run
47
+ end
48
+ end
@@ -21,7 +21,7 @@ describe YARD::Registry do
21
21
  o3 = ModuleObject.new(o2, :C)
22
22
  Registry.resolve(o3, "::A").should == o1
23
23
 
24
- Registry.resolve(o3, "::String", true).should == P(:String)
24
+ Registry.resolve(o3, "::String", false, true).should == P(:String)
25
25
  end
26
26
 
27
27
  it "should resolve instance methods with # prefix" do
@@ -39,6 +39,32 @@ describe YARD::Registry do
39
39
  Registry.resolve(:root, 'methname').should == o
40
40
  end
41
41
 
42
+ it "should resolve superclass methods when inheritance = true" do
43
+ superyard = ClassObject.new(:root, :SuperYard)
44
+ yard = ClassObject.new(:root, :YARD)
45
+ yard.superclass = superyard
46
+ imeth = MethodObject.new(superyard, :hello)
47
+ cmeth = MethodObject.new(superyard, :class_hello, :class)
48
+
49
+ Registry.resolve(yard, "#hello", false).should be_nil
50
+ Registry.resolve(yard, "#hello", true).should == imeth
51
+ Registry.resolve(yard, "class_hello", false).should be_nil
52
+ Registry.resolve(yard, "class_hello", true).should == cmeth
53
+ end
54
+
55
+ it "should resolve mixin methods when inheritance = true" do
56
+ yard = ClassObject.new(:root, :YARD)
57
+ mixin = ModuleObject.new(:root, :Mixin)
58
+ yard.mixins(:instance) << mixin
59
+ imeth = MethodObject.new(mixin, :hello)
60
+ cmeth = MethodObject.new(mixin, :class_hello, :class)
61
+
62
+ Registry.resolve(yard, "#hello", false).should be_nil
63
+ Registry.resolve(yard, "#hello", true).should == imeth
64
+ Registry.resolve(yard, "class_hello", false).should be_nil
65
+ Registry.resolve(yard, "class_hello", true).should == cmeth
66
+ end
67
+
42
68
  it "should allow symbols as object type in #all" do
43
69
  ModuleObject.new(:root, :A)
44
70
  o1 = ClassObject.new(:root, :B)
@@ -67,4 +93,4 @@ describe YARD::Registry do
67
93
  o2 = ClassObject.new(:root, :B)
68
94
  Registry.paths.should include('A', 'B')
69
95
  end
70
- end
96
+ end
@@ -20,7 +20,13 @@ describe YARD::Serializers::FileSystemSerializer do
20
20
 
21
21
  it "should allow no extension to be used" do
22
22
  obj = Serializers::FileSystemSerializer.new :extension => nil
23
- obj.serialized_path(Registry.root).should == 'root'
23
+ yard = CodeObjects::ClassObject.new(nil, :FooBar)
24
+ obj.serialized_path(yard).should == 'FooBar'
25
+ end
26
+
27
+ it "should serialize to top-level-namespace for root" do
28
+ obj = Serializers::FileSystemSerializer.new :extension => nil
29
+ obj.serialized_path(Registry.root).should == "top-level-namespace"
24
30
  end
25
31
 
26
32
  it "should serialize to the correct path" do
data/spec/spec_helper.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  require "rubygems"
2
2
  require "spec"
3
3
 
4
- require File.join(File.dirname(__FILE__), '..', 'lib', 'yard')
4
+ require File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib', 'yard'))
5
5
 
6
6
  def parse_file(file, thisfile = __FILE__)
7
7
  Registry.clear
@@ -0,0 +1,135 @@
1
+ require File.dirname(__FILE__) + '/../spec_helper'
2
+
3
+ describe YARD::Tags::DefaultFactory, "extract_types_and_name_from_text" do
4
+ before { @f = YARD::Tags::DefaultFactory.new }
5
+
6
+ def parse_types(types)
7
+ @f.send(:extract_types_and_name_from_text, types)
8
+ end
9
+
10
+ it "should handle one type" do
11
+ parse_types('[A]').should == [nil, ['A'], ""]
12
+ end
13
+
14
+ it "should handle a list of types" do
15
+ parse_types('[A, B, C]').should == [nil, ['A', 'B', 'C'], ""]
16
+ end
17
+
18
+ it "should return the text before and after the type list" do
19
+ parse_types(' b <String> description').should == ['b', ['String'], 'description']
20
+ end
21
+
22
+ it "should handle a complex list of types" do
23
+ v = parse_types(' [Test, Array<String, Hash, C>, String]')
24
+ v.should include(["Test", "Array<String, Hash, C>", "String"])
25
+ end
26
+
27
+ it "should handle any of the following start/end delimiting chars: (), <>, {}, []" do
28
+ a = parse_types('[a,b,c]')
29
+ b = parse_types('<a,b,c>')
30
+ c = parse_types('(a,b,c)')
31
+ d = parse_types('{a,b,c}')
32
+ a.should == b
33
+ b.should == c
34
+ c.should == d
35
+ a.should include(['a','b','c'])
36
+ end
37
+
38
+ it "should return the text before the type list as the last element" do
39
+ parse_types('b[x, y, z]').should == ['b', ['x', 'y', 'z'], '']
40
+ parse_types(' ! <x>').should == ["!", ['x'], '']
41
+ end
42
+
43
+ it "should return text unparsed if there is no type list" do
44
+ parse_types('').should == [nil, nil, '']
45
+ parse_types('[]').should == [nil, nil, '[]']
46
+ end
47
+
48
+ it "should allow A => B syntax" do
49
+ v = parse_types(' [Test, Array<String, Hash{A => {B => C}}, C>, String]')
50
+ v.should include(["Test", "Array<String, Hash{A => {B => C}}, C>", "String"])
51
+ end
52
+ end
53
+
54
+ describe YARD::Tags::DefaultFactory, '#parse_tag_with_types' do
55
+ before { @f = YARD::Tags::DefaultFactory.new }
56
+
57
+ def parse_types(text)
58
+ @f.send(:parse_tag_with_types, 'test', text)
59
+ end
60
+
61
+ it "should parse given types and description" do
62
+ YARD::Tags::Tag.should_receive(:new).with("test", "description", ["x", "y", "z"])
63
+ parse_types(' [x, y, z] description')
64
+ end
65
+
66
+ it "should parse given types only" do
67
+ YARD::Tags::Tag.should_receive(:new).with("test", "", ["x", "y", "z"])
68
+ parse_types(' [x, y, z] ')
69
+ end
70
+
71
+ it "should allow type list to be omitted" do
72
+ YARD::Tags::Tag.should_receive(:new).with('test', 'description', nil)
73
+ parse_types(' description ')
74
+ end
75
+
76
+ it "should raise an error if a name is specified before type list" do
77
+ lambda { parse_types('b<String> desc') }.should raise_error(YARD::Tags::TagFormatError, 'cannot specify a name before type list for \'@test\'')
78
+ end
79
+ end
80
+
81
+ describe YARD::Tags::DefaultFactory, '#parse_tag_with_types_name_and_default' do
82
+ before { @f = YARD::Tags::DefaultFactory.new }
83
+
84
+ def parse_types(text)
85
+ @f.send(:parse_tag_with_types_name_and_default, 'test', text)
86
+ end
87
+
88
+ it "should parse a standard type list with name before types (no default)" do
89
+ YARD::Tags::DefaultTag.should_receive(:new).with("test", "description", ["x", "y", "z"], 'NAME', nil)
90
+ parse_types('NAME [x, y, z] description')
91
+ end
92
+
93
+ it "should parse a standard type list with name after types (no default)" do
94
+ YARD::Tags::DefaultTag.should_receive(:new).with("test", "description", ["x", "y", "z"], 'NAME', nil)
95
+ parse_types(' [x, y, z] NAME description')
96
+ end
97
+
98
+ it "should parse a tag definition with name, typelist and default" do
99
+ YARD::Tags::DefaultTag.should_receive(:new).with("test", "description", ["x", "y", "z"], 'NAME', ['default', 'values'])
100
+ parse_types(' [x, y, z] NAME (default, values) description')
101
+ end
102
+
103
+ it "should parse a tag definition with name, typelist and default when name is before type list" do
104
+ YARD::Tags::DefaultTag.should_receive(:new).with("test", "description", ["x", "y", "z"], 'NAME', ['default', 'values'])
105
+ parse_types(' NAME [x, y, z] (default, values) description')
106
+ end
107
+
108
+ it "should allow typelist to be omitted" do
109
+ YARD::Tags::DefaultTag.should_receive(:new).with("test", "description", nil, 'NAME', ['default', 'values'])
110
+ parse_types(' NAME (default, values) description')
111
+ end
112
+ end
113
+
114
+ describe YARD::Tags::DefaultFactory, '#parse_tag_with_options' do
115
+ before { @f = YARD::Tags::DefaultFactory.new }
116
+
117
+ def parse_options(text)
118
+ @f.parse_tag_with_options('option', text)
119
+ end
120
+
121
+ it "should have a name before tag info" do
122
+ t = parse_options("xyz key [Types] (default) description")
123
+ t.tag_name.should == 'option'
124
+ t.name.should == 'xyz'
125
+ end
126
+
127
+ it "should parse the rest of the tag like DefaultTag" do
128
+ t = parse_options("xyz key [Types] (default) description")
129
+ t.pair.should be_instance_of(Tags::DefaultTag)
130
+ t.pair.types.should == ["Types"]
131
+ t.pair.name.should == "key"
132
+ t.pair.defaults.should == ["default"]
133
+ t.pair.text.should == "description"
134
+ end
135
+ end
@@ -0,0 +1,11 @@
1
+ require File.dirname(__FILE__) + '/../spec_helper'
2
+
3
+ describe YARD::Tags::DefaultTag do
4
+ it "should create a tag with defaults" do
5
+ o = YARD::Tags::DefaultTag.new('tagname', 'desc', ['types'], 'name', ['defaults'])
6
+ o.defaults.should == ['defaults']
7
+ o.tag_name.should == 'tagname'
8
+ o.name.should == 'name'
9
+ o.types.should == ['types']
10
+ end
11
+ end
@@ -0,0 +1,35 @@
1
+ require File.dirname(__FILE__) + '/../spec_helper'
2
+
3
+ describe YARD::Tags::OverloadTag do
4
+ before do
5
+ @tag = Tags::OverloadTag.new(:overload, nil, <<-'eof')
6
+ def bar(a, b = 1, &block)
7
+ Hello world
8
+ @param a [String]
9
+ @return [String]
10
+ eof
11
+ end
12
+
13
+ it "should parse the first line as a method signature" do
14
+ @tag.signature.should == "def bar(a, b = 1, &block)"
15
+ @tag.parameters.should == [[:a, nil], [:b, "1"], [:"&block", nil]]
16
+ end
17
+
18
+ it "should parse the rest of the text as a new Docstring" do
19
+ @tag.docstring.should be_instance_of(Docstring)
20
+ @tag.docstring.should == "Hello world"
21
+ end
22
+
23
+ it "should set Docstring's object after #object= is called" do
24
+ m = mock(:object)
25
+ @tag.object = m
26
+ @tag.docstring.object.should == m
27
+ end
28
+
29
+ it "should respond to #tag, #tags and #has_tag?" do
30
+ @tag.object = mock(:object)
31
+ @tag.tags.size.should == 2
32
+ @tag.tag(:param).name.should == "a"
33
+ @tag.has_tag?(:return).should == true
34
+ end
35
+ end
@@ -0,0 +1,53 @@
1
+ require File.dirname(__FILE__) + '/../spec_helper'
2
+
3
+ describe YARD::Tags::RefTagList do
4
+ before { YARD::Registry.clear }
5
+
6
+ it "should accept symbol or string as owner's path and convert it into a proxy" do
7
+ t = Tags::RefTagList.new('author', :String)
8
+ t.owner.should == P(:String)
9
+ end
10
+
11
+ it "should accept proxy object as owner" do
12
+ t = Tags::RefTagList.new('author', P(:String))
13
+ t.owner.should == P(:String)
14
+ end
15
+
16
+ it "should return tags from a proxy object" do
17
+ o = CodeObjects::ClassObject.new(:root, :String)
18
+ t = Tags::Tag.new(:author, 'foo')
19
+ o.docstring.add_tag(t)
20
+
21
+ ref = Tags::RefTagList.new('author', :String)
22
+ ref.tags.should == [t]
23
+ ref.tags.first.text.should == 'foo'
24
+ end
25
+
26
+ it "should return named tags from a proxy object" do
27
+ o = CodeObjects::ClassObject.new(:root, :String)
28
+ p1 = Tags::Tag.new(:param, 'bar1', nil, 'foo')
29
+ p2 = Tags::Tag.new(:param, 'bar2', nil, 'foo')
30
+ p3 = Tags::Tag.new(:param, 'bar3', nil, 'bar')
31
+ t1 = Tags::Tag.new(:return, 'blah')
32
+ o.docstring.add_tag(p1, t1, p2, p3)
33
+
34
+ ref = Tags::RefTagList.new('param', :String, 'foo')
35
+ ref.tags.should == [p1, p2]
36
+ ref.tags.first.text.should == 'bar1'
37
+ end
38
+
39
+ it "all tags should respond to #owner and be a RefTag" do
40
+ o = CodeObjects::ClassObject.new(:root, :String)
41
+ p1 = Tags::Tag.new(:param, 'bar1', nil, 'foo')
42
+ p2 = Tags::Tag.new(:param, 'bar2', nil, 'foo')
43
+ p3 = Tags::Tag.new(:param, 'bar3', nil, 'bar')
44
+ t1 = Tags::Tag.new(:return, 'blah')
45
+ o.docstring.add_tag(p1, t1, p2, p3)
46
+
47
+ ref = Tags::RefTagList.new('param', :String)
48
+ ref.tags.each do |t|
49
+ t.should be_kind_of(Tags::RefTag)
50
+ t.owner.should == o
51
+ end
52
+ end
53
+ end
@@ -6,18 +6,21 @@
6
6
  <h2><%= scope.capitalize %> Attributes</h2>
7
7
  <table>
8
8
  <% object.attributes[scope].sort_by {|o| o.to_s.downcase }.each do |name, rw| %>
9
- <tr>
10
- <th class="name"><%= h name %></td>
9
+ <% aliases = (rw[:read] || rw[:write]).aliases %>
10
+ <tr class="<%= 'hasaliases' if aliases.length > 0 %>">
11
+ <th class='signature'>
12
+ <span class='name'><%= h name %></span>
13
+ </td>
11
14
  <td class="readwrite">
12
15
  [<%= ['read', 'write'].map {|t|
13
- rw[t] && !rw[t].is_explicit? ? "<span id='#{anchor_for rw[t]}'>#{t[0,1].upcase}</span>" : t[0,1].upcase
16
+ rw[t] && (rw[t].is_explicit? ? t[0,1].upcase : "<span id='#{anchor_for rw[t]}'>#{t[0,1].upcase}</span>")
14
17
  }.compact.join %>]
15
18
  </td>
16
19
  <td class="visibility">
17
20
  <%= rw.values.compact.first.visibility %>
18
21
  </td>
19
22
  <td class="docstring">
20
- <%= htmlify rw.values.compact.first.short_docstring %>
23
+ <%= htmlify rw.values.compact.first.docstring.summary %>
21
24
  <% if rw[:read] && rw[:read].tag(:return) && rw[:read].tag(:return).types %>
22
25
  <p class='returns'>
23
26
  Returns:
@@ -28,8 +31,17 @@
28
31
  <% end %>
29
32
  </td>
30
33
  </tr>
34
+ <% if aliases.length > 0 %>
35
+ <tr>
36
+ <td colspan='4' class='aliases'><span class='text'>Also known as:</span>
37
+ <% aliases.each_with_index do |obj, i| %>
38
+ <span class='alias'><%= h obj.name.to_s.sub(/=$/, '') %></span><%= "," if i < aliases.length - 1 %>
39
+ <% end %>
40
+ </td>
41
+ </tr>
42
+ <% end %>
31
43
  <% end %>
32
44
  </table>
33
45
  </div>
34
46
  <% end %>
35
- </div>
47
+ </div>
@@ -4,7 +4,7 @@
4
4
  -------------
5
5
  <% ['class', 'instance'].select {|s| object.attributes[s].length > 0 }.each do |scope| %>
6
6
  <% object.attributes[scope].sort_by {|o| o.to_s.downcase }.each do |name, rw| %>
7
- <%= uml_visibility rw.values.compact.first %> <%= rw.values.compact.first.name(true) %><%= " " if scope == 'class' %> [<%= ['read', 'write'].map {|t| rw[t] ? t[0,1].upcase : ' ' }.compact.join %>] (<%= rw.values.compact.first.visibility %>)
7
+ <%= uml_visibility rw.values.compact.first %> <%= name %><%= " " if scope == 'class' %> [<%= ['read', 'write'].map {|t| rw[t] ? t[0,1].upcase : ' ' }.compact.join %>] (<%= rw.values.compact.first.visibility %>)
8
8
  <% end %>
9
9
  <% end %>
10
10