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