Loading lib/jsduck/stats.rb +24 −0 Original line number Diff line number Diff line Loading @@ -14,6 +14,7 @@ module JsDuck :localMembers => cls.all_local_members.length, :fanIn => fan_in(cls), :fanOut => fan_out(cls), :wordCount => class_wc(cls), } end end Loading Loading @@ -51,6 +52,29 @@ module JsDuck @fi_table end # Counts nr of words in class documentation def class_wc(cls) cnt = wc(cls[:doc]) cls.all_local_members.each do |m| cnt += wc(m[:doc]) (m[:params] || []).each {|p| cnt += property_wc(p) } (m[:properties] || []).each {|p| cnt += property_wc(p) } cnt += wc(m[:return][:doc]) if m[:return] end cnt end def property_wc(property) cnt = wc(property[:doc] || "") (property[:properties] || []).each {|p| cnt += property_wc(p) } cnt end # Strips HTML and counts words in text def wc(str) str.gsub(/<\/?[^>]*>/, "").scan(/\w+/).length end end end template/app/model/Stats.js +2 −1 Original line number Diff line number Diff line Loading @@ -8,6 +8,7 @@ Ext.define('Docs.model.Stats', { 'members', 'localMembers', 'fanIn', 'fanOut' 'fanOut', 'wordCount' ] }); template/app/view/stats/Index.js +6 −1 Original line number Diff line number Diff line Loading @@ -44,8 +44,13 @@ Ext.define('Docs.view.stats.Index', { }, { text: 'Fan-out', flex: 1, width: 70, dataIndex: 'fanOut' }, { text: 'Words in docs', flex: 1, dataIndex: 'wordCount' } ] }]; Loading Loading
lib/jsduck/stats.rb +24 −0 Original line number Diff line number Diff line Loading @@ -14,6 +14,7 @@ module JsDuck :localMembers => cls.all_local_members.length, :fanIn => fan_in(cls), :fanOut => fan_out(cls), :wordCount => class_wc(cls), } end end Loading Loading @@ -51,6 +52,29 @@ module JsDuck @fi_table end # Counts nr of words in class documentation def class_wc(cls) cnt = wc(cls[:doc]) cls.all_local_members.each do |m| cnt += wc(m[:doc]) (m[:params] || []).each {|p| cnt += property_wc(p) } (m[:properties] || []).each {|p| cnt += property_wc(p) } cnt += wc(m[:return][:doc]) if m[:return] end cnt end def property_wc(property) cnt = wc(property[:doc] || "") (property[:properties] || []).each {|p| cnt += property_wc(p) } cnt end # Strips HTML and counts words in text def wc(str) str.gsub(/<\/?[^>]*>/, "").scan(/\w+/).length end end end
template/app/model/Stats.js +2 −1 Original line number Diff line number Diff line Loading @@ -8,6 +8,7 @@ Ext.define('Docs.model.Stats', { 'members', 'localMembers', 'fanIn', 'fanOut' 'fanOut', 'wordCount' ] });
template/app/view/stats/Index.js +6 −1 Original line number Diff line number Diff line Loading @@ -44,8 +44,13 @@ Ext.define('Docs.view.stats.Index', { }, { text: 'Fan-out', flex: 1, width: 70, dataIndex: 'fanOut' }, { text: 'Words in docs', flex: 1, dataIndex: 'wordCount' } ] }]; Loading