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
@@ -3,7 +3,7 @@ module YARD
3
3
  class DefaultFactory
4
4
  TYPELIST_OPENING_CHARS = '[({<'
5
5
  TYPELIST_CLOSING_CHARS = '>})]'
6
-
6
+
7
7
  # Parses tag text and creates a new tag with descriptive text
8
8
  #
9
9
  # @param tag_name the name of the tag to parse
@@ -12,7 +12,7 @@ module YARD
12
12
  def parse_tag(tag_name, text)
13
13
  Tag.new(tag_name, text.strip)
14
14
  end
15
-
15
+
16
16
  # Parses tag text and creates a new tag with a key name and descriptive text
17
17
  #
18
18
  # @param tag_name the name of the tag to parse
@@ -22,8 +22,8 @@ module YARD
22
22
  name, text = *extract_name_from_text(text)
23
23
  Tag.new(tag_name, text, nil, name)
24
24
  end
25
-
26
- # Parses tag text and creates a new tag with formally declared types and
25
+
26
+ # Parses tag text and creates a new tag with formally declared types and
27
27
  # descriptive text
28
28
  #
29
29
  # @param tag_name the name of the tag to parse
@@ -34,8 +34,8 @@ module YARD
34
34
  raise TagFormatError, "cannot specify a name before type list for '@#{tag_name}'" if name
35
35
  Tag.new(tag_name, text, types)
36
36
  end
37
-
38
- # Parses tag text and creates a new tag with formally declared types, a key
37
+
38
+ # Parses tag text and creates a new tag with formally declared types, a key
39
39
  # name and descriptive text
40
40
  #
41
41
  # @param tag_name the name of the tag to parse
@@ -46,12 +46,12 @@ module YARD
46
46
  name, text = *extract_name_from_text(text) unless name
47
47
  Tag.new(tag_name, text, types, name)
48
48
  end
49
-
49
+
50
50
  def parse_tag_with_title_and_text(tag_name, text)
51
51
  title, desc = *extract_title_and_desc_from_text(text)
52
52
  Tag.new(tag_name, desc, nil, title)
53
53
  end
54
-
54
+
55
55
  def parse_tag_with_types_name_and_default(tag_name, text)
56
56
  # Can't allow () in a default tag, otherwise the grammar is too ambiguous when types is omitted.
57
57
  open, close = TYPELIST_OPENING_CHARS.gsub('(', ''), TYPELIST_CLOSING_CHARS.gsub(')', '')
@@ -64,23 +64,23 @@ module YARD
64
64
  DefaultTag.new(tag_name, text, types, name, nil)
65
65
  end
66
66
  end
67
-
67
+
68
68
  def parse_tag_with_options(tag_name, text)
69
69
  name, text = *extract_name_from_text(text)
70
70
  OptionTag.new(tag_name, name, parse_tag_with_types_name_and_default(tag_name, text))
71
71
  end
72
-
72
+
73
73
  private
74
-
74
+
75
75
  # Extracts the name from raw tag text returning the name and remaining value
76
76
  #
77
77
  # @param [String] text the raw tag text
78
- # @return [Array] an array holding the name as the first element and the
78
+ # @return [Array] an array holding the name as the first element and the
79
79
  # value as the second element
80
80
  def extract_name_from_text(text)
81
81
  text.strip.split(/\s+/, 2)
82
82
  end
83
-
83
+
84
84
  def extract_title_and_desc_from_text(text)
85
85
  raise TagFormatError if text.nil? || text.empty?
86
86
  title, desc = nil, nil
@@ -93,16 +93,16 @@ module YARD
93
93
  end
94
94
  [title, desc]
95
95
  end
96
-
97
- # Parses a [], <>, {} or () block at the beginning of a line of text
96
+
97
+ # Parses a [], <>, {} or () block at the beginning of a line of text
98
98
  # into a list of comma delimited values.
99
- #
99
+ #
100
100
  # @example
