Skip to content

Commit 7b8b1bf

Browse files
committed
New documentation generator.
1 parent 8e7623e commit 7b8b1bf

16 files changed

Lines changed: 892 additions & 5 deletions

docgen/gen.php

Lines changed: 69 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,8 @@ public function __construct($line)
201201

202202
}
203203

204-
class Class
204+
// Because we can't have a class called "Class", grrr...
205+
class PhaserClass
205206
{
206207
public $name; // Phaser.Sprite
207208
public $parameters = []; // an array containing the parameters
@@ -416,16 +417,77 @@ public function __construct($block)
416417

417418
}
418419

420+
class ScanFile
421+
{
422+
public $filename = '';
423+
public $js = '';
424+
425+
public $blocks;
426+
427+
public $consts = [];
428+
public $properties = [];
429+
public $methods = [];
430+
431+
public function __construct($file)
432+
{
433+
$this->filename = $file;
434+
$js = file($file);
435+
436+
$scanningForOpen = true;
437+
$scanningForClose = false;
419438

420-
$blocks = [];
439+
$openLine = 0;
440+
$closeLine = 0;
441+
$chunk = [];
442+
443+
for ($i = 0; $i < count($js); $i++)
444+
{
445+
$line = trim($js[$i]);
446+
447+
if ($scanningForOpen && $line === "/**")
448+
{
449+
$scanningForOpen = false;
450+
$scanningForClose = true;
451+
$chunk = [];
452+
$openLine = $i;
453+
}
454+
455+
if ($scanningForClose && $line === "*/")
456+
{
457+
$scanningForOpen = true;
458+
$scanningForClose = false;
459+
$closeLine = $i;
421460

422-
$consts = [];
423-
$properties = [];
424-
$methods = [];
461+
// The first element is always the opening /** so remove it
462+
array_shift($chunk);
463+
464+
$this->blocks[] = new Block($openLine, $closeLine, $js[$i + 1], $chunk);
465+
}
466+
else
467+
{
468+
$chunk[] = $line;
469+
}
470+
}
471+
}
472+
473+
public function total()
474+
{
475+
return count($this->blocks);
476+
}
477+
478+
}
479+
480+
481+
// $blocks = [];
482+
483+
// $consts = [];
484+
// $properties = [];
485+
// $methods = [];
425486

426487
// $file = "../src/gameobjects/Sprite.js";
427488
$file = "../src/loader/Cache.js";
428489

490+
/*
429491
$js = file($file);
430492
431493
$scanningForOpen = true;
@@ -463,8 +525,10 @@ public function __construct($block)
463525
$chunk[] = $line;
464526
}
465527
}
528+
*/
466529
467530
// That's the whole file scanned, how many blocks did we get out of it?
531+
468532
echo count($blocks) . " blocks found\n\n";
469533

470534
echo "\nConstants:\n\n";

docgen/json.php

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<?php
2+
require 'src/Block.php';
3+
require 'src/ClassDesc.php';
4+
require 'src/Constant.php';
5+
require 'src/Method.php';
6+
require 'src/Parameter.php';
7+
require 'src/Property.php';
8+
require 'src/ReturnType.php';
9+
require 'src/Processor.php';
10+
11+
// $data = new Processor("../src/gameobjects/Sprite.js");
12+
$data = new Processor("../src/loader/Cache.js");
13+
14+
header('Content-Type: application/json');
15+
16+
$raw = [];
17+
18+
$raw['consts'] = $data->getConstsArray();
19+
20+
echo json_encode($raw);
21+
22+
// echo $data->consts[0]->getJSON();
23+
24+
25+
?>

