/** * Calculates the commenting completion index of a file * @param string $file Path of the file to be analyzed * @return string An fully formed HTML span tag containing the properly colored percentage */ static function AnalyzeFile($file) { $completion = -1; $source = @file_get_contents($file); if ($source) { $blocks = DocBlock::ParseCode($source); if ($blocks !== null) { $complete = 0; $pageblock = false; $total = 0; foreach ($blocks as $block) { $complete += $block->valid ? 1 : 0; if ($block->type == BLOCK_PAGE) { $pageblock = true; } if ($block->type == BLOCK_PAGE && !$_POST['Dpage']) { continue; } $total++; } if (!$pageblock && $_POST['Dpage']) { $total++; } // Statistics if ($total > 0) { $completion = round($complete / $total * 100); } } } return DocBlock::PrepareBullet($completion, $complete, $total); }