yard 0.2.1 → 0.2.2

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 (264) hide show
  1. data/{LICENSE.txt → LICENSE} +1 -1
  2. data/README +211 -0
  3. data/Rakefile +31 -0
  4. data/benchmarks/builtins_vs_eval.rb +23 -0
  5. data/benchmarks/erb_vs_erubis.rb +53 -0
  6. data/benchmarks/generation.rb +37 -0
  7. data/benchmarks/parsing.rb +33 -0
  8. data/bin/view_generator +17 -0
  9. data/bin/yard-graph +4 -0
  10. data/bin/yardoc +1 -93
  11. data/bin/yri +12 -3
  12. data/lib/yard.rb +10 -5
  13. data/lib/yard/autoload.rb +116 -0
  14. data/lib/yard/cli/yard_graph.rb +86 -0
  15. data/lib/yard/cli/yardoc.rb +131 -0
  16. data/lib/yard/code_objects/base.rb +321 -0
  17. data/lib/yard/code_objects/class_object.rb +89 -0
  18. data/lib/yard/code_objects/class_variable_object.rb +4 -0
  19. data/lib/yard/code_objects/constant_object.rb +4 -0
  20. data/lib/yard/code_objects/method_object.rb +51 -0
  21. data/lib/yard/code_objects/module_object.rb +4 -0
  22. data/lib/yard/code_objects/namespace_object.rb +88 -0
  23. data/lib/yard/code_objects/proxy.rb +183 -0
  24. data/lib/yard/code_objects/root_object.rb +8 -0
  25. data/lib/yard/core_ext/file.rb +26 -0
  26. data/lib/yard/core_ext/logger.rb +5 -0
  27. data/lib/yard/core_ext/module.rb +9 -0
  28. data/lib/yard/core_ext/string.rb +13 -0
  29. data/lib/yard/core_ext/symbol_hash.rb +24 -0
  30. data/lib/yard/generators/attributes_generator.rb +22 -0
  31. data/lib/yard/generators/base.rb +285 -0
  32. data/lib/yard/generators/class_generator.rb +25 -0
  33. data/lib/yard/generators/constants_generator.rb +73 -0
  34. data/lib/yard/generators/constructor_generator.rb +25 -0
  35. data/lib/yard/generators/deprecated_generator.rb +15 -0
  36. data/lib/yard/generators/docstring_generator.rb +15 -0
  37. data/lib/yard/generators/full_doc_generator.rb +59 -0
  38. data/lib/yard/generators/helpers/base_helper.rb +52 -0
  39. data/lib/yard/generators/helpers/filter_helper.rb +21 -0
  40. data/lib/yard/generators/helpers/html_helper.rb +137 -0
  41. data/lib/yard/generators/helpers/method_helper.rb +27 -0
  42. data/lib/yard/generators/helpers/uml_helper.rb +16 -0
  43. data/lib/yard/generators/inheritance_generator.rb +16 -0
  44. data/lib/yard/generators/method_details_generator.rb +18 -0
  45. data/lib/yard/generators/method_generator.rb +31 -0
  46. data/lib/yard/generators/method_listing_generator.rb +105 -0
  47. data/lib/yard/generators/method_missing_generator.rb +25 -0
  48. data/lib/yard/generators/method_signature_generator.rb +19 -0
  49. data/lib/yard/generators/method_summary_generator.rb +21 -0
  50. data/lib/yard/generators/mixins_generator.rb +15 -0
  51. data/lib/yard/generators/module_generator.rb +22 -0
  52. data/lib/yard/generators/quick_doc_generator.rb +31 -0
  53. data/lib/yard/generators/source_generator.rb +26 -0
  54. data/lib/yard/generators/tags_generator.rb +50 -0
  55. data/lib/yard/generators/uml_generator.rb +92 -0
  56. data/lib/yard/generators/visibility_group_generator.rb +26 -0
  57. data/lib/yard/handlers/alias_handler.rb +32 -0
  58. data/lib/yard/handlers/attribute_handler.rb +54 -0
  59. data/lib/yard/handlers/base.rb +509 -0
  60. data/lib/yard/handlers/class_handler.rb +44 -0
  61. data/lib/yard/handlers/class_variable_handler.rb +13 -0
  62. data/lib/yard/handlers/constant_handler.rb +13 -0
  63. data/lib/yard/handlers/exception_handler.rb +12 -0
  64. data/lib/yard/handlers/method_handler.rb +27 -0
  65. data/lib/yard/handlers/mixin_handler.rb +16 -0
  66. data/lib/yard/handlers/module_handler.rb +9 -0
  67. data/lib/yard/handlers/visibility_handler.rb +14 -0
  68. data/lib/yard/handlers/yield_handler.rb +26 -0
  69. data/lib/yard/logging.rb +27 -0
  70. data/lib/yard/parser/ruby_lex.rb +1344 -0
  71. data/lib/yard/parser/source_parser.rb +109 -0
  72. data/lib/yard/parser/statement.rb +36 -0
  73. data/lib/yard/parser/statement_list.rb +167 -0
  74. data/lib/yard/parser/token_list.rb +58 -0
  75. data/lib/yard/rake/yardoc_task.rb +30 -0
  76. data/lib/yard/registry.rb +136 -0
  77. data/lib/yard/serializers/base.rb +16 -0
  78. data/lib/yard/serializers/file_system_serializer.rb +48 -0
  79. data/lib/yard/serializers/process_serializer.rb +14 -0
  80. data/lib/yard/serializers/stdout_serializer.rb +21 -0
  81. data/lib/yard/tags/default_factory.rb +98 -0
  82. data/lib/yard/tags/library.rb +109 -0
  83. data/lib/yard/tags/merbdoc_factory.rb +47 -0
  84. data/lib/yard/tags/tag.rb +35 -0
  85. data/spec/code_objects/base_spec.rb +219 -0
  86. data/spec/code_objects/class_object_spec.rb +176 -0
  87. data/spec/code_objects/code_object_list_spec.rb +33 -0
  88. data/spec/code_objects/constants_spec.rb +79 -0
  89. data/spec/code_objects/method_object_spec.rb +30 -0
  90. data/spec/code_objects/module_object_spec.rb +73 -0
  91. data/spec/code_objects/namespace_object_spec.rb +129 -0
  92. data/spec/code_objects/proxy_spec.rb +80 -0
  93. data/spec/code_objects/spec_helper.rb +3 -0
  94. data/spec/core_ext/file_spec.rb +20 -0
  95. data/spec/core_ext/string_spec.rb +4 -0
  96. data/spec/core_ext/symbol_hash_spec.rb +80 -0
  97. data/spec/generators/base_spec.rb +64 -0
  98. data/spec/generators/helpers/base_helper_spec.rb +15 -0
  99. data/spec/generators/helpers/html_helper_spec.rb +56 -0
  100. data/spec/generators/quick_doc_generator_spec.rb +13 -0
  101. data/spec/handlers/alias_handler_spec.rb +50 -0
  102. data/spec/handlers/attribute_handler_spec.rb +78 -0
  103. data/spec/handlers/base_spec.rb +165 -0
  104. data/spec/handlers/class_handler_spec.rb +68 -0
  105. data/spec/handlers/class_variable_handler_spec.rb +9 -0
  106. data/spec/handlers/constant_handler_spec.rb +13 -0
  107. data/spec/handlers/examples/alias_handler_001.rb.txt +24 -0
  108. data/spec/handlers/examples/attribute_handler_001.rb.txt +19 -0
  109. data/spec/handlers/examples/class_handler_001.rb.txt +39 -0
  110. data/spec/handlers/examples/class_variable_handler_001.rb.txt +9 -0
  111. data/spec/handlers/examples/constant_handler_001.rb.txt +10 -0
  112. data/spec/handlers/examples/exception_handler_001.rb.txt +42 -0
  113. data/spec/handlers/examples/method_handler_001.rb.txt +35 -0
  114. data/spec/handlers/examples/mixin_handler_001.rb.txt +12 -0
  115. data/spec/handlers/examples/module_handler_001.rb.txt +16 -0
  116. data/spec/handlers/examples/visibility_handler_001.rb.txt +20 -0
  117. data/spec/handlers/examples/yield_handler_001.rb.txt +55 -0
  118. data/spec/handlers/exception_handler_spec.rb +35 -0
  119. data/spec/handlers/method_handler_spec.rb +35 -0
  120. data/spec/handlers/mixin_handler_spec.rb +30 -0
  121. data/spec/handlers/module_handler_spec.rb +25 -0
  122. data/spec/handlers/spec_helper.rb +21 -0
  123. data/spec/handlers/visibility_handler_spec.rb +24 -0
  124. data/spec/handlers/yield_handler_spec.rb +51 -0
  125. data/spec/parser/examples/example1.rb.txt +8 -0
  126. data/spec/parser/examples/tag_handler_001.rb.txt +8 -0
  127. data/spec/parser/source_parser_spec.rb +43 -0
  128. data/spec/parser/tag_parsing_spec.rb +18 -0
  129. data/spec/parser/token_list_spec.rb +35 -0
  130. data/spec/registry_spec.rb +70 -0
  131. data/spec/serializers/file_system_serializer_spec.rb +91 -0
  132. data/spec/serializers/spec_helper.rb +2 -0
  133. data/spec/spec_helper.rb +77 -0
  134. data/templates/default/attributes/html/header.erb +35 -0
  135. data/templates/default/attributes/text/header.erb +10 -0
  136. data/templates/default/class/html/header.erb +4 -0
  137. data/templates/default/constants/html/constants.erb +9 -0
  138. data/templates/default/constants/html/header.erb +3 -0
  139. data/templates/default/constants/html/included.erb +9 -0
  140. data/templates/default/constants/html/inherited.erb +9 -0
  141. data/templates/default/constructor/html/header.erb +10 -0
  142. data/templates/default/deprecated/html/main.erb +4 -0
  143. data/templates/default/deprecated/text/main.erb +3 -0
  144. data/templates/default/docstring/html/main.erb +3 -0
  145. data/templates/default/docstring/text/main.erb +3 -0
  146. data/templates/default/fulldoc/html/all_methods.erb +25 -0
  147. data/templates/default/fulldoc/html/all_namespaces.erb +19 -0
  148. data/templates/default/fulldoc/html/app.js +18 -0
  149. data/templates/default/fulldoc/html/header.erb +15 -0
  150. data/templates/default/fulldoc/html/html_head.erb +3 -0
  151. data/templates/default/fulldoc/html/index.erb +18 -0
  152. data/templates/default/fulldoc/html/jquery.js +11 -0
  153. data/templates/default/fulldoc/html/readme.erb +15 -0
  154. data/templates/default/fulldoc/html/style.css +65 -0
  155. data/templates/default/fulldoc/html/syntax_highlight.css +21 -0
  156. data/templates/default/inheritance/html/header.erb +8 -0
  157. data/templates/default/inheritance/text/header.erb +3 -0
  158. data/templates/default/method/html/aliases.erb +6 -0
  159. data/templates/default/method/html/header.erb +3 -0
  160. data/templates/default/method/html/title.erb +3 -0
  161. data/templates/default/methoddetails/html/header.erb +8 -0
  162. data/templates/default/methoddetails/html/method_header.erb +3 -0
  163. data/templates/default/methodmissing/html/header.erb +12 -0
  164. data/templates/default/methodsignature/html/main.erb +8 -0
  165. data/templates/default/methodsignature/text/main.erb +5 -0
  166. data/templates/default/methodsummary/html/header.erb +5 -0
  167. data/templates/default/methodsummary/html/included.erb +9 -0
  168. data/templates/default/methodsummary/html/inherited.erb +9 -0
  169. data/templates/default/methodsummary/html/summary.erb +25 -0
  170. data/templates/default/methodsummary/text/header.erb +5 -0
  171. data/templates/default/methodsummary/text/included.erb +0 -0
  172. data/templates/default/methodsummary/text/inherited.erb +0 -0
  173. data/templates/default/methodsummary/text/summary.erb +3 -0
  174. data/templates/default/mixins/html/header.erb +4 -0
  175. data/templates/default/module/html/header.erb +4 -0
  176. data/templates/default/quickdoc/html/header.erb +15 -0
  177. data/templates/default/quickdoc/text/header.erb +12 -0
  178. data/templates/default/source/html/main.erb +15 -0
  179. data/templates/default/source/text/main.erb +4 -0
  180. data/templates/default/tags/html/header.erb +4 -0
  181. data/templates/default/tags/html/see.erb +13 -0
  182. data/templates/default/tags/html/tags.erb +20 -0
  183. data/templates/default/tags/text/header.erb +3 -0
  184. data/templates/default/tags/text/see.erb +5 -0
  185. data/templates/default/tags/text/tags.erb +7 -0
  186. data/templates/default/uml/dot/child.erb +1 -0
  187. data/templates/default/uml/dot/dependencies.erb +10 -0
  188. data/templates/default/uml/dot/header.erb +6 -0
  189. data/templates/default/uml/dot/info.erb +14 -0
  190. data/templates/default/uml/dot/subgraph.erb +6 -0
  191. data/templates/default/uml/dot/superclasses.erb +9 -0
  192. data/templates/default/uml/dot/unknown.erb +3 -0
  193. data/templates/default/uml/dot/unknown_child.erb +1 -0
  194. data/templates/default/visibilitygroup/html/header.erb +6 -0
  195. data/templates/javadoc/attributes/html/header.erb +16 -0
  196. data/templates/javadoc/class/html/header.erb +4 -0
  197. data/templates/javadoc/constants/html/constants.erb +9 -0
  198. data/templates/javadoc/constants/html/header.erb +3 -0
  199. data/templates/javadoc/constants/html/included.erb +12 -0
  200. data/templates/javadoc/constants/html/inherited.erb +12 -0
  201. data/templates/javadoc/constructor/html/header.erb +10 -0
  202. data/templates/javadoc/deprecated/html/main.erb +0 -0
  203. data/templates/javadoc/docstring/html/main.erb +6 -0
  204. data/templates/javadoc/fulldoc/html/all_methods.erb +25 -0
  205. data/templates/javadoc/fulldoc/html/all_namespaces.erb +19 -0
  206. data/templates/javadoc/fulldoc/html/app.js +18 -0
  207. data/templates/javadoc/fulldoc/html/header.erb +15 -0
  208. data/templates/javadoc/fulldoc/html/html_head.erb +3 -0
  209. data/templates/javadoc/fulldoc/html/index.erb +18 -0
  210. data/templates/javadoc/fulldoc/html/jquery.js +11 -0
  211. data/templates/javadoc/fulldoc/html/readme.erb +15 -0
  212. data/templates/javadoc/fulldoc/html/style.css +22 -0
  213. data/templates/javadoc/fulldoc/html/syntax_highlight.css +21 -0
  214. data/templates/javadoc/inheritance/html/header.erb +6 -0
  215. data/templates/javadoc/method/html/aliases.erb +6 -0
  216. data/templates/javadoc/method/html/header.erb +4 -0
  217. data/templates/javadoc/method/html/title.erb +4 -0
  218. data/templates/javadoc/methoddetails/html/header.erb +8 -0
  219. data/templates/javadoc/methoddetails/html/method_header.erb +0 -0
  220. data/templates/javadoc/methodmissing/html/header.erb +12 -0
  221. data/templates/javadoc/methodsignature/html/main.erb +8 -0
  222. data/templates/javadoc/methodsummary/html/header.erb +5 -0
  223. data/templates/javadoc/methodsummary/html/included.erb +12 -0
  224. data/templates/javadoc/methodsummary/html/inherited.erb +12 -0
  225. data/templates/javadoc/methodsummary/html/summary.erb +25 -0
  226. data/templates/javadoc/mixins/html/header.erb +5 -0
  227. data/templates/javadoc/module/html/header.erb +4 -0
  228. data/templates/javadoc/source/html/main.erb +15 -0
  229. data/templates/javadoc/tags/html/header.erb +5 -0
  230. data/templates/javadoc/tags/html/see.erb +8 -0
  231. data/templates/javadoc/tags/html/tags.erb +19 -0
  232. data/templates/javadoc/visibilitygroup/html/header.erb +5 -0
  233. metadata +352 -50
  234. data/README.pdf +0 -0
  235. data/lib/code_object.rb +0 -337
  236. data/lib/extra.rb +0 -8
  237. data/lib/formatter.rb +0 -90
  238. data/lib/handlers/all_handlers.rb +0 -2
  239. data/lib/handlers/attribute_handler.rb +0 -51
  240. data/lib/handlers/class_handler.rb +0 -30
  241. data/lib/handlers/class_variable_handler.rb +0 -9
  242. data/lib/handlers/code_object_handler.rb +0 -104
  243. data/lib/handlers/constant_handler.rb +0 -11
  244. data/lib/handlers/exception_handler.rb +0 -20
  245. data/lib/handlers/method_handler.rb +0 -28
  246. data/lib/handlers/mixin_handler.rb +0 -15
  247. data/lib/handlers/module_handler.rb +0 -9
  248. data/lib/handlers/visibility_handler.rb +0 -7
  249. data/lib/handlers/yield_handler.rb +0 -33
  250. data/lib/logger.rb +0 -19
  251. data/lib/namespace.rb +0 -98
  252. data/lib/quick_doc.rb +0 -104
  253. data/lib/ruby_lex.rb +0 -1321
  254. data/lib/source_parser.rb +0 -253
  255. data/lib/tag_library.rb +0 -175
  256. data/lib/tag_type.rb +0 -155
  257. data/templates/default/html/_fulldoc.erb +0 -64
  258. data/templates/default/html/class.erb +0 -226
  259. data/templates/default/html/method.erb +0 -20
  260. data/templates/default/html/module.erb +0 -126
  261. data/test/fixtures/docstring.txt +0 -23
  262. data/test/fixtures/docstring2.txt +0 -4
  263. data/test/test_code_object.rb +0 -66
  264. data/test/test_namespace.rb +0 -10
