Commit 81cc4fc3 authored by Rene Saarsoo's avatar Rene Saarsoo
Browse files

Support for @author.

In Ext4 codebase @author is quite frequent, so why not support it.
parent d2b7178b
Loading
Loading
Loading
Loading
+11 −0
Original line number Diff line number Diff line
@@ -90,6 +90,8 @@ module JsDuck
          at_xtype
        elsif look(/@member\b/)
          at_member
        elsif look(/@author\b/)
          at_author
        elsif look(/@static\b/)
          boolean_at_tag(/@static/, :static)
        elsif look(/@(private|ignore|hide|protected)\b/)
@@ -207,6 +209,15 @@ module JsDuck
      skip_white
    end

    # matches @author some name ... newline
    def at_author
      match(/@author/)
      add_tag(:author)
      skip_horiz_white
      @current_tag[:name] = @input.scan(/.*$/)
      skip_white
    end

    # Used to match @private, @ignore, @hide, ...
    def boolean_at_tag(regex, propname)
      match(regex)
+5 −0
Original line number Diff line number Diff line
@@ -111,6 +111,7 @@ module JsDuck
        :extends => detect_extends(doc_map, code),
        :mixins => detect_mixins(doc_map, code),
        :xtype => detect_xtype(doc_map),
        :author => detect_author(doc_map),
        :singleton => !!doc_map[:singleton],
        :private => !!doc_map[:private],
      }
@@ -235,6 +236,10 @@ module JsDuck
      doc_map[:xtype] ? doc_map[:xtype].first[:name] : nil
    end

    def detect_author(doc_map)
      doc_map[:author] ? doc_map[:author].first[:name] : nil
    end

    def detect_params(docs, code)
      implicit = detect_implicit_params(code)
      explicit = detect_explicit_params(docs)
+1 −0
Original line number Diff line number Diff line
@@ -55,6 +55,7 @@ module JsDuck
        abstract_row("Defind In:", file_link),
        @subclasses[@cls] ? abstract_row("Subclasses:", subclasses) : "",
        @cls[:xtype] ? abstract_row("xtype:", @cls[:xtype]) : "",
        @cls[:author] ? abstract_row("Author:", @cls[:author]) : "",
       "</table>",
      ].join("\n")
    end
+17 −0
Original line number Diff line number Diff line
@@ -213,6 +213,23 @@ describe JsDuck::Aggregator do
    end
  end

  describe "class with @author" do
    before do
      @doc = parse(<<-EOS)[0]
        /**
         * @class MyClass
         * @author John Doe
         * Comment here.
         */
      EOS
    end

    it_should_behave_like "class"
    it "detects author name" do
      @doc[:author].should == "John Doe"
    end
  end

  describe "member docs after class doc" do
    before do
      @classes = parse(<<-EOS)