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

Split word-count metric into 3 columns.

- words in class header.
- sum of words in all class members.
- average nr of words per class member.
parent ee7919f7
Loading
Loading
Loading
Loading
+8 −4
Original line number Diff line number Diff line
@@ -10,6 +10,8 @@ module JsDuck
      classes.map do |cls|
        local_members = cls.all_local_members
        total_members = cls.all_members
        class_wc = wc(cls[:doc])
        members_wc = members_wc(cls)

        {
          :name => cls[:name],
@@ -29,7 +31,9 @@ module JsDuck
          :fanIn => fan_in(cls),
          :fanOut => fan_out(cls),

          :wordCount => class_wc(cls),
          :class_wc => class_wc,
          :members_wc => members_wc,
          :wc_per_member => local_members.length > 0 ? (members_wc / local_members.length) : 0,
        }
      end
    end
@@ -71,9 +75,9 @@ module JsDuck
      @fi_table
    end

    # Counts nr of words in class documentation
    def class_wc(cls)
      cnt = wc(cls[:doc])
    # Counts nr of words in documentation of all members of class
    def members_wc(cls)
      cnt = 0
      cls.all_local_members.each do |m|
        cnt += wc(m[:doc])
        (m[:params] || []).each {|p| cnt += property_wc(p) }
+3 −1
Original line number Diff line number Diff line
@@ -20,6 +20,8 @@ Ext.define('Docs.model.Stats', {

        'fanIn',
        'fanOut',
        'wordCount'
        'class_wc',
        'members_wc',
        'wc_per_member'
    ]
});
+16 −3
Original line number Diff line number Diff line
@@ -108,11 +108,24 @@ Ext.define('Docs.view.stats.Index', {
                    align: 'right',
                    dataIndex: 'fanOut'
                },

                {
                    text: 'Class word-count',
                    width: 50,
                    align: 'right',
                    dataIndex: 'class_wc'
                },
                {
                    text: 'Word count',
                    width: 70,
                    text: 'Members word-count',
                    width: 50,
                    align: 'right',
                    dataIndex: 'members_wc'
                },
                {
                    text: 'wc / member',
                    width: 50,
                    align: 'right',
                    dataIndex: 'wordCount'
                    dataIndex: 'wc_per_member'
                }
            ]
        }];