yard 0.6.1 → 0.6.2
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of yard might be problematic. Click here for more details.
- data/ChangeLog +356 -0
- data/README.md +27 -5
- data/docs/GettingStarted.md +45 -6
- data/docs/Tags.md +16 -5
- data/docs/WhatsNew.md +60 -2
- data/lib/yard.rb +16 -37
- data/lib/yard/autoload.rb +5 -0
- data/lib/yard/cli/command.rb +18 -6
- data/lib/yard/cli/command_parser.rb +1 -0
- data/lib/yard/cli/config.rb +113 -0
- data/lib/yard/cli/gems.rb +16 -7
- data/lib/yard/cli/server.rb +30 -8
- data/lib/yard/cli/stats.rb +1 -1
- data/lib/yard/cli/yardoc.rb +16 -1
- data/lib/yard/code_objects/base.rb +7 -2
- data/lib/yard/code_objects/class_object.rb +1 -0
- data/lib/yard/code_objects/method_object.rb +1 -0
- data/lib/yard/code_objects/proxy.rb +8 -2
- data/lib/yard/config.rb +225 -0
- data/lib/yard/handlers/base.rb +29 -2
- data/lib/yard/handlers/processor.rb +1 -1
- data/lib/yard/handlers/ruby/class_handler.rb +6 -1
- data/lib/yard/handlers/ruby/constant_handler.rb +13 -15
- data/lib/yard/handlers/ruby/exception_handler.rb +1 -1
- data/lib/yard/handlers/ruby/extend_handler.rb +3 -0
- data/lib/yard/handlers/ruby/legacy/class_condition_handler.rb +1 -0
- data/lib/yard/handlers/ruby/legacy/class_handler.rb +7 -1
- data/lib/yard/handlers/ruby/legacy/constant_handler.rb +8 -10
- data/lib/yard/handlers/ruby/legacy/exception_handler.rb +1 -1
- data/lib/yard/handlers/ruby/legacy/extend_handler.rb +3 -0
- data/lib/yard/handlers/ruby/legacy/method_handler.rb +1 -0
- data/lib/yard/handlers/ruby/legacy/mixin_handler.rb +13 -2
- data/lib/yard/handlers/ruby/method_handler.rb +1 -0
- data/lib/yard/handlers/ruby/mixin_handler.rb +14 -4
- data/lib/yard/handlers/ruby/struct_handler_methods.rb +10 -1
- data/lib/yard/handlers/ruby/visibility_handler.rb +1 -1
- data/lib/yard/parser/c_parser.rb +26 -11
- data/lib/yard/parser/ruby/legacy/statement_list.rb +26 -9
- data/lib/yard/parser/source_parser.rb +5 -2
- data/lib/yard/serializers/yardoc_serializer.rb +2 -2
- data/lib/yard/server.rb +11 -0
- data/lib/yard/server/commands/frames_command.rb +1 -1
- data/lib/yard/server/commands/library_command.rb +22 -13
- data/lib/yard/server/commands/library_index_command.rb +1 -0
- data/lib/yard/server/commands/search_command.rb +2 -0
- data/lib/yard/server/commands/static_file_command.rb +6 -1
- data/lib/yard/server/templates/doc_server/processing/html/processing.erb +3 -3
- data/lib/yard/templates/helpers/html_helper.rb +1 -1
- data/lib/yard/templates/helpers/markup_helper.rb +13 -12
- data/lib/yard/verifier.rb +3 -1
- data/spec/cli/config_spec.rb +72 -0
- data/spec/cli/gems_spec.rb +81 -0
- data/spec/cli/server_spec.rb +35 -5
- data/spec/cli/stats_spec.rb +15 -0
- data/spec/cli/yardoc_spec.rb +39 -1
- data/spec/code_objects/base_spec.rb +2 -0
- data/spec/code_objects/method_object_spec.rb +5 -0
- data/spec/code_objects/proxy_spec.rb +20 -5
- data/spec/config_spec.rb +165 -0
- data/spec/handlers/alias_handler_spec.rb +7 -0
- data/spec/handlers/base_spec.rb +64 -0
- data/spec/handlers/class_condition_handler_spec.rb +13 -8
- data/spec/handlers/class_handler_spec.rb +54 -46
- data/spec/handlers/constant_handler_spec.rb +13 -0
- data/spec/handlers/examples/alias_handler_001.rb.txt +2 -0
- data/spec/handlers/examples/class_handler_001.rb.txt +12 -1
- data/spec/handlers/examples/constant_handler_001.rb.txt +6 -0
- data/spec/handlers/examples/exception_handler_001.rb.txt +8 -0
- data/spec/handlers/examples/method_handler_001.rb.txt +6 -0
- data/spec/handlers/examples/visibility_handler_001.rb.txt +3 -0
- data/spec/handlers/exception_handler_spec.rb +5 -0
- data/spec/handlers/extend_handler_spec.rb +4 -0
- data/spec/handlers/method_handler_spec.rb +5 -0
- data/spec/handlers/mixin_handler_spec.rb +10 -0
- data/spec/handlers/visibility_handler_spec.rb +4 -0
- data/spec/parser/base_spec.rb +1 -1
- data/spec/parser/c_parser_spec.rb +39 -1
- data/spec/parser/examples/override.c.txt +424 -0
- data/spec/parser/ruby/legacy/statement_list_spec.rb +11 -0
- data/spec/parser/source_parser_spec.rb +33 -1
- data/spec/server/commands/static_file_command_spec.rb +20 -3
- data/spec/server_spec.rb +10 -0
- data/spec/templates/examples/method001.html +33 -3
- data/spec/templates/examples/method001.txt +8 -1
- data/spec/templates/helpers/markup_helper_spec.rb +21 -26
- data/spec/templates/method_spec.rb +3 -1
- data/spec/verifier_spec.rb +5 -0
- data/templates/default/fulldoc/html/css/style.css +4 -1
- data/templates/default/fulldoc/html/js/app.js +1 -1
- data/templates/default/tags/html/option.erb +1 -3
- data/templates/default/tags/setup.rb +18 -15
- metadata +11 -4
- data/spec/yard_spec.rb +0 -55
data/docs/Tags.md
CHANGED
@@ -96,19 +96,25 @@ YARD supplies the following built-in tags:
|
|
96
96
|
implementor information.
|
97
97
|
|
98
98
|
@abstract Subclass and override {#run} to implement a custom Threadable class.
|
99
|
+
|
100
|
+
* `@api`: Declares the API that the object belongs to. Does not display in
|
101
|
+
output, but useful for performing queries (`yardoc --query`). Any text is
|
102
|
+
allowable in this tag, and there are no predefined values.
|
103
|
+
|
104
|
+
@api freeform text
|
99
105
|
|
100
106
|
* `@attr`: Declares an attribute from the docstring of a class. Meant to be
|
101
|
-
used on Struct classes (classes that inherit Struct).
|
107
|
+
used on Struct classes only (classes that inherit Struct).
|
102
108
|
|
103
109
|
@attr [Types] attribute_name a full description of the attribute
|
104
110
|
|
105
111
|
* `@attr_reader`: Declares a readonly attribute from the docstring of a class.
|
106
|
-
Meant to be used on Struct classes (classes that inherit Struct). See `@attr`.
|
112
|
+
Meant to be used on Struct classes only (classes that inherit Struct). See `@attr`.
|
107
113
|
|
108
114
|
@attr_reader [Types] name description of a readonly attribute
|
109
115
|
|
110
116
|
* `@attr_writer`: Declares a writeonly attribute from the docstring of class.
|
111
|
-
Meant to be used on Struct classes (classes that inherit Struct). See `@attr`.
|
117
|
+
Meant to be used on Struct classes only (classes that inherit Struct). See `@attr`.
|
112
118
|
|
113
119
|
@attr_writer [Types] name description of writeonly attribute
|
114
120
|
|
@@ -125,7 +131,12 @@ YARD supplies the following built-in tags:
|
|
125
131
|
first line is an optional title.
|
126
132
|
|
127
133
|
@example Reverse a string
|
128
|
-
"mystring.reverse
|
134
|
+
"mystring".reverse #=> "gnirtsym"
|
135
|
+
|
136
|
+
* `@note`: Creates an emphasized note for the users to read about the
|
137
|
+
object.
|
138
|
+
|
139
|
+
@note This method should only be used in outer space.
|
129
140
|
|
130
141
|
* `@option`: Describe an options hash in a method. The tag takes the
|
131
142
|
name of the options parameter first, followed by optional types,
|
@@ -168,7 +179,7 @@ YARD supplies the following built-in tags:
|
|
168
179
|
command-line switch to yardoc (see {file:README.md}).
|
169
180
|
|
170
181
|
@private
|
171
|
-
|
182
|
+
|
172
183
|
* `@raise`: Describes an Exception that a method may throw
|
173
184
|
|
174
185
|
@raise [ExceptionClass] description
|
data/docs/WhatsNew.md
CHANGED
@@ -14,6 +14,11 @@ What's New in 0.6.x?
|
|
14
14
|
11. **Added `--transitive-tags` to register transitive tags** (0.6.0)
|
15
15
|
12. **`yardoc` now displays RDoc-like statistics (`--no-stats` to hide)** (0.6.0)
|
16
16
|
13. **`yri` now works on constants** (0.6.0)
|
17
|
+
14. **Plugins are no longer auto-loaded (added `--plugin` switch)** (0.6.2)
|
18
|
+
15. **Added `YARD::Config` API and `~/.yard/config` configuration file** (0.6.2)
|
19
|
+
16. **Added `yard config` command to view/edit configuration** (0.6.2)
|
20
|
+
17. **Added `yard server -t` template path switch** (0.6.2)
|
21
|
+
18. **Added `YARD::Server.register_static_path` for static server assets** (0.6.2)
|
17
22
|
|
18
23
|
## Local documentation server for RubyGems or projects (`yard server`) (0.6.0)
|
19
24
|
|
@@ -218,6 +223,59 @@ To hide this output when yardoc is run, use `--no-stats`.
|
|
218
223
|
Templates have now been added for text view of constants, which displays any
|
219
224
|
documentation and the constant value.
|
220
225
|
|
226
|
+
## Plugins are no longer auto-loaded (added `--plugin` switch) (0.6.2)
|
227
|
+
|
228
|
+
This is a backwards-incompatible change that disables plugins from automatically
|
229
|
+
loading when YARD starts up. From now on, you should manually declare which
|
230
|
+
plugins your project is using by adding `--plugin PLUGINNAME` to a `.yardopts`
|
231
|
+
file in the root of your project. You can also re-enable autoloaded plugins
|
232
|
+
by setting `load_plugins` to true in your configuration file (`yard config load_plugins true`,
|
233
|
+
see next item). You can also set `autoload_plugins` to a list of plugins
|
234
|
+
to be automatically loaded on start.
|
235
|
+
|
236
|
+
If you are a YARD plugin author, please make sure to inform your users of these
|
237
|
+
changes.
|
238
|
+
|
239
|
+
Note that `--plugin` switches passed on the commandline (not via `.yardopts`)
|
240
|
+
are parsed before commands are loaded, and therefore can add in new CLI commands.
|
241
|
+
|
242
|
+
## Added `YARD::Config` API and `~/.yard/config` configuration file (0.6.2)
|
243
|
+
|
244
|
+
There is a new global configuration API that can be accessed programmatically
|
245
|
+
and set via the `~/.yard/config` file. The file is encoded as a YAML file,
|
246
|
+
and looks like:
|
247
|
+
|
248
|
+
:load_plugins: false
|
249
|
+
:ignored_plugins:
|
250
|
+
- my_plugin
|
251
|
+
- my_other_plugin
|
252
|
+
:autoload_plugins:
|
253
|
+
- my_autoload_plugin
|
254
|
+
:safe_mode: false
|
255
|
+
|
256
|
+
You can also set configuration options via the command-line (see next item).
|
257
|
+
|
258
|
+
## Added `yard config` command to view/edit configuration (0.6.2)
|
259
|
+
|
260
|
+
A new `yard config` command was created to view or edit the configuration
|
261
|
+
file via the commandline.
|
262
|
+
|
263
|
+
* To view the current configuration use `yard config --list`.
|
264
|
+
* To view a specific item use `yard config ITEMNAME`
|
265
|
+
* To modify an item value use `yard config ITEMNAME VALUE`
|
266
|
+
|
267
|
+
## Added `yard server -t` template path switch (0.6.2)
|
268
|
+
|
269
|
+
The `yard server` command now accepts `-t` or `--template-path` to register
|
270
|
+
a new template path for template customization.
|
271
|
+
|
272
|
+
## Added `YARD::Server.register_static_path` for static server assets (0.6.2)
|
273
|
+
|
274
|
+
The server now supports a command to register static asset paths. If you are
|
275
|
+
extending the YARD::Server modules, make sure to register your asset paths
|
276
|
+
through this method.
|
277
|
+
|
278
|
+
|
221
279
|
What's New in 0.5.x?
|
222
280
|
====================
|
223
281
|
|
@@ -254,13 +312,13 @@ Incremental parsing and output generation with `yardoc -c` (0.5.0, 0.5.3)
|
|
254
312
|
YARD now compares file checksums before parsing when using `yardoc -c`
|
255
313
|
(aka `yardoc --use-cache`) to do incremental parsing of only the files that
|
256
314
|
have changed. HTML (or other output format) generation will also only be
|
257
|
-
done on the objects that were parsed from changed files (
|
315
|
+
done on the objects that were parsed from changed files (\*). This makes doing
|
258
316
|
a documentation development cycle much faster for quick HTML previews. Just
|
259
317
|
remember that when using incremental output generation, the index will not
|
260
318
|
be rebuilt and inter-file links might not hook up right, so it is best to
|
261
319
|
perform a full rebuild at the end of such previews.
|
262
320
|
|
263
|
-
(
|
321
|
+
(\*) Only for versions prior to 0.5.3. For 0.5.3+, use `--incremental` for
|
264
322
|
incremental HTML output.
|
265
323
|
|
266
324
|
Improved `yri` support to perform lookups on installed Gems (0.5.0)
|
data/lib/yard.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
module YARD
|
2
|
-
VERSION = "0.6.
|
2
|
+
VERSION = "0.6.2"
|
3
3
|
|
4
4
|
# The root path for YARD source libraries
|
5
5
|
ROOT = File.expand_path(File.dirname(__FILE__))
|
@@ -7,7 +7,7 @@ module YARD
|
|
7
7
|
# The root path for YARD builtin templates
|
8
8
|
TEMPLATE_ROOT = File.join(ROOT, '..', 'templates')
|
9
9
|
|
10
|
-
#
|
10
|
+
# @deprecated Use {Config::CONFIG_DIR}
|
11
11
|
CONFIG_DIR = File.expand_path('~/.yard')
|
12
12
|
|
13
13
|
# An alias to {Parser::SourceParser}'s parsing method
|
@@ -24,39 +24,23 @@ module YARD
|
|
24
24
|
# @see Parser::SourceParser.parse_string
|
25
25
|
def self.parse_string(*args) Parser::SourceParser.parse_string(*args) end
|
26
26
|
|
27
|
-
#
|
28
|
-
#
|
29
|
-
|
30
|
-
#
|
31
|
-
# @return [true] always returns true
|
32
|
-
def self.load_plugins
|
33
|
-
ignored_plugins_file = File.join(CONFIG_DIR, "ignored_plugins")
|
34
|
-
if File.file?(ignored_plugins_file)
|
35
|
-
ignored_plugins = IO.read(ignored_plugins_file).split(/\s+/)
|
36
|
-
else
|
37
|
-
ignored_plugins = []
|
38
|
-
end
|
39
|
-
|
40
|
-
Gem.source_index.find_name('').each do |gem|
|
41
|
-
begin
|
42
|
-
if gem.name =~ /^yard[-_](?!doc-)/ && !ignored_plugins.include?(gem.name)
|
43
|
-
log.debug "Loading plugin '#{gem.name}'..."
|
44
|
-
require gem.name
|
45
|
-
end
|
46
|
-
rescue Gem::LoadError, LoadError
|
47
|
-
log.warn "Error loading plugin '#{gem.name}'"
|
48
|
-
end
|
49
|
-
end
|
50
|
-
true
|
51
|
-
end
|
27
|
+
# (see YARD::Config.load_plugins)
|
28
|
+
# @deprecated Use {Config.load_plugins}
|
29
|
+
def self.load_plugins; YARD::Config.load_plugins end
|
52
30
|
end
|
53
31
|
|
54
|
-
# Ruby 1.9.2 removes '.' which is not exactly a good idea
|
55
|
-
$LOAD_PATH.push('.') if RUBY_VERSION >= '1.9.2'
|
56
|
-
|
57
32
|
# Keep track of Ruby version for compatibility code
|
58
33
|
RUBY19, RUBY18 = *(RUBY_VERSION >= "1.9.1" ? [true, false] : [false, true])
|
59
34
|
|
35
|
+
# Whether or not continuations are (properly) supported
|
36
|
+
begin
|
37
|
+
begin; require 'continuation'; rescue LoadError; end
|
38
|
+
cc = callcc {|cc| cc }; cc.call if cc
|
39
|
+
CONTINUATIONS_SUPPORTED = true
|
40
|
+
rescue
|
41
|
+
CONTINUATIONS_SUPPORTED = false
|
42
|
+
end
|
43
|
+
|
60
44
|
# Load Ruby core extension classes
|
61
45
|
Dir.glob(File.join(YARD::ROOT, 'yard', 'core_ext', '*.rb')).each do |file|
|
62
46
|
require file
|
@@ -66,10 +50,5 @@ end
|
|
66
50
|
require File.join(YARD::ROOT, 'yard', file)
|
67
51
|
end
|
68
52
|
|
69
|
-
# Load
|
70
|
-
|
71
|
-
require 'rubygems'
|
72
|
-
YARD.load_plugins
|
73
|
-
rescue LoadError
|
74
|
-
log.debug "RubyGems is not present, skipping plugin loading"
|
75
|
-
end
|
53
|
+
# Load YARD configuration options (and plugins)
|
54
|
+
YARD::Config.load
|
data/lib/yard/autoload.rb
CHANGED
@@ -5,6 +5,7 @@ module YARD
|
|
5
5
|
module CLI # Namespace for command-line interface components
|
6
6
|
autoload :Command, __p('cli/command')
|
7
7
|
autoload :CommandParser, __p('cli/command_parser')
|
8
|
+
autoload :Config, __p('cli/config')
|
8
9
|
autoload :Diff, __p('cli/diff')
|
9
10
|
autoload :Gems, __p('cli/gems')
|
10
11
|
autoload :Graph, __p('cli/graph')
|
@@ -136,6 +137,8 @@ module YARD
|
|
136
137
|
# Namespace for classes and modules that handle serving documentation over HTTP
|
137
138
|
# @since 0.6.0
|
138
139
|
module Server
|
140
|
+
require __p('server')
|
141
|
+
|
139
142
|
module Commands
|
140
143
|
autoload :Base, __p('server/commands/base')
|
141
144
|
autoload :DisplayFileCommand, __p('server/commands/display_file_command')
|
@@ -197,10 +200,12 @@ module YARD
|
|
197
200
|
autoload :Template, __p('templates/template')
|
198
201
|
end
|
199
202
|
|
203
|
+
autoload :Config, __p('config')
|
200
204
|
autoload :Docstring, __p('docstring')
|
201
205
|
autoload :Logger, __p('logging')
|
202
206
|
autoload :Registry, __p('registry')
|
203
207
|
autoload :RegistryStore, __p('registry_store')
|
208
|
+
autoload :StubProxy, __p('serializers/yardoc_serializer')
|
204
209
|
autoload :Verifier, __p('verifier')
|
205
210
|
end
|
206
211
|
|
data/lib/yard/cli/command.rb
CHANGED
@@ -24,12 +24,11 @@ module YARD
|
|
24
24
|
opts.separator ""
|
25
25
|
opts.separator "Other options:"
|
26
26
|
opts.on('-e', '--load FILE', 'A Ruby script to load before the source tree is parsed.') do |file|
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
end
|
27
|
+
load_script(file)
|
28
|
+
end
|
29
|
+
opts.on('--plugin PLUGIN', 'Load a YARD plugin (gem with `yard-\' prefix)') do |name|
|
30
|
+
# Not actually necessary to load here, this is done at boot in YARD::Config.load_plugins
|
31
|
+
# YARD::Config.load_plugin(name)
|
33
32
|
end
|
34
33
|
opts.on('--legacy', 'Use old style Ruby parser and handlers. Always on in 1.8.x.') do
|
35
34
|
YARD::Parser::SourceParser.parser_type = :ruby18
|
@@ -53,6 +52,19 @@ module YARD
|
|
53
52
|
rescue OptionParser::InvalidOption => e
|
54
53
|
log.warn "Unrecognized/#{e.message}"
|
55
54
|
end
|
55
|
+
|
56
|
+
# Loads a Ruby script. If +Config.options[:safe_mode]+ is enabled,
|
57
|
+
# this method will do nothing.
|
58
|
+
#
|
59
|
+
# @param [String] file the path to the script to load
|
60
|
+
# @since 0.6.2
|
61
|
+
def load_script(file)
|
62
|
+
return if YARD::Config.options[:safe_mode]
|
63
|
+
require(file.gsub(/\.rb$/, ''))
|
64
|
+
rescue LoadError
|
65
|
+
log.error "The file `#{file}' could not be loaded, check the path and try again."
|
66
|
+
exit
|
67
|
+
end
|
56
68
|
end
|
57
69
|
end
|
58
70
|
end
|
@@ -0,0 +1,113 @@
|
|
1
|
+
module YARD
|
2
|
+
module CLI
|
3
|
+
# CLI command to view or edit configuration options
|
4
|
+
# @since 0.6.2
|
5
|
+
class Config < Command
|
6
|
+
# @return [Symbol, nil] the key to view/edit, if any
|
7
|
+
attr_accessor :key
|
8
|
+
|
9
|
+
# @return [Array, nil] the list of values to set (or single value), if modifying
|
10
|
+
attr_accessor :values
|
11
|
+
|
12
|
+
# @return [Boolean] whether to reset the {#key}
|
13
|
+
attr_accessor :reset
|
14
|
+
|
15
|
+
def initialize
|
16
|
+
super
|
17
|
+
self.key = nil
|
18
|
+
self.values = []
|
19
|
+
self.reset = false
|
20
|
+
end
|
21
|
+
|
22
|
+
def description
|
23
|
+
'Views or edits current global configuration'
|
24
|
+
end
|
25
|
+
|
26
|
+
def run(*args)
|
27
|
+
optparse(*args)
|
28
|
+
if key
|
29
|
+
if reset || values.size > 0
|
30
|
+
modify_item
|
31
|
+
else
|
32
|
+
view_item
|
33
|
+
end
|
34
|
+
else
|
35
|
+
list_configuration
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
private
|
40
|
+
|
41
|
+
def modify_item
|
42
|
+
if reset
|
43
|
+
log.debug "Resetting #{key}"
|
44
|
+
YARD::Config.options[key] = YARD::Config::DEFAULT_CONFIG_OPTIONS[key]
|
45
|
+
else
|
46
|
+
log.debug "Setting #{key} to #{values.inspect}"
|
47
|
+
YARD::Config.options[key] = encode_values
|
48
|
+
end
|
49
|
+
YARD::Config.save
|
50
|
+
end
|
51
|
+
|
52
|
+
def view_item
|
53
|
+
log.debug "Viewing #{key}"
|
54
|
+
puts YARD::Config.options[key].inspect
|
55
|
+
end
|
56
|
+
|
57
|
+
def list_configuration
|
58
|
+
log.debug "Listing configuration"
|
59
|
+
require 'yaml'
|
60
|
+
puts YAML.dump(YARD::Config.options).sub(/\A--.*\n/, '').gsub(/\n\n/, "\n")
|
61
|
+
end
|
62
|
+
|
63
|
+
def encode_values
|
64
|
+
if values.size == 1
|
65
|
+
encode_value(values.first)
|
66
|
+
else
|
67
|
+
values.map {|v| encode_value(v) }
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
def encode_value(value)
|
72
|
+
case value
|
73
|
+
when /^-?\d+/; value.to_i
|
74
|
+
when "true"; true
|
75
|
+
when "false"; false
|
76
|
+
else value
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
def optparse(*args)
|
81
|
+
list = false
|
82
|
+
opts = OptionParser.new
|
83
|
+
opts.banner = "Usage: yard config [options] [item [value ...]]"
|
84
|
+
opts.separator ""
|
85
|
+
opts.separator "Example: yard config load_plugins true"
|
86
|
+
opts.separator ""
|
87
|
+
opts.separator "Views and sets configuration items. If an item is provided"
|
88
|
+
opts.separator "With no value, the item is viewed. If a value is provided,"
|
89
|
+
opts.separator "the item is modified. Specifying no item is equivalent to --list."
|
90
|
+
opts.separator "If you specify multiple space delimited values, these are"
|
91
|
+
opts.separator "parsed as an array of values."
|
92
|
+
opts.separator ""
|
93
|
+
opts.separator "Note that `true` and `false` are reserved words."
|
94
|
+
opts.separator ""
|
95
|
+
opts.separator "General options:"
|
96
|
+
|
97
|
+
opts.on('-l', '--list', 'List current configuration') do
|
98
|
+
list = true
|
99
|
+
end
|
100
|
+
opts.on('-r', '--reset', 'Resets the specific item to default') do
|
101
|
+
self.reset = true
|
102
|
+
end
|
103
|
+
common_options(opts)
|
104
|
+
parse_options(opts, args)
|
105
|
+
args = [] if list
|
106
|
+
self.key = args.shift.to_sym if args.size >= 1
|
107
|
+
self.values = args if args.size >= 1
|
108
|
+
args
|
109
|
+
end
|
110
|
+
|
111
|
+
end
|
112
|
+
end
|
113
|
+
end
|
data/lib/yard/cli/gems.rb
CHANGED
@@ -15,8 +15,8 @@ module YARD
|
|
15
15
|
# @param [Array<String>] args the list of arguments
|
16
16
|
# @return [void]
|
17
17
|
def run(*args)
|
18
|
+
require 'rubygems'
|
18
19
|
optparse(*args)
|
19
|
-
@gems += Gem.source_index.find_name('') if @gems.empty?
|
20
20
|
build_gems
|
21
21
|
end
|
22
22
|
|
@@ -44,9 +44,14 @@ module YARD
|
|
44
44
|
end
|
45
45
|
|
46
46
|
def add_gems(gems)
|
47
|
-
gems.
|
48
|
-
|
49
|
-
|
47
|
+
0.step(gems.size - 1, 2) do |index|
|
48
|
+
gem, ver_require = gems[index], gems[index + 1] || ">= 0"
|
49
|
+
specs = Gem.source_index.find_name(gem, ver_require)
|
50
|
+
if specs.empty?
|
51
|
+
log.warn "#{gem} #{ver_require} could not be found in RubyGems index"
|
52
|
+
else
|
53
|
+
@gems += specs
|
54
|
+
end
|
50
55
|
end
|
51
56
|
end
|
52
57
|
|
@@ -61,13 +66,17 @@ module YARD
|
|
61
66
|
opts.on('--rebuild', 'Rebuilds index') do
|
62
67
|
@rebuild = true
|
63
68
|
end
|
64
|
-
opts.on('--legacy', 'Use old style parser and handlers. Unavailable under Ruby 1.8.x') do
|
65
|
-
YARD::Parser::SourceParser.parser_type = :ruby18
|
66
|
-
end
|
67
69
|
|
68
70
|
common_options(opts)
|
69
71
|
parse_options(opts, args)
|
70
72
|
add_gems(args)
|
73
|
+
|
74
|
+
|
75
|
+
if !args.empty? && @gems.empty?
|
76
|
+
log.error "No specified gems could be found for command"
|
77
|
+
elsif @gems.empty?
|
78
|
+
@gems += Gem.source_index.find_name('') if @gems.empty?
|
79
|
+
end
|
71
80
|
end
|
72
81
|
end
|
73
82
|
end
|