docgen/process.php

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
<?php
2+
require 'src/Block.php';
3+
require 'src/ClassDesc.php';
4+
require 'src/Constant.php';
5+
require 'src/Method.php';
6+
require 'src/Parameter.php';
7+
require 'src/Property.php';
8+
require 'src/ReturnType.php';
9+
require 'src/Processor.php';
10+
?>
11+
<!doctype html>
12+
<html>
13+
<head>
14+
<meta charset="UTF-8" />
15+
<title>Phaser Documentation Generator v0.1</title>
16+
<style type="text/css">
17+
body {
18+
font-family: Arial;
19+
font-size: 14px;
20+
background-color: #fff;
21+
color: #000;
22+
}
23+
24+
textarea {
25+
width: 100%;
26+
height: 1000px;
27+
}
28+
</style>
29+
</head>
30+
<body>
31+
32+
<pre spellcheck="false">
33+
<?php
34+
35+
// $data = new Processor("../src/gameobjects/Sprite.js");
36+
$data = new Processor("../src/loader/Cache.js");
37+
38+
echo $data->total() . " blocks found\n\n";
39+
40+
echo "\nConstants:\n\n";
41+
42+
for ($i = 0; $i < count($data->consts); $i++)
43+
{
44+
print_r($data->consts[$i]->getJSON());
45+
// $const = $data->consts[$i];
46+
// echo "\n\n";
47+
// echo $const->name;
48+
// echo "\n";
49+
// print_r($const->types);
50+
}
51+
52+
/*
53+
echo "\nMethods:\n\n";
54+
55+
for ($i = 0; $i < count($data->methods); $i++)
56+
{
57+
$method = $data->methods[$i];
58+
echo "\n\n";
59+
echo $method->name;
60+
echo "\n";
61+
print_r($method->help);
62+
print_r($method->parameters);
63+
print_r($method->returns);
64+
}
65+
66+
echo "\nProperties:\n\n";
67+
68+
for ($i = 0; $i < count($data->properties); $i++)
69+
{
70+
$property = $data->properties[$i];
71+
echo "\n\n";
72+
echo $property->name . "\n";
73+
// print_r($property->types);
74+
echo "Source code line " . $property->line . "\n";
75+
echo "Default: " . $property->default . "\n";
76+
echo "Help: " . "\n";
77+
print_r($property->help);
78+
echo "\n\n";
79+
}
80+
*/
81+
?>
82+
</pre>
83+
84+
</body>
85+
</html>

docgen/project/Phaser Doc Gen.dsk

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
[Files]
2+
File0=D:\wamp\www\phaser\docgen\src\ClassDesc.php
3+
IsActive0=0
4+
ZIndex3=2
5+
File1=D:\wamp\www\phaser\docgen\src\Processor.php
6+
IsActive1=0
7+
ZIndex2=3
8+
File2=D:\wamp\www\phaser\docgen\src\Block.php
9+
IsActive2=0
10+
ZIndex1=1
11+
File3=D:\wamp\www\phaser\docgen\process.php
12+
IsActive3=1
13+
ZIndex0=0
14+
Files=4
15+
16+
[breakpoints]
17+
bp_count=0
18+
19+
[parameters]
20+
value=LCw
21+
22+
[watches]
23+
count=0
24+

docgen/project/Phaser Doc Gen.ppd

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<?xml version="1.0" encoding="utf-8"?><profile count="1"><session_0><profile_lines subitemscount="0" has_subitems="1" total="0"/><profile_contexts count="0"/><profile_modlist count="1"/></session_0></profile>

docgen/project/Phaser Doc Gen.ppj

