Class: Inch::Language::Nodejs::Provider::JSDoc::Docstring
Instance Method Summary
collapse
#code_examples, #contains_code_example?, #describes_private_object?, #empty?, #initialize, #to_s
Instance Method Details
#describes_internal_api? ⇒ Boolean
20
21
22
|
# File 'lib/inch/language/nodejs/provider/jsdoc/docstring.rb', line 20
def describes_internal_api?
tag?(:api, :private) || super
end
|
#describes_parameter?(name) ⇒ Boolean
24
25
26
27
28
|
# File 'lib/inch/language/nodejs/provider/jsdoc/docstring.rb', line 24
def describes_parameter?(name)
return false if name.nil?
parameter = parameter_notations(name)
tag?(:param, /#{parameter}\s+\S+/)
end
|
#describes_return? ⇒ Boolean
40
41
42
43
|
# File 'lib/inch/language/nodejs/provider/jsdoc/docstring.rb', line 40
def describes_return?
type_notation = /(\{[^\}]+\}|\[[^\]]+\])/
tag?(:return, /#{type_notation}*(\s\w+)/) || super
end
|
#mentions_parameter?(name) ⇒ Boolean
30
31
32
33
34
|
# File 'lib/inch/language/nodejs/provider/jsdoc/docstring.rb', line 30
def mentions_parameter?(name)
return false if name.nil?
parameter = parameter_notations(name)
tag?(:param, /#{parameter}/) || super
end
|
#mentions_return? ⇒ Boolean
36
37
38
|
# File 'lib/inch/language/nodejs/provider/jsdoc/docstring.rb', line 36
def mentions_return?
tag?(:return) || super
end
|
#tag?(tagname, regex = nil) ⇒ Boolean
51
52
53
54
55
56
57
58
59
|
# File 'lib/inch/language/nodejs/provider/jsdoc/docstring.rb', line 51
def tag?(tagname, regex = nil)
if =~ /^\s*\@#{tagname}([^\n]*)$/m
if regex.nil?
true
else
$1 =~ /#{regex}/
end
end
end
|
#visibility ⇒ Object
45
46
47
48
49
|
# File 'lib/inch/language/nodejs/provider/jsdoc/docstring.rb', line 45
def visibility
%w(public protected private).detect do |v|
tag?(v)
end || 'public'
end
|
Removes the comment markers // /* */ from the docstring.
Docstring.new("// test").
14
15
16
17
18
|
# File 'lib/inch/language/nodejs/provider/jsdoc/docstring.rb', line 14
def
@text.lines.map do |line|
line.strip.gsub(/^(\s*(\/\*+|\/\/|\*+\/|\*)+\s?)/m, '')
end.join("\n").strip
end
|