yard 0.6.8 → 0.7.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.

Files changed (224) hide show
  1. data/.yardopts +1 -0
  2. data/ChangeLog +723 -0
  3. data/README.md +16 -6
  4. data/docs/CodeObjects.md +10 -16
  5. data/docs/GettingStarted.md +232 -32
  6. data/docs/Glossary.md +1 -2
  7. data/docs/Handlers.md +10 -16
  8. data/docs/Overview.md +14 -13
  9. data/docs/Parser.md +13 -22
  10. data/docs/Tags.md +209 -16
  11. data/docs/Templates.md +237 -26
  12. data/docs/WhatsNew.md +178 -2
  13. data/lib/yard.rb +13 -10
  14. data/lib/yard/autoload.rb +22 -18
  15. data/lib/yard/cli/command.rb +13 -12
  16. data/lib/yard/cli/command_parser.rb +20 -19
  17. data/lib/yard/cli/config.rb +19 -19
  18. data/lib/yard/cli/diff.rb +46 -21
  19. data/lib/yard/cli/gems.rb +11 -11
  20. data/lib/yard/cli/graph.rb +13 -13
  21. data/lib/yard/cli/help.rb +1 -1
  22. data/lib/yard/cli/list.rb +22 -0
  23. data/lib/yard/cli/server.rb +17 -17
  24. data/lib/yard/cli/stats.rb +32 -32
  25. data/lib/yard/cli/yardoc.rb +181 -135
  26. data/lib/yard/cli/yri.rb +29 -29
  27. data/lib/yard/code_objects/base.rb +101 -101
  28. data/lib/yard/code_objects/class_object.rb +20 -20
  29. data/lib/yard/code_objects/constant_object.rb +1 -1
  30. data/lib/yard/code_objects/extended_method_object.rb +5 -5
  31. data/lib/yard/code_objects/extra_file_object.rb +89 -0
  32. data/lib/yard/code_objects/macro_object.rb +215 -0
  33. data/lib/yard/code_objects/method_object.rb +30 -30
  34. data/lib/yard/code_objects/module_object.rb +1 -1
  35. data/lib/yard/code_objects/namespace_object.rb +39 -39
  36. data/lib/yard/code_objects/proxy.rb +38 -38
  37. data/lib/yard/code_objects/root_object.rb +1 -1
  38. data/lib/yard/config.rb +40 -40
  39. data/lib/yard/core_ext/array.rb +2 -2
  40. data/lib/yard/core_ext/file.rb +11 -11
  41. data/lib/yard/core_ext/insertion.rb +10 -10
  42. data/lib/yard/core_ext/module.rb +2 -2
  43. data/lib/yard/core_ext/string.rb +2 -2
  44. data/lib/yard/core_ext/symbol_hash.rb +14 -14
  45. data/lib/yard/docstring.rb +122 -54
  46. data/lib/yard/globals.rb +2 -2
  47. data/lib/yard/handlers/base.rb +216 -127
  48. data/lib/yard/handlers/processor.rb +65 -27
  49. data/lib/yard/handlers/ruby/alias_handler.rb +6 -3
  50. data/lib/yard/handlers/ruby/attribute_handler.rb +7 -6
  51. data/lib/yard/handlers/ruby/base.rb +50 -31
  52. data/lib/yard/handlers/ruby/class_condition_handler.rb +11 -11
  53. data/lib/yard/handlers/ruby/class_handler.rb +10 -10
  54. data/lib/yard/handlers/ruby/class_variable_handler.rb +3 -3
  55. data/lib/yard/handlers/ruby/constant_handler.rb +7 -7
  56. data/lib/yard/handlers/ruby/exception_handler.rb +2 -2
  57. data/lib/yard/handlers/ruby/extend_handler.rb +1 -1
  58. data/lib/yard/handlers/ruby/legacy/alias_handler.rb +8 -5
  59. data/lib/yard/handlers/ruby/legacy/attribute_handler.rb +6 -5
  60. data/lib/yard/handlers/ruby/legacy/base.rb +42 -27
  61. data/lib/yard/handlers/ruby/legacy/class_condition_handler.rb +9 -9
  62. data/lib/yard/handlers/ruby/legacy/class_handler.rb +13 -12
  63. data/lib/yard/handlers/ruby/legacy/class_variable_handler.rb +3 -6
  64. data/lib/yard/handlers/ruby/legacy/constant_handler.rb +5 -8
  65. data/lib/yard/handlers/ruby/legacy/exception_handler.rb +1 -1
  66. data/lib/yard/handlers/ruby/legacy/extend_handler.rb +1 -0
  67. data/lib/yard/handlers/ruby/legacy/macro_handler.rb +40 -0
  68. data/lib/yard/handlers/ruby/legacy/method_handler.rb +10 -10
  69. data/lib/yard/handlers/ruby/legacy/mixin_handler.rb +4 -3
  70. data/lib/yard/handlers/ruby/legacy/module_handler.rb +2 -1
  71. data/lib/yard/handlers/ruby/legacy/private_constant_handler.rb +4 -4
  72. data/lib/yard/handlers/ruby/legacy/visibility_handler.rb +2 -1
  73. data/lib/yard/handlers/ruby/legacy/yield_handler.rb +3 -3
  74. data/lib/yard/handlers/ruby/macro_handler.rb +41 -0
  75. data/lib/yard/handlers/ruby/macro_handler_methods.rb +130 -0
  76. data/lib/yard/handlers/ruby/method_condition_handler.rb +1 -1
  77. data/lib/yard/handlers/ruby/method_handler.rb +13 -13
  78. data/lib/yard/handlers/ruby/mixin_handler.rb +4 -4
  79. data/lib/yard/handlers/ruby/module_handler.rb +2 -1
  80. data/lib/yard/handlers/ruby/private_constant_handler.rb +4 -4
  81. data/lib/yard/handlers/ruby/struct_handler_methods.rb +11 -11
  82. data/lib/yard/handlers/ruby/visibility_handler.rb +1 -1
  83. data/lib/yard/handlers/ruby/yield_handler.rb +5 -5
  84. data/lib/yard/logging.rb +11 -11
  85. data/lib/yard/parser/base.rb +8 -8
  86. data/lib/yard/parser/c_parser.rb +42 -33
  87. data/lib/yard/parser/ruby/ast_node.rb +62 -61
  88. data/lib/yard/parser/ruby/legacy/ruby_lex.rb +66 -66
  89. data/lib/yard/parser/ruby/legacy/ruby_parser.rb +4 -4
  90. data/lib/yard/parser/ruby/legacy/statement.rb +11 -11
  91. data/lib/yard/parser/ruby/legacy/statement_list.rb +15 -15
  92. data/lib/yard/parser/ruby/legacy/token_list.rb +9 -9
  93. data/lib/yard/parser/ruby/ruby_parser.rb +51 -37
  94. data/lib/yard/parser/source_parser.rb +271 -46
  95. data/lib/yard/rake/yardoc_task.rb +18 -17
  96. data/lib/yard/registry.rb +64 -64
  97. data/lib/yard/registry_store.rb +34 -34
  98. data/lib/yard/rubygems/backports.rb +8 -0
  99. data/lib/yard/rubygems/backports/LICENSE.txt +57 -0
  100. data/lib/yard/rubygems/backports/MIT.txt +20 -0
  101. data/lib/yard/rubygems/backports/gem.rb +8 -0
  102. data/lib/yard/rubygems/backports/source_index.rb +353 -0
  103. data/lib/yard/rubygems/specification.rb +2 -2
  104. data/lib/yard/serializers/base.rb +20 -20
  105. data/lib/yard/serializers/file_system_serializer.rb +28 -24
  106. data/lib/yard/serializers/process_serializer.rb +3 -3
  107. data/lib/yard/serializers/stdout_serializer.rb +6 -6
  108. data/lib/yard/serializers/yardoc_serializer.rb +17 -17
  109. data/lib/yard/server/adapter.rb +12 -12
  110. data/lib/yard/server/commands/base.rb +26 -26
  111. data/lib/yard/server/commands/display_file_command.rb +3 -2
  112. data/lib/yard/server/commands/display_object_command.rb +5 -5
  113. data/lib/yard/server/commands/frames_command.rb +1 -1
  114. data/lib/yard/server/commands/library_command.rb +7 -7
  115. data/lib/yard/server/commands/library_index_command.rb +2 -2
  116. data/lib/yard/server/commands/list_command.rb +8 -8
  117. data/lib/yard/server/commands/search_command.rb +8 -8
  118. data/lib/yard/server/commands/static_file_command.rb +3 -3
  119. data/lib/yard/server/doc_server_helper.rb +6 -3
  120. data/lib/yard/server/doc_server_serializer.rb +1 -1
  121. data/lib/yard/server/library_version.rb +45 -45
  122. data/lib/yard/server/rack_adapter.rb +10 -10
  123. data/lib/yard/server/router.rb +28 -28
  124. data/lib/yard/server/static_caching.rb +5 -5
  125. data/lib/yard/server/templates/default/fulldoc/html/css/custom.css +3 -3
  126. data/lib/yard/server/templates/default/fulldoc/html/js/live.js +1 -1
  127. data/lib/yard/server/templates/default/layout/html/breadcrumb.erb +2 -2
  128. data/lib/yard/server/templates/default/layout/html/headers.erb +13 -8
  129. data/lib/yard/server/templates/default/layout/html/setup.rb +7 -0
  130. data/lib/yard/server/templates/doc_server/full_list/html/full_list.erb +2 -2
  131. data/lib/yard/server/templates/doc_server/full_list/html/setup.rb +14 -4
  132. data/lib/yard/server/templates/doc_server/library_list/html/contents.erb +2 -2
  133. data/lib/yard/server/templates/doc_server/library_list/html/headers.erb +2 -2
  134. data/lib/yard/server/templates/doc_server/processing/html/processing.erb +1 -1
  135. data/lib/yard/server/templates/doc_server/search/html/search.erb +1 -1
  136. data/lib/yard/server/webrick_adapter.rb +2 -2
  137. data/lib/yard/tags/default_factory.rb +19 -19
  138. data/lib/yard/tags/default_tag.rb +1 -1
  139. data/lib/yard/tags/library.rb +68 -63
  140. data/lib/yard/tags/option_tag.rb +1 -1
  141. data/lib/yard/tags/overload_tag.rb +9 -9
  142. data/lib/yard/tags/ref_tag_list.rb +2 -2
  143. data/lib/yard/tags/tag.rb +7 -7
  144. data/lib/yard/templates/engine.rb +31 -31
  145. data/lib/yard/templates/erb_cache.rb +1 -1
  146. data/lib/yard/templates/helpers/base_helper.rb +46 -32
  147. data/lib/yard/templates/helpers/filter_helper.rb +2 -2
  148. data/lib/yard/templates/helpers/html_helper.rb +120 -81
  149. data/lib/yard/templates/helpers/html_syntax_highlight_helper.rb +4 -4
  150. data/lib/yard/templates/helpers/markup/rdoc_markup.rb +9 -9
  151. data/lib/yard/templates/helpers/markup_helper.rb +37 -30
  152. data/lib/yard/templates/helpers/method_helper.rb +7 -7
  153. data/lib/yard/templates/helpers/text_helper.rb +7 -7
  154. data/lib/yard/templates/helpers/uml_helper.rb +3 -3
  155. data/lib/yard/templates/section.rb +14 -14
  156. data/lib/yard/templates/template.rb +54 -54
  157. data/lib/yard/verifier.rb +27 -27
  158. data/spec/cli/list_spec.rb +8 -0
  159. data/spec/cli/yardoc_spec.rb +58 -10
  160. data/spec/code_objects/extra_file_object_spec.rb +132 -0
  161. data/spec/code_objects/macro_object_spec.rb +154 -0
  162. data/spec/docstring_spec.rb +90 -0
  163. data/spec/handlers/base_spec.rb +22 -0
  164. data/spec/handlers/examples/macro_handler_001.rb.txt +73 -0
  165. data/spec/handlers/examples/method_handler_001.rb.txt +17 -0
  166. data/spec/handlers/macro_handler_spec.rb +140 -0
  167. data/spec/handlers/method_handler_spec.rb +28 -0
  168. data/spec/handlers/processor_spec.rb +4 -0
  169. data/spec/handlers/spec_helper.rb +1 -1
  170. data/spec/parser/c_parser_spec.rb +47 -16
  171. data/spec/parser/examples/extrafile.c.txt +8 -0
  172. data/spec/parser/examples/multifile.c.txt +6 -0
  173. data/spec/parser/ruby/ruby_parser_spec.rb +5 -0
  174. data/spec/parser/source_parser_spec.rb +235 -0
  175. data/spec/rake/yardoc_task_spec.rb +22 -17
  176. data/spec/serializers/file_system_serializer_spec.rb +6 -0
  177. data/spec/server/commands/library_command_spec.rb +39 -0
  178. data/spec/spec_helper.rb +14 -0
  179. data/spec/templates/examples/method001.html +6 -6
  180. data/spec/templates/examples/method002.html +4 -4
  181. data/spec/templates/examples/method003.html +10 -10
  182. data/spec/templates/examples/method005.html +2 -2
  183. data/spec/templates/examples/module001.dot +2 -0
  184. data/spec/templates/examples/module001.html +76 -37
  185. data/spec/templates/examples/module001.txt +1 -1
  186. data/spec/templates/helpers/base_helper_spec.rb +7 -2
  187. data/spec/templates/helpers/html_helper_spec.rb +49 -5
  188. data/spec/templates/helpers/markup_helper_spec.rb +9 -8
  189. data/spec/templates/module_spec.rb +7 -0
  190. data/spec/templates/onefile_spec.rb +47 -0
  191. data/templates/default/fulldoc/html/css/style.css +7 -5
  192. data/templates/default/fulldoc/html/full_list.erb +13 -10
  193. data/templates/default/fulldoc/html/full_list_files.erb +1 -1
  194. data/templates/default/fulldoc/html/js/app.js +16 -14
  195. data/templates/default/fulldoc/html/js/full_list.js +7 -6
  196. data/templates/default/fulldoc/html/setup.rb +78 -17
  197. data/templates/default/layout/html/files.erb +1 -1
  198. data/templates/default/layout/html/headers.erb +11 -7
  199. data/templates/default/layout/html/search.erb +4 -4
  200. data/templates/default/layout/html/setup.rb +28 -8
  201. data/templates/default/module/html/inherited_attributes.erb +17 -0
  202. data/templates/default/module/setup.rb +1 -1
  203. data/templates/default/onefile/html/files.erb +2 -2
  204. data/templates/default/onefile/html/layout.erb +1 -1
  205. data/templates/default/onefile/html/setup.rb +7 -5
  206. data/templates/default/tags/html/option.erb +1 -1
  207. data/templates/default/tags/html/tag.erb +3 -3
  208. data/templates/guide/class/html/setup.rb +1 -0
  209. data/templates/guide/docstring/html/setup.rb +1 -0
  210. data/templates/guide/fulldoc/html/css/style.css +91 -0
  211. data/templates/guide/fulldoc/html/js/app.js +33 -0
  212. data/templates/guide/fulldoc/html/setup.rb +54 -0
  213. data/templates/guide/layout/html/layout.erb +81 -0
  214. data/templates/guide/layout/html/setup.rb +24 -0
  215. data/templates/guide/method/html/header.erb +18 -0
  216. data/templates/guide/method/html/setup.rb +21 -0
  217. data/templates/guide/module/html/header.erb +7 -0
  218. data/templates/guide/module/html/method_list.erb +5 -0
  219. data/templates/guide/module/html/setup.rb +26 -0
  220. data/templates/guide/tags/html/setup.rb +8 -0
  221. metadata +40 -7
  222. data/lib/yard/handlers/ruby/legacy/process_handler.rb +0 -13
  223. data/lib/yard/handlers/ruby/process_handler.rb +0 -18
  224. data/spec/handlers/process_handler_spec.rb +0 -17
