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.

Files changed (107) hide show
  1. data/ChangeLog +341 -0
  2. data/LICENSE +1 -1
  3. data/README.md +31 -6
  4. data/Rakefile +22 -3
  5. data/docs/Tags.md +5 -1
  6. data/docs/WhatsNew.md +18 -1
  7. data/lib/rubygems_plugin.rb +3 -99
  8. data/lib/yard.rb +1 -1
  9. data/lib/yard/autoload.rb +37 -35
  10. data/lib/yard/cli/config.rb +25 -2
  11. data/lib/yard/cli/graph.rb +1 -1
  12. data/lib/yard/cli/yardoc.rb +4 -0
  13. data/lib/yard/code_objects/base.rb +17 -9
  14. data/lib/yard/code_objects/method_object.rb +0 -9
  15. data/lib/yard/code_objects/proxy.rb +6 -0
  16. data/lib/yard/docstring.rb +5 -0
  17. data/lib/yard/handlers/base.rb +3 -1
  18. data/lib/yard/handlers/processor.rb +1 -1
  19. data/lib/yard/handlers/ruby/alias_handler.rb +9 -8
  20. data/lib/yard/handlers/ruby/class_handler.rb +3 -3
  21. data/lib/yard/handlers/ruby/legacy/alias_handler.rb +9 -7
  22. data/lib/yard/handlers/ruby/legacy/method_handler.rb +7 -0
  23. data/lib/yard/handlers/ruby/legacy/private_constant_handler.rb +21 -0
  24. data/lib/yard/handlers/ruby/method_condition_handler.rb +1 -1
  25. data/lib/yard/handlers/ruby/method_handler.rb +7 -0
  26. data/lib/yard/handlers/ruby/private_constant_handler.rb +36 -0
  27. data/lib/yard/parser/ruby/ast_node.rb +41 -24
  28. data/lib/yard/parser/ruby/legacy/ruby_parser.rb +3 -0
  29. data/lib/yard/parser/ruby/legacy/statement.rb +2 -0
  30. data/lib/yard/parser/ruby/legacy/statement_list.rb +27 -4
  31. data/lib/yard/parser/ruby/ruby_parser.rb +71 -36
  32. data/lib/yard/parser/source_parser.rb +11 -10
  33. data/lib/yard/registry.rb +62 -24
  34. data/lib/yard/registry_store.rb +18 -5
  35. data/lib/yard/rubygems/doc_manager.rb +75 -0
  36. data/lib/yard/rubygems/specification.rb +23 -0
  37. data/lib/yard/serializers/process_serializer.rb +1 -1
  38. data/lib/yard/serializers/yardoc_serializer.rb +7 -2
  39. data/lib/yard/server/commands/display_object_command.rb +1 -1
  40. data/lib/yard/server/commands/library_command.rb +2 -2
  41. data/lib/yard/tags/default_factory.rb +1 -1
  42. data/lib/yard/tags/library.rb +2 -2
  43. data/lib/yard/templates/helpers/base_helper.rb +19 -0
  44. data/lib/yard/templates/helpers/html_helper.rb +22 -9
  45. data/lib/yard/templates/helpers/html_syntax_highlight_helper.rb +28 -0
  46. data/lib/yard/templates/helpers/markup_helper.rb +14 -22
  47. data/lib/yard/templates/template.rb +1 -1
  48. data/spec/cli/config_spec.rb +20 -0
  49. data/spec/cli/yardoc_spec.rb +12 -0
  50. data/spec/code_objects/base_spec.rb +13 -0
  51. data/spec/code_objects/proxy_spec.rb +9 -0
  52. data/spec/config_spec.rb +4 -1
  53. data/spec/docstring_spec.rb +5 -0
  54. data/spec/handlers/alias_handler_spec.rb +14 -1
  55. data/spec/handlers/attribute_handler_spec.rb +1 -1
  56. data/spec/handlers/base_spec.rb +21 -21
  57. data/spec/handlers/class_condition_handler_spec.rb +1 -1
  58. data/spec/handlers/class_handler_spec.rb +1 -1
  59. data/spec/handlers/class_variable_handler_spec.rb +1 -1
  60. data/spec/handlers/constant_handler_spec.rb +2 -2
  61. data/spec/handlers/examples/alias_handler_001.rb.txt +14 -0
  62. data/spec/handlers/examples/method_handler_001.rb.txt +6 -0
  63. data/spec/handlers/examples/module_handler_001.rb.txt +4 -0
  64. data/spec/handlers/examples/private_constant_handler_001.rb.txt +8 -0
  65. data/spec/handlers/exception_handler_spec.rb +1 -1
  66. data/spec/handlers/extend_handler_spec.rb +1 -1
  67. data/spec/handlers/method_condition_handler_spec.rb +1 -1
  68. data/spec/handlers/method_handler_spec.rb +7 -1
  69. data/spec/handlers/mixin_handler_spec.rb +1 -1
  70. data/spec/handlers/module_handler_spec.rb +5 -1
  71. data/spec/handlers/private_constant_handler_spec.rb +24 -0
  72. data/spec/handlers/process_handler_spec.rb +1 -1
  73. data/spec/handlers/ruby/base_spec.rb +4 -4
  74. data/spec/handlers/visibility_handler_spec.rb +1 -1
  75. data/spec/handlers/yield_handler_spec.rb +1 -1
  76. data/spec/parser/base_spec.rb +3 -5
  77. data/spec/parser/c_parser_spec.rb +1 -1
  78. data/spec/parser/ruby/ast_node_spec.rb +23 -26
  79. data/spec/parser/ruby/legacy/statement_list_spec.rb +9 -0
  80. data/spec/parser/ruby/ruby_parser_spec.rb +179 -177
  81. data/spec/parser/source_parser_spec.rb +41 -7
  82. data/spec/rake/yardoc_task_spec.rb +3 -3
  83. data/spec/registry_spec.rb +52 -0
  84. data/spec/registry_store_spec.rb +71 -1
  85. data/spec/serializers/yardoc_serializer_spec.rb +18 -7
  86. data/spec/server/rack_adapter_spec.rb +2 -2
  87. data/spec/spec_helper.rb +10 -0
  88. data/spec/tags/default_factory_spec.rb +122 -120
  89. data/spec/templates/helpers/base_helper_spec.rb +38 -14
  90. data/spec/templates/helpers/html_helper_spec.rb +19 -0
  91. data/spec/templates/helpers/html_syntax_highlight_helper_spec.rb +10 -6
  92. data/spec/templates/helpers/markup_helper_spec.rb +21 -5
  93. data/templates/default/class/dot/superklass.erb +1 -1
  94. data/templates/default/docstring/setup.rb +1 -1
  95. data/templates/default/fulldoc/html/css/style.css +12 -4
  96. data/templates/default/fulldoc/html/js/app.js +1 -1
  97. data/templates/default/fulldoc/html/js/jquery.js +5 -143
  98. data/templates/default/layout/html/files.erb +11 -0
  99. data/templates/default/layout/html/headers.erb +1 -1
  100. data/templates/default/layout/html/index.erb +2 -49
  101. data/templates/default/layout/html/listing.erb +4 -0
  102. data/templates/default/layout/html/objects.erb +32 -0
  103. data/templates/default/layout/html/setup.rb +1 -1
  104. data/templates/default/module/dot/info.erb +1 -1
  105. data/templates/default/module/dot/setup.rb +1 -1
  106. metadata +15 -6
  107. 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 descendents of a namespace (class
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
  ====================
@@ -1,100 +1,4 @@
1
- require 'rubygems/specification'
2
- require 'rubygems/doc_manager'
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
@@ -1,5 +1,5 @@
1
1
  module YARD
2
- VERSION = "0.6.4"
2
+ VERSION = "0.6.5"
3
3
 
4
4
  # The root path for YARD source libraries
5
5
  ROOT = File.expand_path(File.dirname(__FILE__))
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, __p('handlers/ruby/legacy/base')
59
+ autoload :Base, __p('handlers/ruby/legacy/base')
60
60
 
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 :ProcessHandler, __p('handlers/ruby/legacy/process_handler')
73
- autoload :VisibilityHandler, __p('handlers/ruby/legacy/visibility_handler')
74
- autoload :YieldHandler, __p('handlers/ruby/legacy/yield_handler')
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, __p('handlers/ruby/base')
78
+ autoload :Base, __p('handlers/ruby/base')
78
79
 
79
- autoload :AliasHandler, __p('handlers/ruby/alias_handler')
80
- autoload :AttributeHandler, __p('handlers/ruby/attribute_handler')
81
- autoload :ClassHandler, __p('handlers/ruby/class_handler')
82
- autoload :ClassConditionHandler, __p('handlers/ruby/class_condition_handler')
83
- autoload :ClassVariableHandler, __p('handlers/ruby/class_variable_handler')
84
- autoload :ConstantHandler, __p('handlers/ruby/constant_handler')
85
- autoload :ExceptionHandler, __p('handlers/ruby/exception_handler')
86
- autoload :ExtendHandler, __p('handlers/ruby/extend_handler')
87
- autoload :MethodHandler, __p('handlers/ruby/method_handler')
88
- autoload :MethodConditionHandler, __p('handlers/ruby/method_condition_handler')
89
- autoload :MixinHandler, __p('handlers/ruby/mixin_handler')
90
- autoload :ModuleHandler, __p('handlers/ruby/module_handler')
91
- autoload :ProcessHandler, __p('handlers/ruby/process_handler')
92
- autoload :StructHandlerMethods, __p('handlers/ruby/struct_handler_methods')
93
- autoload :VisibilityHandler, __p('handlers/ruby/visibility_handler')
94
- autoload :YieldHandler, __p('handlers/ruby/yield_handler')
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, __p('handlers/base')
98
- autoload :Processor, __p('handlers/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' + (RUBY18 ? '18' : ''))
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')
@@ -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] = encode_values
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
@@ -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 direclty to `dot` with optional arguments.') do |dotopts|
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
 
@@ -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
- # This attribute exists in order to maintain a consistent interface
156
- # with the {MethodObject} class, so that a {Verifier} expression need
157
- # not check the object type before accessing visibility.
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 oject by parsing the comments attached to the statement
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 =~ /^\s*\(see (\S+)\s*\)(?:\s|$)/
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
- result = other.sub(/^#{Regexp.quote common}(::|\.|)?/, '')
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