Sha256: be28b2ea6e230d6f1022be28a13e6756aa669d70eeaeb57053490308aa0bc066

Contents?: true

Size: 1.29 KB

Versions: 52

Compression:

Stored size: 1.29 KB

Contents

require 'jsduck/inline_examples'

module JsDuck
  module Exporter

    # Exporter for inline examples.
    #
    # It produces the following structure:
    #
    # {
    #   :type => :class,  # can also be :guide
    #   :name => "Panel",
    #   :examples => [
    #     {:code => "bla bla", :options => {}},
    #     {:code => "bla bla", :options => {"raw" => true}},
    #     ...
    #   ]
    # }
    #
    class Examples
      def initialize(relations, opts)
        # All params ignored, they're present to be compatible with
        # other exporters.
        @inline_examples = InlineExamples.new
      end

      # Returns hash of class name and inline examples
      def export(cls)
        examples = @inline_examples.extract(cls[:doc])
        if examples.length > 0
          {
            :type => :class,
            :name => cls[:name],
            :examples => examples,
          }
        else
          nil
        end
      end

      # Returns hash of guide name and inline examples
      def export_guide(guide)
        examples = @inline_examples.extract(guide[:html] || "")
        if examples.length > 0
          {
            :type => :guide,
            :name => guide["name"],
            :examples => examples,
          }
        else
          nil
        end
      end

    end

  end
end

Version data entries

52 entries across 52 versions & 3 rubygems

Version Path
solvas-jsduck-6.0.0.30539 lib/jsduck/exporter/examples.rb
solvas-jsduck-6.0.0.9571 lib/jsduck/exporter/examples.rb
solvas-jsduck-6.0.0.6154 lib/jsduck/exporter/examples.rb
solvas-jsduck-6.0.0.4021 lib/jsduck/exporter/examples.rb
solvas-jsduck-6.0.0.2554 lib/jsduck/exporter/examples.rb
solvas-jsduck-6.0.0.1891 lib/jsduck/exporter/examples.rb
solvas-jsduck-6.0.0.beta.1888 lib/jsduck/exporter/examples.rb
jsduck-troopjs-0.0.10 lib/jsduck/exporter/examples.rb
jsduck-troopjs-0.0.9 lib/jsduck/exporter/examples.rb
jsduck-troopjs-0.0.8 lib/jsduck/exporter/examples.rb
jsduck-troopjs-0.0.7 lib/jsduck/exporter/examples.rb
jsduck-troopjs-0.0.5 lib/jsduck/exporter/examples.rb
jsduck-troopjs-0.0.4 lib/jsduck/exporter/examples.rb
jsduck-troopjs-0.0.3 lib/jsduck/exporter/examples.rb
jsduck-troopjs-0.0.1 lib/jsduck/exporter/examples.rb
jsduck-6.0.0beta lib/jsduck/exporter/examples.rb
jsduck-5.3.4 lib/jsduck/exporter/examples.rb
jsduck-5.3.3 lib/jsduck/exporter/examples.rb
jsduck-5.3.2 lib/jsduck/exporter/examples.rb
jsduck-5.3.1 lib/jsduck/exporter/examples.rb