@@ -2,31 +2,31 @@ module YARD::CodeObjects
2
2
  # Represents a Ruby method in source
3
3
  class MethodObject < Base
4
4
  # The scope of the method (+:class+ or +:instance+)
5
- #
5
+ #
6
6
  # @return [Symbol] the scope
7
7
  attr_reader :scope
8
-
8
+
9
9
  # Whether the object is explicitly defined in source or whether it was
10
10
  # inferred by a handler. For instance, attribute methods are generally
11
- # inferred and therefore not explicitly defined in source.
12
- #
11
+ # inferred and therefore not explicitly defined in source.
12
+ #
13
13
  # @return [Boolean] whether the object is explicitly defined in source.
14
14
  attr_accessor :explicit
15
-
15
+
16
16
  # Returns the list of parameters parsed out of the method signature
17
17
  # with their default values.
18
- #
18
+ #
19
19
  # @return [Array<Array(String, String)>] a list of parameter names followed
20
20
  # by their default values (or nil)
21
21
  attr_accessor :parameters
22
-
22
+
23
23
  # Creates a new method object in +namespace+ with +name+ and an instance
24
24
  # or class +scope+
25
- #
25
+ #
26
26
  # @param [NamespaceObject] namespace the namespace
27
27
  # @param [String, Symbol] name the method name
