function _drush_devel_print_function

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

Print the specified function, including any doxygen-style comments that come before it.

1 call to _drush_devel_print_function()
drush_devel_fn_view in drush/devel.drush8.inc
Command handler. Show source code of specified function or method.

File

drush/devel.drush8.inc, line 223

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));
    }
}