Commit 5599fa4f authored by Nick Poulden's avatar Nick Poulden
Browse files

Add extra fields for docAuthor and alternateClassName

parent 2971197e
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -77,7 +77,7 @@ module JsDuck

    # Merges new class-doc into old one.
    def merge_classes(old, new)
      [:extends, :xtype, :singleton, :private].each do |tag|
      [:extends, :xtype, :singleton, :private, :alternateClassName].each do |tag|
        old[tag] = old[tag] || new[tag]
      end
      old[:doc] = old[:doc].length > 0 ? old[:doc] : new[:doc]
+11 −0
Original line number Diff line number Diff line
@@ -97,6 +97,8 @@ module JsDuck
          at_member
        elsif look(/@author\b/)
          at_author
        elsif look(/@docauthor\b/)
          at_docauthor
        elsif look(/@var\b/)
          at_var
        elsif look(/@static\b/)
@@ -237,6 +239,15 @@ module JsDuck
      skip_white
    end

    # matches @docauthor some name ... newline
    def at_docauthor
      match(/@docauthor/)
      add_tag(:docauthor)
      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)
+33 −2
Original line number Diff line number Diff line
@@ -205,6 +205,12 @@ module JsDuck
        if look("extend", ":", :string)
          cfg[:extend] = ext_define_extend
          found = true
        elsif look("alternateClassName", ":", '[')
          cfg[:alternateClassName] = ext_define_alternate_class_names
          found = true
        elsif look("alternateClassName", ":", :string)
          cfg[:alternateClassName] = ext_define_alternate_class_name
          found = true
        elsif look("mixins", ":", "{")
          cfg[:mixins] = ext_define_mixins
          found = true
@@ -231,6 +237,28 @@ module JsDuck
      match("extend", ":", :string)
    end

    # <ext-define-alternate-class-name> := "alternateClassName" ":" <string>
    def ext_define_alternate_class_name
      match("alternateClassName", ":", :string)
    end

    # <ext-define-alternate-class-name> := "alternateClassName" ":" <string>
    def ext_define_alternate_class_names
      match("alternateClassName", ":", "[")
      strs = []
      while look(:string)
        strs << match(:string)
        match(",") if look(",")
      end

      if look("]")
        match("]")
        strs
      else
        false
      end
    end

    # <ext-define-mixins> := "mixins" ":" "{" [ <ident> ":" <string> ","? ]* "}"
    def ext_define_mixins
      match("mixins", ":", "{")
@@ -246,14 +274,17 @@ module JsDuck
    # <array-of-strings> := "[" [ <string> ","? ]* "]"
    def array_of_strings
      match("[")
      
      strs = []
      
      while look(:string)
        match(:string)
        strs << match(:string)
        match(",") if look(",")
      end

      if look("]")
        match("]")
        true
        strs
      else
        false
      end
+1 −0
Original line number Diff line number Diff line
@@ -120,6 +120,7 @@ module JsDuck
        :doc => detect_doc(docs),
        :extends => detect_extends(doc_map, code),
        :mixins => detect_mixins(doc_map, code),
        :alternateClassName => code[:alternateClassName],
        :xtype => detect_xtype(doc_map),
        :author => detect_author(doc_map),
        :singleton => !!doc_map[:singleton],