28
28
  # @param [Symbol] scope +:instance+ or +:class+
29
- def initialize(namespace, name, scope = :instance)
29
+ def initialize(namespace, name, scope = :instance)
30
30
  @scope = nil
31
31
  self.visibility = :public
32
32
  self.scope = scope
@@ -34,22 +34,22 @@ module YARD::CodeObjects
34
34
 
35
35
  super
36
36
  end
37
-
37
+
38
38
  # Changes the scope of an object from :instance or :class
39
39
  # @param [Symbol] v the new scope
40
- def scope=(v)
40
+ def scope=(v)
41
41
  reregister = @scope ? true : false
42
42
  YARD::Registry.delete(self) if reregister
43
43
  @path = nil
44
- @scope = v.to_sym
44
+ @scope = v.to_sym
45
45
  YARD::Registry.register(self) if reregister
46
46
  end
47
-
47
+
48
48
  # @return whether or not the method is the #initialize constructor method
49
49
  def constructor?
50
50
  name == :initialize && scope == :instance && namespace.is_a?(ClassObject)
51
51
  end
52
-
52
+
53
53
  # Returns the read/writer info for the attribute if it is one
54
54
  # @return [SymbolHash] if there is information about the attribute
55
55
  # @return [nil] if the method is not an attribute
@@ -58,7 +58,7 @@ module YARD::CodeObjects
58
58
  return nil unless namespace.is_a?(NamespaceObject)
