Sha256: d49def81afca70500994a827a974c31fd18dfe56c936ccad4134dfab1330673a
Contents?: true
Size: 1.88 KB
Versions: 4
Compression:
Stored size: 1.88 KB
Contents
module Inch module Language module Nodejs module Provider module JSDoc class Docstring < Ruby::Provider::YARD::Docstring VISIBILITIES = %w(public protected private) # Removes the comment markers // /* */ from the docstring. # # Docstring.new("// test").without_comment_markers # # => "test" # # @return [String] def without_comment_markers @text.lines.map do |line| line.strip.gsub(/^(\s*(\/\*+|\/\/|\*+\/|\*)+\s?)/m, '') end.join("\n").strip end def describes_internal_api? tag?(:api, :private) || super end def describes_parameter?(name) return false if name.nil? parameter = parameter_notations(name) tag?(:param, /#{parameter}\s+\S+/) end def mentions_parameter?(name) return false if name.nil? parameter = parameter_notations(name) tag?(:param, /#{parameter}/) || super end def mentions_return? tag?(:return) || super end def describes_return? type_notation = /(\{[^\}]+\}|\[[^\]]+\])/ tag?(:return, /#{type_notation}*(\s\w+)/) || super end def visibility tagged_value = VISIBILITIES.detect do |v| tag?(v) end (tagged_value || 'public').to_sym end def tag?(tagname, regex = nil) if without_comment_markers =~ /^\s*\@#{tagname}([^\n]*)$/m if regex.nil? true else $1 =~ /#{regex}/ end end end end end end end end end
Version data entries
4 entries across 4 versions & 1 rubygems