Skip to content

Commit 40efc32

Browse files
committed
Updated index browser and viewer to handle any depth nesting.
1 parent e5eea56 commit 40efc32

2 files changed

Lines changed: 32 additions & 21 deletions

File tree

docgen/index.php

Lines changed: 30 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@
2424

2525
function dirToArray($dir) {
2626

27-
// $ignore = array('.', '..', 'pixi');
27+
global $src;
28+
2829
$ignore = array('.', '..');
2930
$fileIgnore = array('p2.js');
3031
$result = array();
@@ -33,17 +34,32 @@ function dirToArray($dir) {
3334

3435
foreach ($dirs as $key => $value)
3536
{
36-
if (is_dir($dir . DIRECTORY_SEPARATOR . $value))
37-
{
38-
$result[$value] = dirToArray($dir . DIRECTORY_SEPARATOR . $value);
37+
$path = realpath($dir . DIRECTORY_SEPARATOR . $value);
38+
39+
if (is_dir($path))
40+
{
41+
$result[$value] = dirToArray($path);
3942
}
4043
else
4144
{
4245
if (substr($value, -3) == '.js')
4346
{
4447
if (!in_array($value, $fileIgnore))
4548
{
46-
$result[] = substr($value, 0, -3);
49+
$index = str_replace($src, "", $path);
50+
$index = substr($index, 1);
51+
52+
// $slash = strrpos($index, DIRECTORY_SEPARATOR);
53+
54+
// if ($slash > 0)
55+
// {
56+
// // $index = substr($index, 0, $slash);
57+
// }
58+
59+
$result[substr($value, 0, -3)] = $index;
60+
61+
// $result[$index] = substr($value, 0, -3);
62+
// $result[] = [ substr($value, 0, -3), $index ];
4763
}
4864
}
4965
}
@@ -52,7 +68,7 @@ function dirToArray($dir) {
5268
return $result;
5369
}
5470

55-
function displaySection($title, $files, $parent = "") {
71+
function displaySection($title, $files) {
5672

5773
if ($title === "")
5874
{
@@ -65,35 +81,30 @@ function displaySection($title, $files, $parent = "") {
6581

6682
echo "<ul>";
6783

68-
foreach ($files as $key => $file)
84+
foreach ($files as $name => $file)
6985
{
7086
if (is_array($file))
7187
{
72-
displaySection($key, $file, $title);
88+
displaySection($name, $file);
7389
}
7490
else
7591
{
76-
$src = $title . "/" . $file;
77-
78-
if ($parent !== "")
79-
{
80-
$src = $parent . "/" . $src;
81-
}
82-
83-
echo "<li><a href=\"view.php?src=$src\">$file</a></li>";
92+
echo "<li><a href=\"view.php?src=$file\">$name</a></li>";
8493
}
8594
}
8695

8796
echo "</ul>";
8897

8998
}
9099

91-
$path = realpath('../src');
92-
$files = dirToArray($path);
100+
$src = realpath('../src');
101+
102+
$files = dirToArray($src);
93103

94-
displaySection("", $files, "");
104+
displaySection("", $files);
95105

96106
// echo "<pre>";
107+
// var_dump($src);
97108
// print_r($files);
98109
// echo "</pre>";
99110

docgen/view.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22

3-
$src = "loader/Cache";
3+
$src = "loader/Cache.js";
44
$method = null;
55
$property = null;
66

@@ -28,7 +28,7 @@
2828
require 'src/ReturnType.php';
2929
require 'src/Processor.php';
3030

31-
$data = new Processor("../src/" . $src . ".js");
31+
$data = new Processor("../src/$src");
3232
?>
3333
<!doctype html>
3434
<html>

0 commit comments

Comments
 (0)