Skip to content

Commit

Permalink
New documentation generator.
Browse files Browse the repository at this point in the history
  • Loading branch information
photonstorm committed Jul 9, 2014
1 parent 8e7623e commit 7b8b1bf
Show file tree
Hide file tree
Showing 16 changed files with 892 additions and 5 deletions.
74 changes: 69 additions & 5 deletions docgen/gen.php
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,8 @@ public function __construct($line)

}

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

}

class ScanFile
{
public $filename = '';
public $js = '';

public $blocks;

public $consts = [];
public $properties = [];
public $methods = [];

public function __construct($file)
{
$this->filename = $file;
$js = file($file);

$scanningForOpen = true;
$scanningForClose = false;

$blocks = [];
$openLine = 0;
$closeLine = 0;
$chunk = [];

for ($i = 0; $i < count($js); $i++)
{
$line = trim($js[$i]);

if ($scanningForOpen && $line === "/**")
{
$scanningForOpen = false;
$scanningForClose = true;
$chunk = [];
$openLine = $i;
}

if ($scanningForClose && $line === "*/")
{
$scanningForOpen = true;
$scanningForClose = false;
$closeLine = $i;

$consts = [];
$properties = [];
$methods = [];
// The first element is always the opening /** so remove it
array_shift($chunk);

$this->blocks[] = new Block($openLine, $closeLine, $js[$i + 1], $chunk);
}
else
{
$chunk[] = $line;
}
}
}

public function total()
{
return count($this->blocks);
}

}


// $blocks = [];

// $consts = [];
// $properties = [];
// $methods = [];

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

/*
$js = file($file);
$scanningForOpen = true;
Expand Down Expand Up @@ -463,8 +525,10 @@ public function __construct($block)
$chunk[] = $line;
}
}
*/
// That's the whole file scanned, how many blocks did we get out of it?
echo count($blocks) . " blocks found\n\n";

echo "\nConstants:\n\n";
Expand Down
25 changes: 25 additions & 0 deletions docgen/json.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php
require 'src/Block.php';
require 'src/ClassDesc.php';
require 'src/Constant.php';
require 'src/Method.php';
require 'src/Parameter.php';
require 'src/Property.php';
require 'src/ReturnType.php';
require 'src/Processor.php';

// $data = new Processor("../src/gameobjects/Sprite.js");
$data = new Processor("../src/loader/Cache.js");

header('Content-Type: application/json');

$raw = [];

$raw['consts'] = $data->getConstsArray();

echo json_encode($raw);

// echo $data->consts[0]->getJSON();


?>
85 changes: 85 additions & 0 deletions docgen/process.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
<?php
require 'src/Block.php';
require 'src/ClassDesc.php';
require 'src/Constant.php';
require 'src/Method.php';
require 'src/Parameter.php';
require 'src/Property.php';
require 'src/ReturnType.php';
require 'src/Processor.php';
?>
<!doctype html>
<html>
<head>
<meta charset="UTF-8" />
<title>Phaser Documentation Generator v0.1</title>
<style type="text/css">
body {
font-family: Arial;
font-size: 14px;
background-color: #fff;
color: #000;
}

textarea {
width: 100%;
height: 1000px;
}
</style>
</head>
<body>

<pre spellcheck="false">
<?php

// $data = new Processor("../src/gameobjects/Sprite.js");
$data = new Processor("../src/loader/Cache.js");

echo $data->total() . " blocks found\n\n";

echo "\nConstants:\n\n";

for ($i = 0; $i < count($data->consts); $i++)
{
print_r($data->consts[$i]->getJSON());
// $const = $data->consts[$i];
// echo "\n\n";
// echo $const->name;
// echo "\n";
// print_r($const->types);
}

/*
echo "\nMethods:\n\n";
for ($i = 0; $i < count($data->methods); $i++)
{
$method = $data->methods[$i];
echo "\n\n";
echo $method->name;
echo "\n";
print_r($method->help);
print_r($method->parameters);
print_r($method->returns);
}
echo "\nProperties:\n\n";
for ($i = 0; $i < count($data->properties); $i++)
{
$property = $data->properties[$i];
echo "\n\n";
echo $property->name . "\n";
// print_r($property->types);
echo "Source code line " . $property->line . "\n";
echo "Default: " . $property->default . "\n";
echo "Help: " . "\n";
print_r($property->help);
echo "\n\n";
}
*/
?>
</pre>

</body>
</html>
24 changes: 24 additions & 0 deletions docgen/project/Phaser Doc Gen.dsk
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
[Files]
File0=D:\wamp\www\phaser\docgen\src\ClassDesc.php
IsActive0=0
ZIndex3=2
File1=D:\wamp\www\phaser\docgen\src\Processor.php
IsActive1=0
ZIndex2=3
File2=D:\wamp\www\phaser\docgen\src\Block.php
IsActive2=0
ZIndex1=1
File3=D:\wamp\www\phaser\docgen\process.php
IsActive3=1
ZIndex0=0
Files=4

