Sha256: d323f6c0d359dc789ff5926d8827460139596160eff06ee817e76dc4b85d53f9

Contents?: true

Size: 1.26 KB

Versions: 21

Compression:

Stored size: 1.26 KB

Contents

module Aws
  module Api
    # @api private
    # This module loads the API documentation for the given API.
    module Docstrings

      def self.apply(client_class, path)
        api = client_class.api.definition
        docs = File.open(path, 'r', encoding: 'UTF-8') { |f| f.read }
        docs = MultiJson.load(docs)

        api['documentation'] = docs['service']

        docs['operations'].each do |operation, doc|
          api['operations'][operation]['documentation'] = doc
        end

        docs['shapes'].each do |shape_name, shape|
          api['shapes'][shape_name]['documentation'] = shape['base']
          shape['refs'].each do |ref,doc|
            if doc.nil?
              doc = shape['base']
            end
            target_shape_name, member = ref.split('$')
            target_shape = api['shapes'][target_shape_name]
            case target_shape['type']
            when 'structure' then target_shape['members'][member]['documentation'] = doc
            when 'list' then target_shape[member]['documentation'] = doc
            when 'map' then target_shape[member]['documentation'] = doc
            else raise 'not handled'
            end
          end
        end
        client_class.set_api(Seahorse::Model::Api.new(api))
      end
    end
  end
end

Version data entries

21 entries across 21 versions & 1 rubygems

Version Path
aws-sdk-core-2.0.48 lib/aws-sdk-core/api/docstrings.rb
aws-sdk-core-2.0.47 lib/aws-sdk-core/api/docstrings.rb
aws-sdk-core-2.0.46 lib/aws-sdk-core/api/docstrings.rb
aws-sdk-core-2.0.45 lib/aws-sdk-core/api/docstrings.rb
aws-sdk-core-2.0.44 lib/aws-sdk-core/api/docstrings.rb
aws-sdk-core-2.0.43 lib/aws-sdk-core/api/docstrings.rb
aws-sdk-core-2.0.42 lib/aws-sdk-core/api/docstrings.rb
aws-sdk-core-2.0.41 lib/aws-sdk-core/api/docstrings.rb
aws-sdk-core-2.0.40 lib/aws-sdk-core/api/docstrings.rb
aws-sdk-core-2.0.39 lib/aws-sdk-core/api/docstrings.rb
aws-sdk-core-2.0.38 lib/aws-sdk-core/api/docstrings.rb
aws-sdk-core-2.0.37 lib/aws-sdk-core/api/docstrings.rb
aws-sdk-core-2.0.36 lib/aws-sdk-core/api/docstrings.rb
aws-sdk-core-2.0.35 lib/aws-sdk-core/api/docstrings.rb
aws-sdk-core-2.0.34 lib/aws-sdk-core/api/docstrings.rb
aws-sdk-core-2.0.33 lib/aws-sdk-core/api/docstrings.rb
aws-sdk-core-2.0.32 lib/aws-sdk-core/api/docstrings.rb
aws-sdk-core-2.0.31 lib/aws-sdk-core/api/docstrings.rb
aws-sdk-core-2.0.30 lib/aws-sdk-core/api/docstrings.rb
aws-sdk-core-2.0.29 lib/aws-sdk-core/api/docstrings.rb