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
data/lib/yard/cli/diff.rb CHANGED
@@ -9,27 +9,34 @@ module YARD
9
9
  # @since 0.6.0
10
10
  class Diff < Command
11
11
  def initialize
12
- require_rubygems
13
12
  super
14
13
  @list_all = false
14
+ @use_git = false
15
+ @old_git_commit = nil
16
+ @old_path = Dir.pwd
15
17
  log.show_backtraces = true
16
18
  end
17
-
19
+
18
20
  def description
19
21
  'Returns the object diff of two gems or .yardoc files'
20
22
  end
21
-
23
+
22
24
  def run(*args)
23
25
  registry = optparse(*args).map do |gemfile|
24
- if load_gem_data(gemfile)
25
- log.info "Found #{gemfile}"
26
+ if @use_git
27
+ load_git_commit(gemfile)
26
28
  Registry.all.map {|o| o.path }
27
29
  else
28
- log.error "Cannot find gem #{gemfile}"
29
- nil
30
+ if load_gem_data(gemfile)
31
+ log.info "Found #{gemfile}"
32
+ Registry.all.map {|o| o.path }
33
+ else
34
+ log.error "Cannot find gem #{gemfile}"
35
+ nil
36
+ end
30
37
  end
31
38
  end.compact
32
-
39
+
33
40
  return if registry.size != 2
34
41
 
