diff --git a/index.php b/index.php index 5770ceb2..7e5c1f01 100755 --- a/index.php +++ b/index.php @@ -2,7 +2,7 @@ /** * Set up include path for source handling */ -set_include_path(get_include_path().":".__DIR__.'/src/'); +set_include_path(get_include_path() . ":" . __DIR__ . '/src/'); /** * Set up required classes (with the autoloader) @@ -14,13 +14,23 @@ use PHPDraft\Parse\JsonToHTML; define('VERSION', '0'); - $values = UI::main($argv); $apib = new ApibFileParser($values['file']); $json = new Drafter($apib); $html = new JsonToHTML($json->parseToJson()); -$html->get_html($values['template'], $values['image']); +$html->sorting = $values['sorting']; +$html->get_html($values['template'], $values['image'], $values['css'], $values['js']); + +function phpdraft_var_dump($var) +{ + if (defined('__PHPDRAFT_PHAR__')) { + return; + } + echo '
';
+    var_dump($var);
+    echo '
'; +} ?> diff --git a/src/PHPDraft/In/ApibFileParser.php b/src/PHPDraft/In/ApibFileParser.php index 11ab555f..bd2bf343 100644 --- a/src/PHPDraft/In/ApibFileParser.php +++ b/src/PHPDraft/In/ApibFileParser.php @@ -12,12 +12,14 @@ class ApibFileParser { /** * Complete API Blueprint + * * @var string */ protected $full_apib; /** * Location of the API Blueprint to parse + * * @var string */ protected $location; @@ -29,7 +31,7 @@ class ApibFileParser */ public function __construct($filename = 'index.apib') { - $this->location = pathinfo($filename, PATHINFO_DIRNAME) . '/'; + $this->location = pathinfo($filename, PATHINFO_DIRNAME) . '/'; $this->full_apib = $this->get_apib($filename); } @@ -49,7 +51,8 @@ function get_apib($filename) $matches = []; preg_match_all('', $file, $matches); foreach ($matches[1] as $value) { - $file = str_replace('', $this->get_apib($this->location . $value . '.apib'), $file); + $file = str_replace('', + $this->get_apib($this->location . $value . '.apib'), $file); } return $file; @@ -57,8 +60,7 @@ function get_apib($filename) private function file_check($filename) { - if(!file_exists($filename)) - { + if (!file_exists($filename)) { file_put_contents('php://stderr', "API File not found: $filename\n"); exit(1); } diff --git a/src/PHPDraft/Model/Category.php b/src/PHPDraft/Model/Category.php index 2e7f54c6..3a22b8ec 100644 --- a/src/PHPDraft/Model/Category.php +++ b/src/PHPDraft/Model/Category.php @@ -14,6 +14,7 @@ class Category extends HierarchyElement { /** * API Structure element + * * @var DataStructureElement[] */ public $structures = []; @@ -28,10 +29,8 @@ class Category extends HierarchyElement function parse($object) { parent::parse($object); - foreach ($object->content as $key => $item) - { - switch ($item->element) - { + foreach ($object->content as $key => $item) { + switch ($item->element) { case 'resource': $resource = new Resource($this); $this->children[] = $resource->parse($item); @@ -42,12 +41,9 @@ function parse($object) $struct->deps = $deps; $struct->parse($item, $deps); - if (isset($item->content[0]->meta->id)) - { + if (isset($item->content[0]->meta->id)) { $this->structures[$item->content[0]->meta->id] = $struct; - } - else - { + } else { $this->structures[] = $struct; } diff --git a/src/PHPDraft/Model/Elements/ArrayStructureElement.php b/src/PHPDraft/Model/Elements/ArrayStructureElement.php index 73f980f1..46453edf 100644 --- a/src/PHPDraft/Model/Elements/ArrayStructureElement.php +++ b/src/PHPDraft/Model/Elements/ArrayStructureElement.php @@ -13,18 +13,22 @@ class ArrayStructureElement extends DataStructureElement implements StructureElement { + /** + * Type of objects in the array + * + * @var + */ + public $type_of; + public function parse($item, &$dependencies) { $this->element = (isset($item->element)) ? $item->element : 'array'; - $this->value = (isset($item->content)) ? $item->content : NULL; + $this->value = (isset($item->content)) ? $item->content : null; - if (isset($item->content)) - { - foreach ($item->content as $key => $sub_item) - { + if (isset($item->content)) { + foreach ($item->content as $key => $sub_item) { $this->type[$key] = $sub_item->element; - switch ($sub_item->element) - { + switch ($sub_item->element) { case 'array': $value = new ArrayStructureElement(); $this->value[$key] = $value->parse($sub_item, $dependencies); @@ -38,7 +42,7 @@ public function parse($item, &$dependencies) $this->value[$key] = $value->parse($sub_item, $dependencies); break; default: - $this->value[$key] = (isset($sub_item->content)) ? $sub_item->content : NULL; + $this->value[$key] = (isset($sub_item->content)) ? $sub_item->content : null; break; } } @@ -49,18 +53,17 @@ public function parse($item, &$dependencies) function __toString() { - if (!is_array($this->type)) - { + if (!is_array($this->type)) { return ''; } $return = '