101
101
  # obj.parse_types('[String, Array<Hash, String>, nil]') # => [nil, ['String', 'Array<Hash, String>', 'nil'], ""]
102
102
  # obj.parse_types('b<String> A string') # => ['b', ['String'], 'A string']
103
- #
104
- # @return [Array(String, Array<String>, String)] the text before the type
105
- # list (or nil), followed by the type list parsed into an array of
103
+ #
104
+ # @return [Array(String, Array<String>, String)] the text before the type
105
+ # list (or nil), followed by the type list parsed into an array of
106
106
  # strings, followed by the text following the type list.
107
107
  def extract_types_and_name_from_text(text, opening_types = TYPELIST_OPENING_CHARS, closing_types = TYPELIST_CLOSING_CHARS)
108
108
  s, e = 0, 0
@@ -2,7 +2,7 @@ module YARD
2
2
  module Tags
3
3
  class DefaultTag < Tag
4
4
  attr_reader :defaults
5
-
5
+
6
6
  def initialize(tag_name, text, types = nil, name = nil, defaults = nil)
7
7
  super(tag_name, text, types, name)
8
8
  @defaults = defaults
@@ -17,7 +17,7 @@ module YARD
17
17
  #
18
18
  # The second line will expand to:
19
19
  # def author_tag(text) tag_factory.parse_tag(text) end
20
- #
20
+ #
21
21
  # Note that +tag_factory+ is the factory object used to parse tags. This value
22
22
  # defaults to the {DefaultFactory} class and can be set by changing {Library.default_factory}.
23
23
  #
@@ -30,10 +30,10 @@ module YARD
30
30
  #
31
31
  # This will allow you to use @mytag TEXT to add meta data to classes through
32
32
  # the docstring. You can use the {Library#factory} object to help parse standard
33
- # tag syntax.
34
- #
33
+ # tag syntax.
34
+ #
35
35
  # == Adding/Changing the Tag Syntax
36
- # If you have specialized tag parsing needs you can substitute the {#factory}
36
+ # If you have specialized tag parsing needs you can substitute the {#factory}
37
37
  # object with your own by setting {Library.default_factory= Library.default_factory}
38
38
  # to a new class with its own parsing methods before running YARD. This is useful
39
39
  # if you want to change the syntax of existing tags (@see, @since, etc.)
@@ -43,34 +43,34 @@ module YARD
43
43
  class Library
44
44
  class << self
45
45
  attr_reader :labels
46
-
46
+
47
47
  def instance
48
48
  @instance ||= new
49
49
  end
50
-
50
+
51
51
  def default_factory
52
52
  @default_factory ||= DefaultFactory.new
53
53
  end
54
-
54
+
55
55
  # Replace the factory object responsible for parsing tags by setting
56
56
  # this to an object (or class) that responds to +parse_TAGNAME+ methods
57
57
  # where +TAGNAME+ is the name of the tag.
58
- #
58
+ #
59
59
  # You should set this value before performing any source parsing with
60
60
  # YARD, otherwise your factory class will not be used.
61
- #
61
+ #
62
62
  # @example
63
63
  # YARD::Tags::Library.default_factory = MyFactory
64
- #
64
+ #
65
65
  # @param [Class, Object] factory the factory that parses all tags
66
- #
66
+ #
67
67
  # @see DefaultFactory
68
68
  def default_factory=(factory)
69
69
  @default_factory = factory.is_a?(Class) ? factory.new : factory
70
70
  end
71
-
71
+
72
72
  # Returns the factory method used to parse the tag text for a specific tag
73
- #
73
+ #
74
74
  # @param [Symbol] tag the tag name
75
75
  # @return [Symbol] the factory method name for the tag
76
76
  # @return [Class<Tag>] the Tag class to use to parse the tag
@@ -79,48 +79,48 @@ module YARD
79
79
  def factory_method_for(tag)
80
80
  @factory_methods[tag]
81
81
  end