35
42
  [ ["Added objects", registry[1] - registry[0]],
@@ -54,12 +61,27 @@ module YARD
54
61
  puts
55
62
  end
56
63
  end
57
-
64
+
58
65
  private
59
66
 
67
+ def load_git_commit(commit)
68
+ commit_path = 'git_commit' + commit.gsub(/\W/, '_')
69
+ tmpdir = File.join(Dir.tmpdir, commit_path)
70
+ log.info "Expanding #{commit} to #{tmpdir}..."
71
+ Dir.chdir(@old_path)
72
+ FileUtils.mkdir_p(tmpdir)
73
+ FileUtils.cp_r('.', tmpdir)
74
+ Dir.chdir(tmpdir)
75
+ log.info("git says: " + `git reset --hard #{commit}`.chomp)
76
+ generate_yardoc(tmpdir)
77
+ Dir.chdir(@old_path)
78
+ cleanup(commit_path)
79
+ end
80
+
60
81
  def load_gem_data(gemfile)
82
+ require_rubygems
61
83
  Registry.clear
62
-
84
+
63
85
  # First check for argument as .yardoc file
64
86
  [File.join(gemfile, '.yardoc'), gemfile].each do |yardoc|
65
87
  log.info "Searching for .yardoc db at #{yardoc}"
@@ -69,11 +91,11 @@ module YARD
69
91
  return true
70
92
  end
71
93
  end
72
-
94
+
73
95
  # Next check installed RubyGems
74
96
  gemfile_without_ext = gemfile.sub(/\.gem$/, '')
75
97
  log.info "Searching for installed gem #{gemfile_without_ext}"
76
- Gem.source_index.find_name('').find do |spec|
98
+ Gem.source_index.find_name('').find do |spec|
77
99
  if spec.full_name == gemfile_without_ext
78
100
  if yardoc = Registry.yardoc_file_for_gem(spec.name, "= #{spec.version}")
79
101
  Registry.load_yardoc(yardoc)
@@ -88,7 +110,7 @@ module YARD
88
110
  return true
89
111
  end
90
112
  end
91
-
113
+
92
114
  # Look for local .gem file
93
115
  gemfile += '.gem' unless gemfile =~ /\.gem$/
94
116
  log.info "Searching for local gem file #{gemfile}"
@@ -98,7 +120,7 @@ module YARD
98
120
  end
99
121
  return true
100
122
  end
101
-
123
+
102
124
  # Remote gemfile from rubygems.org
103
125
  url = "http://rubygems.org/downloads/#{gemfile}"
104
126
  log.info "Searching for remote gem file #{url}"
@@ -109,20 +131,20 @@ module YARD
109
131
  end
110
132
  false
111
133
  end
112
-
134
+
113
135
  def expand_and_parse(gemfile, io)
114
136
  dir = expand_gem(gemfile, io)
115
137
  generate_yardoc(dir)
116
138
  cleanup(gemfile)
117
139
  end
118
-
140
+
119
141
  def generate_yardoc(dir)
120
142
  olddir = Dir.pwd
121
143
  Dir.chdir(dir)
122
144
  log.enter_level(Logger::ERROR) { Yardoc.run('-n', '--no-save') }
123
145
  Dir.chdir(olddir)
124
146
  end
125
-
147
+
126
148
  def expand_gem(gemfile, io)
127
149
  tmpdir = File.join(Dir.tmpdir, gemfile)
128
150
  log.info "Expanding #{gemfile} to #{tmpdir}..."
@@ -142,13 +164,13 @@ module YARD
142
164
  log.error "Missing RubyGems, cannot run this command."
143
165
  raise(e)
144
166
  end
145
-
167
+
146
168
  def cleanup(gemfile)
147
169
  dir = File.join(Dir.tmpdir, gemfile)
148
170
  log.info "Cleaning up #{dir}..."
149
171
  FileUtils.rm_rf(dir)
150
172
  end
151
-
173
+
152
174
  def optparse(*args)
153
175
  opts = OptionParser.new
154
176
  opts.banner = "Usage: yard diff [options] oldgem newgem"
@@ -158,17 +180,20 @@ module YARD
158
180
  opts.separator "If the files don't exist locally, they will be grabbed using the `gem fetch`"
159
181
  opts.separator "command. If the gem is a .yardoc directory, it will be used. Finally, if the"
160
182
  opts.separator "gem name matches an installed gem (full name-version syntax), that gem will be used."
161
-
183
+
162
184
  opts.on('-a', '--all', 'List all objects, even if they are inside added/removed module/class') do
163
185
  @list_all = true
164
186
  end
187
+ opts.on('--git', 'Compare versions from two git commit/branches') do
188
+ @use_git = true
189
+ end
165
190
  common_options(opts)
166
191
  parse_options(opts, args)
167
192
  unless args.size == 2
168
193
  puts opts.banner
169
194
  exit(0)
170
195
  end
171
-
196
+
172
197
  args
173
198
  end
174
199
  end
data/lib/yard/cli/gems.rb CHANGED
@@ -6,22 +6,22 @@ module YARD
6
6
  @rebuild = false
7
7
  @gems = []
8
8
  end
9
-
9
+
10
10
  def description; "Builds YARD index for gems" end
11
-
11
+
12
12
  # Runs the commandline utility, parsing arguments and generating
13
13
  # YARD indexes for gems.
14
- #
14
+ #
15
15
  # @param [Array<String>] args the list of arguments
16
- # @return [void]
16
+ # @return [void]
17
17
  def run(*args)
18
18
  require 'rubygems'
19
19
  optparse(*args)
20
20
  build_gems
21
21
  end
22
-
22
+
23
23
  private
24
-
24
+
25
25
  # Builds .yardoc files for all non-existing gems
26
26
  # @param [Array] gems
27
27
  def build_gems
@@ -42,7 +42,7 @@ module YARD
42
42
  end
43
43
  end
44
44
  end
45
-
45
+
46
46
  def add_gems(gems)
47
47
  0.step(gems.size - 1, 2) do |index|
48
48
  gem, ver_require = gems[index], gems[index + 1] || ">= 0"
@@ -54,7 +54,7 @@ module YARD
54
54
  end
55
55
  end
56
56
  end
57
-
57
+
58
58
  # Parses options
59
59
  def optparse(*args)
60
60
  opts = OptionParser.new
@@ -66,12 +66,12 @@ module YARD
66
66
  opts.on('--rebuild', 'Rebuilds index') do
67
67
  @rebuild = true
68
68
  end
69
-
69
+
70
70
  common_options(opts)
71
71
  parse_options(opts, args)
72
72
  add_gems(args)
73
-
74
-
73
+
74
+
75
75
  if !args.empty? && @gems.empty?
76
76
  log.error "No specified gems could be found for command"
77
77
  elsif @gems.empty?
@@ -2,7 +2,7 @@ module YARD
2
2
  module CLI
3
3
  # A command-line utility to generate Graphviz graphs from
4
4
  # a set of objects
5
- #
5
+ #
6
6
  # @see Graph#run
7
7
  # @since 0.6.0
8
8
  class Graph < Command
@@ -10,7 +10,7 @@ module YARD
10
10
  # Default options are:
11
11
  # :format => :dot
12
12
  attr_reader :options
13
-
13
+
14
14
  # The set of objects to include in the graph.
15
15
  attr_reader :objects
16
16
 
@@ -20,13 +20,13 @@ module YARD
20
20
  @serializer = YARD::Serializers::StdoutSerializer.new
21
21
  @options = SymbolHash[:format => :dot]
22
22
  end
23
-
23
+
24
24
  def description
25
25
  "Graphs class diagram using Graphviz"
26
26
  end
27
-
27
+
28
28
  # Runs the command-line utility.
29
- #
29
+ #
30
30
  # @example
31
31
  # grapher = Graph.new
32
32
  # grapher.run('--private')
@@ -34,15 +34,15 @@ module YARD
34
34
  def run(*args)
35
35
  Registry.load
36
36
  optparse(*args)
37
-
37
+
38
38
  contents = objects.map {|o| o.format(options) }.join("\n")
39
39
  Templates::Engine.render(:format => :dot, :type => :layout,
40
40
  :verifier => @verifier, :serializer => @serializer,
41
41
  :contents => contents)
42
42
  end
43
-
43
+
44
44
  private
45
-
45
+
46
46
  # Parses commandline options.
47
47
  # @param [Array<String>] args each tokenized argument
48
48
  def optparse(*args)
@@ -63,8 +63,8 @@ module YARD
63
63
  opts.on('-d', '--dependencies', 'Show mixins in dependency graph.') do
64
64
  options[:dependencies] = true
65
65
  end
66
-
67
- opts.on('--no-public', "Don't show public methods. (default shows public)") do
66
+
67
+ opts.on('--no-public', "Don't show public methods. (default shows public)") do
68
68
  visibilities.delete(:public)
69
69
  end
70
70
 
@@ -72,7 +72,7 @@ module YARD
72
72
  visibilities.push(:protected)
73
73
  end
74
74
 
75
- opts.on('--private', "Show or don't show private methods. (default hides private)") do
75
+ opts.on('--private', "Show or don't show private methods. (default hides private)") do
76
76
  visibilities.push(:private)
77
77
  end
78
78
 
@@ -82,12 +82,12 @@ module YARD
82
82
  opts.on('--dot [OPTIONS]', 'Send the results directly to `dot` with optional arguments.') do |dotopts|
83
83
  @serializer = Serializers::ProcessSerializer.new('dot ' + dotopts.to_s)
84
84
  end
85
-
85
+
86
86
  opts.on('-f', '--file [FILE]', 'Writes output to a file instead of stdout.') do |file|
87
87
  @serializer = Serializers::FileSystemSerializer.new(:basepath => '.', :extension => nil)
88
88
  @serializer.instance_eval "def serialized_path(object) #{file.inspect} end"
89
89
  end
90
-
90
+
91
91
  common_options(opts)
92
92
  parse_options(opts, args)
93
93
 
data/lib/yard/cli/help.rb CHANGED
@@ -4,7 +4,7 @@ module YARD
4
4
  # @since 0.6.0
5
5
  class Help < Command
6
6
  def description; "Retrieves help for a command" end
7
-
7
+
8
8
  def run(*args)
9
9
  if args.first && cmd = CommandParser.commands[args.first.to_sym]
10
10
  cmd.run('--help')
@@ -0,0 +1,22 @@
1
+ module YARD
2
+ module CLI
3
+ # Lists all constant and method names in the codebase. Uses {Yardoc} --list.
4
+ class List < Command
5
+ def description; 'Lists all constant and methods. Uses `yard doc --list`' end
6
+
7
+ # Runs the commandline utility, parsing arguments and displaying a
8
+ # list of objects
9
+ #
10
+ # @param [Array<String>] args the list of arguments.
11
+ # @return [void]
12
+ def run(*args)
13
+ if args.include?('--help')
14
+ puts "Usage: yard list [yardoc_options]"
15
+ puts "Takes the same arguments as yardoc. See yardoc --help"
16
+ else
17
+ Yardoc.run('--list', *args)
18
+ end
19
+ end
20
+ end
21
+ end
22
+ end
@@ -5,28 +5,28 @@ module YARD
5
5
  class Server < Command
6
6
  # @return [Hash] a list of options to pass to the doc server
7
7
  attr_accessor :options
8
-
8
+
9
9
  # @return [Hash] a list of options to pass to the web server
10
10
  attr_accessor :server_options
11
-
11
+
12
12
  # @return [Hash] a list of library names and yardoc files to serve
13
13
  attr_accessor :libraries
14
-
14
+
15
15
  # @return [Adapter] the adapter to use for loading the web server
16
16
  attr_accessor :adapter
17
-
17
+
18
18
  # @return [Array<String>] a list of scripts to load
19
19
  # @since 0.6.2
20
20
  attr_accessor :scripts
21
-
21
+
22
22
  # @return [Array<String>] a list of template paths to register
23
23
  # @since 0.6.2
24
24
  attr_accessor :template_paths
25
-
25
+
26
26
  def description
27
27
  "Runs a local documentation server"
28
28
  end
29
-
29
+
30
30
  def run(*args)
31
31
  self.scripts = []
32
32
  self.template_paths = []
@@ -37,24 +37,24 @@ module YARD
37
37
  )
