Commit 4445d615 authored by Rene Saarsoo's avatar Rene Saarsoo
Browse files

Merge branch 'extra_fields'

parents f816cd88 519e8882
Loading
Loading
Loading
Loading
+2 −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, :mixins].each do |tag|
        old[tag] = old[tag] || new[tag]
      end
      old[:doc] = old[:doc].length > 0 ? old[:doc] : new[:doc]
@@ -154,6 +154,7 @@ module JsDuck
        :tagname => :class,
        :name => name,
        :doc => "",
        :mixins => [],
        :cfg => [],
        :property => [],
        :method => [],
+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)
+19 −3
Original line number Diff line number Diff line
@@ -195,7 +195,7 @@ module JsDuck
      cfg
    end

    # <ext-define-cfg> := "{" ( <extend> | <mixins> | <?> )*
    # <ext-define-cfg> := "{" ( <extend> | <mixins> | <alternate-class-name> | <?> )*
    def ext_define_cfg
      match("{")
      cfg = {}
@@ -208,6 +208,9 @@ module JsDuck
        elsif look("mixins", ":", "{")
          cfg[:mixins] = ext_define_mixins
          found = true
        elsif look("alternateClassName", ":")
          cfg[:alternateClassName] = ext_define_alternate_class_name
          found = true
        elsif look(:ident, ":")
          match(:ident, ":")
          if look(:string) || look(:number) || look(:regex) ||
@@ -231,6 +234,18 @@ module JsDuck
      match("extend", ":", :string)
    end

    # <ext-define-alternate-class-name> := "alternateClassName" ":" ( <string> | <array-of-strings> )
    def ext_define_alternate_class_name
      match("alternateClassName", ":")
      if look(:string)
        [ match(:string) ]
      elsif look("[")
        array_of_strings
      else
        []
      end
    end

    # <ext-define-mixins> := "mixins" ":" "{" [ <ident> ":" <string> ","? ]* "}"
    def ext_define_mixins
      match("mixins", ":", "{")
@@ -246,14 +261,15 @@ 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],