Sha256: 434d9c8a019782a030b83d299d16ab5dd608febead5cc2d06c51d33d06633291

Contents?: true

Size: 1.04 KB

Versions: 1

Compression:

Stored size: 1.04 KB

Contents

module YARD
  module APIPlugin
    class Verifier < ::YARD::Verifier
      def initialize(verbose=false)
        @verbose = verbose
        super()
      end

      def run(list)
        relevant = list.select { |o| relevant_object?(o) }

        if @verbose && relevant.any?
          log "#{relevant.length}/#{list.length} objects are relevant:"

          relevant.each do |object|
            log "\t- #{object.path}"
          end
        end

        relevant
      end

      def relevant_object?(object)
        case object.type
        when :root, :module, :constant
          false
        when :method, :class
          return false if object.tags('internal').any?

          object.tags('API').any?.tap do |is_api|
            if @verbose && !is_api
              log "Resource #{object} will be ignored as it contains no @API tag."
            end
          end
        else
          object.parent.nil? && relevant_object?(object.parent)
        end
      end

      def log(*args)
        ::YARD::APIPlugin.log(*args)
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
yard-api-0.2.3 lib/yard-api/verifier.rb