Skip to content

Commit bc0f174

Browse files
committed
More rigid corruption checks for the pixi docs.
1 parent eb72e4c commit bc0f174

4 files changed

Lines changed: 58 additions & 7 deletions

File tree

docgen/export.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737

3838
foreach ($gen->classes as $key => $processor)
3939
{
40+
// echo $key . " = " . $processor . "\n";
4041
echo $key . "\n";
4142
}
4243

docgen/src/ClassDesc.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,18 @@ class ClassDesc
1010
public $hasConstructor = false;
1111
public $isStatic = false;
1212

13+
public $corrupted = false;
14+
1315
public function __construct($processor, $block)
1416
{
1517
$this->processor = $processor;
1618

19+
if ($block->getTypeBoolean('@class') === false)
20+
{
21+
$this->corrupted = true;
22+
return;
23+
}
24+
1725
$this->name = $block->getLineContent('@class');
1826

1927
if (substr($this->name, 0, 6) !== 'Phaser')

docgen/src/PhaserDocGen.php

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -69,12 +69,26 @@ private function dirToArray($dir)
6969
$index = substr($index, 1);
7070
$tempProcessor = new Processor($this, "../src/$index");
7171

72-
$classKey = $tempProcessor->class->name;
73-
74-
// $classKey = substr($value, 0, -3);
75-
// $classKey = str_replace(DIRECTORY_SEPARATOR, ".", $index);
76-
$result[$classKey] = $index;
77-
$this->classes[$classKey] = $tempProcessor;
72+
if ($tempProcessor->corrupted === false)
73+
{
74+
if ($tempProcessor->class)
75+
{
76+
$classKey = $tempProcessor->class->name;
77+
}
78+
else
79+
{
80+
$classKey = 'wtf' . rand();
81+
}
82+
83+
// $classKey = substr($value, 0, -3);
84+
// $classKey = str_replace(DIRECTORY_SEPARATOR, ".", $index);
85+
$result[$classKey] = $index;
86+
$this->classes[$classKey] = $tempProcessor;
87+
}
88+
else
89+
{
90+
$this->classes[$index] = 'corrupted';
91+
}
7892

7993
// Dump to log
8094
// echo $index . "\n";

docgen/src/Processor.php

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ class Processor
1212
public $docgen;
1313
public $processLog;
1414

15+
public $corrupted;
16+
1517
/**
1618
* Processes the given JS source file.
1719
*
@@ -22,11 +24,14 @@ public function __construct($docgen, $file)
2224
{
2325
$this->docgen = $docgen;
2426

27+
$this->class = null;
2528
$this->consts = [];
2629
$this->methods = [];
2730
$this->properties = [];
2831
$this->file = $file;
2932

33+
$this->corrupted = false;
34+
3035
$this->methods['private'] = [];
3136
$this->methods['protected'] = [];
3237
$this->methods['public'] = [];
@@ -91,7 +96,13 @@ private function scanFile() {
9196
{
9297
if ($this->blocks[$i]->isClass)
9398
{
94-
$this->class = new ClassDesc($this, $this->blocks[$i]);
99+
$tempClass = new ClassDesc($this, $this->blocks[$i]);
100+
$this->class = $tempClass;
101+
102+
if ($tempClass->corrupted)
103+
{
104+
$this->corrupted = true;
105+
}
95106
}
96107
else if ($this->blocks[$i]->isConst)
97108
{
@@ -142,6 +153,11 @@ private function scanFile() {
142153
}
143154
}
144155

156+
if ($this->class === null)
157+
{
158+
$this->corrupted = true;
159+
}
160+
145161
// Alphabetically sort the arrays based on the key
146162
ksort($this->consts);
147163

@@ -155,6 +171,18 @@ private function scanFile() {
155171
ksort($this->properties['private']);
156172

157173
}
174+
175+
public function __toString()
176+
{
177+
if ($this->corrupted)
178+
{
179+
return "JSDoc Corrupted Class";
180+
}
181+
else
182+
{
183+
return "Class: " . $this->class->name . ", Methods: " . count($this->methods['public']);
184+
}
185+
}
158186

159187
public function getArray()
160188
{

0 commit comments

Comments
 (0)