Commit 9b3b58ea authored by Rene Saarsoo's avatar Rene Saarsoo
Browse files

Process @property tag fully inside Tag::Property.

Additionally process the @type tag.
parent 11e36aa4
Loading
Loading
Loading
Loading
+0 −4
Original line number Diff line number Diff line
@@ -74,11 +74,7 @@ module JsDuck
      def create_property(docs, doc_map)
        return add_shared({
            :tagname => :property,
            :name => detect_name(:property, doc_map),
            :type => detect_type(:property, doc_map),
            :doc => detect_doc(:property, doc_map),
            :default => detect_default(:property, doc_map),
            :properties => detect_subproperties(:property, docs),
          }, doc_map)
      end

+17 −0
Original line number Diff line number Diff line
require "jsduck/tag/tag"
require "jsduck/doc/subproperties"

module JsDuck::Tag
  class Property < Tag
    def initialize
      @pattern = "property"
      @key = :property
      @member_type = :property
    end

@@ -13,5 +15,20 @@ module JsDuck::Tag
      tag[:doc] = :multiline
      tag
    end

    def process_doc(h, tags, pos)
      p = tags[0]
      h[:name] = p[:name]
      # Type might also come from @type, don't overwrite it with nil.
      h[:type] = p[:type] if p[:type]
      h[:default] = p[:default]
      h[:properties] = nest_properties(tags, pos)
    end

    def nest_properties(tags, pos)
      items, warnings = JsDuck::Doc::Subproperties.nest(tags)
      warnings.each {|msg| JsDuck::Logger.warn(:subproperty, msg, pos[:filename], pos[:linenr]) }
      items[0][:properties]
    end
  end
end
+5 −0
Original line number Diff line number Diff line
@@ -4,6 +4,7 @@ module JsDuck::Tag
  class Type < Tag
    def initialize
      @pattern = "type"
      @key = :type
    end

    # matches @type {type}  or  @type type
@@ -21,5 +22,9 @@ module JsDuck::Tag
      p.hw.match(/\S+/)
    end

    def process_doc(h, tags, pos)
      h[:type] = tags[0][:type] unless h[:type]
    end

  end
end