Commit e22c488e authored by Rene Saarsoo's avatar Rene Saarsoo
Browse files

Add support for @readonly and @abstract tags.

Refactor those tags along with @protected and @template into
new property 'attributes'.
parent 93c47edf
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -58,6 +58,7 @@ module JsDuck
        :files => cfg[:files],
        :id => "method-" + name,
        :deprecated => cfg[:deprecated],
        :attributes => {},
        :meta => cfg[:meta],
      }
    end
@@ -81,6 +82,7 @@ module JsDuck
        :files => cfg[:files],
        :id => "method-" + name,
        :deprecated => cfg[:deprecated],
        :attributes => {},
        :meta => cfg[:meta]
      }
    end
@@ -118,6 +120,7 @@ module JsDuck
        :files => cfg[:files],
        :id => "event-" + name,
        :deprecated => cfg[:deprecated],
        :attributes => {},
        :meta => cfg[:meta]
      }
    end
+5 −1
Original line number Diff line number Diff line
@@ -85,13 +85,17 @@ module JsDuck
    # Merges new class-doc into old one.
    def merge_classes(old, new)
      # Merge booleans
      [:extends, :singleton, :private, :protected].each do |tag|
      [:extends, :singleton, :private].each do |tag|
        old[tag] = old[tag] || new[tag]
      end
      # Merge arrays
      [:mixins, :alternateClassNames, :files].each do |tag|
        old[tag] = old[tag] + new[tag]
      end
      # Merge attribute hashes
      new[:attributes].each_pair do |name, value|
        old[:attributes][name] = old[:attributes][name] || value
      end
      # Merge hashes of arrays
      [:aliases, :meta].each do |tag|
        new[tag].each_pair do |key, contents|
+1 −1
Original line number Diff line number Diff line
@@ -45,7 +45,7 @@ module JsDuck

    def compact_member(m)
      m_copy = {}
      [:name, :tagname, :owner, :protected, :static, :deprecated, :required, :template, :id].each do |key|
      [:name, :tagname, :owner, :static, :deprecated, :required, :attributes, :id].each do |key|
        m_copy[key] = m[key]
      end
      m_copy
+1 −1
Original line number Diff line number Diff line
@@ -52,7 +52,7 @@ module JsDuck
    end

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

    def format_item(it, is_css_tag)
+16 −6
Original line number Diff line number Diff line
@@ -144,20 +144,21 @@ module JsDuck
          boolean_at_tag(/@inheritable/, :inheritable)
        elsif look(/@(private|ignore|hide)\b/)
          boolean_at_tag(/@(private|ignore|hide)/, :private)
        elsif look(/@protected\b/)
          boolean_at_tag(/@protected/, :protected)
        elsif look(/@accessor\b/)
          boolean_at_tag(/@accessor/, :accessor)
        elsif look(/@evented\b/)
          boolean_at_tag(/@evented/, :evented)
        elsif look(/@protected\b/)
          attribute_tag(/@protected/, :protected)
        elsif look(/@template\b/)
          boolean_at_tag(/@template/, :template)
          attribute_tag(/@template/, :template)
        elsif look(/@abstract\b/)
          attribute_tag(/@abstract\b/, :abstract)
        elsif look(/@readonly\b/)
          attribute_tag(/@readonly\b/, :readonly)
        elsif look(/@markdown\b/)
          # this is detected just to be ignored
          boolean_at_tag(/@markdown/, :markdown)
        elsif look(/@abstract\b/)
          # this is detected just to be ignored
          boolean_at_tag(/@abstract/, :abstract)
        elsif look(/@/)
          @input.scan(/@/)
          tag = @meta_tags_map[look(/\w+/)]
@@ -369,6 +370,15 @@ module JsDuck
      skip_white
    end

    # Matches tag like @protected, @abstract, @readonly, @template
    # Creates :attribute tag with that name
    def attribute_tag(regex, attr_name)
      match(regex)
      add_tag(:attribute)
      @current_tag[:name] = attr_name
      skip_white
    end

    # matches {type} if possible and sets it on @current_tag
    def maybe_type
      skip_horiz_white
Loading