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
@@ -13,9 +13,9 @@ module YARD
13
13
  html_syntax_highlight_ruby_legacy(source)
14
14
  end
15
15
  end
16
-
16
+
17
17
  private
18
-
18
+
19
19
  def html_syntax_highlight_ruby_ripper(source)
20
20
  tokenlist = Parser::Ruby::RubyParser.parse(source, "(syntax_highlight)").tokens
21
21
  output = ""
@@ -35,10 +35,10 @@ module YARD
35
35
  rescue Parser::ParserSyntaxError
36
36
  h(source)
37
37
  end
38
-
38
+
39
39
  def html_syntax_highlight_ruby_legacy(source)
40
40
  tokenlist = Parser::Ruby::Legacy::TokenList.new(source)
41
- tokenlist.map do |s|
41
+ tokenlist.map do |s|
42
42
  prettyclass = s.class.class_name.sub(/^Tk/, '').downcase
43
43
  prettysuper = s.class.superclass.class_name.sub(/^Tk/, '').downcase
44
44
 
@@ -17,15 +17,15 @@ module YARD
17
17
  raise NameError, "could not load RDocMarkup (rdoc is not installed)"
18
18
  end
19
19
  end
20
-
20
+
21
21
  class RDocMarkup
22
22
  attr_accessor :from_path
23
-
23
+
24
24
  def initialize(text)
25
25
  @text = text
26
26
  @markup = MARKUP.new
27
27
  end
28
-
28
+
29
29
  def to_html
30
30
  formatter = RDocMarkupToHtml.new
31
31
  formatter.from_path = from_path
@@ -34,11 +34,11 @@ module YARD
34
34
  html = fix_typewriter(html)
35
35
  html
36
36
  end
37
-
37
+
38
38
  private
39
39
 
40
40
  # Fixes RDoc behaviour with ++ only supporting alphanumeric text.
41
- #
41
+ #
42
42
  # @todo Refactor into own SimpleMarkup subclass
43
43
  def fix_typewriter(text)
44
44
  text.gsub(/(\s|^|>)\+(?! )([^\n\+]{1,900})(?! )\+/) do
@@ -54,21 +54,21 @@ module YARD
54
54
 
55
55
  # Don't allow -- to turn into — element. The chances of this being
56
56
  # some --option is far more likely than the typographical meaning.
57
- #
57
+ #
58
58
  # @todo Refactor into own SimpleMarkup subclass
59
59
  def fix_dash_dash(text)
60
60
  text.gsub(/—(?=\S)/, '--')
61
61
  end
62
62
  end
63
-
63
+
64
64
  class RDocMarkupToHtml
65
65
  attr_accessor :from_path
66
-
66
+
67
67
  # Disable auto-link of URLs
68
68
  def handle_special_HYPERLINK(special)
69
69
  @hyperlink ? special.text : super
70
70
  end
71
-
71
+
72
72
  def accept_paragraph(*args)
73
73
  par = args.last
74
74
  text = par.respond_to?(:txt) ? par.txt : par.text
@@ -10,35 +10,37 @@ module YARD
10
10
  def clear_markup_cache
11
11
  self.markup_cache = {}
12
12
  end
13
-
13
+
14
14
  # @return [Hash{Symbol=>{(:provider,:class)=>Object}}] the cached markup providers
15
15
  # @private
16
16
  # @since 0.6.4
17
17
  attr_accessor :markup_cache
18
18
  end
19
-
19
+
20
20
  MarkupHelper.clear_markup_cache
21
-
21
+
22
22
  # The default list of markup providers for each markup type
23
23
  MARKUP_PROVIDERS = {
24
24
  :markdown => [
25
+ {:lib => :rdiscount, :const => 'RDiscount'},
26
+ {:lib => :kramdown, :const => 'Kramdown::Document'},
25
27
  {:lib => :bluecloth, :const => 'BlueCloth'},
26
- {:lib => :kramdown, :const => "Kramdown::Document"},
27
28
  {:lib => :maruku, :const => 'Maruku'},
28
- {:lib => :"rpeg-markdown", :const => "PEGMarkdown"},
29
- {:lib => :rdiscount, :const => "RDiscount"}
29
+ {:lib => :redcarpet, :const => 'RedcarpetCompat'},
30
+ {:lib => :'rpeg-markdown', :const => 'PEGMarkdown'},
30
31
  ],
31
32
  :textile => [
32
- {:lib => :redcloth, :const => 'RedCloth'}
33
+ {:lib => :redcloth, :const => 'RedCloth'},
33
34
  ],
34
35
  :rdoc => [
35
36
  {:lib => nil, :const => 'YARD::Templates::Helpers::Markup::RDocMarkup'},
36
37
  ],
38
+ :ruby => [],
37
39
  :text => [],
38
40
  :html => [],
39
- :none => []
41
+ :none => [],
40
42
  }
