function doc_test($ns, $file, $debug)
{
    // the testing of a single file. this is where the actual testing goes.
    try {
        $ret = true;
        $data = dojo_get_contents($ns, $file);
        // test other things. like we're expecting at the _very_ least a $data['#provides'] key?
        if (empty($data['#provides'])) {
            if ($debug) {
                print "Warning: no provide() determined. [" . $ns . "/" . $file . "]\n";
            }
            $ret = false;
        } else {
            if (count($data['#provides']) > 1) {
                if ($debug) {
                    print "Warning: Multiple provides() found?\n";
                    $ret = false;
                }
            }
        }
        if (count($data) == 0) {
            if ($debug) {
                print "Error: No data found. [" . $ns . "/" . $file . "]";
            }
            $ret = false;
        } else {
        }
        return $ret;
    } catch (Exception $e) {
        print "Error: Exception trapped processing [" . $ns . "/" . $file . "]\nException:\n";
        print $e;
        return false;
    }
}
示例#2
0
$nodes = new Freezer('cache', 'nodes');
$resources = new Freezer('cache', 'resources');
print "=== PARSING FILES ===\n";
flush();
foreach ($files as $set) {
    list($namespace, $file) = $set;
    if (!$namespaces[$namespace]) {
        $namespaces[$namespace] = true;
    }
    $ctime = dojo_get_file_time($namespace, $file);
    if ($ctime == $resources->open($namespace . '%' . $file, null)) {
        continue;
    }
    printf("%-100s %6s KB\n", $namespace . '/' . $file, number_format(memory_get_usage() / 1024));
    flush();
    $contents = dojo_get_contents($namespace, $file);
    $provides = $contents['#provides'];
    unset($contents['#provides']);
    $resource = $contents['#resource'];
    unset($contents['#resource']);
    $requires = $contents['#requires'];
    unset($contents['#requires']);
    foreach ($contents as $var => $content) {
        foreach ($content as $key_key => $key_value) {
            $key_type = 'undefined';
            if (is_numeric($key_value)) {
                $key_type = 'numeric';
            } elseif (is_array($key_value)) {
                $key_type = 'array';
            } elseif (is_bool($key_value)) {
                $key_type = 'bool';
<?php

ini_set("ERROR_REPORTING", 0);
include_once 'lib/parser2/dojo2.inc';
$allfiles = @dojo_get_files();
if ($argc || !empty($_GET['f'])) {
    $argfile = empty($_GET['f']) ? $argv[1] : $_GET['f'];
    $parts = explode("/", $argfile);
    $ns = array_shift($parts);
    $file = implode("/", $parts);
    try {
        $data = @dojo_get_contents($ns, $file);
    } catch (Exception $e) {
        $data = array("success" => False, "error" => $e);
    }
    if (!empty($_GET['f'])) {
        header("Content-type: application/json");
    }
    print json_encode($data);
}
示例#4
0
function dojo_get_contents_cache($namespace, $file, $forceNew = false)
{
    // summary: a shim to dojo_get_contents, providing filemtime checking/caching
    // 		from parsing: XML takes ~ 80000ms on my MacBook Pro, from cache:
    // 		7000ms ... pass true as third param to force cache reloading.
    // if the file hasn't been change since the last time, skip parsing it
    $mtime = dojo_get_file_time($namespace, $file);
    $cfile = "./cache/" . md5($namespace . $file) . "." . $mtime;
    if (!$forceNew && file_exists($cfile)) {
        // read it from the cache:
        $cache = file_get_contents($cfile);
        $data = unserialize($cache);
    } else {
        // parse the file, and save the cached results:
        $data = @dojo_get_contents($namespace, $file);
        $cache = serialize($data);
        $fp = fopen($cfile, "w+");
        fputs($fp, $cache);
        fclose($fp);
    }
    return $data;
}
示例#5
0
            } else {
                $tree .= "<li><a href=\"?ns=" . $ns . "&amp;file=" . $file . "&amp;showall=" . $showall . "\">" . $ns . "/" . $file . "</a></li>";
            }
        } else {
            $testfiles[] = $ns . "/" . $file;
        }
    }
    $tree .= "</ul>";
    $trees[$ns] = $tree;
}
unset($files);
if (!empty($_REQUEST['ns'])) {
    $ns = $_REQUEST['ns'];
    $ifile = $_REQUEST['file'];
    if ($ifile) {
        $apiData = dojo_get_contents($ns, $ifile);
        $print .= "<h2>" . $ns . "/" . $ifile . "</h2><ul>";
        foreach ($apiData as $key => $val) {
            switch ($key) {
                case "#resource":
                    break;
                case "#requires":
                    $print .= "<li><h3>Requires:</h3><ul>";
                    foreach ($val as $resource) {
                        $print .= "<li>{$resource[1]} in {$resource[0]}";
                        if ($resource[2]) {
                            $print .= " in project {$resource[2]}";
                        }
                        $print .= "</li>";
                    }
                    $print .= "</ul></li>";