Sha256: 0b2977e8458ebe34bb3fe425c1fa25058da4ee482dec813810cd092d7965ff71

Contents?: true

Size: 1.18 KB

Versions: 29

Compression:

Stored size: 1.18 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|
            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

29 entries across 29 versions & 1 rubygems

Version Path
aws-sdk-core-2.0.27 lib/aws-sdk-core/api/docstrings.rb
aws-sdk-core-2.0.26 lib/aws-sdk-core/api/docstrings.rb
aws-sdk-core-2.0.25 lib/aws-sdk-core/api/docstrings.rb
aws-sdk-core-2.0.24 lib/aws-sdk-core/api/docstrings.rb
aws-sdk-core-2.0.23 lib/aws-sdk-core/api/docstrings.rb
aws-sdk-core-2.0.22 lib/aws-sdk-core/api/docstrings.rb
aws-sdk-core-2.0.21 lib/aws-sdk-core/api/docstrings.rb
aws-sdk-core-2.0.20 lib/aws-sdk-core/api/docstrings.rb
aws-sdk-core-2.0.19 lib/aws-sdk-core/api/docstrings.rb
aws-sdk-core-2.0.18 lib/aws-sdk-core/api/docstrings.rb
aws-sdk-core-2.0.17 lib/aws-sdk-core/api/docstrings.rb
aws-sdk-core-2.0.16 lib/aws-sdk-core/api/docstrings.rb
aws-sdk-core-2.0.15 lib/aws-sdk-core/api/docstrings.rb
aws-sdk-core-2.0.14 lib/aws-sdk-core/api/docstrings.rb
aws-sdk-core-2.0.13 lib/aws-sdk-core/api/docstrings.rb
aws-sdk-core-2.0.12 lib/aws-sdk-core/api/docstrings.rb
aws-sdk-core-2.0.11 lib/aws-sdk-core/api/docstrings.rb
aws-sdk-core-2.0.10 lib/aws-sdk-core/api/docstrings.rb
aws-sdk-core-2.0.9 lib/aws-sdk-core/api/docstrings.rb
aws-sdk-core-2.0.8 lib/aws-sdk-core/api/docstrings.rb