41
-
43
+
42
44
  # Returns a list of extensions for various markup types. To register
43
45
  # extensions for a type, add them to the array of extensions for the
44
46
  # type.
@@ -49,39 +51,40 @@ module YARD
49
51
  :textile => ['textile', 'txtile'],
50
52
  :markdown => ['markdown', 'md', 'mdown', 'mkd'],
51
53
  :rdoc => ['rdoc'],
54
+ :ruby => ['rb', 'ru']
52
55
  }
53
-
56
+
54
57
  # Contains the Regexp object that matches the shebang line of extra
55
58
  # files to detect the markup type.
56
59
  MARKUP_FILE_SHEBANG = /\A#!(\S+)\s*$/
57
60
 
58
61
  # Attempts to load the first valid markup provider in {MARKUP_PROVIDERS}.
59
62
  # If a provider is specified, immediately try to load it.
60
- #
63
+ #
61
64
  # On success this sets `@markup_provider` and `@markup_class` to
62
65
  # the provider name and library constant class/module respectively for
63
66
  # the loaded provider.
64
- #
67
+ #
65
68
  # On failure this method will inform the user that no provider could be
66
69
  # found and exit the program.
67
- #
70
+ #
68
71
  # @return [Boolean] whether the markup provider was successfully loaded.
69
72
  def load_markup_provider(type = options[:markup])
70
73
  return true if MarkupHelper.markup_cache[type]
71
74
  MarkupHelper.markup_cache[type] ||= {}
72
-
75
+
73
76
  providers = MARKUP_PROVIDERS[type.to_sym]
74
77
  return true if providers && providers.empty?
75
78
  if providers && options[:markup_provider]
76
79
  providers = providers.select {|p| p[:lib] == options[:markup_provider] }
77
80
  end
78
-
81
+
79
82
  if providers == nil || providers.empty?
80
83
  log.error "Invalid markup type '#{type}' or markup provider " +
81
84
  "(#{options[:markup_provider]}) is not registered."
82
85
  return false
83
86
  end
84
-
87
+
85
88
  # Search for provider, return the library class name as const if found
86
89
  providers.each do |provider|
87
90
  begin require provider[:lib].to_s; rescue LoadError; next end if provider[:lib]
@@ -90,28 +93,30 @@ module YARD
90
93
  MarkupHelper.markup_cache[type][:class] = klass
91
94
  return true
92
95
  end
93
-
96
+
94
97
  # Show error message telling user to install first potential provider
95
98
  name, lib = *[providers.first[:const], providers.first[:lib] || type]
96
99
  log.error "Missing '#{lib}' gem for #{options[:markup].to_s.capitalize} formatting. Install it with `gem install #{lib}`"
97
100
  false
98
101
  end
99
-
102
+
100
103
  # Checks for a shebang or looks at the file extension to determine
101
104
  # the markup type for the file contents. File extensions are registered
102
105
  # for a markup type in {MARKUP_EXTENSIONS}.
103
- #
106
+ #
104
107
  # A shebang should be on the first line of a file and be in the form:
105
- #
108
+ #
106
109
  # #!markup_type
107
- #
110
+ #
108
111
  # Standard markup types are text, html, rdoc, markdown, textile
109
- #
112
+ #
113
+ # @param [String] contents Unused. Was necessary prior to 0.7.0.
114
+ # Newer versions of YARD use {CodeObjects::ExtraFileObject#contents}
110
115
  # @return [Symbol] the markup type recognized for the file
111
116
  # @see MARKUP_EXTENSIONS
112
117
  # @since 0.6.0
113
118
  def markup_for_file(contents, filename)
114
- if contents =~ MARKUP_FILE_SHEBANG # Shebang support
119
+ if contents && contents =~ MARKUP_FILE_SHEBANG # Shebang support
115
120
  return $1.to_sym
116
121
  end
117
122
 
@@ -121,28 +126,30 @@ module YARD
121
126
  end
122
127
  options[:markup]
123
128
  end