59
59
  namespace.attributes[scope][name.to_s.gsub(/=$/, '')]
60
60
  end
61
-
61
+
62
62
  # @return [Boolean] whether the method is a writer attribute
63
63
  # @since 0.5.3
64
64
  def writer?
@@ -70,28 +70,28 @@ module YARD::CodeObjects
70
70
  def reader?
71
71
  !!((info = attr_info) && info[:read] == self)
72
72
  end
73
-
73
+
74
74
  # Tests if the object is defined as an attribute in the namespace
75
75
  # @return [Boolean] whether the object is an attribute
76
76
  def is_attribute?
77
77
  return false unless info = attr_info
78
78
  info[name.to_s =~ /=$/ ? :write : :read] ? true : false
79
79
  end
80
-
80
+
81
81
  # Tests if the object is defined as an alias of another method
82
82
  # @return [Boolean] whether the object is an alias
83
83
  def is_alias?
84
84
  return false unless namespace.is_a?(NamespaceObject)
85
85
  namespace.aliases.has_key? self
86
86
  end
87
-
87
+
88
88
  # Tests boolean {#explicit} value.
89
- #
89
+ #
90
90
  # @return [Boolean] whether the method is explicitly defined in source
91
91
  def is_explicit?
92
92
  explicit ? true : false
