Sha256: 16faae88dbbd1ec951f07c73b7d249f5e933a77c2652c0a0d878b3c2d99a1f32

Contents?: true

Size: 1.52 KB

Versions: 3

Compression:

Stored size: 1.52 KB

Contents

module Inch
  module CodeObject
    module Provider
      # Parses the source tree (using YARD)
      module YARD

        # Returns +true+ if the docstring was generated by YARD
        #
        # @param docstring [Docstring,String]
        # @param method [MethodObject]
        def self.implicit_docstring?(docstring, method)
          name = method.name
          if method.getter?
            docstring.to_s == "Returns the value of attribute #{name}"
          elsif method.setter?
            basename = name.to_s.gsub(/(\=)$/, '')
            docstring.to_s == "Sets the attribute #{basename}"
          else
            false
          end
        end

        # Returns +true+ if the tag was generated by YARD
        #
        # @param tag [::YARD::Tag]
        # @param method [MethodObject]
        def self.implicit_tag?(tag, method)
          name = method.name
          if method.getter?
            tag.tag_name == 'return' &&
              tag.text == "the current value of #{name}"
          elsif method.setter?
            tag.tag_name == 'return' &&
              tag.text == 'the newly set value'
          else
            false
          end
        end

        def self.parse(dir, config = Inch::Config.codebase)
          Parser.parse(dir, config)
        end

      end
    end
  end
end

require 'logger'
require 'yard'

log.level = ::Logger::UNKNOWN # basically disable YARD's logging

require_relative 'yard/parser'
require_relative 'yard/docstring'
require_relative 'yard/nodoc_helper'
require_relative 'yard/object'

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
inch-0.4.4 lib/inch/code_object/provider/yard.rb
inch-0.4.4.rc4 lib/inch/code_object/provider/yard.rb
inch-0.4.4.rc3 lib/inch/code_object/provider/yard.rb