Sha256: 62b0f362d395ba67dfc0bee9aefe21766cc6664fe139c2f2ec3b273a69c91021

Contents?: true

Size: 1.07 KB

Versions: 1

Compression:

Stored size: 1.07 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 :api
          true
        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.3.0 lib/yard-api/verifier.rb