Example #1
0
function readAndWriteAllDocs($index_array,$output_dir) {
	// this will blow away all old docs and make a new set each time. don't be precious.
	foreach ($index_array as $index => $item_list) {
		if ($index == 'home') {
			file_put_contents($output_dir . '/index.html',buildDocOutput(parseComments($item_list[0]),$index_array,true));
		} else {
			$tmp_dirname = $output_dir . '/' . strtolower(str_replace(' ','',$index));
			if (is_dir($tmp_dirname)) {
				rrmdir($tmp_dirname);
			}
			if (mkdir($tmp_dirname)) {
				if (count($item_list)) {
					foreach ($item_list as $key => $item) {
						$replace_these = array(' ','(',')','.php','_');
						if (is_dir($item)) {
							if ($tmp_dir = opendir($item)) {
								while (false !== ($file = readdir($tmp_dir))) {
									if (substr($file,0,1) != "." && !is_dir($file)) {
										file_put_contents($tmp_dirname . '/' . strtolower(str_replace($replace_these,'',basename($file,'.php'))) . '.html',buildDocOutput(parseComments($item . '/' . $file),$index_array));
									}
								}
								closedir($tmp_dir);
							}
						} else {
							file_put_contents($tmp_dirname . '/' . strtolower(str_replace($replace_these,'',$key)) . '.html',buildDocOutput(parseComments($item),$index_array));
						}
					}
				}
			} else {
				return false;
			}
		}
	}
	return true;
}
Example #2
0
function parseComments($file, $placeholder, $class = '')
{
    $contents = file_get_contents($file);
    if (!$class) {
        list($class) = explode('.', pathinfo($file, PATHINFO_FILENAME));
    }
    $start = strpos($contents, "\nclass {$class} ");
    $contents = substr($contents, $start, strpos($contents, "\n}", $start));
    preg_match_all("#/\\*\\*([\\s\\S]+?)\\*/\\s+(?:static\\s+public\\s+function\\s*&|static\\s+public\\s+function|public\\s+static\\s+function\\s*&|public\\s+static\\s+function|public\\s+function|public\\s+function\\s*&|const)\\s*([\\w_]+?)(?:\\s|\\(|=)#", $contents, $m, PREG_SET_ORDER);
    $ret = array();
    foreach ($m as $desc) {
        $func = $desc[2];
        $info = $desc[1];
        if (preg_match("#\n\\s*\\* @import:\\s+([\\w.]+)\\s*\$#", $info, $o)) {
            $info = str_replace(trim($o[0]), "", $info);
            $information = preg_replace(array("#(^|\n)\\s*\\* @#", "#\n\\s*\\*#"), array("\$1{$placeholder}| @", "\n{$placeholder}|"), $info);
            $importfile = str_replace(".class.php", "/{$o[1]}", $file);
            $ret[$func]['sons'] = parseComments($importfile, $placeholder . '    ');
        } elseif (preg_match("#\n\\s*\\* @new:\\s+(\\w+)\\s*\$#", $info, $n)) {
            $info = str_replace(trim($n[0]), "", $info);
            $information = preg_replace(array("#(^|\n)\\s*\\* @#", "#\n\\s*\\*#"), array("\$1{$placeholder}| @", "\n{$placeholder}|"), $info);
            $ret[$func]['sons'] = parseComments($file, $placeholder . '    ', $n[1]);
        } else {
            $information = preg_replace(array("#(^|\n)\\s*\\* @#", "#\n\\s*\\*#"), array("\$1{$placeholder}| @", "\n{$placeholder}|"), $info);
        }
        $information = preg_replace('/fg:(\\w+)(?=,|\\n)/e', "\\biophp\\utils::color('\$1', '\$1')", $information);
        $information = preg_replace('/bg:(\\w+)(?=,|\\n)/e', "\\biophp\\utils::color('\$1', '', '\$1')", $information);
        $ret[$func]['info'] = rtrim($information) . "\n";
    }
    return $ret;
}
Example #3
0
    } else {
        // file not found
        return false;
    }
}
// create an array to house all data for output to mustache, other initial variables
$docs_data = array();
$current_directory = dirname(__FILE__);
include_once $current_directory . '/../../framework/cashmusic.php';
$docs_data['page_content'] = '';
$all_requests = '';
$all_requests_menu = '<li>Request types:</li>';
// ALL THE PLANTS!!!
$all_plants = array('system' => array('classname' => 'SystemPlant', 'filename' => $current_directory . '/../../framework/classes/plants/SystemPlant.php'), 'asset' => array('classname' => 'AssetPlant', 'filename' => $current_directory . '/../../framework/classes/plants/AssetPlant.php'), 'people' => array('classname' => 'PeoplePlant', 'filename' => $current_directory . '/../../framework/classes/plants/PeoplePlant.php'), 'commerce' => array('classname' => 'CommercePlant', 'filename' => $current_directory . '/../../framework/classes/plants/CommercePlant.php'), 'calendar' => array('classname' => 'CalendarPlant', 'filename' => $current_directory . '/../../framework/classes/plants/CalendarPlant.php'), 'element' => array('classname' => 'ElementPlant', 'filename' => $current_directory . '/../../framework/classes/plants/ElementPlant.php'));
foreach ($all_plants as $type => $plant) {
    $comments = parseComments($plant['filename']);
    include_once $plant['filename'];
    $plant_name = $plant['classname'];
    $plant = new $plant_name('direct', false);
    $routing_table = $plant->getRoutingTable();
    $actions = array();
    foreach ($routing_table as $action => $details) {
        // reflect the target method for each route, returning an array of params
        $method = new ReflectionMethod($plant, $details[0]);
        $params = $method->getParameters();
        $final_parameters = array();
        foreach ($params as $param) {
            // $param is an instance of ReflectionParameter
            $param_name = $param->getName();
            $param_optional = false;
            $param_default = null;