38
38
  self.server_options = {:Port => 8808}
39
39
  optparse(*args)
40
-
40
+
41
41
  select_adapter.setup
42
42
  load_scripts
43
43
  load_template_paths
44
44
  adapter.new(libraries, options, server_options).start
45
45
  end
46
-
46
+
47
47
  private
48
-
48
+
49
49
  def load_scripts
50
50
  scripts.each {|file| load_script(file) }
51
51
  end
52
-
52
+
53
53
  def load_template_paths
54
54
  return if YARD::Config.options[:safe_mode]
55
55
  Templates::Engine.template_paths |= template_paths
56
56
  end
57
-
57
+
58
58
  def select_adapter
59
59
  return adapter if adapter
60
60
  require 'rubygems'
@@ -63,7 +63,7 @@ module YARD
63
63
  rescue LoadError
64
64
  self.adapter = YARD::Server::WebrickAdapter
65
65
  end
66
-
66
+
67
67
  def add_libraries(args)
68
68
  (0...args.size).step(2) do |index|
69
69
  library, yardoc = args[index], args[index + 1]
@@ -76,7 +76,7 @@ module YARD
76
76
  end
77
77
  end
78
78
  end
79
-
79
+
80
80
  def add_gems
81
81
  require 'rubygems'
82
82
  Gem.source_index.find_name('').each do |spec|
@@ -84,7 +84,7 @@ module YARD
84
84
  libraries[spec.name] << YARD::Server::LibraryVersion.new(spec.name, spec.version.to_s, nil, :gem)
85
85
  end
86
86
  end
87
-
87
+
88
88
  def optparse(*args)
89
89
  opts = OptionParser.new
90
90
  opts.banner = 'Usage: yard server [options] [[library yardoc_file] ...]'
@@ -108,7 +108,7 @@ module YARD
108
108
  opts.on('-g', '--gems', 'Serves documentation for installed gems') do
109
109
  add_gems
110
110
  end
111
- opts.on('-t', '--template-path PATH',
111
+ opts.on('-t', '--template-path PATH',
112
112
  'The template path to look for templates in. (used with -t).') do |path|
113
113
  self.template_paths << path
114
114
  end
@@ -140,7 +140,7 @@ module YARD
140
140
  self.scripts << file
141
141
  end
142
142
  parse_options(opts, args)
143
-
143
+
144
144
  if args.empty? && libraries.empty?
145
145
  if !File.exist?('.yardoc')
146
146
  log.enter_level(Logger::INFO) do