124
-
125
- # Strips any shebang lines on the file contents that pertain to
129
+
130
+ # Strips any shebang lines on the file contents that pertain to
126
131
  # markup or preprocessing data.
127
- #
132
+ #
133
+ # @deprecated Use {CodeObjects::ExtraFileObject#contents} instead
128
134
  # @return [String] the file contents minus any preprocessing tags
129
135
  # @since 0.6.0
130
136
  def markup_file_contents(contents)
131
137
  contents =~ MARKUP_FILE_SHEBANG ? $' : contents
132
138
  end
133
-
139
+
134
140
  # Gets the markup provider class/module constant for a markup type
135
141
  # Call {#load_markup_provider} before using this method.
136
- #
142
+ #
137
143
  # @param [Symbol] the markup type (:rdoc, :markdown, etc.)
138
144
  # @return [Class] the markup class
139
145
  def markup_class(type = options[:markup])
146
+ load_markup_provider(type)
140
147
  MarkupHelper.markup_cache[type][:class]
141
148
  end
142
-
149
+
143
150
  # Gets the markup provider name for a markup type
144
151
  # Call {#load_markup_provider} before using this method.
145
- #
152
+ #
146
153
  # @param [Symbol] the markup type (:rdoc, :markdown, etc.)
147
154
  # @return [Symbol] the markup provider name (usually the gem name of the library)
148
155
  def markup_provider(type = options[:markup])
@@ -12,7 +12,7 @@ module YARD
12
12
  !object.tags(:param).any? {|t| t.name == param[0][1..-1] }
13
13
  end
14
14
  end
15
-
15
+
16
16
  unless params.empty?
17
17
  args = params.map {|n, v| v ? "#{n} = #{v}" : n.to_s }.join(", ")
18
18
  h("(#{args})")
@@ -20,14 +20,14 @@ module YARD
20
20
  ""
21
21
  end
22
22
  end
23
-
23
+
24
24
  # @return [String] formatted and linked return types for a method
25
25
  def format_return_types(object)
26
26
  return unless object.has_tag?(:return) && object.tag(:return).types
27
27
  return if object.tag(:return).types.empty?
28
28
  format_types [object.tag(:return).types.first], false
29
29
  end
30
-
30
+
31
31
  # @return [String] formatted block if one exists
32
32
  def format_block(object)
33
33
  if object.has_tag?(:yield) && object.tag(:yield).types
@@ -42,25 +42,25 @@ module YARD
42
42
 
43
43
  params ? h("{|" + params.join(", ") + "| ... }") : ""
44
44
  end
45
-
45
+
46
46
  # @return [String] formats line numbers for source code of an object
47
47
  def format_lines(object)
48
48
  return "" if object.source.nil? || object.line.nil?
49
49
  i = -1
50
50
  object.source.split(/\n/).map { object.line + (i += 1) }.join("\n")
51
51
  end
52
-
52
+
53
53
  # @return [String] formats source of an object
54
54
  def format_code(object, show_lines = false)
55
55
  i = -1
56
56
  lines = object.source.split(/\n/)
57
57
  longestline = (object.line + lines.size).to_s.length
58
- lines.map do |line|
58
+ lines.map do |line|
59
59
  lineno = object.line + (i += 1)
60
60
  (" " * (longestline - lineno.to_s.length)) + lineno.to_s + " " + line
61
61
  end.join("\n")
62
62
  end
63
-
63
+
64
64
  # @return [String] formats source code of a constant value
65
65
  def format_constant(value)
66
66
  sp = value.split("\n").last[/^(\s+)/, 1]
@@ -8,7 +8,7 @@ module YARD
8
8
  out = ""
9
9
  text = text.split(/\n/)
10
10
  text.each_with_index do |line, i|
11
- out <<
11
+ out <<
12
12
  case line
13
13
  when /^\s*$/; "\n\n"
14
14
  when /^\s+\S/, /^=/; line + "\n"
@@ -20,30 +20,30 @@ module YARD
20
20
 
21
21
  # @return [String] wraps text at +col+ columns.
22
22
  def wrap(text, col = 72)
