yard 0.6.4 → 0.6.5
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 +341 -0
- data/LICENSE +1 -1
- data/README.md +31 -6
- data/Rakefile +22 -3
- data/docs/Tags.md +5 -1
- data/docs/WhatsNew.md +18 -1
- data/lib/rubygems_plugin.rb +3 -99
- data/lib/yard.rb +1 -1
- data/lib/yard/autoload.rb +37 -35
- data/lib/yard/cli/config.rb +25 -2
- data/lib/yard/cli/graph.rb +1 -1
- data/lib/yard/cli/yardoc.rb +4 -0
- data/lib/yard/code_objects/base.rb +17 -9
- data/lib/yard/code_objects/method_object.rb +0 -9
- data/lib/yard/code_objects/proxy.rb +6 -0
- data/lib/yard/docstring.rb +5 -0
- data/lib/yard/handlers/base.rb +3 -1
- data/lib/yard/handlers/processor.rb +1 -1
- data/lib/yard/handlers/ruby/alias_handler.rb +9 -8
- data/lib/yard/handlers/ruby/class_handler.rb +3 -3
- data/lib/yard/handlers/ruby/legacy/alias_handler.rb +9 -7
- data/lib/yard/handlers/ruby/legacy/method_handler.rb +7 -0
- data/lib/yard/handlers/ruby/legacy/private_constant_handler.rb +21 -0
- data/lib/yard/handlers/ruby/method_condition_handler.rb +1 -1
- data/lib/yard/handlers/ruby/method_handler.rb +7 -0
- data/lib/yard/handlers/ruby/private_constant_handler.rb +36 -0
- data/lib/yard/parser/ruby/ast_node.rb +41 -24
- data/lib/yard/parser/ruby/legacy/ruby_parser.rb +3 -0
- data/lib/yard/parser/ruby/legacy/statement.rb +2 -0
- data/lib/yard/parser/ruby/legacy/statement_list.rb +27 -4
- data/lib/yard/parser/ruby/ruby_parser.rb +71 -36
- data/lib/yard/parser/source_parser.rb +11 -10
- data/lib/yard/registry.rb +62 -24
- data/lib/yard/registry_store.rb +18 -5
- data/lib/yard/rubygems/doc_manager.rb +75 -0
- data/lib/yard/rubygems/specification.rb +23 -0
- data/lib/yard/serializers/process_serializer.rb +1 -1
- data/lib/yard/serializers/yardoc_serializer.rb +7 -2
- data/lib/yard/server/commands/display_object_command.rb +1 -1
- data/lib/yard/server/commands/library_command.rb +2 -2
- data/lib/yard/tags/default_factory.rb +1 -1
- data/lib/yard/tags/library.rb +2 -2
- data/lib/yard/templates/helpers/base_helper.rb +19 -0
- data/lib/yard/templates/helpers/html_helper.rb +22 -9
- data/lib/yard/templates/helpers/html_syntax_highlight_helper.rb +28 -0
- data/lib/yard/templates/helpers/markup_helper.rb +14 -22
- data/lib/yard/templates/template.rb +1 -1
- data/spec/cli/config_spec.rb +20 -0
- data/spec/cli/yardoc_spec.rb +12 -0
- data/spec/code_objects/base_spec.rb +13 -0
- data/spec/code_objects/proxy_spec.rb +9 -0
- data/spec/config_spec.rb +4 -1
- data/spec/docstring_spec.rb +5 -0
- data/spec/handlers/alias_handler_spec.rb +14 -1
- data/spec/handlers/attribute_handler_spec.rb +1 -1
- data/spec/handlers/base_spec.rb +21 -21
- data/spec/handlers/class_condition_handler_spec.rb +1 -1
- data/spec/handlers/class_handler_spec.rb +1 -1
- data/spec/handlers/class_variable_handler_spec.rb +1 -1
- data/spec/handlers/constant_handler_spec.rb +2 -2
- data/spec/handlers/examples/alias_handler_001.rb.txt +14 -0
- data/spec/handlers/examples/method_handler_001.rb.txt +6 -0
- data/spec/handlers/examples/module_handler_001.rb.txt +4 -0
- data/spec/handlers/examples/private_constant_handler_001.rb.txt +8 -0
- data/spec/handlers/exception_handler_spec.rb +1 -1
- data/spec/handlers/extend_handler_spec.rb +1 -1
- data/spec/handlers/method_condition_handler_spec.rb +1 -1
- data/spec/handlers/method_handler_spec.rb +7 -1
- data/spec/handlers/mixin_handler_spec.rb +1 -1
- data/spec/handlers/module_handler_spec.rb +5 -1
- data/spec/handlers/private_constant_handler_spec.rb +24 -0
- data/spec/handlers/process_handler_spec.rb +1 -1
- data/spec/handlers/ruby/base_spec.rb +4 -4
- data/spec/handlers/visibility_handler_spec.rb +1 -1
- data/spec/handlers/yield_handler_spec.rb +1 -1
- data/spec/parser/base_spec.rb +3 -5
- data/spec/parser/c_parser_spec.rb +1 -1
- data/spec/parser/ruby/ast_node_spec.rb +23 -26
- data/spec/parser/ruby/legacy/statement_list_spec.rb +9 -0
- data/spec/parser/ruby/ruby_parser_spec.rb +179 -177
- data/spec/parser/source_parser_spec.rb +41 -7
- data/spec/rake/yardoc_task_spec.rb +3 -3
- data/spec/registry_spec.rb +52 -0
- data/spec/registry_store_spec.rb +71 -1
- data/spec/serializers/yardoc_serializer_spec.rb +18 -7
- data/spec/server/rack_adapter_spec.rb +2 -2
- data/spec/spec_helper.rb +10 -0
- data/spec/tags/default_factory_spec.rb +122 -120
- data/spec/templates/helpers/base_helper_spec.rb +38 -14
- data/spec/templates/helpers/html_helper_spec.rb +19 -0
- data/spec/templates/helpers/html_syntax_highlight_helper_spec.rb +10 -6
- data/spec/templates/helpers/markup_helper_spec.rb +21 -5
- data/templates/default/class/dot/superklass.erb +1 -1
- data/templates/default/docstring/setup.rb +1 -1
- data/templates/default/fulldoc/html/css/style.css +12 -4
- data/templates/default/fulldoc/html/js/app.js +1 -1
- data/templates/default/fulldoc/html/js/jquery.js +5 -143
- data/templates/default/layout/html/files.erb +11 -0
- data/templates/default/layout/html/headers.erb +1 -1
- data/templates/default/layout/html/index.erb +2 -49
- data/templates/default/layout/html/listing.erb +4 -0
- data/templates/default/layout/html/objects.erb +32 -0
- data/templates/default/layout/html/setup.rb +1 -1
- data/templates/default/module/dot/info.erb +1 -1
- data/templates/default/module/dot/setup.rb +1 -1
- metadata +15 -6
- data/lib/yard/templates/helpers/html_syntax_highlight_helper18.rb +0 -25
data/docs/Tags.md
CHANGED
@@ -99,9 +99,13 @@ YARD supplies the following built-in tags:
|
|
99
99
|
|
100
100
|
* `@api`: Declares the API that the object belongs to. Does not display in
|
101
101
|
output, but useful for performing queries (`yardoc --query`). Any text is
|
102
|
-
allowable in this tag, and there are no predefined values.
|
102
|
+
allowable in this tag, and there are no predefined values(*).
|
103
103
|
|
104
104
|
@api freeform text
|
105
|
+
|
106
|
+
(*) Note that the special name `@api private` does display a notice in
|
107
|
+
documentation if it is listed, letting users know that the method is not
|
108
|
+
to be used.
|
105
109
|
|
106
110
|
* `@attr`: Declares an attribute from the docstring of a class. Meant to be
|
107
111
|
used on Struct classes only (classes that inherit Struct).
|
data/docs/WhatsNew.md
CHANGED
@@ -19,6 +19,8 @@ What's New in 0.6.x?
|
|
19
19
|
16. **Added `yard config` command to view/edit configuration** (0.6.2)
|
20
20
|
17. **Added `yard server -t` template path switch** (0.6.2)
|
21
21
|
18. **Added `YARD::Server.register_static_path` for static server assets** (0.6.2)
|
22
|
+
19. **YARD::Registry is now thread local** (0.6.5)
|
23
|
+
20. **Support for ripper gem in Ruby 1.8.7** (0.6.5)
|
22
24
|
|
23
25
|
## Local documentation server for RubyGems or projects (`yard server`) (0.6.0)
|
24
26
|
|
@@ -201,7 +203,7 @@ in the templates, use the `--hide-tag` option to hide it from generated output:
|
|
201
203
|
|
202
204
|
## Added `--transitive-tags` to register transitive tags (0.6.0)
|
203
205
|
|
204
|
-
Transitive tags are tags that apply to all
|
206
|
+
Transitive tags are tags that apply to all descendants of a namespace (class
|
205
207
|
or module) when documented on that namespace. For instance, the `@since` tag
|
206
208
|
is a transitive tag. Applying `@since` to a class will automatically apply
|
207
209
|
`@since` to all methods in the class. Creating a `@since` tag directly on a
|
@@ -275,6 +277,21 @@ The server now supports a command to register static asset paths. If you are
|
|
275
277
|
extending the YARD::Server modules, make sure to register your asset paths
|
276
278
|
through this method.
|
277
279
|
|
280
|
+
## YARD::Registry is now thread local (0.6.5)
|
281
|
+
|
282
|
+
Creating a new thread will now implicitly load a new Registry that can be used
|
283
|
+
to parse and process new code objects independently of the other threads. Note
|
284
|
+
that this means you can no longer use the Registry across threads; you must
|
285
|
+
either access the threadlocal object directly, or synchronize threads to do
|
286
|
+
the processing in the initial registry's thread.
|
287
|
+
|
288
|
+
## Support for ripper gem in Ruby 1.8.7 (0.6.5)
|
289
|
+
|
290
|
+
YARD now supports the Ruby 1.8.7 port of the `ripper` gem to improve parsing
|
291
|
+
of source, both in terms of performance and functionality. When the `ripper`
|
292
|
+
gem is available, YARD will use the "new-style" handlers. You can take advantage
|
293
|
+
of this functionality by performing a `gem install ripper`.
|
294
|
+
|
278
295
|
|
279
296
|
What's New in 0.5.x?
|
280
297
|
====================
|
data/lib/rubygems_plugin.rb
CHANGED
@@ -1,100 +1,4 @@
|
|
1
|
-
|
2
|
-
require 'rubygems/
|
3
|
-
|
4
|
-
unless defined? Gem::DocManager.load_yardoc
|
5
|
-
class Gem::Specification
|
6
|
-
# has_rdoc should not be ignored!
|
7
|
-
overwrite_accessor(:has_rdoc) { @has_rdoc }
|
8
|
-
overwrite_accessor(:has_rdoc=) {|v| @has_rdoc = v }
|
9
|
-
|
10
|
-
# @since 0.5.3
|
11
|
-
def has_yardoc=(value)
|
12
|
-
@has_rdoc = 'yard'
|
13
|
-
end
|
14
|
-
|
15
|
-
def has_yardoc
|
16
|
-
@has_rdoc == 'yard'
|
17
|
-
end
|
18
|
-
|
19
|
-
undef has_rdoc?
|
20
|
-
def has_rdoc?
|
21
|
-
@has_rdoc && @has_rdoc != 'yard'
|
22
|
-
end
|
23
|
-
|
24
|
-
alias has_yardoc? has_yardoc
|
25
|
-
end
|
26
|
-
|
27
|
-
class Gem::DocManager
|
28
|
-
def self.load_yardoc
|
29
|
-
require File.dirname(__FILE__) + '/yard'
|
30
|
-
end
|
31
|
-
|
32
|
-
def run_yardoc(*args)
|
33
|
-
args << '--quiet'
|
34
|
-
args << @spec.require_paths
|
35
|
-
if @spec.extra_rdoc_files.size > 0
|
36
|
-
args << '-'
|
37
|
-
args += @spec.extra_rdoc_files
|
38
|
-
end
|
39
|
-
args = args.flatten.map {|arg| arg.to_s }
|
40
|
-
|
41
|
-
old_pwd = Dir.pwd
|
42
|
-
Dir.chdir(@spec.full_gem_path)
|
43
|
-
YARD::CLI::Yardoc.run(*args)
|
44
|
-
rescue Errno::EACCES => e
|
45
|
-
dirname = File.dirname e.message.split("-")[1].strip
|
46
|
-
raise Gem::FilePermissionError.new(dirname)
|
47
|
-
rescue => ex
|
48
|
-
alert_error "While generating documentation for #{@spec.full_name}"
|
49
|
-
ui.errs.puts "... MESSAGE: #{ex}"
|
50
|
-
ui.errs.puts "... YARDDOC args: #{args.join(' ')}"
|
51
|
-
ui.errs.puts "\t#{ex.backtrace.join("\n\t")}" if Gem.configuration.backtrace
|
52
|
-
ui.errs.puts "(continuing with the rest of the installation)"
|
53
|
-
ensure
|
54
|
-
Dir.chdir(old_pwd)
|
55
|
-
end
|
56
|
-
|
57
|
-
undef setup_rdoc
|
58
|
-
def setup_rdoc
|
59
|
-
if File.exist?(@doc_dir) && !File.writable?(@doc_dir) then
|
60
|
-
raise Gem::FilePermissionError.new(@doc_dir)
|
61
|
-
end
|
62
|
-
|
63
|
-
FileUtils.mkdir_p @doc_dir unless File.exist?(@doc_dir)
|
64
|
-
|
65
|
-
self.class.load_rdoc if @spec.has_rdoc?
|
66
|
-
self.class.load_yardoc if @spec.has_yardoc?
|
67
|
-
end
|
68
|
-
|
69
|
-
def install_yardoc
|
70
|
-
rdoc_dir = File.join(@doc_dir, 'rdoc')
|
71
|
-
|
72
|
-
FileUtils.rm_rf rdoc_dir
|
73
|
-
|
74
|
-
say "Installing YARD documentation for #{@spec.full_name}..."
|
75
|
-
run_yardoc '-o', rdoc_dir
|
76
|
-
end
|
77
|
-
|
78
|
-
def install_ri_yard
|
79
|
-
install_ri_yard_orig if @spec.has_rdoc?
|
80
|
-
return if @spec.has_rdoc? == false
|
81
|
-
return if @spec.has_yardoc?
|
82
|
-
|
83
|
-
self.class.load_yardoc
|
84
|
-
say "Building YARD (yri) index for #{@spec.full_name}..."
|
85
|
-
run_yardoc '-c', '-n'
|
86
|
-
end
|
87
|
-
alias install_ri_yard_orig install_ri
|
88
|
-
alias install_ri install_ri_yard
|
89
|
-
|
90
|
-
def install_rdoc_yard
|
91
|
-
if @spec.has_rdoc?
|
92
|
-
install_rdoc_yard_orig
|
93
|
-
elsif @spec.has_yardoc?
|
94
|
-
install_yardoc
|
95
|
-
end
|
96
|
-
end
|
97
|
-
alias install_rdoc_yard_orig install_rdoc
|
98
|
-
alias install_rdoc install_rdoc_yard
|
99
|
-
end
|
1
|
+
unless defined?(Gem::DocManager.load_yardoc)
|
2
|
+
require File.expand_path(File.dirname(__FILE__) + '/yard/rubygems/specification')
|
3
|
+
require File.expand_path(File.dirname(__FILE__) + '/yard/rubygems/doc_manager')
|
100
4
|
end
|
data/lib/yard.rb
CHANGED
data/lib/yard/autoload.rb
CHANGED
@@ -56,46 +56,48 @@ module YARD
|
|
56
56
|
module Handlers
|
57
57
|
module Ruby # All Ruby handlers
|
58
58
|
module Legacy # Handlers for old Ruby 1.8 parser
|
59
|
-
autoload :Base,
|
59
|
+
autoload :Base, __p('handlers/ruby/legacy/base')
|
60
60
|
|
61
|
-
autoload :AliasHandler,
|
62
|
-
autoload :AttributeHandler,
|
63
|
-
autoload :ClassHandler,
|
64
|
-
autoload :ClassConditionHandler,
|
65
|
-
autoload :ClassVariableHandler,
|
66
|
-
autoload :ConstantHandler,
|
67
|
-
autoload :ExceptionHandler,
|
68
|
-
autoload :ExtendHandler,
|
69
|
-
autoload :MethodHandler,
|
70
|
-
autoload :MixinHandler,
|
71
|
-
autoload :ModuleHandler,
|
72
|
-
autoload :
|
73
|
-
autoload :
|
74
|
-
autoload :
|
61
|
+
autoload :AliasHandler, __p('handlers/ruby/legacy/alias_handler')
|
62
|
+
autoload :AttributeHandler, __p('handlers/ruby/legacy/attribute_handler')
|
63
|
+
autoload :ClassHandler, __p('handlers/ruby/legacy/class_handler')
|
64
|
+
autoload :ClassConditionHandler, __p('handlers/ruby/legacy/class_condition_handler')
|
65
|
+
autoload :ClassVariableHandler, __p('handlers/ruby/legacy/class_variable_handler')
|
66
|
+
autoload :ConstantHandler, __p('handlers/ruby/legacy/constant_handler')
|
67
|
+
autoload :ExceptionHandler, __p('handlers/ruby/legacy/exception_handler')
|
68
|
+
autoload :ExtendHandler, __p('handlers/ruby/legacy/extend_handler')
|
69
|
+
autoload :MethodHandler, __p('handlers/ruby/legacy/method_handler')
|
70
|
+
autoload :MixinHandler, __p('handlers/ruby/legacy/mixin_handler')
|
71
|
+
autoload :ModuleHandler, __p('handlers/ruby/legacy/module_handler')
|
72
|
+
autoload :PrivateConstantHandler, __p('handlers/ruby/legacy/private_constant_handler')
|
73
|
+
autoload :ProcessHandler, __p('handlers/ruby/legacy/process_handler')
|
74
|
+
autoload :VisibilityHandler, __p('handlers/ruby/legacy/visibility_handler')
|
75
|
+
autoload :YieldHandler, __p('handlers/ruby/legacy/yield_handler')
|
75
76
|
end
|
76
77
|
|
77
|
-
autoload :Base,
|
78
|
+
autoload :Base, __p('handlers/ruby/base')
|
78
79
|
|
79
|
-
autoload :AliasHandler,
|
80
|
-
autoload :AttributeHandler,
|
81
|
-
autoload :ClassHandler,
|
82
|
-
autoload :ClassConditionHandler,
|
83
|
-
autoload :ClassVariableHandler,
|
84
|
-
autoload :ConstantHandler,
|
85
|
-
autoload :ExceptionHandler,
|
86
|
-
autoload :ExtendHandler,
|
87
|
-
autoload :MethodHandler,
|
88
|
-
autoload :MethodConditionHandler,
|
89
|
-
autoload :MixinHandler,
|
90
|
-
autoload :ModuleHandler,
|
91
|
-
autoload :
|
92
|
-
autoload :
|
93
|
-
autoload :
|
94
|
-
autoload :
|
80
|
+
autoload :AliasHandler, __p('handlers/ruby/alias_handler')
|
81
|
+
autoload :AttributeHandler, __p('handlers/ruby/attribute_handler')
|
82
|
+
autoload :ClassHandler, __p('handlers/ruby/class_handler')
|
83
|
+
autoload :ClassConditionHandler, __p('handlers/ruby/class_condition_handler')
|
84
|
+
autoload :ClassVariableHandler, __p('handlers/ruby/class_variable_handler')
|
85
|
+
autoload :ConstantHandler, __p('handlers/ruby/constant_handler')
|
86
|
+
autoload :ExceptionHandler, __p('handlers/ruby/exception_handler')
|
87
|
+
autoload :ExtendHandler, __p('handlers/ruby/extend_handler')
|
88
|
+
autoload :MethodHandler, __p('handlers/ruby/method_handler')
|
89
|
+
autoload :MethodConditionHandler, __p('handlers/ruby/method_condition_handler')
|
90
|
+
autoload :MixinHandler, __p('handlers/ruby/mixin_handler')
|
91
|
+
autoload :ModuleHandler, __p('handlers/ruby/module_handler')
|
92
|
+
autoload :PrivateConstantHandler, __p('handlers/ruby/private_constant_handler')
|
93
|
+
autoload :ProcessHandler, __p('handlers/ruby/process_handler')
|
94
|
+
autoload :StructHandlerMethods, __p('handlers/ruby/struct_handler_methods')
|
95
|
+
autoload :VisibilityHandler, __p('handlers/ruby/visibility_handler')
|
96
|
+
autoload :YieldHandler, __p('handlers/ruby/yield_handler')
|
95
97
|
end
|
96
98
|
|
97
|
-
autoload :Base,
|
98
|
-
autoload :Processor,
|
99
|
+
autoload :Base, __p('handlers/base')
|
100
|
+
autoload :Processor, __p('handlers/processor')
|
99
101
|
end
|
100
102
|
|
101
103
|
# The parser namespace holds all parsing engines used by YARD.
|
@@ -196,7 +198,7 @@ module YARD
|
|
196
198
|
autoload :BaseHelper, __p('templates/helpers/base_helper')
|
197
199
|
autoload :FilterHelper, __p('templates/helpers/filter_helper')
|
198
200
|
autoload :HtmlHelper, __p('templates/helpers/html_helper')
|
199
|
-
autoload :HtmlSyntaxHighlightHelper, __p('templates/helpers/html_syntax_highlight_helper'
|
201
|
+
autoload :HtmlSyntaxHighlightHelper, __p('templates/helpers/html_syntax_highlight_helper')
|
200
202
|
autoload :MarkupHelper, __p('templates/helpers/markup_helper')
|
201
203
|
autoload :MethodHelper, __p('templates/helpers/method_helper')
|
202
204
|
autoload :ModuleHelper, __p('templates/helpers/module_helper')
|
data/lib/yard/cli/config.rb
CHANGED
@@ -12,11 +12,19 @@ module YARD
|
|
12
12
|
# @return [Boolean] whether to reset the {#key}
|
13
13
|
attr_accessor :reset
|
14
14
|
|
15
|
+
# @return [Boolean] whether the value being set should be inside a list
|
16
|
+
attr_accessor :as_list
|
17
|
+
|
18
|
+
# @return [Boolean] whether to append values to existing key
|
19
|
+
attr_accessor :append
|
20
|
+
|
15
21
|
def initialize
|
16
22
|
super
|
17
23
|
self.key = nil
|
18
24
|
self.values = []
|
19
25
|
self.reset = false
|
26
|
+
self.append = false
|
27
|
+
self.as_list = false
|
20
28
|
end
|
21
29
|
|
22
30
|
def description
|
@@ -44,7 +52,9 @@ module YARD
|
|
44
52
|
YARD::Config.options[key] = YARD::Config::DEFAULT_CONFIG_OPTIONS[key]
|
45
53
|
else
|
46
54
|
log.debug "Setting #{key} to #{values.inspect}"
|
47
|
-
YARD::Config.options[key]
|
55
|
+
items, current_items = encode_values, YARD::Config.options[key]
|
56
|
+
items = [current_items].flatten + [items].flatten if append
|
57
|
+
YARD::Config.options[key] = items
|
48
58
|
end
|
49
59
|
YARD::Config.save
|
50
60
|
end
|
@@ -61,7 +71,7 @@ module YARD
|
|
61
71
|
end
|
62
72
|
|
63
73
|
def encode_values
|
64
|
-
if values.size == 1
|
74
|
+
if values.size == 1 && !as_list
|
65
75
|
encode_value(values.first)
|
66
76
|
else
|
67
77
|
values.map {|v| encode_value(v) }
|
@@ -79,6 +89,8 @@ module YARD
|
|
79
89
|
|
80
90
|
def optparse(*args)
|
81
91
|
list = false
|
92
|
+
self.as_list = false
|
93
|
+
self.append = false
|
82
94
|
opts = OptionParser.new
|
83
95
|
opts.banner = "Usage: yard config [options] [item [value ...]]"
|
84
96
|
opts.separator ""
|
@@ -100,6 +112,17 @@ module YARD
|
|
100
112
|
opts.on('-r', '--reset', 'Resets the specific item to default') do
|
101
113
|
self.reset = true
|
102
114
|
end
|
115
|
+
|
116
|
+
opts.separator ""
|
117
|
+
opts.separator "Modifying keys:"
|
118
|
+
|
119
|
+
opts.on('-a', '--append', 'Appends items to existing key values') do
|
120
|
+
self.append = true
|
121
|
+
end
|
122
|
+
opts.on('--as-list', 'Forces the value(s) to be wrapped in an array') do
|
123
|
+
self.as_list = true
|
124
|
+
end
|
125
|
+
|
103
126
|
common_options(opts)
|
104
127
|
parse_options(opts, args)
|
105
128
|
args = [] if list
|
data/lib/yard/cli/graph.rb
CHANGED
@@ -79,7 +79,7 @@ module YARD
|
|
79
79
|
opts.separator ""
|
80
80
|
opts.separator "Output options:"
|
81
81
|
|
82
|
-
opts.on('--dot [OPTIONS]', 'Send the results
|
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
|
|
data/lib/yard/cli/yardoc.rb
CHANGED
@@ -432,6 +432,10 @@ module YARD
|
|
432
432
|
opts.on('-b', '--db FILE', 'Use a specified .yardoc db to load from or save to. (defaults to .yardoc)') do |yfile|
|
433
433
|
YARD::Registry.yardoc_file = yfile
|
434
434
|
end
|
435
|
+
|
436
|
+
opts.on('--[no-]single-db', 'Whether code objects should be stored to single database file (advanced)') do |use_single_db|
|
437
|
+
Registry.single_object_db = use_single_db
|
438
|
+
end
|
435
439
|
|
436
440
|
opts.on('-n', '--no-output', 'Only generate .yardoc database, no documentation.') do
|
437
441
|
self.generate = false
|
@@ -152,12 +152,10 @@ module YARD
|
|
152
152
|
# @see #dynamic
|
153
153
|
def dynamic?; @dynamic end
|
154
154
|
|
155
|
-
#
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
# @return [Symbol] always returns public for a base object.
|
160
|
-
def visibility; :public end
|
155
|
+
# @return [Symbol] the visibility of an object (:public, :private, :protected)
|
156
|
+
attr_accessor :visibility
|
157
|
+
undef visibility=
|
158
|
+
def visibility=(v) @visibility = v.to_sym end
|
161
159
|
|
162
160
|
class << self
|
163
161
|
# Allocates a new code object
|
@@ -165,6 +163,10 @@ module YARD
|
|
165
163
|
# @see #initialize
|
166
164
|
def new(namespace, name, *args, &block)
|
167
165
|
raise ArgumentError, "invalid empty object name" if name.to_s.empty?
|
166
|
+
if namespace.is_a?(ConstantObject)
|
167
|
+
namespace = Proxy.new(namespace.namespace, namespace.value)
|
168
|
+
end
|
169
|
+
|
168
170
|
if name.to_s[0,2] == NSEP
|
169
171
|
name = name.to_s[2..-1]
|
170
172
|
namespace = Registry.root
|
@@ -212,6 +214,7 @@ module YARD
|
|
212
214
|
@current_file_has_comments = false
|
213
215
|
@name = name.to_sym
|
214
216
|
@source_type = :ruby
|
217
|
+
@visibility = :public
|
215
218
|
@tags = []
|
216
219
|
@docstring = Docstring.new('', self)
|
217
220
|
@namespace = nil
|
@@ -353,14 +356,14 @@ module YARD
|
|
353
356
|
@docstring_extra ? value + @docstring_extra : value
|
354
357
|
end
|
355
358
|
|
356
|
-
# Attaches a docstring to a code
|
359
|
+
# Attaches a docstring to a code object by parsing the comments attached to the statement
|
357
360
|
# and filling the {#tags} and {#docstring} methods with the parsed information.
|
358
361
|
#
|
359
362
|
# @param [String, Array<String>, Docstring] comments
|
360
363
|
# the comments attached to the code object to be parsed
|
361
364
|
# into a docstring and meta tags.
|
362
365
|
def docstring=(comments)
|
363
|
-
if comments =~
|
366
|
+
if comments =~ /\A\s*\(see (\S+)\s*\)(?:\s|$)/
|
364
367
|
path, extra = $1, $'
|
365
368
|
@docstring_extra = extra.empty? ? nil : Docstring.new(extra, self)
|
366
369
|
@docstring = Proxy.new(namespace, path)
|
@@ -410,7 +413,12 @@ module YARD
|
|
410
413
|
common = [path, other].join(" ").match(/^(\S*)\S*(?: \1\S*)*$/)[1]
|
411
414
|
common = path unless common =~ /(\.|::|#)$/
|
412
415
|
common = common.sub(/(\.|::|#)[^:#\.]*?$/, '') if same_parent
|
413
|
-
|
416
|
+
if %w(. :).include?(common[-1,1]) || other[common.size,1] == '#'
|
417
|
+
suffix = ''
|
418
|
+
else
|
419
|
+
suffix = '(::|\.)'
|
420
|
+
end
|
421
|
+
result = other.sub(/^#{Regexp.quote common}#{suffix}/, '')
|
414
422
|
result.empty? ? other : result
|
415
423
|
end
|
416
424
|
|
@@ -1,11 +1,6 @@
|
|
1
1
|
module YARD::CodeObjects
|
2
2
|
# Represents a Ruby method in source
|
3
3
|
class MethodObject < Base
|
4
|
-
# The visibility of the method (+:public:+, +:protected+, +:private+)
|
5
|
-
#
|
6
|
-
# @return [Symbol] the method visibility
|
7
|
-
attr_reader :visibility
|
8
|
-
|
9
4
|
# The scope of the method (+:class+ or +:instance+)
|
10
5
|
#
|
11
6
|
# @return [Symbol] the scope
|
@@ -49,10 +44,6 @@ module YARD::CodeObjects
|
|
49
44
|
@scope = v.to_sym
|
50
45
|
YARD::Registry.register(self) if reregister
|
51
46
|
end
|
52
|
-
|
53
|
-
# Sets the visibility
|
54
|
-
# @param [Symbol] v the new visibility (:public, :private, or :protected)
|
55
|
-
def visibility=(v) @visibility = v.to_sym end
|
56
47
|
|
57
48
|
# @return whether or not the method is the #initialize constructor method
|
58
49
|
def constructor?
|
@@ -47,6 +47,12 @@ module YARD
|
|
47
47
|
@obj = nil
|
48
48
|
@imethod ||= nil
|
49
49
|
|
50
|
+
if @namespace.is_a?(ConstantObject)
|
51
|
+
@origname = nil # forget these for a constant
|
52
|
+
@orignamespace = nil
|
53
|
+
@namespace = Proxy.new(@namespace.namespace, @namespace.value)
|
54
|
+
end
|
55
|
+
|
50
56
|
unless @namespace.is_a?(NamespaceObject) or @namespace.is_a?(Proxy)
|
51
57
|
raise ArgumentError, "Invalid namespace object: #{namespace}"
|
52
58
|
end
|