93
93
  end
94
-
94
+
95
95
  # @return [MethodObject] the object that this method overrides
96
96
  # @return [nil] if it does not override a method
97
97
  # @since 0.6.0
@@ -100,45 +100,45 @@ module YARD::CodeObjects
100
100
  meths = namespace.meths(:all => true)
101
101
  meths.find {|m| m.path != path && m.name == name && m.scope == scope }
102
102
  end
103
-
103
+
104
104
  # Returns all alias names of the object
105
105
  # @return [Array<Symbol>] the alias names
106
106
  def aliases
107
107
  list = []
108
108
  return list unless namespace.is_a?(NamespaceObject)
109
- namespace.aliases.each do |o, aname|
110
- list << o if aname == name && o.scope == scope
109
+ namespace.aliases.each do |o, aname|
110
+ list << o if aname == name && o.scope == scope
111
111
  end
112
112
  list
113
113
  end
114
-
114
+
115
115
  # Override path handling for instance methods in the root namespace
116
116
  # (they should still have a separator as a prefix).
117
117
  # @return [String] the path of a method
118
118
  def path
119
- @path ||= if !namespace || namespace.path == ""
119
+ @path ||= if !namespace || namespace.path == ""
120
120
  sep + super
121
121
  else
122
122
  super
123
123
  end
124
124
  end
125
-
125
+
126
126
  # Returns the name of the object.
127
- #
127
+ #
128
128
  # @example The name of an instance method (with prefix)
129
129
  # an_instance_method.name(true) # => "#mymethod"
130
130
  # @example The name of a class method (with prefix)
131
131
  # a_class_method.name(true) # => "mymethod"
132
132
  # @param [Boolean] prefix whether or not to show the prefix
133
- # @return [String] returns {#sep} + +name+ for an instance method if
133
+ # @return [String] returns {#sep} + +name+ for an instance method if
134
134
  # prefix is true
135
135
  # @return [Symbol] the name without {#sep} if prefix is set to false
136
136
  def name(prefix = false)
137
137
  prefix ? (sep == ISEP ? "#{sep}#{super}" : super.to_s) : super
138
138
  end
139
-
139
+
140
140
  protected
141
-
141
+
142
142
  # Override separator to differentiate between class and instance
143
143
  # methods.
144
144
  # @return [String] "#" for an instance method, "." for class
@@ -2,7 +2,7 @@ module YARD::CodeObjects
2
2
  # Represents a Ruby module.
3
3
  class ModuleObject < NamespaceObject
4
4
  # Returns the inheritance tree of mixins.
5
- #
5
+ #
6
6
  # @param [Boolean] include_mods if true, will include mixed in
7
7
  # modules (which is likely what is wanted).
8
8
  # @return [Array<NamespaceObject>] a list of namespace objects
@@ -1,12 +1,12 @@
1
1
  module YARD::CodeObjects
2
2
  # A "namespace" is any object that can store other objects within itself.
3
- # The two main Ruby objects that can act as namespaces are modules
3
+ # The two main Ruby objects that can act as namespaces are modules
4
4
  # ({ModuleObject}) and classes ({ClassObject}).
5
5
  class NamespaceObject < Base
6
6
  attr_writer :constants, :cvars, :mixins, :child, :meths
7
7
  attr_writer :class_attributes, :instance_attributes
8
8
  attr_writer :included_constants, :included_meths
9
-
9
+
10
10
  # @return [Array<String>] a list of ordered group names inside the namespace
11
11
  # @since 0.6.0
12
12
  attr_accessor :groups
@@ -18,19 +18,19 @@ module YARD::CodeObjects
18
18
  # A hash containing two keys, class and instance, each containing
19
19
  # the attribute name with a { :read, :write } hash for the read and
20
20
  # write objects respectively.
21
- #
21
+ #
22
22
  # @example The attributes of an object
23
23
  # >> Registry.at('YARD::Docstring').attributes
24
24
  # => {
25
- # :class => { },
25
+ # :class => { },
26
26
  # :instance => {
27
27
  # :ref_tags => {
28
- # :read => #<yardoc method YARD::Docstring#ref_tags>,
29
- # :write => nil
30
- # },
28
+ # :read => #<yardoc method YARD::Docstring#ref_tags>,
29
+ # :write => nil
30
+ # },
31
31
  # :object => {
