}
function is_constant(s) {
- return s.length > 1 && s.toUpperCase(s) === s;
+ s = s.replace(/v\d+(_\d+)?$/, "");
+ if (s.length < 2) {
+ return false;
+ }
+ return s.toUpperCase(s) === s;
}
function is_variable(s) {
case "RecursiveArrayIterator":
case "SplObserver":
case "SplSubject":
+ case "SplObjectStorage":
return "<code>";
// keywords
function blink(c) {
var $c = $(c);
- $c.fadeOut("slow").queue(function(next) {
+ $c.fadeOut("fast").queue(function(next) {
this.style.color = "red";
next();
- }).fadeIn("fast").fadeOut("fast").queue(function(next) {
+ }).fadeIn("fast").fadeOut("slow").queue(function(next) {
this.style.color = "";
next();
}).fadeIn("slow");
return $ld;
}
-function ns($file) {
+function ns($path) {
+ $ns = "";
+ $parts = explode("/", $path);
+ $upper = ctype_upper($path[0]);
+ for ($i = 0; $i < count($parts); ++$i) {
+ if (!strlen($parts[$i]) || $parts[$i] === ".") {
+ continue;
+ }
+ if (strlen($ns)) {
+ if ($upper && !ctype_upper($parts[$i][0])) {
+ $ns .= "::";
+ } else {
+ $ns .= "\\";
+ }
+ }
+ $ns .= $parts[$i];
+ $upper = ctype_upper($parts[$i][0]);
+ }
+ return $ns;
return str_replace("/", "\\", str_replace("//", "/", trim($file, "/.")));
}
if (!isset($pi["extension"]) || $pi["extension"] != "md") {
continue;
}
- if (!is_dir("$dir/".$pi["filename"])) {
+ /* ignore files where an accompanying directory exists */
+ if (is_dir("$dir/".$pi["filename"])) {
continue;
}
} else {
- /* ignore directories where an companying file exists */
- if (is_file("$path.md")) {
+ /* ignore directories where no accompanying file exists */
+ if (!is_file("$path.md")) {
continue;
}
}
return;
}
if (!ctype_upper($pi["filename"][0])) {
- return;
- }
- $dir = $pi["dirname"] . "/" . $pi["filename"];
- if (is_dir($dir)) {
- printf("<h2>Methods:</h2>\n");
- printf("<ul>\n");
- foreach (scandir($dir) as $file) {
- if (!is_file("$dir/$file") || ctype_upper($file{0})) {
- continue;
+ // namespaced functions
+ $dir = $pi["dirname"] . "/" . $pi["filename"];
+ if (is_dir($dir)) {
+ printf("<h2>Functions:</h2>\n");
+ printf("<ul>\n");
+ foreach (scandir($dir) as $file) {
+ if ($file{0} === "." || !is_file("$dir/$file") || ctype_upper($file{0})) {
+ continue;
+ }
+ printf("<li><h3><a href=\"/%s\">%s</a></h3><p>%s</p><p>%s</p></li>\n",
+ urlpath($dir, $file),
+ basename($file, ".md"),
+ @end(head("$dir/$file", 3)),
+ join(" ", cut(head("$dir/$file"), ["f"=>"1-"]))
+ );
}
- printf("<li><h3><a href=\"/%s\">%s</a></h3><p>%s</p><p>%s</p></li>\n",
- urlpath($dir, $file),
- basename($file, ".md"),
- @end(head("$dir/$file", 3)),
- join(" ", cut(head("$dir/$file"), ["f"=>"1-"]))
- );
+ printf("</ul>\n");
+ }
+ } else {
+ // methods
+ $dir = $pi["dirname"] . "/" . $pi["filename"];
+ if (is_dir($dir)) {
+ printf("<h2>Methods:</h2>\n");
+ printf("<ul>\n");
+ foreach (scandir($dir) as $file) {
+ if ($file{0} === "." || !is_file("$dir/$file") || ctype_upper($file{0})) {
+ continue;
+ }
+ printf("<li><h3><a href=\"/%s\">%s</a></h3><p>%s</p><p>%s</p></li>\n",
+ urlpath($dir, $file),
+ basename($file, ".md"),
+ @end(head("$dir/$file", 3)),
+ join(" ", cut(head("$dir/$file"), ["f"=>"1-"]))
+ );
+ }
+ printf("</ul>\n");
}
- printf("</ul>\n");
}
}
case "md":
$r = fopen($file, "r");
$md = MarkdownDocument::createFromStream($r);
- $md->compile(MarkdownDocument::AUTOLINK);
+ $md->compile(MarkdownDocument::AUTOLINK|MarkdownDocument::TOC);
print str_replace("<br/>","<br />",$md->getHtml());
fclose($r);
ml($file);