function _drush_devel_print_function

Same name in other branches
  1. 6.x-1.x devel.drush.inc \_drush_devel_print_function()
  2. 8.x-1.x drush/devel.drush8.inc \_drush_devel_print_function()

Prints a function including any Doxygen-style comments preceding it.

1 call to _drush_devel_print_function()
drush_devel_fn_view in ./devel.drush.inc
A command handler for showing source code of a function or method.

File

./devel.drush.inc, line 181

Code

function _drush_devel_print_function($file, $start_line, $end_line) {
    $line_num = 0;
    $doxygen = NULL;
    $fp = fopen($file, 'r');
    while (!feof($fp) && $line_num < $start_line - 1) {
        $line = fgets($fp);
        ++$line_num;
        if (substr($line, 0, 3) == '/**') {
            $doxygen = $line;
        }
        elseif (isset($doxygen)) {
            $doxygen .= $line;
            if ($line_num + 1 == $start_line) {
                drush_print(rtrim($doxygen));
            }
            if (strstr($line, '*/') !== FALSE) {
                $doxygen = NULL;
            }
        }
    }
    while (!feof($fp) && $line_num < $end_line) {
        $line = fgets($fp);
        ++$line_num;
        drush_print(rtrim($line));
    }
}