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

Move (optional) and (required) parsing out of DocScanner.

parent 84c69f60
Loading
Loading
Loading
Loading
+0 −18
Original line number Diff line number Diff line
@@ -63,24 +63,6 @@ module JsDuck
      end
    end

    # matches: "(optional)"
    def maybe_optional
      skip_horiz_white
      if look(/\(optional\)/i)
        match(/\(optional\)/i)
        @current_tag[:optional] = true
      end
    end

    # matches: "(required)"
    def maybe_required
      skip_horiz_white
      if look(/\(required\)/i)
        match(/\(required\)/i)
        @current_tag[:optional] = false
      end
    end

    # matches ident.chain if possible and sets it on @current_tag
    def maybe_ident_chain(propname)
      skip_horiz_white
+5 −1
Original line number Diff line number Diff line
@@ -12,7 +12,11 @@ module JsDuck::Tag
      p.add_tag(:cfg)
      p.maybe_type
      p.maybe_name_with_default
      p.maybe_required
      p.current_tag[:optional] = false if parse_required(p)
    end

    def parse_required(p)
      p.hw.match(/\(required\)/i)
    end
  end
end
+5 −1
Original line number Diff line number Diff line
@@ -11,7 +11,11 @@ module JsDuck::Tag
      p.add_tag(:param)
      p.maybe_type
      p.maybe_name_with_default
      p.maybe_optional
      p.current_tag[:optional] = true if parse_optional(p)
    end

    def parse_optional(p)
      p.hw.match(/\(optional\)/i)
    end
  end
end