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

Allow use of meta-tags in members.

Formerly meta-tags only worked inside class comment.
parent f90d4eec
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -124,7 +124,6 @@ module JsDuck
        :mixins => detect_list(:mixins, doc_map, code),
        :alternateClassNames => detect_list(:alternateClassNames, doc_map, code),
        :xtypes => detect_xtypes(doc_map, code),
        :meta => detect_meta(doc_map),
        :singleton => detect_singleton(doc_map, code),
        :requires => detect_list(:requires, doc_map, code),
        :uses => detect_list(:uses, doc_map, code),
@@ -228,6 +227,7 @@ module JsDuck
        :inheritable => !!doc_map[:inheritable],
        :deprecated => detect_deprecated(doc_map),
        :alias => doc_map[:alias] ? doc_map[:alias].first : nil,
        :meta => detect_meta(doc_map),
      })
      hash[:id] = create_member_id(hash)
      return hash
+7 −3
Original line number Diff line number Diff line
@@ -17,7 +17,7 @@ module JsDuck
            "<div class='doc-contents'>",
              render_private_class_notice,
              @cls[:doc],
              render_meta_data,
              render_meta_data(@cls[:meta]),
            "</div>",
            "<div class='members'>",
              render_member_sections,
@@ -35,9 +35,11 @@ module JsDuck
      ]
    end

    def render_meta_data
    def render_meta_data(meta_data)
      return if meta_data.size == 0

      @meta_tags.map do |tag|
        contents = @cls[:meta][tag.name]
        contents = meta_data[tag.name]
        if contents
          tag.to_html(contents)
        else
@@ -274,6 +276,8 @@ module JsDuck
        ]
      end

      doc << render_meta_data(m[:meta])

      doc << render_params_and_return(m)

      doc
+22 −0
Original line number Diff line number Diff line
@@ -91,4 +91,26 @@ describe JsDuck::Aggregator do
      }
    end
  end

  describe "meta-tag inside class member" do
    before do
      @doc = parse(<<-EOS)[0]
        /**
         * @method foo
         * Some description.
         * @author John Doe
         */
      EOS
    end

    it "detects the meta tag" do
      @doc[:meta].should == {
        "author" => ["John Doe"],
      }
    end

    it "leaves member description as is" do
      @doc[:doc].should == "Some description."
    end
  end
end