82
-
83
- # Sets the list of tags to display when rendering templates. The order of
84
- # tags in the list is also significant, as it represents the order that
82
+
83
+ # Sets the list of tags to display when rendering templates. The order of
84
+ # tags in the list is also significant, as it represents the order that
85
85
  # tags are displayed in templates.
86
- #
87
- # You can use the {Array#place} to insert new tags to be displayed in
86
+ #
87
+ # You can use the {Array#place} to insert new tags to be displayed in
88
88
  # the templates at specific positions:
89
- #
89
+ #
90
90
  # Library.visible_tags.place(:mytag).before(:return)
91
- #
91
+ #
92
92
  # @return [Array<Symbol>] a list of ordered tags
93
93
  # @since 0.6.0
94
94
  attr_accessor :visible_tags
95
-
95
+
96
96
  # Sets the list of tags that should apply to any children inside the
97
97
  # namespace they are defined in. For instance, a "@since" tag should
98
98
  # apply to all methods inside a module is it defined in. Transitive
99
99
  # tags can be overridden by directly defining a tag on the child object.
100
- #
100
+ #
101
101
  # @return [Array<Symbol>] a list of transitive tags
102
102
  # @since 0.6.0
103
103
  attr_accessor :transitive_tags
104
-
104
+
105
105
  # Sorts the labels lexically by their label name, often used when displaying
106
106
  # the tags.
107
- #
107
+ #
108
108
  # @return [Array<Symbol>, String] the sorted labels as an array of the tag name and label
109
109
  def sorted_labels
110
110
  labels.sort_by {|a| a.last.downcase }
111
111
  end
112
-
112
+
113
113
  # Convenience method to define a new tag using one of {Tag}'s factory methods, or the
114
114
  # regular {DefaultFactory#parse_tag} factory method if none is supplied.
115
115
  #
116
116
  # @param [#to_s] tag the tag name to create
117
- # @param [#to_s, Class<Tag>] meth the {Tag} factory method to call when
117
+ # @param [#to_s, Class<Tag>] meth the {Tag} factory method to call when
118
118
  # creating the tag or the name of the class to directly create a tag for
119
119
  def define_tag(label, tag, meth = nil)
120
120
  if meth.is_a?(Class) && Tag > meth
121
121
  class_eval <<-eof, __FILE__, __LINE__
122
- def #{tag}_tag(text)
123
- #{meth}.new(#{tag.inspect}, text)
122
+ def #{tag}_tag(text)
123
+ #{meth}.new(#{tag.inspect}, text)
124
124
  end
125
125
  eof
126
126
  else
@@ -138,9 +138,9 @@ module YARD
138
138
  tag
139
139
  end
140
140
  end
141
-
141
+
142
142
  private
143
-
143
+
144
144
  def send_to_factory(tag_name, meth, text)
145
145
  meth = meth.to_s
146
146
  send_name = "parse_tag" + (meth.empty? ? "" : "_" + meth)
@@ -151,46 +151,51 @@ module YARD
151
151
  raise NoMethodError, "Factory #{@factory.class_name} does not implement factory method :#{meth}."
152
152
  end
153
153
  end
154
-
154
+
155
155
  public
156
-
156
+
157
157
  # A factory class to handle parsing of tags, defaults to {default_factory}
158
158
  attr_accessor :factory
159
-
159
+
160
160
  def initialize(factory = Library.default_factory)
161
161
  self.factory = factory
162
162
  end