Lines changed: 128 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
1+
[Debugger]
2+
dbgsessions=1
3+
stopbeginning=1
4+
excset=
5+
errlevel=3 - All errors and warnings
6+
profwithdbg=0
7+
excign=
8+
breakexc=
9+
cp=System default encoding
10+
tunnel=
11+
readonlyed=0
12+
host=clienthost
13+
custom=0
14+
errset=
15+
sesstimeout=15
16+
blkout=
17+
Custom.Debug.Settings=0
18+
showmaperrors=1
19+
breakerr=
20+
21+
[PHPEdProject.Filters.Allow]
22+
\=
23+
24+
[Test.Suite]
25+
/=>
26+
27+
[PHPEdProject.Filters]
28+
\=
29+
30+
[Encoder]
31+
excl=0
32+
asptags=0
33+
stoponerr=0
34+
obfusclevel=0
35+
extinfo=0
36+
phpdoc=1
37+
licensing=0
38+
compatibilitylevel=1
39+
copyall=1
40+
suppresssucc=0
41+
headertype=0
42+
lineinfo=0
43+
shorttags=1
44+
destinationtype=0
45+
46+
[PHPEdProject.Encodings]
47+
\=UTF-8
48+
49+
[Wizard]
50+
srunmode=1
51+
sprojectroot=D:\wamp\www\phaser\docgen
52+
sremotewebroot=d:\wamp\www\phaser\docgen\
53+
swebrooturl=http://localhost/
54+
55+
[PHPEdProject.JSLibraries]
56+
Count=0
57+
58+
[Testing]
59+
TestingCustomLoader=
60+
TestingCustomLoaderExtraArg=
61+
TestingConfig=
62+
FindTestMode=0
63+
TestingRoot=
64+
EnableTesting=0
65+
66+
[PHPEdProject]
67+
HideDirs=CVS;.svn
68+
CvsRoot=
69+
MappingLocal0=D:\wamp\www\phaser\docgen
70+
ParserProp_CSS_SubLang=1
71+
UrlMappingCount=0
72+
CvsModule=
73+
EncoderEnabled=0
74+
DefaultEncodingCount=1
75+
CvsPassw=KQ66584HSbX6s4CB8Z9rjbXL+NlON3xlm+MDMZPPfj0y+4yJwWdnFQ0TBeEI//zt0iuqOXGXnsW/QzORoi/snQ==
76+
DriverID=
77+
IncPath_count=0
78+
UsedPHPFrameworkPath=
79+
RelativeRootDir=..\..\docgen
80+
MappingMainIdx=0
81+
ParserProp_CSS_ParsePHP=0
82+
MappingURL0=
83+
ParserProp_PHP_AspTags=0
84+
MappingPublishingRoot=
85+
MappingRemote0=
86+
CvsHost=
87+
RunMode=1
88+
CvsMethod=pserver
89+
CvsUser=
90+
URL=
91+
CvsCVSROOT=:pserver:@
92+
DefaultFile=
93+
ChangeTime=0
94+
RemoteCliAccount=
95+
ParserProp_JS_ParsePHP=0
96+
ParserProp_Override=1
97+
GUID={CF5D4786-6D94-4B0B-A2E6-44BE31187F34}
98+
RemoteCliPhp=
99+
CvsUseUtf8=0
100+
MappingCount=1
101+
ParserProp_AllowSingleAsteriskXDoc=1
102+
UsedPHPFrameworkId=
103+
PublishingAllowFilterCount=1
104+
MappingRemoteDir=
105+
DontPublishDirs=CVS;.svn
106+
MappingPublishing0=
107+
SourceControl=0
108+
ScriptRunTarget=1
109+
ParserProp_HTML_SubLang=2
110+
UsedPHPFrameworkChecked=0
111+
ParserPropPHPShortTags=0
112+
ParserProp_PHP_SubLang=3
113+
HideFiles=.gitignore;.cvsignore
114+
CustomPropCount=0
115+
PublishingFilterCount=1
116+
117+
[Publishing]
118+
publmap.main0=0
119+
publmap.publishingdriverid0=
120+
DebuggerPublishingIdx=0
121+
publmap.publishing0.0=
122+
count=1
123+
DfltPublishingIdx=0
124+
publmap.local0.0=D:\wamp\www\phaser\docgen
125+
publmap.count0=1
126+
publmap.prjdriverid0=
127+
caption0=
128+

docgen/project/Phaser Doc Gen.ppw

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
[PHPEdWorkspace]
2+
Project0=D:\wamp\www\phaser\docgen\project\Phaser Doc Gen.ppj
3+
ProjectCount=1
4+
ActiveProject=D:\wamp\www\phaser\docgen\project\Phaser Doc Gen.ppj
5+
[Expanded]
6+
Phaser Doc Gen=1
7+
Phaser Doc Gen:Phaser Doc Gen=1
8+
Phaser Doc Gen:Phaser Doc Gen:src=1

docgen/project/Phaser Doc Gen.ppx

Lines changed: 1 addition & 0 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)