yard 0.4.0 → 0.5.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.
- data/ChangeLog +585 -1
- data/README.md +10 -2
- data/benchmarks/yri_cache.rb +19 -0
- data/bin/yri +1 -26
- data/docs/WhatsNew.md +99 -0
- data/lib/rubygems_plugin.rb +2 -0
- data/lib/yard.rb +2 -2
- data/lib/yard/autoload.rb +9 -4
- data/lib/yard/cli/base.rb +26 -0
- data/lib/yard/cli/yard_graph.rb +2 -9
- data/lib/yard/cli/yardoc.rb +93 -33
- data/lib/yard/cli/yri.rb +128 -0
- data/lib/yard/code_objects/base.rb +16 -5
- data/lib/yard/code_objects/class_object.rb +11 -4
- data/lib/yard/code_objects/method_object.rb +11 -1
- data/lib/yard/code_objects/proxy.rb +5 -2
- data/lib/yard/code_objects/root_object.rb +1 -0
- data/lib/yard/core_ext/file.rb +1 -1
- data/lib/yard/core_ext/hash.rb +15 -0
- data/lib/yard/core_ext/module.rb +2 -2
- data/lib/yard/core_ext/string.rb +66 -0
- data/lib/yard/core_ext/symbol_hash.rb +1 -1
- data/lib/yard/docstring.rb +5 -5
- data/lib/yard/handlers/base.rb +10 -4
- data/lib/yard/handlers/processor.rb +3 -4
- data/lib/yard/handlers/ruby/attribute_handler.rb +3 -2
- data/lib/yard/handlers/ruby/legacy/attribute_handler.rb +2 -2
- data/lib/yard/handlers/ruby/legacy/method_handler.rb +7 -1
- data/lib/yard/handlers/ruby/method_handler.rb +7 -1
- data/lib/yard/logging.rb +11 -1
- data/lib/yard/parser/c_parser.rb +407 -0
- data/lib/yard/parser/ruby/ast_node.rb +2 -2
- data/lib/yard/parser/ruby/legacy/ruby_lex.rb +3 -4
- data/lib/yard/parser/source_parser.rb +18 -7
- data/lib/yard/rake/yardoc_task.rb +1 -1
- data/lib/yard/registry.rb +83 -29
- data/lib/yard/registry_store.rb +213 -0
- data/lib/yard/serializers/base.rb +1 -1
- data/lib/yard/serializers/yardoc_serializer.rb +113 -0
- data/lib/yard/tags/library.rb +4 -0
- data/lib/yard/tags/overload_tag.rb +16 -5
- data/lib/yard/tags/tag.rb +1 -2
- data/lib/yard/templates/engine.rb +3 -3
- data/lib/yard/templates/helpers/html_helper.rb +50 -16
- data/lib/yard/templates/helpers/html_syntax_highlight_helper.rb +1 -3
- data/lib/yard/templates/helpers/html_syntax_highlight_helper18.rb +1 -3
- data/lib/yard/templates/helpers/method_helper.rb +11 -4
- data/lib/yard/templates/helpers/text_helper.rb +24 -2
- data/lib/yard/verifier.rb +3 -3
- data/spec/cli/yardoc_spec.rb +33 -6
- data/spec/cli/yri_spec.rb +30 -0
- data/spec/code_objects/base_spec.rb +7 -0
- data/spec/code_objects/class_object_spec.rb +6 -1
- data/spec/code_objects/method_object_spec.rb +25 -0
- data/spec/core_ext/hash_spec.rb +10 -0
- data/spec/core_ext/module_spec.rb +1 -1
- data/spec/core_ext/string_spec.rb +50 -12
- data/spec/handlers/attribute_handler_spec.rb +4 -0
- data/spec/handlers/examples/method_handler_001.rb.txt +9 -0
- data/spec/handlers/method_handler_spec.rb +22 -4
- data/spec/parser/c_parser_spec.rb +22 -0
- data/spec/parser/examples/array.c.txt +3887 -0
- data/spec/parser/source_parser_spec.rb +29 -7
- data/spec/registry_spec.rb +93 -72
- data/spec/registry_store_spec.rb +184 -0
- data/spec/serializers/file_system_serializer_spec.rb +96 -75
- data/spec/spec_helper.rb +2 -2
- data/spec/tags/overload_tag_spec.rb +18 -0
- data/spec/templates/examples/class001.html +32 -30
- data/spec/templates/examples/method001.html +4 -1
- data/spec/templates/examples/method002.html +7 -2
- data/spec/templates/examples/method002.txt +1 -1
- data/spec/templates/examples/method003.html +30 -8
- data/spec/templates/examples/method003.txt +4 -4
- data/spec/templates/examples/method004.html +44 -0
- data/spec/templates/examples/method004.txt +10 -0
- data/spec/templates/examples/method005.html +99 -0
- data/spec/templates/examples/method005.txt +33 -0
- data/spec/templates/examples/module001.dot +1 -1
- data/spec/templates/examples/module001.html +391 -37
- data/spec/templates/examples/module001.txt +1 -1
- data/spec/templates/helpers/base_helper_spec.rb +2 -2
- data/spec/templates/helpers/html_helper_spec.rb +83 -0
- data/spec/templates/helpers/method_helper_spec.rb +47 -0
- data/spec/templates/helpers/shared_signature_examples.rb +102 -0
- data/spec/templates/helpers/text_helper_spec.rb +31 -0
- data/spec/templates/method_spec.rb +43 -18
- data/spec/templates/module_spec.rb +22 -1
- data/spec/templates/spec_helper.rb +10 -1
- data/spec/yard_spec.rb +4 -3
- data/templates/default/class/html/constructor_details.erb +1 -1
- data/templates/default/docstring/html/returns_void.erb +1 -0
- data/templates/default/docstring/setup.rb +9 -4
- data/templates/default/docstring/text/returns_void.erb +1 -0
- data/templates/default/fulldoc/html/css/style.css +4 -2
- data/templates/default/fulldoc/html/full_list.erb +2 -2
- data/templates/default/fulldoc/html/js/app.js +1 -1
- data/templates/default/fulldoc/html/setup.rb +14 -6
- data/templates/default/layout/dot/setup.rb +1 -1
- data/templates/default/layout/html/breadcrumb.erb +2 -2
- data/templates/default/layout/html/index.erb +2 -2
- data/templates/default/layout/html/setup.rb +5 -5
- data/templates/default/method/html/header.erb +6 -4
- data/templates/default/method_details/html/method_signature.erb +2 -1
- data/templates/default/method_details/html/source.erb +1 -1
- data/templates/default/method_details/setup.rb +2 -1
- data/templates/default/method_details/text/setup.rb +1 -1
- data/templates/default/module/html/attribute_details.erb +4 -4
- data/templates/default/module/html/attribute_summary.erb +3 -3
- data/templates/default/module/html/box_info.erb +2 -2
- data/templates/default/module/html/defines.erb +1 -1
- data/templates/default/module/html/inherited_constants.erb +1 -1
- data/templates/default/module/html/inherited_methods.erb +1 -1
- data/templates/default/module/html/item_summary.erb +13 -4
- data/templates/default/module/html/method_details_list.erb +5 -4
- data/templates/default/module/html/method_summary.erb +5 -4
- data/templates/default/module/html/methodmissing.erb +1 -1
- data/templates/default/module/setup.rb +14 -5
- data/templates/default/tags/html/overload.erb +3 -2
- data/templates/default/tags/setup.rb +4 -0
- metadata +23 -2
data/lib/yard/cli/yri.rb
ADDED
@@ -0,0 +1,128 @@
|
|
1
|
+
module YARD
|
2
|
+
module CLI
|
3
|
+
# A tool to view documentation in the console like `ri`
|
4
|
+
class YRI < Base
|
5
|
+
CACHE_FILE = File.expand_path('~/.yard/yri_cache')
|
6
|
+
|
7
|
+
# Helper method to run the utility on an instance.
|
8
|
+
# @see #run
|
9
|
+
def self.run(*args) new.run(*args) end
|
10
|
+
|
11
|
+
def initialize
|
12
|
+
@cache = {}
|
13
|
+
@search_paths = [Registry.yardoc_file, YARD::ROOT + '/../.yardoc']
|
14
|
+
add_gem_paths
|
15
|
+
load_cache
|
16
|
+
@search_paths.uniq!
|
17
|
+
end
|
18
|
+
|
19
|
+
# Runs the command-line utility.
|
20
|
+
#
|
21
|
+
# @example
|
22
|
+
# YRI.new.run('String#reverse')
|
23
|
+
# @param [Array<String>] args each tokenized argument
|
24
|
+
def run(*args)
|
25
|
+
optparse(*args)
|
26
|
+
|
27
|
+
@serializer ||= YARD::Serializers::ProcessSerializer.new('less')
|
28
|
+
|
29
|
+
if object = find_object(@name)
|
30
|
+
print_object(object)
|
31
|
+
else
|
32
|
+
STDERR.puts "No documentation for `#{@name}'"
|
33
|
+
exit(1)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
protected
|
38
|
+
|
39
|
+
def cache_object(name, path)
|
40
|
+
return if path == Registry.yardoc_file
|
41
|
+
@cache[name] = path
|
42
|
+
|
43
|
+
File.open(CACHE_FILE, 'w') do |file|
|
44
|
+
@cache.each do |key, value|
|
45
|
+
file.puts("#{key} #{value}")
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
def print_object(object)
|
51
|
+
if object.type == :method && object.is_alias?
|
52
|
+
tmp = P(object.namespace, (object.scope == :instance ? "#" : "") +
|
53
|
+
object.namespace.aliases[object].to_s)
|
54
|
+
object = tmp unless YARD::CodeObjects::Proxy === tmp
|
55
|
+
end
|
56
|
+
object.format(:serializer => @serializer)
|
57
|
+
end
|
58
|
+
|
59
|
+
def find_object(name)
|
60
|
+
@search_paths.unshift(@cache[name]) if @cache[name]
|
61
|
+
|
62
|
+
log.debug "Searching for #{name} in search paths"
|
63
|
+
@search_paths.each do |path|
|
64
|
+
log.debug "Searching for #{name} in #{path}..."
|
65
|
+
Registry.load(path)
|
66
|
+
obj = Registry.at(name)
|
67
|
+
if obj
|
68
|
+
cache_object(name, path)
|
69
|
+
return obj
|
70
|
+
end
|
71
|
+
end
|
72
|
+
nil
|
73
|
+
end
|
74
|
+
|
75
|
+
private
|
76
|
+
|
77
|
+
def load_cache
|
78
|
+
return unless File.file?(CACHE_FILE)
|
79
|
+
File.readlines(CACHE_FILE).each do |line|
|
80
|
+
line = line.strip.split(/\s+/)
|
81
|
+
@cache[line[0]] = line[1]
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
def add_gem_paths
|
86
|
+
require 'rubygems'
|
87
|
+
Gem.source_index.find_name('').each do |spec|
|
88
|
+
if yfile = Registry.yardoc_file_for_gem(spec.name)
|
89
|
+
@search_paths << yfile
|
90
|
+
end
|
91
|
+
end
|
92
|
+
rescue LoadError
|
93
|
+
end
|
94
|
+
|
95
|
+
# Parses commandline options.
|
96
|
+
# @param [Array<String>] args each tokenized argument
|
97
|
+
def optparse(*args)
|
98
|
+
opts = OptionParser.new
|
99
|
+
|
100
|
+
opts.separator ""
|
101
|
+
opts.separator "General Options:"
|
102
|
+
|
103
|
+
opts.on('-b', '--db FILE', 'Use a specified .yardoc db to search in') do |yfile|
|
104
|
+
@search_paths.unshift(yfile)
|
105
|
+
end
|
106
|
+
|
107
|
+
opts.on('-T', '--no-pager', 'No pager') do
|
108
|
+
@serializer = YARD::Serializers::StdoutSerializer.new
|
109
|
+
end
|
110
|
+
|
111
|
+
opts.on('-p PAGER', '--pager') do |pager|
|
112
|
+
@serializer = YARD::Serializers::ProcessSerializer.new(pager)
|
113
|
+
end
|
114
|
+
|
115
|
+
common_options(opts)
|
116
|
+
|
117
|
+
begin
|
118
|
+
opts.parse!(args)
|
119
|
+
@name = args.first
|
120
|
+
rescue => e
|
121
|
+
STDERR.puts e.message
|
122
|
+
STDERR << "\n" << opts
|
123
|
+
exit
|
124
|
+
end
|
125
|
+
end
|
126
|
+
end
|
127
|
+
end
|
128
|
+
end
|
@@ -36,7 +36,7 @@ module YARD
|
|
36
36
|
CSEPQ = Regexp.quote CSEP
|
37
37
|
CONSTANTMATCH = /[A-Z]\w*/
|
38
38
|
NAMESPACEMATCH = /(?:(?:#{NSEPQ})?#{CONSTANTMATCH})+/
|
39
|
-
METHODNAMEMATCH = /[a-zA-Z_]\w*[!?=]?|[-+~]
|
39
|
+
METHODNAMEMATCH = /[a-zA-Z_]\w*[!?=]?|[-+~]\@|<<|>>|=~|===?|<=>|[<>]=?|\*\*|[-\/+%^&*~`|]|\[\]=?/
|
40
40
|
METHODMATCH = /(?:(?:#{NAMESPACEMATCH}|self)\s*(?:#{CSEPQ}|#{NSEPQ})\s*)?#{METHODNAMEMATCH}/
|
41
41
|
|
42
42
|
BUILTIN_EXCEPTIONS = ["SecurityError", "Exception", "NoMethodError", "FloatDomainError",
|
@@ -99,6 +99,12 @@ module YARD
|
|
99
99
|
# @return [String, nil] source, if present, or nil
|
100
100
|
attr_accessor :source
|
101
101
|
|
102
|
+
# Language of the source code associated with the object. Defaults to
|
103
|
+
# +:ruby+.
|
104
|
+
#
|
105
|
+
# @return [Symbol] the language type
|
106
|
+
attr_accessor :source_type
|
107
|
+
|
102
108
|
# The one line signature representing an object. For a method, this will
|
103
109
|
# be of the form "def meth(arguments...)". This is usually the first
|
104
110
|
# source line.
|
@@ -157,7 +163,7 @@ module YARD
|
|
157
163
|
# @param [Object] other the other object to compare classes with
|
158
164
|
# @return [Boolean] true if other is a subclass of self
|
159
165
|
def ===(other)
|
160
|
-
|
166
|
+
other.is_a?(self)
|
161
167
|
end
|
162
168
|
end
|
163
169
|
|
@@ -184,6 +190,7 @@ module YARD
|
|
184
190
|
@files = []
|
185
191
|
@current_file_has_comments = false
|
186
192
|
@name = name.to_sym
|
193
|
+
@source_type = :ruby
|
187
194
|
@tags = []
|
188
195
|
@docstring = Docstring.new('', self)
|
189
196
|
self.namespace = namespace
|
@@ -262,7 +269,7 @@ module YARD
|
|
262
269
|
# Sets a custom attribute on the object
|
263
270
|
# @param [#to_s] key the name of the custom attribute
|
264
271
|
# @param [Object] value the value to associate
|
265
|
-
# @return [
|
272
|
+
# @return [void]
|
266
273
|
# @see #[]
|
267
274
|
def []=(key, value)
|
268
275
|
if respond_to?("#{key}=")
|
@@ -331,7 +338,7 @@ module YARD
|
|
331
338
|
# @return [String] the unique path of the object
|
332
339
|
# @see #sep
|
333
340
|
def path
|
334
|
-
if parent && parent
|
341
|
+
if parent && !parent.root?
|
335
342
|
[parent.path, name.to_s].join(sep)
|
336
343
|
else
|
337
344
|
name.to_s
|
@@ -396,6 +403,9 @@ module YARD
|
|
396
403
|
# Tests if the {#docstring} has a tag
|
397
404
|
# @see Docstring#has_tag?
|
398
405
|
def has_tag?(name); @docstring.has_tag?(name) end
|
406
|
+
|
407
|
+
# @return whether or not this object is a RootObject
|
408
|
+
def root?; false end
|
399
409
|
|
400
410
|
protected
|
401
411
|
|
@@ -414,7 +424,8 @@ module YARD
|
|
414
424
|
# @return [String] formatted source
|
415
425
|
def format_source(source)
|
416
426
|
source.chomp!
|
417
|
-
|
427
|
+
last = source.split(/\r?\n/).last
|
428
|
+
indent = last ? last[/^([ \t]*)/, 1].length : 0
|
418
429
|
source.gsub(/^[ \t]{#{indent}}/, '')
|
419
430
|
end
|
420
431
|
end
|
@@ -13,7 +13,14 @@ module YARD::CodeObjects
|
|
13
13
|
if is_exception?
|
14
14
|
self.superclass ||= :Exception unless P(namespace, name) == P(:Exception)
|
15
15
|
else
|
16
|
-
|
16
|
+
case P(namespace, name).path
|
17
|
+
when "BasicObject"
|
18
|
+
nil
|
19
|
+
when "Object"
|
20
|
+
self.superclass ||= :BasicObject
|
21
|
+
else
|
22
|
+
self.superclass ||= :Object
|
23
|
+
end
|
17
24
|
end
|
18
25
|
end
|
19
26
|
|
@@ -33,7 +40,7 @@ module YARD::CodeObjects
|
|
33
40
|
def inheritance_tree(include_mods = false)
|
34
41
|
list = (include_mods ? mixins(:instance) : [])
|
35
42
|
if superclass.is_a?(Proxy) || superclass.respond_to?(:inheritance_tree)
|
36
|
-
list += [superclass] unless superclass == P(:Object)
|
43
|
+
list += [superclass] unless superclass == P(:Object) || superclass == P(:BasicObject)
|
37
44
|
end
|
38
45
|
[self] + list.map do |m|
|
39
46
|
next m unless m.respond_to?(:inheritance_tree)
|
@@ -102,7 +109,7 @@ module YARD::CodeObjects
|
|
102
109
|
# Sets the superclass of the object
|
103
110
|
#
|
104
111
|
# @param [Base, Proxy, String, Symbol, nil] object the superclass value
|
105
|
-
# @return [
|
112
|
+
# @return [void]
|
106
113
|
def superclass=(object)
|
107
114
|
case object
|
108
115
|
when Base, Proxy, NilClass
|
@@ -113,7 +120,7 @@ module YARD::CodeObjects
|
|
113
120
|
raise ArgumentError, "superclass must be CodeObject, Proxy, String or Symbol"
|
114
121
|
end
|
115
122
|
|
116
|
-
if name == @superclass.name && namespace != YARD::Registry.root
|
123
|
+
if name == @superclass.name && namespace != YARD::Registry.root && object.is_a?(String)
|
117
124
|
@superclass = Proxy.new(namespace.namespace, object)
|
118
125
|
end
|
119
126
|
|
@@ -52,15 +52,24 @@ module YARD::CodeObjects
|
|
52
52
|
# @param [Symbol] v the new visibility (:public, :private, or :protected)
|
53
53
|
def visibility=(v) @visibility = v.to_sym end
|
54
54
|
|
55
|
+
# @return whether or not the method is the #initialize constructor method
|
56
|
+
def constructor?
|
57
|
+
name == :initialize && scope == :instance && namespace.is_a?(ClassObject)
|
58
|
+
end
|
59
|
+
|
55
60
|
# Tests if the object is defined as an attribute in the namespace
|
56
61
|
# @return [Boolean] whether the object is an attribute
|
57
62
|
def is_attribute?
|
58
|
-
namespace.
|
63
|
+
return false unless namespace.is_a?(NamespaceObject)
|
64
|
+
attr_obj = namespace.attributes[scope][name.to_s.gsub(/=$/, '')]
|
65
|
+
return false unless attr_obj
|
66
|
+
attr_obj[name.to_s =~ /=$/ ? :write : :read] ? true : false
|
59
67
|
end
|
60
68
|
|
61
69
|
# Tests if the object is defined as an alias of another method
|
62
70
|
# @return [Boolean] whether the object is an alias
|
63
71
|
def is_alias?
|
72
|
+
return false unless namespace.is_a?(NamespaceObject)
|
64
73
|
namespace.aliases.has_key? self
|
65
74
|
end
|
66
75
|
|
@@ -75,6 +84,7 @@ module YARD::CodeObjects
|
|
75
84
|
# @return [Array<Symbol>] the alias names
|
76
85
|
def aliases
|
77
86
|
list = []
|
87
|
+
return list unless namespace.is_a?(NamespaceObject)
|
78
88
|
namespace.aliases.each do |o, aname|
|
79
89
|
list << o if aname == name && o.scope == scope
|
80
90
|
end
|
@@ -75,7 +75,7 @@ module YARD
|
|
75
75
|
if obj = to_obj
|
76
76
|
obj.path
|
77
77
|
else
|
78
|
-
if @namespace
|
78
|
+
if @namespace.root?
|
79
79
|
(@imethod ? ISEP : "") + name.to_s
|
80
80
|
elsif @origname
|
81
81
|
if @origname =~ /^[A-Z]/
|
@@ -154,7 +154,7 @@ module YARD
|
|
154
154
|
|
155
155
|
# Allows a parser to infer the type of the proxy by its path.
|
156
156
|
# @param [#to_sym] type the proxy's inferred type
|
157
|
-
# @return [
|
157
|
+
# @return [void]
|
158
158
|
def type=(type) Registry.proxy_types[path] = type.to_sym end
|
159
159
|
|
160
160
|
# @return [Boolean]
|
@@ -199,6 +199,9 @@ module YARD
|
|
199
199
|
end
|
200
200
|
end
|
201
201
|
end
|
202
|
+
|
203
|
+
# This class is never a root object
|
204
|
+
def root?; false end
|
202
205
|
|
203
206
|
private
|
204
207
|
|
data/lib/yard/core_ext/file.rb
CHANGED
data/lib/yard/core_ext/module.rb
CHANGED
@@ -11,9 +11,9 @@ class Module
|
|
11
11
|
# Returns the module namespace path minus the class/module name
|
12
12
|
#
|
13
13
|
# @example
|
14
|
-
# module A::B::C;
|
14
|
+
# module A::B::C; namespace_name end # => "A::B"
|
15
15
|
# @return [String] the namespace minus the class/module name
|
16
|
-
def
|
16
|
+
def namespace_name
|
17
17
|
name.split("::")[0..-2].join("::")
|
18
18
|
end
|
19
19
|
end
|
data/lib/yard/core_ext/string.rb
CHANGED
@@ -17,4 +17,70 @@ class String
|
|
17
17
|
def camelcase
|
18
18
|
gsub(/([a-z])_([a-z])/i) { $1 + $2.upcase }.sub(/^(.)/) { $1.upcase }.gsub('/', '::')
|
19
19
|
end
|
20
|
+
|
21
|
+
# Splits text into tokens the way a shell would, handling quoted
|
22
|
+
# text as a single token. Use '\"' and "\'" to escape quotes and
|
23
|
+
# '\\' to escape a backslash.
|
24
|
+
#
|
25
|
+
# @return [Array] an array representing the tokens
|
26
|
+
def shell_split
|
27
|
+
out = [""]
|
28
|
+
state = :none
|
29
|
+
escape_next = false
|
30
|
+
quote = ""
|
31
|
+
strip.split(//).each do |char|
|
32
|
+
case state
|
33
|
+
when :none, :space
|
34
|
+
case char
|
35
|
+
when /\s/
|
36
|
+
out << "" unless state == :space
|
37
|
+
state = :space
|
38
|
+
escape_next = false
|
39
|
+
when "\\"
|
40
|
+
if escape_next
|
41
|
+
out.last << char
|
42
|
+
escape_next = false
|
43
|
+
else
|
44
|
+
escape_next = true
|
45
|
+
end
|
46
|
+
when '"', "'"
|
47
|
+
if escape_next
|
48
|
+
out.last << char
|
49
|
+
escape_next = false
|
50
|
+
else
|
51
|
+
state = char
|
52
|
+
quote = ""
|
53
|
+
end
|
54
|
+
else
|
55
|
+
state = :none
|
56
|
+
out.last << char
|
57
|
+
escape_next = false
|
58
|
+
end
|
59
|
+
when '"', "'"
|
60
|
+
case char
|
61
|
+
when '"', "'"
|
62
|
+
if escape_next
|
63
|
+
quote << char
|
64
|
+
escape_next = false
|
65
|
+
elsif char == state
|
66
|
+
out.last << quote
|
67
|
+
state = :none
|
68
|
+
else
|
69
|
+
quote << char
|
70
|
+
end
|
71
|
+
when '\\'
|
72
|
+
if escape_next
|
73
|
+
quote << char
|
74
|
+
escape_next = false
|
75
|
+
else
|
76
|
+
escape_next = true
|
77
|
+
end
|
78
|
+
else
|
79
|
+
quote << char
|
80
|
+
escape_next = false
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
84
|
+
out
|
85
|
+
end
|
20
86
|
end
|
data/lib/yard/docstring.rb
CHANGED
@@ -39,7 +39,6 @@ module YARD
|
|
39
39
|
# @param [CodeObjects::Base] object an object to associate the docstring
|
40
40
|
# with.
|
41
41
|
def initialize(content = '', object = nil)
|
42
|
-
@tag_factory = Tags::Library.new
|
43
42
|
@object = object
|
44
43
|
|
45
44
|
self.all = content
|
@@ -165,12 +164,13 @@ module YARD
|
|
165
164
|
return create_ref_tag(tag_name, $1, $2)
|
166
165
|
end
|
167
166
|
|
167
|
+
tag_factory = Tags::Library.instance
|
168
168
|
tag_method = "#{tag_name}_tag"
|
169
|
-
if tag_name &&
|
170
|
-
if
|
171
|
-
add_tag
|
169
|
+
if tag_name && tag_factory.respond_to?(tag_method)
|
170
|
+
if tag_factory.method(tag_method).arity == 2
|
171
|
+
add_tag *tag_factory.send(tag_method, tag_buf, raw_buf.join("\n"))
|
172
172
|
else
|
173
|
-
add_tag
|
173
|
+
add_tag *tag_factory.send(tag_method, tag_buf)
|
174
174
|
end
|
175
175
|
else
|
176
176
|
log.warn "Unknown tag @#{tag_name}" + (object ? " in file `#{object.file}` near line #{object.line}" : "")
|