didou Sun Mar 4 03:55:16 2007 UTC
Modified files: /phpdoc/scripts/check_phpdoc view_check_phpdoc.php Log: Display readable statistics on first page and allow sorting. Some cosmetics too http://cvs.php.net/viewvc.cgi/phpdoc/scripts/check_phpdoc/view_check_phpdoc.php?r1=1.1&r2=1.2&diff_format=u Index: phpdoc/scripts/check_phpdoc/view_check_phpdoc.php diff -u phpdoc/scripts/check_phpdoc/view_check_phpdoc.php:1.1 phpdoc/scripts/check_phpdoc/view_check_phpdoc.php:1.2 --- phpdoc/scripts/check_phpdoc/view_check_phpdoc.php:1.1 Sat Mar 3 03:05:33 2007 +++ phpdoc/scripts/check_phpdoc/view_check_phpdoc.php Sun Mar 4 03:55:16 2007 @@ -16,7 +16,7 @@ | Authors: Mehdi Achour <[EMAIL PROTECTED]> | +----------------------------------------------------------------------+ - $Id: view_check_phpdoc.php,v 1.1 2007/03/03 03:05:33 didou Exp $ + $Id: view_check_phpdoc.php,v 1.2 2007/03/04 03:55:16 didou Exp $ */ /** @@ -68,7 +68,6 @@ ), - ); $restrict = (isset($_GET['restrict']) && isset($errors[$_GET['restrict']])) ? $_GET['restrict'] : false; @@ -89,9 +88,11 @@ tr.h:hover { background-color: #FAEBD7;} dt {color: #000066;font-weight: bold;} dd {font-style: italic;} - tr.header {background-color:#000066;color:#fff;} - tr.subheader {background-color:#E0E0E0;color:#000066;font-size: 95%;} - td.err {background-color: #f00;} + table.stats {border-collapse: collapse; border: 1px solid black; width: 100%;} + table.stats td { border: 1px solid gray;} + tr.subheader {background-color: #9999cc;color:#fff;font-size: 95%;} + tr.subheader a {color: #fff;} + td.err {background-color: #DEDEDE;} h2 { margin: 0; margin-top: 10px;} </style> </head> @@ -99,22 +100,21 @@ <?php $dbhandle = sqlite_open('check_phpdoc.sqlite'); -$where = ''; - -if ($restrict) { - $where = ' WHERE ' . $restrict . ' = 1'; -} - -$query = sqlite_query($dbhandle, 'SELECT * FROM reference' . $where); -$status = array(); -$result = sqlite_fetch_all($query, SQLITE_ASSOC); -foreach ($result as $res) { - $status[$res['extension']][$res['funcname']] = $res; -} echo '<h1>PHPDOC Check</h1>'; if (!$restrict) { + + $order = isset($_GET['order']) && $_GET['order'] == 'DESC' ? 'DESC' : 'ASC'; + $sort = isset($_GET['sort']) && in_array($_GET['sort'], array_keys($errors)) ? 'SUM(' . $_GET['sort'] . ')' : 'extension'; + + $sql = 'SELECT extension, COUNT(*) AS total, SUM(' . implode('), SUM(', array_keys($errors)) . ') FROM reference GROUP BY extension ORDER BY ' . $sort . ' ' . $order; + $result = sqlite_query($dbhandle, $sql); + $extensions = array(); + while ($row = sqlite_fetch_array($result, SQLITE_ASSOC)) { + $extensions[$row['extension']] = $row; + } + echo '<p> This script parses the <i>reference/</i> directory of the PHPDOC module and checks for common problems in the documentation. For now, supported tests are: @@ -125,58 +125,36 @@ echo ' </ul> </p>'; - $exts = ''; - $funcn = 0; - foreach ($status as $extension => $functions) { - $nb = count($functions); - if ($nb != 0) { - $funcn += $nb; - $exts .= '<a href="#' . $extension . '">' . $extension . '</a> '; - } + echo '<table class="stats">'; + echo '<tr class="subheader">'; + echo '<td>Extension</td>'; + $order = ($order == 'ASC') ? 'DESC' : 'ASC'; + foreach ($errors as $type => $info) { + echo "<td><a href=\"view_check_phpdoc.php?sort=$type&order=$order\">{$info['label']}</a></td>"; } - echo "The following $funcn functions from " . count($status) . " extensions lacks some information: $exts"; - echo '</p>'; - echo '<table width="100%">'; - $cols = count($errors) + 1; - foreach ($status as $extension => $functions) { - // Skip if no functions - if (count($functions) == 0) { - continue; - } - echo '<tr class="header" id="' . $extension . '"><td colspan="' . $cols . '" align="center">' . $extension . ' (' . count($functions) . ')</td></tr>'; - echo '<tr class="subheader"> - <td></td> - <td>Not documented</td> - <td>Old Style</td> - <td>Bad refsect1 order</td> - <td>No parameters</td> - <td>No return values</td> - <td>No examples</td> - <td>No errors</td> - <td>No see also</td> - <td>Role error</td> - </tr>'; - foreach ($functions as $function => $problems) { - echo "<tr class=\"h\"> - <td><a href=\"http://php.net/" . substr($function, 0, -4) . "\">$function</a></td>"; - echo "<td" . (isset($problems['undoc']) ? ' class="err">' : '>') . "</td>"; - echo "<td" . (isset($problems['oldstyle']) ? ' class="err">' : '>') . "</td>"; - echo "<td" . (isset($problems['badorder']) ? ' class="err">' : '>') . "</td>"; - echo "<td" . (isset($problems['noparameters']) ? ' class="err">' : '>') . "</td>"; - echo "<td" . (isset($problems['noreturnvalues']) ? ' class="err">' : '>') . "</td>"; - echo "<td" . (isset($problems['noexamples']) ? ' class="err">' : '>') . "</td>"; - echo "<td" . (isset($problems['noerrors']) ? ' class="err">' : '>') . "</td>"; - echo "<td" . (isset($problems['noseealso']) ? ' class="err">' : '>') . "</td>"; - echo "<td" . (isset($problems['roleerror']) ? ' class="err">' : '>') . "</td>"; - echo "</tr>"; + echo '</tr>'; + foreach ($extensions as $extension => $stats) { + echo "<tr class=\"h\">"; + echo "<td><a href=\"http://php.net/$extension\">$extension</a></td>"; + foreach ($errors as $type => $info) { + echo "<td title=\"{$info['label']}\"". ($stats['SUM(' . $type . ')'] ? ' class="err"><a href="view_check_phpdoc.php?restrict=' . $type . '#' . $extension . '">' . $stats['SUM(' . $type . ')'] . '</a>' : '> '). "</td>"; } + echo "</tr>"; } echo '</table>'; + } else { - $type = $restrict; + + $query = sqlite_query($dbhandle, 'SELECT * FROM reference WHERE ' . $restrict . ' = 1'); + $status = array(); + $result = sqlite_fetch_all($query, SQLITE_ASSOC); + foreach ($result as $res) { + $status[$res['extension']][$res['funcname']] = $res; + } + echo '<p> <dl>'; - echo "<dt>{$errors[$type]['label']} (<a href=\"{$_SERVER['PHP_SELF']}\">All</a>)</dt><dd>{$errors[$type]['description']}</dd>"; + echo "<dt>{$errors[$restrict]['label']} (<a href=\"{$_SERVER['PHP_SELF']}\">All</a>)</dt><dd>{$errors[$restrict]['description']}</dd>"; echo ' </dl> </p>'; echo '<p>'; @@ -190,18 +168,28 @@ echo "$funcn functions from " . count($status) . " extensions: $exts"; echo ' </p>'; - echo '<table width="100%">'; + echo '<table width="100%">'; foreach ($status as $extension => $functions) { - echo '<tr class="header" id="' . $extension . '"><td align="center">' . $extension . ' (' . count($functions) . ')</td></tr>'; + $i = 0; + echo '<tr class="subheader" id="' . $extension . '"><td colspan="4" align="center">' . $extension . ' (' . count($functions) . ')</td></tr><tr>'; + foreach ($functions as $function => $problems) { - if (!isset($problems[$type])) { + if (!isset($problems[$restrict])) { continue; } - echo "<tr> - <td><a href=\"http://php.net/" . substr($function, 0, -4) . "\">$function</a></td>"; - echo "</tr>"; + + if ($i % 4 == 0) { + echo '<tr>'; + } + $i++; + echo "<td><a href=\"http://php.net/" . substr($function, 0, -4) . "\">$function</a></td>"; + if ($i % 4 == 0) { + echo '</tr>'; + } } + + } echo '</table>'; }