Commit 7d1d71a6 authored by Rene Saarsoo's avatar Rene Saarsoo
Browse files

Export superclasses list.

Moved superclasses method to JsDuck::Class - so both export and
doc pages generator can use it.
parent 2511bf84
Loading
Loading
Loading
Loading
+11 −0
Original line number Diff line number Diff line
@@ -18,6 +18,16 @@ module JsDuck
      @doc[:extends] ? lookup(@doc[:extends]) : nil
    end

    # Returns array of ancestor classes.
    # Example result when asking ancestors of MyPanel might be:
    #
    #   [Ext.util.Observable, Ext.Component, Ext.Panel]
    #
    def superclasses
      p = parent
      p ? p.superclasses + [p]  : []
    end

    # Returns array of mixin class instances.
    # Returns empty array if no mixins
    def mixins
@@ -49,6 +59,7 @@ module JsDuck
      doc.delete(:method)
      doc.delete(:event)
      doc[:component] = inherits_from?("Ext.Component")
      doc[:superclasses] = superclasses.collect {|cls| cls.full_name }
      doc
    end

+1 −11
Original line number Diff line number Diff line
@@ -9,7 +9,7 @@ module JsDuck
    # Renders the tree using HTML <pre> element
    def to_html
      i = -1
      html = ancestors(@cls).reverse.collect do |cls|
      html = (@cls.superclasses + [@cls]).collect do |cls|
        i += 1
        make_indent(i) + make_link(cls)
      end.join("\n")
@@ -21,16 +21,6 @@ module JsDuck
      EOHTML
    end

    # Returns array of the names of ancestor classes for given class.
    # Including the name of the class itself.
    # Example result when ascing ancestors of MyPanel might be:
    #
    #   [MyPanel, Ext.Panel, Ext.Component, Ext.util.Observable]
    #
    def ancestors(cls)
      cls.parent ? [cls] + ancestors(cls.parent) : [cls]
    end

    def make_indent(level)
      if level > 0
        ("  " * level) + "<img src='resources/elbow-end.gif' alt=''>"