[breakpoints]
bp_count=0

[parameters]
value=LCw

[watches]
count=0

1 change: 1 addition & 0 deletions docgen/project/Phaser Doc Gen.ppd
Original file line number Diff line number Diff line change
@@ -0,0 +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>
128 changes: 128 additions & 0 deletions docgen/project/Phaser Doc Gen.ppj
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
[Debugger]
dbgsessions=1
stopbeginning=1
excset=
errlevel=3 - All errors and warnings
profwithdbg=0
excign=
breakexc=
cp=System default encoding
tunnel=
readonlyed=0
host=clienthost
custom=0
errset=
sesstimeout=15
blkout=
Custom.Debug.Settings=0
showmaperrors=1
breakerr=

[PHPEdProject.Filters.Allow]
\=

[Test.Suite]
/=>

[PHPEdProject.Filters]
\=

[Encoder]
excl=0
asptags=0
stoponerr=0
obfusclevel=0
extinfo=0
phpdoc=1
licensing=0
compatibilitylevel=1
copyall=1
suppresssucc=0
headertype=0
lineinfo=0
shorttags=1
destinationtype=0

[PHPEdProject.Encodings]
\=UTF-8

[Wizard]
srunmode=1
sprojectroot=D:\wamp\www\phaser\docgen
sremotewebroot=d:\wamp\www\phaser\docgen\
swebrooturl=http://localhost/

[PHPEdProject.JSLibraries]
Count=0

[Testing]
TestingCustomLoader=
TestingCustomLoaderExtraArg=
TestingConfig=
FindTestMode=0
TestingRoot=
EnableTesting=0

[PHPEdProject]
HideDirs=CVS;.svn
CvsRoot=
MappingLocal0=D:\wamp\www\phaser\docgen
ParserProp_CSS_SubLang=1
UrlMappingCount=0
CvsModule=
EncoderEnabled=0
DefaultEncodingCount=1
CvsPassw=KQ66584HSbX6s4CB8Z9rjbXL+NlON3xlm+MDMZPPfj0y+4yJwWdnFQ0TBeEI//zt0iuqOXGXnsW/QzORoi/snQ==
DriverID=
IncPath_count=0
UsedPHPFrameworkPath=
RelativeRootDir=..\..\docgen
MappingMainIdx=0
ParserProp_CSS_ParsePHP=0
MappingURL0=
ParserProp_PHP_AspTags=0
MappingPublishingRoot=
MappingRemote0=
CvsHost=
RunMode=1
CvsMethod=pserver
CvsUser=
URL=
CvsCVSROOT=:pserver:@
DefaultFile=
ChangeTime=0
RemoteCliAccount=
ParserProp_JS_ParsePHP=0
ParserProp_Override=1
GUID={CF5D4786-6D94-4B0B-A2E6-44BE31187F34}
RemoteCliPhp=
CvsUseUtf8=0
MappingCount=1
ParserProp_AllowSingleAsteriskXDoc=1
UsedPHPFrameworkId=
PublishingAllowFilterCount=1
MappingRemoteDir=
DontPublishDirs=CVS;.svn
MappingPublishing0=
SourceControl=0
ScriptRunTarget=1
ParserProp_HTML_SubLang=2
UsedPHPFrameworkChecked=0
ParserPropPHPShortTags=0
ParserProp_PHP_SubLang=3
HideFiles=.gitignore;.cvsignore
CustomPropCount=0
PublishingFilterCount=1

[Publishing]
publmap.main0=0
publmap.publishingdriverid0=
DebuggerPublishingIdx=0
publmap.publishing0.0=
count=1
DfltPublishingIdx=0
publmap.local0.0=D:\wamp\www\phaser\docgen
publmap.count0=1
publmap.prjdriverid0=
caption0=

8 changes: 8 additions & 0 deletions docgen/project/Phaser Doc Gen.ppw
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[PHPEdWorkspace]
Project0=D:\wamp\www\phaser\docgen\project\Phaser Doc Gen.ppj
ProjectCount=1
ActiveProject=D:\wamp\www\phaser\docgen\project\Phaser Doc Gen.ppj
[Expanded]
Phaser Doc Gen=1
Phaser Doc Gen:Phaser Doc Gen=1
Phaser Doc Gen:Phaser Doc Gen:src=1
1 change: 1 addition & 0 deletions docgen/project/Phaser Doc Gen.ppx

Large diffs are not rendered by default.

Loading

0 comments on commit 7b8b1bf

Please sign in to comment.