32
32
  # :read => #<yardoc method YARD::Docstring#object>,
33
- # :write => #<yardoc method YARD::Docstring#object=>
33
+ # :write => #<yardoc method YARD::Docstring#object=>
34
34
  # },
35
35
  # ...
36
36
  # }
@@ -42,15 +42,15 @@ module YARD::CodeObjects
42
42
  # a hash of objects and their alias names.
43
43
  # @return [Hash] a list of methods
44
44
  attr_reader :aliases
45
-
45
+
46
46
  # Class mixins
47
47
  # @return [Array<ModuleObject>] a list of mixins
48
48
  attr_reader :class_mixins
49
-
49
+
50
50
  # Instance mixins
51
51
  # @return [Array<ModuleObject>] a list of mixins
52
52
  attr_reader :instance_mixins
53
-
53
+
54
54
  # Creates a new namespace object inside +namespace+ with +name+.
55
55
  # @see Base#initialize
56
56
  def initialize(namespace, name, *args, &block)
@@ -62,23 +62,23 @@ module YARD::CodeObjects
62
62
  @groups = []
63
63
  super
64
64
  end
65
-
65
+
66
66
  # Only the class attributes
67
67
  # @return [Hash] a list of method names and their read/write objects
68
68
  # @see #attributes
69
69
  def class_attributes
70
70
  attributes[:class]
71
71
  end
72
-
72
+
73
73
  # Only the instance attributes
74
74
  # @return [Hash] a list of method names and their read/write objects
75
75
  # @see #attributes
76
- def instance_attributes
76
+ def instance_attributes
77
77
  attributes[:instance]
78
78
  end
79
-
79
+
80
80
  # Looks for a child that matches the attributes specified by +opts+.
81
- #
81
+ #
82
82
  # @example Finds a child by name and scope
83
83
  # namespace.child(:name => :to_s, :scope => :instance)
84
84
  # # => #<yardoc method MyClass#to_s>
@@ -88,26 +88,26 @@ module YARD::CodeObjects
88
88
  children.find {|o| o.name == opts.to_sym }
89
89
  else
90
90
  opts = SymbolHash[opts]
91
- children.find do |obj|
91
+ children.find do |obj|
92
92
  opts.each do |meth, value|
93
93
  break false if !(value.is_a?(Array) ? value.include?(obj[meth]) : obj[meth] == value)
94
94
  end
95
95
  end
96
96
  end
97
97
  end
98
-
98
+
99
99
  # Returns all methods that match the attributes specified by +opts+. If
100
100
  # no options are provided, returns all methods.
101
- #
101
+ #
102
102
  # @example Finds all private and protected class methods
103
103
  # namespace.meths(:visibility => [:private, :protected], :scope => :class)
104
104
  # # => [#<yardoc method MyClass.privmeth>, #<yardoc method MyClass.protmeth>]
105
- # @option opts [Array<Symbol>, Symbol] :visibility ([:public, :private,
106
- # :protected]) the visibility of the methods to list. Can be an array or
105
+ # @option opts [Array<Symbol>, Symbol] :visibility ([:public, :private,
106
+ # :protected]) the visibility of the methods to list. Can be an array or
107
107
  # single value.
108
- # @option opts [Array<Symbol>, Symbol] :scope ([:class, :instance]) the
108
+ # @option opts [Array<Symbol>, Symbol] :scope ([:class, :instance]) the
109
109
  # scope of the methods to list. Can be an array or single value.
110
- # @option opts [Boolean] :included (true) whether to include mixed in
110
+ # @option opts [Boolean] :included (true) whether to include mixed in
111
111
  # methods in the list.
112
112
  # @return [Array<MethodObject>] a list of method objects
113
113
  def meths(opts = {})
@@ -116,29 +116,29 @@ module YARD::CodeObjects
116
116
  :scope => [:class, :instance],
117
117
  :included => true
118
118
  ].update(opts)
119
-
119
+
120
120
  opts[:visibility] = [opts[:visibility]].flatten
121
121
  opts[:scope] = [opts[:scope]].flatten
122
122
 
123
- ourmeths = children.select do |o|
124
- o.is_a?(MethodObject) &&
123
+ ourmeths = children.select do |o|
124
+ o.is_a?(MethodObject) &&
125
125
  opts[:visibility].include?(o.visibility) &&
126
126
  opts[:scope].include?(o.scope)
127
127
  end
128
-
128
+
129
129
  ourmeths + (opts[:included] ? included_meths(opts) : [])
130
130
  end
131
-
131
+
132
132
  # Returns methods included from any mixins that match the attributes
133
133
  # specified by +opts+. If no options are specified, returns all included
134
134
  # methods.
135
- #
136
- # @option opts [Array<Symbol>, Symbol] :visibility ([:public, :private,
137
- # :protected]) the visibility of the methods to list. Can be an array or
135
+ #
136
+ # @option opts [Array<Symbol>, Symbol] :visibility ([:public, :private,
137
+ # :protected]) the visibility of the methods to list. Can be an array or
138
138
  # single value.