@@ -0,0 +1,70 @@
1
+ require File.join(File.dirname(__FILE__), "spec_helper")
2
+ include CodeObjects
3
+
4
+ describe YARD::Registry do
5
+ before { Registry.clear }
6
+ it "should have an empty path for root" do
7
+ Registry.root.path.should == ""
8
+ end
9
+
10
+ it "should #resolve any existing namespace" do
11
+ o1 = ModuleObject.new(:root, :A)
12
+ o2 = ModuleObject.new(o1, :B)
13
+ o3 = ModuleObject.new(o2, :C)
14
+ Registry.resolve(o1, "B::C").should == o3
15
+ Registry.resolve(:root, "A::B::C")
16
+ end
17
+
18
+ it "should resolve an object in the root namespace when prefixed with ::" do
19
+ o1 = ModuleObject.new(:root, :A)
20
+ o2 = ModuleObject.new(o1, :B)
21
+ o3 = ModuleObject.new(o2, :C)
22
+ Registry.resolve(o3, "::A").should == o1
23
+
24
+ Registry.resolve(o3, "::String", true).should == P(:String)
25
+ end
26
+
27
+ it "should resolve instance methods with # prefix" do
28
+ o1 = ModuleObject.new(:root, :A)
29
+ o2 = ModuleObject.new(o1, :B)
30
+ o3 = ModuleObject.new(o2, :C)
31
+ o4 = MethodObject.new(o3, :methname)
32
+ Registry.resolve(o1, "B::C#methname").should == o4
33
+ Registry.resolve(o2, "C#methname").should == o4
34
+ Registry.resolve(o3, "#methname").should == o4
35
+ end
36
+
37
+ it "should resolve instance methods in the root without # prefix" do
38
+ o = MethodObject.new(:root, :methname)
39
+ Registry.resolve(:root, 'methname').should == o
40
+ end
41
+
42
+ it "should allow symbols as object type in #all" do
43
+ ModuleObject.new(:root, :A)
44
+ o1 = ClassObject.new(:root, :B)
45
+ o2 = MethodObject.new(:root, :testing)
46
+ r = Registry.all(:method, :class)
47
+ r.should include(o1, o2)
48
+ end
49
+
50
+ it "should allow code object classes in #all" do
51
+ o1 = ModuleObject.new(:root, :A)
52
+ o2 = ClassObject.new(:root, :B)
53
+ MethodObject.new(:root, :testing)
54
+ r = Registry.all(CodeObjects::NamespaceObject)
55
+ r.should include(o1, o2)
56
+ end
57
+
58
+ it "should allow #all to omit list" do
59
+ o1 = ModuleObject.new(:root, :A)
60
+ o2 = ClassObject.new(:root, :B)
61
+ r = Registry.all
62
+ r.should include(o1, o2)
63
+ end
64
+
65
+ it "should respond to #paths" do
66
+ o1 = ModuleObject.new(:root, :A)
67
+ o2 = ClassObject.new(:root, :B)
68
+ Registry.paths.should include('A', 'B')
69
+ end
70
+ end
@@ -0,0 +1,91 @@
1
+ require File.join(File.dirname(__FILE__), "spec_helper")
2
+
3
+ require 'stringio'
4
+
5
+ describe YARD::Serializers::FileSystemSerializer do
6
+ before do
7
+ FileUtils.stub!(:mkdir_p)
8
+ File.stub!(:open)
9
+ end
10
+
11
+ it "should default the base path to the 'doc/'" do
12
+ obj = Serializers::FileSystemSerializer.new
13
+ obj.basepath.should == 'doc'
14
+ end
15
+
16
+ it "should default the file extension to .html" do
17
+ obj = Serializers::FileSystemSerializer.new
18
+ obj.extension.should == "html"
19
+ end
20
+
21
+ it "should allow no extension to be used" do
22
+ obj = Serializers::FileSystemSerializer.new :extension => nil
23
+ obj.serialized_path(Registry.root).should == 'root'
24
+ end
25
+
26
+ it "should serialize to the correct path" do
27
+ yard = CodeObjects::ClassObject.new(nil, :FooBar)
28
+ meth = CodeObjects::MethodObject.new(yard, :baz, :class)
29
+ meth2 = CodeObjects::MethodObject.new(yard, :baz)
30
+
31
+ { 'foo/FooBar/baz_c.txt' => meth,
32
+ 'foo/FooBar/baz_i.txt' => meth2,
33
+ 'foo/FooBar.txt' => yard }.each do |path, obj|
34
+ io = StringIO.new
35
+ File.should_receive(:open).with(path, 'w').and_yield(io)
36
+ io.should_receive(:write).with("data")
37
+
38
+ s = Serializers::FileSystemSerializer.new(:basepath => 'foo', :extension => 'txt')
39
+ s.serialize(obj, "data")
40
+ end
41
+ end
42
+
43
+ it "should return serialized_path for a String" do
44
+ s = Serializers::FileSystemSerializer.new(:basepath => 'foo', :extension => 'txt')
45
+ s.serialized_path('test.txt').should == 'test.txt'
46
+ end
47
+
48
+ it "should remove special chars from path" do
49
+ m = CodeObjects::MethodObject.new(nil, 'a')
50
+ s = Serializers::FileSystemSerializer.new
51
+
52
+ { :/ => '_2F_i.html',
53
+ :gsub! => 'gsub_21_i.html',
54
+ :ask? => 'ask_3F_i.html',
55
+ :=== => '_3D_3D_3D_i.html',
56
+ :+ => '_2B_i.html',
57
+ :- => '-_i.html',
58
+ :[]= => '_5B_5D_3D_i.html',
59
+ :<< => '_3C_3C_i.html',
60
+ :>= => '_3E_3D_i.html',
61
+ :` => '_60_i.html',
62
+ :& => '_26_i.html',
63
+ :* => '_2A_i.html',
64
+ :| => '_7C_i.html',
65
+ :/ => '_2F_i.html',
66
+ :=~ => '_3D_7E_i.html'
67
+ }.each do |meth, value|
68
+ m.stub!(:name).and_return(meth)
69
+ s.serialized_path(m).should == value
70
+ end
71
+ end
72
+
73
+ it "should differentiate instance and class methods from serialized path" do
74
+ s = Serializers::FileSystemSerializer.new
75
+ m1 = CodeObjects::MethodObject.new(nil, 'meth')
76
+ m2 = CodeObjects::MethodObject.new(nil, 'meth', :class)
77
+ s.serialized_path(m1).should_not == s.serialized_path(m2)
78
+ end
79
+
80
+ it "should guarantee the directory exists" do
81
+ o1 = CodeObjects::ClassObject.new(nil, :Really)
82
+ o2 = CodeObjects::ClassObject.new(o1, :Long)
83
+ o3 = CodeObjects::ClassObject.new(o2, :PathName)
84
+ obj = CodeObjects::MethodObject.new(o3, :foo)
85
+
86
+ FileUtils.should_receive(:mkdir_p).once.with('doc/Really/Long/PathName')
87
+
88
+ s = Serializers::FileSystemSerializer.new
89
+ s.serialize(obj, "data")
90
+ end
91
+ end
@@ -0,0 +1,2 @@
1
+ require File.join(File.dirname(__FILE__), "..", "spec_helper")
2
+ include YARD
@@ -0,0 +1,77 @@
1
+ require "rubygems"
2
+ require "spec"
3
+
4
+ require File.join(File.dirname(__FILE__), '..', 'lib', 'yard')
5
+
6
+ def parse_file(file, thisfile = __FILE__)
7
+ Registry.clear
8
+ path = File.join(File.dirname(thisfile), 'examples', file.to_s + '.rb.txt')
9
+ p = YARD::Parser::SourceParser.new
10
+ p.parse(path)
11
+ p
12
+ end
13
+
14
+ def described_in_docs(klass, meth, file = nil)
15
+ YARD::Tags::Library.define_tag "RSpec Specification", :it, :with_raw_title_and_text
16
+
17
+ # Parse the file (could be multiple files)
18
+ if file
19
+ filename = File.join(YARD::ROOT, file)
20
+ YARD::Parser::SourceParser.new.parse(filename)
21
+ else
22
+ $".find_all {|p| p.include? klass.class_name.underscore }.each do |filename|
23
+ next unless File.exists? filename
24
+ YARD::Parser::SourceParser.new.parse(filename)
25
+ end
26
+ end
27
+
28
+ # Get the object
29
+ objname = klass.name + (meth[0,1] == '#' ? meth : '::' + meth)
30
+ obj = Registry.at(objname)
31
+ raise "Cannot find object #{objname} described by spec." unless obj
32
+ raise "#{obj.path} has no @it tags to spec." unless obj.has_tag? :it
33
+
34
+ # Run examples
35
+ describe(klass, meth) do
36
+ obj.tags(:it).each do |it|
37
+ path = File.relative_path(YARD::ROOT, obj.file)
38
+ it(it.name + " (from #{path}:#{obj.line})") do
39
+ begin
40
+ eval(it.text)
41
+ rescue => e
42
+ e.set_backtrace(["#{path}:#{obj.line}:in @it tag specification"])
43
+ raise e
44
+ end
45
+ end
46
+ end
47
+ end
48
+ end
49
+
50
+ def docspec(objname = self.class.description, klass = self.class.described_type)
51
+ # Parse the file (could be multiple files)
52
+ $".find_all {|p| p.include? klass.class_name.underscore }.each do |filename|
53
+ filename = File.join(YARD::ROOT, filename)
54
+ next unless File.exists? filename
55
+ YARD::Parser::SourceParser.new.parse(filename)
56
+ end
57
+
58
+ # Get the object
59
+ objname = klass.name + objname if objname =~ /^[^A-Z]/
60
+ obj = Registry.at(objname)
61
+ raise "Cannot find object #{objname} described by spec." unless obj
62
+ raise "#{obj.path} has no @example tags to spec." unless obj.has_tag? :example
63
+
64
+ # Run examples
65
+ obj.tags(:example).each do |exs|
66
+ exs.text.split(/\n/).each do |ex|
67
+ begin
68
+ hash = eval("{ #{ex} }")
69
+ hash.keys.first.should == hash.values.first
70
+ rescue => e
71
+ raise e, "#{e.message}\nInvalid spec example in #{objname}:\n\n\t#{ex}\n"
72
+ end
73
+ end
74
+ end
75
+ end
76
+
77
+ include YARD
@@ -0,0 +1,35 @@
1
+ <div class="section <%= generator_name %>">
2
+ <h1>Attributes</h1>
3
+
4
+ <% ['class', 'instance'].select {|s| object.attributes[s].length > 0 }.each do |scope| %>
5
+ <div class="<%= scope %>">
6
+ <h2><%= scope.capitalize %> Attributes</h2>
7
+ <table>
8
+ <% object.attributes[scope].sort_by {|o| o.to_s.downcase }.each do |name, rw| %>
9
+ <tr>
10
+ <th class="name"><%= h name %></td>
11
+ <td class="readwrite">
12
+ [<%= ['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
14
+ }.compact.join %>]
15
+ </td>
16
+ <td class="visibility">
17
+ <%= rw.values.compact.first.visibility %>
18
+ </td>
19
+ <td class="docstring">
20
+ <%= htmlify rw.values.compact.first.short_docstring %>
21
+ <% if rw[:read] && rw[:read].tag(:return) && rw[:read].tag(:return).types %>
22
+ <p class='returns'>
23
+ Returns:
24
+ <span class='return_types'>
25
+ <%= format_return_types rw[:read] %>
26
+ </span>
27
+ </p>
28
+ <% end %>
29
+ </td>
30
+ </tr>
31
+ <% end %>
32
+ </table>
33
+ </div>
34
+ <% end %>
35
+ </div>
@@ -0,0 +1,10 @@
1
+
2
+
3
+ > Attributes:
4
+ -------------
5
+ <% ['class', 'instance'].select {|s| object.attributes[s].length > 0 }.each do |scope| %>
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 %>)
8
+ <% end %>
9
+ <% end %>
10
+
@@ -0,0 +1,4 @@
1
+ <div class="section class <%= object.path.gsub(/::|\.|#/, '_') %>">
2
+ <h1 class="title"><%= h format_object_type(object) %>: <%= h object.path %></h1>
3
+ <%= yield object %>
4
+ </div>
@@ -0,0 +1,9 @@
1
+ <div class="thisclass">
2
+ <h1>Constants</h1>
3
+ <dl>
4
+ <% object.constants(:included => false, :inherited => false).sort_by {|c| c.name.to_s.downcase }.each do |const| %>
5
+ <dt id="<%= anchor_for(const) %>"><%= h const.name %></dt>
6
+ <dd><%= h const.source.gsub(/\A.+?\=\s*/, '') %></dd>
7
+ <% end %>
8
+ </dl>
9
+ </div>
@@ -0,0 +1,3 @@
1
+ <div class="section <%= generator_name %>">
2
+ <%= yield object %>
3
+ </div>
@@ -0,0 +1,9 @@
1
+ <div class="included">
2
+ <% included_constants_by_module do |klass, consts| %>
3
+ <div>
4
+ <h1>Constants Included from <%= linkify klass %></h1>
5
+ <p><%= format_object_name_list consts %></p>
6
+ </div>
7
+ <% end %>
8
+ </div>
9
+ <div class="clear"></div>
@@ -0,0 +1,9 @@
1
+ <div class="inherited">
2
+ <% inherited_constants_by_class do |klass, consts| %>
3
+ <div>
4
+ <h1>Constants Inherited from <%= linkify klass %></h1>
5
+ <p><%= format_object_name_list consts %></p>
6
+ </div>
7
+ <% end %>
8
+ </div>
9
+ <div class="clear"></div>
@@ -0,0 +1,10 @@
1
+ <div class="section <%= generator_name %>">
2
+ <h1>Constructor Summary</h1>
3
+ <% if constructor_method_inherited? %>
4
+ <p class="inherited_msg">
5
+ This class inherits a constructor from <%= linkify constructor_method, constructor_method.namespace.path %>.
6
+ </p>
7
+ <% else %>
8
+ <%= yield constructor_method %>
9
+ <% end %>
10
+ </div>
@@ -0,0 +1,4 @@
1
+ <p class="section <%= generator_name %>">
2
+ <strong>Deprecated.</strong> <em><%= htmlify object.tag(:deprecated).text %></em>
3
+ </p>
4
+
@@ -0,0 +1,3 @@
1
+
2
+ !! This <%= object.type %> is deprecated<%= object.tag(:deprecated).text ? ": " + object.tag(:deprecated).text : "" %>.
3
+
@@ -0,0 +1,3 @@
1
+ <div class="section <%= generator_name %>">
2
+ <%= htmlify object.docstring %>
3
+ </div>
@@ -0,0 +1,3 @@
1
+ <%= object.docstring %>
2
+
3
+
@@ -0,0 +1,25 @@
1
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
2
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
3
+ <html>
4
+ <head>
5
+ <%= render :html_head %>
6
+ <title>All Modules / Classes</title>
7
+ <base target="main" />
8
+ </head>
9
+ <body>
10
+ <div id="nav" class="methods">
11
+ <h1>Method List</h1>
12
+ <ul>
13
+ <% for obj in YARD::Registry.all(:method).sort_by {|o| o.path } %>
14
+ <% next if obj.namespace == Registry.root %>
15
+ <li nowrap>
16
+ <%= linkify(obj, (obj.scope == :class ? '' : '#') + obj.name.to_s) %>
17
+ <% if obj.namespace != Registry.root %>
18
+ <em>(<%= obj.namespace.type %> <%= obj.namespace.name %>)</em>
19
+ <% end %>
20
+ </li>
21
+ <% end %>
22
+ </ul>
23
+ </div>
24
+ </body>
25
+ </html>
@@ -0,0 +1,19 @@
1
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
2
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
3
+ <html>
4
+ <head>
5
+ <%= render :html_head %>
6
+ <title>All Modules / Classes</title>
7
+ <base target="main" />
8
+ </head>
9
+ <body>
10
+ <div id="nav" class="namespaces">
11
+ <h1>All Modules / Classes</h1>
12
+ <ul>
13
+ <% for obj in YARD::Registry.all(:module, :class).sort_by {|o| o.path } %>
14
+ <li><%= linkify(obj) %> <em>(<%= obj.type %>)</em></li>
15
+ <% end %>
16
+ </ul>
17
+ </div>
18
+ </body>
19
+ </html>
@@ -0,0 +1,18 @@
1
+ $(document).ready(function() {
2
+ // Set the title of this page as the index title
3
+ if (parent && parent.document) {
4
+ $('html head title', parent.document).text($('html head title').text());
5
+ }
6
+
7
+ // Setup the view source links
8
+ $(".section.source a.source_link").toggle(
9
+ function() {
10
+ $(this).text('Hide source');
11
+ $(this).parent().next().show();
12
+ },
13
+ function() {
14
+ $(this).text('View source');
15
+ $(this).parent().next().hide();
16
+ }
17
+ );
18
+ });
@@ -0,0 +1,15 @@
1
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
2
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
3
+ <html>
4
+ <head>
5
+ <%= render :html_head %>
6
+ <script src="<%= url_for(js_file) %>" type="text/javascript" charset="utf-8"></script>
7
+ <script src="<%= url_for(js_app_file) %>" type="text/javascript" charset="utf-8"></script>
8
+ <title><%= h format_object_type(object) %>: <%= h object.path %></title>
9
+ </head>
10
+ <body>
11
+ <div id="content">
12
+ <%= yield object %>
13
+ </div>
14
+ </body>
15
+ </html>