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

Add warning message for @tag syntax errors.

parent d0443ab1
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -95,14 +95,14 @@ module JsDuck

          if !tag.repeatable
            if @non_repeatable_tags[name]
              Logger.warn(:tag_repeated, "@#{name} tag can occur only once per doc-comment", @position)
              warn(:tag_repeated, "@#{name} tag can occur only once per doc-comment")
            end
            @non_repeatable_tags[name] = true
          end

          skip_white
        else
          Logger.warn(:tag, "Unsupported tag: @#{name}", @position)
          warn(:tag, "Unsupported tag: @#{name}")
          @multiline_tag[:doc] += "@"
        end
      end
+6 −0
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@ module JsDuck
        @ident_chain_pattern = /[$\w-]+(\.[$\w-]+)*/

        @input = nil # set to StringScanner in subclass
        @position = {} # set in subclass
      end

      # Provides access to StringScanner
@@ -70,6 +71,11 @@ module JsDuck
        self
      end

      # Prints a warning message
      def warn(type, msg)
        Logger.warn(type, msg, @position)
      end

    end

  end
+10 −5
Original line number Diff line number Diff line
@@ -30,6 +30,7 @@ module JsDuck
      # were specified and how their matching succeeded.
      #
      def parse(cfg)
        @tagname = cfg[:tagname]
        tag = {:tagname => cfg[:tagname]}
        add_type(tag) if cfg[:type]
        add_name_with_default(tag) if cfg[:name]
@@ -61,7 +62,7 @@ module JsDuck
          optional = nil
        end

        match(/\}/)
        match(/\}/) or warn("@#{tagname} tag syntax: '}' expected")

        return {:type => name, :optional => optional}
      end
@@ -74,7 +75,7 @@ module JsDuck
            hw
            tag[:default] = default_value
          end
        hw.match(/\]/)
          hw.match(/\]/) or warn("@#{tagname} tag syntax: ']' expected")
          tag[:optional] = true
        else
          tag[:name] = hw.ident_chain
@@ -148,6 +149,10 @@ module JsDuck
      def hw
        @ds.hw
      end

      def warn(msg)
        @ds.warn(:tag_syntax, msg)
      end
    end

  end
+1 −0
Original line number Diff line number Diff line
@@ -18,6 +18,7 @@ module JsDuck
        [:extend, "@extend/mixin/requires/uses referring to unknown class"],
        [:tag, "Use of unsupported @tag"],
        [:tag_repeated, "An @tag used multiple times, but only once allowed"],
        [:tag_syntax, "@tag syntax error"],
        [:link, "{@link} to unknown class or member"],
        [:link_ambiguous, "{@link} is ambiguous"],
        [:link_auto, "Auto-detected link to unknown class or member"],