From: Geoffrey T. D. <da...@us...> - 2001-12-14 20:15:07
|
Update of /cvsroot/phpwiki/phpwiki/lib In directory usw-pr-cvs1:/tmp/cvs-serv9036/lib Modified Files: diff.php difflib.php Log Message: Added a few comments. Index: diff.php =================================================================== RCS file: /cvsroot/phpwiki/phpwiki/lib/diff.php,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -r1.18 -r1.19 *** diff.php 2001/12/13 18:29:24 1.18 --- diff.php 2001/12/14 20:15:02 1.19 *************** *** 11,14 **** --- 11,23 ---- require_once('lib/difflib.php'); + /** + * HTML unified diff formatter. + * + * This class formats a diff into a CSS-based + * unified diff format. + * + * Within groups of changed lines, diffs are highlit + * at the character-diff level. + */ class HtmlUnifiedDiffFormatter extends UnifiedDiffFormatter { *************** *** 114,117 **** --- 123,136 ---- } + /** + * HTML table-based unified diff formatter. + * + * This class formats a diff into a table-based + * unified diff format. (Similar to what was produced + * by previous versions of PhpWiki.) + * + * Within groups of changed lines, diffs are highlit + * at the character-diff level. + */ class TableUnifiedDiffFormatter extends HtmlUnifiedDiffFormatter { Index: difflib.php =================================================================== RCS file: /cvsroot/phpwiki/phpwiki/lib/difflib.php,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -r1.1 -r1.2 *** difflib.php 2001/12/13 05:10:04 1.1 --- difflib.php 2001/12/14 20:15:02 1.2 *************** *** 19,26 **** var $final; - function _DiffOp () { - trigger_error("pure virtual", E_USER_ERROR); - } - function reverse() { trigger_error("pure virtual", E_USER_ERROR); --- 19,22 ---- *************** *** 97,100 **** --- 93,99 ---- * Finally, some ideas (subdivision by NCHUNKS > 2, and some optimizations) * are my own. + * + * @author Geoffrey T. Dairiki + * @access private */ class _DiffEngine *************** *** 476,480 **** /** ! * Class representing a diff between two files. */ class Diff --- 475,479 ---- /** ! * Class representing a 'diff' between two sequences of strings. */ class Diff *************** *** 483,487 **** /** ! * Compute diff between lists of strings. */ function Diff($from_lines, $to_lines) { --- 482,491 ---- /** ! * Constructor. ! * Computes diff between sequences of strings. ! * ! * @param $from_lines array An array of strings. ! * (Typically these are lines from a file.) ! * @param $to_lines array An array of strings. */ function Diff($from_lines, $to_lines) { *************** *** 498,504 **** * $diff = new Diff($lines1, $lines2); * $rev = $diff->reverse(); ! * ! * // reconstruct $lines1 from $lines2: ! * $out = $rev->apply($lines2); */ function reverse () { --- 502,507 ---- * $diff = new Diff($lines1, $lines2); * $rev = $diff->reverse(); ! * @return object A Diff object representing the inverse of the ! * original diff. */ function reverse () { *************** *** 512,516 **** /** ! * Return true if two files were equal. */ function isEmpty () { --- 515,521 ---- /** ! * Check for empty diff. ! * ! * @return bool True iff two sequences were identical. */ function isEmpty () { *************** *** 526,529 **** --- 531,536 ---- * * This is mostly for diagnostic purposed. + * + * @return int The length of the LCS. */ function lcs () { *************** *** 538,541 **** --- 545,553 ---- /** * Get the original set of lines. + * + * This reconstructs the $from_lines parameter passed to the + * constructor. + * + * @return array The original sequence of strings. */ function orig() { *************** *** 551,554 **** --- 563,571 ---- /** * Get the final set of lines. + * + * This reconstructs the $to_lines parameter passed to the + * constructor. + * + * @return array The sequence of strings. */ function final() { *************** *** 592,600 **** } class DiffFormatter { var $leading_context_lines = 0; var $trailing_context_lines = 0; ! function format($diff) { --- 609,643 ---- } + /** + * A class to format Diffs + * + * This class formats the diff in classic diff format. + * It is intended that this class be customized via inheritance, + * to obtain fancier outputs. + */ class DiffFormatter { + /** + * Number of leading context "lines" to preserve. + * + * This should be left at zero for this class, but subclasses + * may want to set this to other values. + */ var $leading_context_lines = 0; + + /** + * Number of trailing context "lines" to preserve. + * + * This should be left at zero for this class, but subclasses + * may want to set this to other values. + */ var $trailing_context_lines = 0; ! ! /** ! * Format a diff. ! * ! * @param $diff object A Diff object. ! * @return string The formatted output. ! */ function format($diff) { *************** *** 674,678 **** $this->_end_block(); } ! function _start_diff() { } --- 717,721 ---- $this->_end_block(); } ! function _start_diff() { } *************** *** 720,723 **** --- 763,771 ---- } + /** + * "Unified" diff formatter. + * + * This class formats the diff in classic "unified diff" format. + */ class UnifiedDiffFormatter extends DiffFormatter { |