# Number of warnings and advices
var warnings = new Counter[MPackage]
+ # Documentation score (between 0 and 100)
+ var documentation_score = new Counter[MPackage]
+
# Number of commits by package
var commits = new Counter[MPackage]
var loc = 0
var errors = 0
var warnings = 0
+ # The documentation value of each entity is ad hoc.
+ var entity_score = 0.0
+ var doc_score = 0.0
for g in mpackage.mgroups do
mmodules += g.mmodules.length
+ entity_score += 1.0
+ if g.mdoc != null then doc_score += 1.0
for m in g.mmodules do
var source = m.location.file
if source != null then
loc += file.line_starts.length - 1
end
end
+ entity_score += 1.0
+ if m.mdoc != null then doc_score += 1.0
for cd in m.mclassdefs do
+ var s = 0.2
+ if not cd.is_intro then s /= 10.0
+ if not cd.mclass.visibility <= private_visibility then s /= 10.0
+ entity_score += s
+ if cd.mdoc != null then doc_score += s
mclasses += 1
for pd in cd.mpropdefs do
+ s = 0.1
+ if not pd.is_intro then s /= 10.0
+ if not pd.mproperty.visibility <= private_visibility then s /= 10.0
+ entity_score += s
+ if pd.mdoc != null then doc_score += s
if not pd isa MMethodDef then continue
mmethods += 1
end
self.loc[mpackage] = loc
self.errors[mpackage] = errors
self.warnings[mpackage] = warnings
+ var documentation_score = (100.0 * doc_score / entity_score).to_i
+ self.documentation_score[mpackage] = documentation_score
#score += mmodules.score
score += mclasses.score
score += mmethods.score
score += loc.score
+ score += documentation_score.score
self.score[mpackage] = score.to_i
end
res.add "<li>{errors} errors</li>\n"
end
res.add "<li>{warnings[mpackage]} warnings</li>\n"
+ res.add "<li>{documentation_score[mpackage]}% documented</li>\n"
res.add "</ul>\n"
res.add "<h3>Tags</h3>\n"
res.add "<th data-field=\"score\" data-sortable=\"true\">score</th>\n"
res.add "<th data-field=\"errors\" data-sortable=\"true\">errors</th>\n"
res.add "<th data-field=\"warnings\" data-sortable=\"true\">warnings</th>\n"
+ res.add "<th data-field=\"doc\" data-sortable=\"true\">doc</th>\n"
res.add "</tr></thead>"
for p in mpackages do
res.add "<tr>"
res.add "<td>{score[p]}</td>"
res.add "<td>{errors[p]}</td>"
res.add "<td>{warnings[p]}</td>"
+ res.add "<td>{documentation_score[p]}</td>"
res.add "</tr>\n"
end
res.add "</table>\n"