23
- text.gsub(/(.{1,#{col}})( +|$\n?)|(.{1,#{col}})/, "\\1\\3\n")
23
+ text.gsub(/(.{1,#{col}})( +|$\n?)|(.{1,#{col}})/, "\\1\\3\n")
24
24
  end
25
-
25
+
26
26
  # @return [String] indents +text+ by +len+ characters.
27
27
  def indent(text, len = 4)
28
28
  text.gsub(/^/, ' ' * len)
29
29
  end
30
-
30
+
31
31
  # @return [String] aligns a title to the right
32
32
  def title_align_right(text, col = 72)
33
33
  align_right(text, '-', col)
34
34
  end
35
-
35
+
36
36
  # @return [String] aligns text to the right
37
37
  def align_right(text, spacer = ' ', col = 72)
38
38
  text = text[0, col - 4] + '...' if (col - 1 - text.length) < 0
39
39
  spacer * (col - 1 - text.length) + " " + text
40
40
  end
41
-
41
+
42
42
  # @return [String] returns a horizontal rule for output
43
43
  def hr(col = 72, sep = "-")
44
44
  sep * col
45
45
  end
46
-
46
+
47
47
  # @return [String] the formatted signature for a method
48
48
  def signature(meth)
49
49
  # use first overload tag if it has a return type and method itself does not
@@ -12,21 +12,21 @@ module YARD
12
12
  when :private; '-'
13
13
  end
14
14
  end
15
-
15
+
16
16
  # Formats the path of an object for Graphviz syntax
17
17
  # @param [CodeObjects::Base] object an object to format the path of
18
18
  # @return [String] the encoded path
19
19
  def format_path(object)
20
20
  object.path.gsub('::', '_')
21
21
  end
22
-
22
+
23
23
  # Encodes text in escaped Graphviz syntax
24
24
  # @param [String] text text to encode
25
25
  # @return [String] the encoded text
26
26
  def h(text)
27
27
  text.to_s.gsub(/(\W)/, '\\\\\1')
28
28
  end
29
-
29
+
30
30
  # Tidies data by formatting and indenting text
31
31
  # @param [String] data pre-formatted text
32
32
  # @return [String] tidied text.
@@ -5,18 +5,18 @@ module YARD
5
5
  # @since 0.6.0
6
6
  class Section < Array
7
7
  attr_accessor :name
8
-
8
+
9
9
  def initialize(name, *args)
10
10
  self.name = name
11
11
  replace(parse_sections(args))
12
12
  end
13
-
13
+
14
14
  def dup
15
15
  obj = super
16
16
  obj.name = name
17
17
  obj
18
18
  end
19
-
19
+
20
20
  def [](*args)
21
21
  if args.first.is_a?(Range) || args.size > 1
22
22
  obj = super(*args)
@@ -27,11 +27,11 @@ module YARD
27
27
  end
28
28
  find {|o| o.name == args.first }
29
29
  end
30
-
30
+
31
31
  def eql?(other)
32
32
  super(other) && name == other.name
33
33
  end
34
-
34
+
35
35
  def ==(other)
36
36
  case other
37
37
  when Section
@@ -42,26 +42,26 @@ module YARD
42
42
  name == other
43
43
  end
44
44
  end
45
-
45
+
46
46
  def push(*args)
47
47
  super(*parse_sections(args))
48
48
  end
49
49
  alias << push
50
-
50
+
51
51
  def unshift(*args)
52
52
  super(*parse_sections(args))
53
53
  end
54
-
54
+
55
55
  def inspect
56
56
  n = name.respond_to?(:path) ? "T('#{name.path}')" : name.inspect
57
57
  subsects = empty? ? "" : ", subsections=#{super}"
58
58
  "Section(#{n}#{subsects})"
59
59
  end
60
-
60
+
61
61
  def place(*args)
62
62
  super(*parse_sections(args))
63
63
  end
64
-
64
+
65
65
  def to_a
66
66
  list = [name]
67
67
  unless empty?
@@ -71,7 +71,7 @@ module YARD
71
71
  end
72
72
  list
73
73
  end
74
-
74
+
75
75
  def any(item)
76
76
  find do |section|
77
77
  return section if section == item
@@ -79,9 +79,9 @@ module YARD
79
79
  end
80
80
  nil
81
81
  end
82
-
82
+
83
83
  private
84
-
84
+
85
85
  def parse_sections(args)
86
86
  if args.size == 1 && args.first.is_a?(Array) && !args.first.is_a?(Section)
87
87
  args = args.first
@@ -94,7 +94,7 @@ module YARD
94
94
  else
95
95
  subsections = args[index + 1].is_a?(Array) ? args[index + 1] : []
96
96
  if subsections.is_a?(Section)
97
- subsections = []
97
+ subsections = []
98
98
  end
99
99
  sections << Section.new(name, subsections)
100
100
  end