Sha256: d926c9722c1af5dbbfaa9f8355d509b2c506036e1207bb63658728b2d65d6b15
Contents?: true
Size: 815 Bytes
Versions: 2
Compression:
Stored size: 815 Bytes
Contents
module RuboCop module RSpec # Extracts cop descriptions from YARD docstrings class DescriptionExtractor COP_NAMESPACE = 'RuboCop::Cop::RSpec'.freeze COP_FORMAT = 'RSpec/%s'.freeze def initialize(yardocs) @yardocs = yardocs end def to_h cop_documentation.each_with_object({}) do |(name, docstring), config| config[format(COP_FORMAT, name)] = { 'Description' => docstring.split("\n\n").first.to_s } end end private def cop_documentation yardocs .select(&method(:cop?)) .map { |doc| [doc.name, doc.docstring] } end def cop?(doc) doc.type.equal?(:class) && doc.to_s.start_with?(COP_NAMESPACE) end attr_reader :yardocs end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
rubocop-rspec-1.8.0 | lib/rubocop/rspec/description_extractor.rb |
rubocop-rspec-1.7.0 | lib/rubocop/rspec/description_extractor.rb |