Skip to content

Commit 908e9d6

Browse files
committed
Lots of docgen updates to get the doc browser and json export ready.
1 parent 57295d7 commit 908e9d6

11 files changed

Lines changed: 151 additions & 13 deletions

File tree

docgen/index.php

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
<!doctype html>
2+
<html>
3+
<head>
4+
<meta charset="UTF-8" />
5+
<title>Phaser Documentation Viewer</title>
6+
<style type="text/css">
7+
body {
8+
font-family: Arial;
9+
font-size: 14px;
10+
background-color: #fff;
11+
color: #000;
12+
}
13+
14+
textarea {
15+
width: 100%;
16+
height: 1000px;
17+
}
18+
</style>
19+
</head>
20+
<body>
21+
22+
<?php
23+
// http://uk1.php.net/manual/en/class.splfileinfo.php
24+
25+
function dirToArray($dir) {
26+
27+
$ignore = array('.', '..', 'pixi');
28+
$fileIgnore = array('p2.js');
29+
$result = array();
30+
$root = scandir($dir);
31+
$dirs = array_diff($root, $ignore);
32+
33+
foreach ($dirs as $key => $value)
34+
{
35+
if (is_dir($dir . DIRECTORY_SEPARATOR . $value))
36+
{
37+
$result[$value] = dirToArray($dir . DIRECTORY_SEPARATOR . $value);
38+
}
39+
else
40+
{
41+
if (substr($value, -3) == '.js')
42+
{
43+
if (!in_array($value, $fileIgnore))
44+
{
45+
$result[] = substr($value, 0, -3);
46+
}
47+
}
48+
}
49+
}
50+
51+
return $result;
52+
}
53+
54+
function displaySection($title, $files) {
55+
56+
echo "<h2>$title</h2>";
57+
echo "<ul>";
58+
59+
foreach ($files as $key => $file)
60+
{
61+
if (is_array($file))
62+
{
63+
displaySection($key, $file);
64+
}
65+
else
66+
{
67+
echo "<li><a href=\"view.php?src=$title/$file\">$file</a></li>";
68+
}
69+
}
70+
71+
echo "</ul>";
72+
73+
}
74+
75+
$path = realpath('../src');
76+
$files = dirToArray($path);
77+
78+
displaySection("Phaser v2.1.1", $files);
79+
80+
// echo "<pre>";
81+
// print_r($files);
82+
// echo "</pre>";
83+
84+
?>
85+
86+
</body>
87+
</html>

docgen/src/ClassDesc.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,5 +42,23 @@ public function __construct($block)
4242

4343
}
4444

45+
public function getArray()
46+
{
47+
return array(
48+
'name' => $this->name,
49+
'parameters' => $this->parameters,
50+
'help' => implode('\n', $this->help),
51+
'extends' => $this->extends,
52+
'static' => $this->isStatic,
53+
'constructor' => $this->hasConstructor
54+
);
55+
56+
}
57+
58+
public function getJSON()
59+
{
60+
return json_encode($this->getArray());
61+
}
62+
4563
}
4664
?>

docgen/src/Constant.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public function __construct($block)
3838

3939
public function getArray()
4040
{
41-
$a = array(
41+
return array(
4242
'name' => $this->name,
4343
'type' => $this->types[0],
4444
'help' => implode('\n', $this->help),

docgen/src/Method.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,18 +75,17 @@ public function getVisibility()
7575

7676
public function getArray()
7777
{
78-
$a = array(
78+
return array(
7979
'title' => $this->title,
8080
'returns' => $this->returns,
8181
'help' => implode('\n', $this->help),
8282
'line' => $this->line,
8383
'public' => $this->isPublic,
8484
'protected' => $this->isProtected,
8585
'private' => $this->isPrivate,
86+
'parameters' => $this->parameters
8687
);
8788

88-
return $a;
89-
9089
}
9190

9291
public function getJSON()

docgen/src/Processor.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,8 @@ private function scanFile() {
7373
{
7474
if ($this->blocks[$i]->isConst)
7575
{
76-
$this->consts[] = new Constant($this->blocks[$i]);
76+
$tempConst = new Constant($this->blocks[$i]);
77+
$this->consts[$tempConst->name] = $tempConst;
7778
}
7879
else if ($this->blocks[$i]->isMethod)
7980
{
@@ -88,7 +89,9 @@ private function scanFile() {
8889
}
8990

9091
// Alphabetically sort the arrays based on the key
92+
ksort($this->consts);
9193
ksort($this->methods);
94+
ksort($this->properties);
9295

9396
}
9497

docgen/src/Property.php

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,5 +55,27 @@ public function __construct($block)
5555

5656
}
5757

58+
public function getArray()
59+
{
60+
return array(
61+
'name' => $this->name,
62+
'type' => $this->types,
63+
'help' => implode('\n', $this->help),
64+
'inlineHelp' => $this->inlineHelp,
65+
'line' => $this->line,
66+
'default' => $this->default,
67+
'public' => $this->isPublic,
68+
'protected' => $this->isProtected,
69+
'private' => $this->isPrivate,
70+
'readOnly' => $this->isReadOnly
71+
);
72+
73+
}
74+
75+
public function getJSON()
76+
{
77+
return json_encode($this->getArray());
78+
}
79+
5880
}
5981
?>

docgen/view.php

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
<html>
3535
<head>
3636
<meta charset="UTF-8" />
37-
<title>Phaser Documentation Viewer: <?php echo $srcfile ?></title>
37+
<title>Phaser Documentation Viewer: <?php echo $src ?></title>
3838
<style type="text/css">
3939
body {
4040
font-family: Arial;
@@ -54,21 +54,31 @@
5454
<h1><?php echo $src ?></h1>
5555

5656
<?php
57+
// echo "<pre>";
58+
// print_r($data->methods[$method]->getArray());
59+
// echo "</pre>";
60+
5761
if ($method)
5862
{
5963
echo "<pre>";
6064
print_r($data->methods[$method]->getArray());
6165
echo "</pre>";
6266
}
67+
68+
if ($property)
69+
{
70+
echo "<pre>";
71+
print_r($data->properties[$property]->getArray());
72+
echo "</pre>";
73+
}
6374
?>
6475

6576
<h2>Constants</h2>
6677

6778
<ul>
6879
<?php
69-
for ($i = 0; $i < count($data->consts); $i++)
80+
foreach ($data->consts as $constName => $const)
7081
{
71-
$const = $data->consts[$i];
7282
echo "<li>{$const->name}</li>";
7383
}
7484
?>
@@ -89,11 +99,10 @@
8999

90100
<ul>
91101
<?php
92-
// for ($i = 0; $i < count($data->properties); $i++)
93-
// {
94-
// $property = $data->properties[$i];
95-
// echo "<li><a href=\"view.php?src=$src&amp;property={$property->name}\">{$property->name}</a></li>";
96-
// }
102+
foreach ($data->properties as $propertyName => $property)
103+
{
104+
echo "<li><a href=\"view.php?src=$src&amp;property={$property->name}\">{$property->name}</a></li>";
105+
}
97106
?>
98107
</ul>
99108

File renamed without changes.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)