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

Special class "global".

Variables, functions, etc not assigned to any class are listed there.

This class only gets created if there is at least one member to place
into it.
parent 9ca3871c
Loading
Loading
Loading
Loading
+27 −10
Original line number Diff line number Diff line
@@ -128,9 +128,31 @@ module JsDuck
        if orph[:member]
          class_name = orph[:member]
          if !@classes[class_name]
            add_empty_class(class_name)
          end
          add_member(orph)
          @orphans.delete(orph)
        end
      end
    end

    # Creates class with name "global" and inserts all the remaining
    # orphans into it (but only if there are any orphans).
    def create_global_class
      return if @orphans.length == 0

      add_empty_class("global")
      @orphans.each do |orph|
        orph[:member] = "global"
        add_member(orph)
      end
      @orphans = []
    end

    def add_empty_class(name)
      add_class({
          :tagname => :class,
              :name => class_name,
          :name => name,
          :cfg => [],
          :property => [],
          :method => [],
@@ -139,11 +161,6 @@ module JsDuck
          :css_mixin => [],
        })
    end
          add_member(orph)
          @orphans.delete(orph)
        end
      end
    end

    def result
      @documentation + @orphans
+1 −0
Original line number Diff line number Diff line
@@ -89,6 +89,7 @@ module JsDuck
        agr.aggregate(file[:data], file[:filename], file[:html_filename])
      end
      agr.classify_orphans
      agr.create_global_class
      agr.result
    end