139
- # @option opts [Array<Symbol>, Symbol] :scope ([:class, :instance]) the
139
+ # @option opts [Array<Symbol>, Symbol] :scope ([:class, :instance]) the
140
140
  # scope of the methods to list. Can be an array or single value.
141
- # @option opts [Boolean] :included (true) whether to include mixed in
141
+ # @option opts [Boolean] :included (true) whether to include mixed in
142
142
  # methods in the list.
143
143
  # @see #meths
144
144
  def included_meths(opts = {})
@@ -155,9 +155,9 @@ module YARD::CodeObjects
155
155
  end
156
156
  end.flatten
157
157
  end
158
-
158
+
159
159
  # Returns all constants in the namespace
160
- #
160
+ #
161
161
  # @option opts [Boolean] :included (true) whether or not to include
162
162
  # mixed in constants in list
163
163
  # @return [Array<ConstantObject>] a list of constant objects
@@ -166,13 +166,13 @@ module YARD::CodeObjects
166
166
  consts = children.select {|o| o.is_a? ConstantObject }
167
167
  consts + (opts[:included] ? included_constants : [])
168
168
  end
169
-
169
+
170
170
  # Returns constants included from any mixins
171
171
  # @return [Array<ConstantObject>] a list of constant objects
172
172
  def included_constants
173
173
  instance_mixins.inject([]) do |list, mixin|
174
174
  if mixin.respond_to? :constants
175
- list += mixin.constants.reject do |o|
175
+ list += mixin.constants.reject do |o|
176
176
  child(:name => o.name) || list.find {|o2| o2.name == o.name }
177
177
  end
178
178
  else
@@ -180,10 +180,10 @@ module YARD::CodeObjects
180
180
  end
181
181
  end
182
182
  end
183
-
183
+
184
184
  # Returns class variables defined in this namespace.
185
185
  # @return [Array<ClassVariableObject>] a list of class variable objects
186
- def cvars
186
+ def cvars
187
187
  children.select {|o| o.is_a? ClassVariableObject }
188
188
  end
189
189
 
@@ -8,7 +8,7 @@ module YARD
8
8
  # an unresolved path until a method is called on the object, at which
9
9
  # point it does a lookup using {Registry.resolve}. If the object is
10
10
  # not found, a warning is raised and {ProxyMethodError} might be raised.
11
- #
11
+ #
12
12
  # @example Creates a Proxy to the String class from a module
13
13
  # # When the String class is parsed this method will
14
14
  # # begin to act like the String ClassObject.
@@ -22,17 +22,17 @@ module YARD
22
22
  alias_method :parent, :namespace
23
23
 
24
24
  # Creates a new Proxy
25
- #
25
+ #
26
26
  # @raise [ArgumentError] if namespace is not a NamespaceObject
27
27
  # @return [Proxy] self
28
28
  def initialize(namespace, name)
29
29
  namespace = Registry.root if !namespace || namespace == :root
30
-
30
+
31
31
  if name =~ /^#{NSEPQ}/
32
32
  namespace = Registry.root
33
33
  name = name[2..-1]
34
34
  end
