Sha256: b5180c2b164c800435fff915a815ff848f67a7128a306a690ddb8af5cb53941a

Contents?: true

Size: 728 Bytes

Versions: 30

Compression:

Stored size: 728 Bytes

Contents

require "jsduck/tag/tag"
require 'jsduck/format/shortener'

module JsDuck::Tag
  # A special class for rendering the documentation field inside
  # classes and members.
  class Doc < Tag
    def initialize
      @tagname = :doc
      @html_position = POS_DOC
      @shortener = JsDuck::Format::Shortener.new
    end

    def format(m, formatter)
      m[:doc] = formatter.format(m[:doc])

      if expandable?(m) || @shortener.too_long?(m[:doc])
        m[:short_doc] = @shortener.shorten(m[:doc])
      end
    end

    def to_html(m)
      m[:doc]
    end

    private

    def expandable?(m)
      m[:params] || (m[:properties] && m[:properties].length > 0) || m[:default] || m[:deprecated] || m[:template]
    end
  end
end

Version data entries

30 entries across 30 versions & 3 rubygems

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