Commit 9701db5a authored by Rene Saarsoo's avatar Rene Saarsoo
Browse files

The Tag#parse can now return a hash of tag.

This will then be added as a new tag through #add_tag.
parent 376a6ec7
Loading
Loading
Loading
Loading
+5 −2
Original line number Diff line number Diff line
@@ -58,7 +58,7 @@ module JsDuck

    # The main loop of the DocParser
    def parse_loop
      add_tag(:default)
      add_tag({:tagname => :default, :doc => ""})

      while !@input.eos? do
        if look(/@/)
@@ -83,7 +83,10 @@ module JsDuck
        # ignore
      elsif tag = TagRegistry.get_by_pattern(name)
        match(/\w+/)
        tag.parse(self)

        t = tag.parse(self)
        add_tag(t) if t.is_a?(Hash)

        skip_white
      else
        Logger.warn(:tag, "Unsupported tag: @#{name}", @filename, @linenr)
+5 −1
Original line number Diff line number Diff line
@@ -23,8 +23,12 @@ module JsDuck

    # Appends new @tag to parsed tags list
    def add_tag(tag)
      if tag.is_a?(Hash)
        @tags << @current_tag = tag
      else
        @tags << @current_tag = {:tagname => tag, :doc => ""}
      end
    end

    # Forgets the previously parsed tag
    def remove_last_tag
+3 −0
Original line number Diff line number Diff line
@@ -21,6 +21,9 @@ module JsDuck::Tag
      unless p.current_tag[:override]
        p.remove_last_tag
      end

      # Ensure #parse returns nothing
      nil
    end

    def process_doc(tags)