163
-
164
- define_tag "Abstract", :abstract
165
- define_tag "API Visibility", :api
166
- define_tag "Attribute", :attr, :with_types_and_name
167
- define_tag "Attribute Getter", :attr_reader, :with_types_and_name
168
- define_tag "Attribute Setter", :attr_writer, :with_types_and_name
169
- define_tag "Author", :author
170
- define_tag "Deprecated", :deprecated
171
- define_tag "Example", :example, :with_title_and_text
172
- define_tag "End Grouping", :endgroup
173
- define_tag "Grouping", :group
174
- define_tag "Note", :note
175
- define_tag "Options Hash", :option, :with_options
176
- define_tag "Overloads", :overload, OverloadTag
177
- define_tag "Parameters", :param, :with_types_and_name
178
- define_tag "Private", :private
179
- define_tag "Raises", :raise, :with_types
180
- define_tag "Returns", :return, :with_types
181
- define_tag "See Also", :see, :with_name
182
- define_tag "Since", :since
183
- define_tag "Todo Item", :todo
184
- define_tag "Version", :version
185
- define_tag "Yields", :yield, :with_types
186
- define_tag "Yield Parameters", :yieldparam, :with_types_and_name
187
- define_tag "Yield Returns", :yieldreturn, :with_types
188
-
189
- self.visible_tags = [:abstract, :deprecated, :note, :todo, :example, :overload,
190
- :param, :option, :yield, :yieldparam, :yieldreturn, :return, :raise,
163
+
164
+ define_tag "Abstract", :abstract
165
+ define_tag "API Visibility", :api
166
+ define_tag "Attribute (macro)", :attribute, :with_types
167
+ define_tag "Attribute", :attr, :with_types_and_name
168
+ define_tag "Attribute Getter", :attr_reader, :with_types_and_name
169
+ define_tag "Attribute Setter", :attr_writer, :with_types_and_name
170
+ define_tag "Author", :author
171
+ define_tag "Deprecated", :deprecated
172
+ define_tag "Example", :example, :with_title_and_text
173
+ define_tag "End Grouping", :endgroup
174
+ define_tag "Grouping", :group
175
+ define_tag "Macro", :macro, :with_types_and_name
176
+ define_tag "Method (macro)", :method, :with_title_and_text
177
+ define_tag "Note", :note
178
+ define_tag "Options Hash", :option, :with_options
179
+ define_tag "Overloads", :overload, OverloadTag
180
+ define_tag "Parameters", :param, :with_types_and_name
181
+ define_tag "Private", :private
182
+ define_tag "Raises", :raise, :with_types
183
+ define_tag "Returns", :return, :with_types
184
+ define_tag "Scope (macro)", :scope
185
+ define_tag "See Also", :see, :with_name
186
+ define_tag "Since", :since
187
+ define_tag "Todo Item", :todo
188
+ define_tag "Version", :version
189
+ define_tag "Visibility (macro)", :visibility
190
+ define_tag "Yields", :yield, :with_types
191
+ define_tag "Yield Parameters", :yieldparam, :with_types_and_name
192
+ define_tag "Yield Returns", :yieldreturn, :with_types
193
+
194
+ self.visible_tags = [:abstract, :deprecated, :note, :todo, :example, :overload,
195
+ :param, :option, :yield, :yieldparam, :yieldreturn, :return, :raise,
191
196
  :see, :author, :since, :version]
192
-
193
- self.transitive_tags = [:since]
197
+
198
+ self.transitive_tags = [:since, :api]
194
199
  end
195
200
  end
196
201
  end
@@ -2,7 +2,7 @@ module YARD
2
2
  module Tags
3
3
  class OptionTag < Tag
4
4
  attr_accessor :pair
5
-
5
+
6
6
  def initialize(tag_name, name, pair)
7
7
  super(tag_name, nil, nil, name)
8
8
  @pair = pair
@@ -2,17 +2,17 @@ module YARD
2
2
  module Tags
3
3
  class OverloadTag < Tag
4
4
  attr_reader :signature, :parameters, :docstring
5
-
5
+
6
6
  def initialize(tag_name, text)
7
7
  super(tag_name, nil)
8
8
  parse_tag(text)
9
9
  parse_signature
10
10
  end
11
-
11
+
12
12
  def tag(name) docstring.tag(name) end
13
13
  def tags(name = nil) docstring.tags(name) end
14
14
  def has_tag?(name) docstring.has_tag?(name) end
15
-
15
+
16
16
  def object=(value)
17
17
  super(value)
18
18
  docstring.object = value
@@ -22,22 +22,22 @@ module YARD
22
22
  return @name unless prefix
23
23
  object.scope == :class ? @name.to_s : "#{object.send(:sep)}#{@name}"
24
24
  end
25
-
25
+
26
26
  def method_missing(*args, &block)
27
27
  object.send(*args, &block)
28
28
  end
29
-
29
+
30
30
  def type
31
31
  object.type
32
32
  end
33
-
33
+
34
34
  def is_a?(other)
35
35
  object.is_a?(other) || self.class >= other.class || false
36
36
  end
37
37
  alias kind_of? is_a?
38
-
38
+
39
39
  private
40
-
40
+
41
41
  def parse_tag(text)
42
42
  @signature, text = *text.split(/\r?\n/, 2)
43
43
  @signature.strip!
@@ -47,7 +47,7 @@ module YARD
47
47
  text.strip!
48
48
  @docstring = Docstring.new(text, nil)
49
49
  end
50
-
50
+
51
51
  def parse_signature
52
52
  if signature =~ /^(?:def\s)?\s*(#{CodeObjects::METHODMATCH})(?:(?:\s+|\s*\()(.*)(?:\)\s*$)?)?/m
53
53
  meth, args = $1, $2
@@ -2,13 +2,13 @@ module YARD
2
2
  module Tags
3
3
  class RefTagList
4
4
  attr_accessor :owner, :tag_name, :name
5
-
5
+
6
6
  def initialize(tag_name, owner, name = nil)
7
7
  @owner = CodeObjects::Proxy === owner ? owner : P(owner)
8
8
  @tag_name = tag_name.to_s
9
9
  @name = name
10
10
  end
11
-
11
+
12
12
  def tags
13
13
  if owner.is_a?(CodeObjects::Base)
14
14
  o = owner.tags(tag_name)
data/lib/yard/tags/tag.rb CHANGED
@@ -2,7 +2,7 @@ module YARD
2
2
  module Tags
3
3
  # Represents a metadata tag value (+@tag+). Tags can have any combination of
4
4
  # {#types}, {#name} and {#text}, or none of the above.
5
- #
5
+ #
6
6
  # @example Programmatic tag creation
7
7
  # # The following docstring syntax:
8
8
  # # @param [String, nil] arg an argument
@@ -12,18 +12,18 @@ module YARD
12
12
  class Tag
13
13
  # @return [String] the name of the tag
14
14
  attr_accessor :tag_name
15
-
15
+
16
16
  # @return [String] the tag text associated with the tag
17
17
  # @return [nil] if no tag text is supplied
18
18
  attr_accessor :text
19
-
19
+
20
20
  # @return [Array<String>] a list of types associated with the tag
21
21
  # @return [nil] if no types are associated with the tag
22
22
  attr_accessor :types
23
-
23
+
24
24
  # @return [String] a name associated with the tag
25
25
  attr_accessor :name
26
-
26
+
27
27
  # @return [CodeObjects::Base] the associated object
28
28
  attr_accessor :object
29
29
 
@@ -31,7 +31,7 @@ module YARD
31
31
  # and a key name can be specified.
32
32
  #
33
33
  # Types are mainly for meta tags that rely on type information, such as +param+, +return+, etc.
34
- #
34
+ #
35
35
  # Key names are for tags that declare meta data for a specific key or name, such as +param+,
36
36
  # +raise+, etc.
37
37
  #
@@ -47,7 +47,7 @@ module YARD
47
47
  # Convenience method to access the first type specified. This should mainly
48
48
  # be used for tags that only specify one type.
49
49
  #
50
- # @return [String] the first of the list of specified types
50
+ # @return [String] the first of the list of specified types
51
51
  # @see #types
52
52
  def type
53
53
  types.first