35
-
35
+
36
36
  if name =~ /(?:#{NSEPQ}|#{ISEPQ}|#{CSEPQ})([^#{NSEPQ}#{ISEPQ}#{CSEPQ}]+)$/
37
37
  @orignamespace, @origname = namespace, name
38
38
  @imethod = true if name.include? ISEP
@@ -40,23 +40,23 @@ module YARD
40
40
  name = $1
41
41
  else
42
42
  @orignamespace, @origname, @imethod = nil, nil, nil
43
- end
44
-
43
+ end
44
+
45
45
  @name = name.to_sym
46
46
  @namespace = namespace
47
47
  @obj = nil
48
48
  @imethod ||= nil
49
-
49
+
50
50
  if @namespace.is_a?(ConstantObject)
51
51
  @origname = nil # forget these for a constant
52
52
  @orignamespace = nil
53
53
  @namespace = Proxy.new(@namespace.namespace, @namespace.value)
54
54
  end
55
-
55
+
56
56
  unless @namespace.is_a?(NamespaceObject) or @namespace.is_a?(Proxy)
57
57
  raise ArgumentError, "Invalid namespace object: #{namespace}"
58
58
  end
59
-
59
+
60
60
  # If the name begins with "::" (like "::String")
61
61
  # this is definitely a root level object, so
62
62
  # remove the namespace and attach it to the root
@@ -65,7 +65,7 @@ module YARD
65
65
  @namespace = Registry.root
66
66
  end
67
67
  end
68
-
68
+
69
69
  # (see Base#name)
70
70
  def name(prefix = false)
71
71
  prefix ? (@imethod ? ISEP : '') + @name.to_s : @name
@@ -80,10 +80,10 @@ module YARD
80
80
  "P(#{path})"
81
81
  end
82
82
  end
83
-
83
+
84
84
  # If the proxy resolves to an object, returns its path, otherwise
85
85
  # guesses at the correct path using the original namespace and name.
86
- #
86
+ #
87
87
  # @return [String] the assumed path of the proxy (or the real path
88
88
  # of the resolved object)
89
89
  def path
@@ -107,8 +107,8 @@ module YARD
107
107
  end
108
108
  alias to_s path
109
109
  alias to_str path
110
-
111
- # @return [Boolean]
110
+
111
+ # @return [Boolean]
112
112
  def is_a?(klass)
113
113
  if obj = to_obj
114
114
  obj.is_a?(klass)
@@ -116,8 +116,8 @@ module YARD
116
116
  self.class <= klass
117
117
  end
118
118
  end
119
-
120
- # @return [Boolean]
119
+
120
+ # @return [Boolean]
121
121
  def ===(other)
122
122
  if obj = to_obj
123
123
  obj === other
@@ -125,8 +125,8 @@ module YARD
125
125
  self.class <= other.class
126
126
  end
127
127
  end
128
-
129
- # @return [Boolean]
128
+
129
+ # @return [Boolean]
130
130
  def <=>(other)
131
131
  if other.respond_to? :path
132
132
  path <=> other.path
@@ -134,8 +134,8 @@ module YARD
134
134
  false
135
135
  end
136
136
  end
137
-
138
- # @return [Boolean]
137
+
138
+ # @return [Boolean]
139
139
  def equal?(other)
140
140
  if other.respond_to? :path
141
141
  path == other.path
@@ -144,12 +144,12 @@ module YARD
144
144
  end
145
145
  end
146
146
  alias == equal?
147
-
147
+
148
148
  # @return [Integer] the object's hash value (for equality checking)
149
149
  def hash; path.hash end
150
150
 
151
151
  # Returns the class name of the object the proxy is mimicking, if
152
- # resolved. Otherwise returns +Proxy+.
152
+ # resolved. Otherwise returns +Proxy+.
153
153
  # @return [Class] the resolved object's class or +Proxy+
154
154
  def class
155
155
  if obj = to_obj
@@ -158,7 +158,7 @@ module YARD
158
158
  Proxy
159
159
  end
160
160
  end
161
-
161
+
162
162
  # Returns the type of the proxy. If it cannot be resolved at the
163
163
  # time of the call, it will either return the inferred proxy type
164
164
  # (see {#type=}) or +:proxy+
@@ -171,23 +171,23 @@ module YARD
171
171
  Registry.proxy_types[path] || :proxy
172
172
  end
173
173
  end
174
-
174
+
175
175
  # Allows a parser to infer the type of the proxy by its path.
176
176
  # @param [#to_sym] type the proxy's inferred type
177
- # @return [void]
177
+ # @return [void]
178
178
  def type=(type) Registry.proxy_types[path] = type.to_sym end
179
-
180
- # @return [Boolean]
179
+
180
+ # @return [Boolean]
181
181
  def instance_of?(klass)
182
182
  self.class == klass
183
183
  end
184
-
185
- # @return [Boolean]
184
+
185
+ # @return [Boolean]
186
186
  def kind_of?(klass)
187
187
  self.class <= klass
188
188
  end
189
-
190
- # @return [Boolean]
189
+
190
+ # @return [Boolean]
191
191
  def respond_to?(meth, include_private = false)
192
192
  if obj = to_obj
193
193
  obj.respond_to?(meth, include_private)
@@ -195,9 +195,9 @@ module YARD
195
195
  super
196
196
  end
197
197
  end
198
-
198
+
199
199
  # Dispatches the method to the resolved object.
200
- #
200
+ #
201
201
  # @raise [ProxyMethodError] if the proxy cannot find the real object
202
202
  def method_missing(meth, *args, &block)
203
203
  if obj = to_obj
@@ -212,26 +212,26 @@ module YARD
212
212
  log.warn "YARD will recover from this error and continue to parse but you *may* have problems"
213
213
  log.warn "with your generated documentation. You should probably fix this."
214
214
  log.warn "-"
215
- begin
215
+ begin
216
216
  super
217
217
  rescue NoMethodError
218
218
  raise ProxyMethodError, "Proxy cannot call method ##{meth} on object '#{path}'"
219
219
  end
220
220
  end
221
221
  end
222
-
222
+
223
223
  # This class is never a root object
224
224
  def root?; false end
225
-
225
+
226
226
  private
227
227
 
228
228
  # @note this method fixes a bug in 1.9.2: http://gist.github.com/437136
229
229
  def to_ary; nil end
230
-
230
+
231
231
  # Attempts to find the object that this unresolved object
232
232
  # references by checking if any objects by this name are
233
233
  # registered all the way up the namespace tree.
234
- #
234
+ #
235
235
  # @return [Base, nil] the registered code object or nil
236
236
  def to_obj
237
237
  return @obj if @obj