Sha256: f13a4dd0e7b19154426aca774c145b8f4495385463ce921c7ac9b4a72b856576

Contents?: true

Size: 809 Bytes

Versions: 2

Compression:

Stored size: 809 Bytes

Contents

module Dox
  module Printers
    class ActionPrinter < BasePrinter

      def print(action)
        @output.puts "### #{action.name}\n\n#{print_desc(action.desc)}\n\n"

        if action.uri_params.present?
          @output.puts("+ Parameters\n#{formatted_params(action.uri_params)}")
        end

        action.examples.each do |example|
          example_printer.print(example)
        end
      end

      private

      def example_printer
        @example_printer ||= ExamplePrinter.new(@output)
      end

      def formatted_params(uri_params)
        uri_params.map do |param, details|
          "    + #{CGI.escape(param.to_s)}: `#{CGI.escape(details[:value].to_s)}` (#{details[:type]}, #{details[:required]}) - #{details[:description]}"
        end.flatten.join("\n")
      end

    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
dox-0.0.3 lib/dox/printers/action_printer.rb
dox-0.0.2 lib/dox/printers/action_printer.rb