Commit: 33bdafef333b90e0cf335cfb1379564da0a3026e
Author: Nate Abele | Date: 2010-06-11 14:36:44 -0400
diff --git a/config/bootstrap.php b/config/bootstrap.php
index 1baded0..5cd575c 100644
--- a/config/bootstrap.php
+++ b/config/bootstrap.php
@@ -25,7 +25,7 @@ use \lithium\net\http\Media;
Dispatcher::applyFilter('_callable', function($self, $params, $chain) {
list($plugin, $asset) = explode('/', $params['request']->url, 2) + array("", "");
- if ($asset && $library = Libraries::get($plugin)) {
+ if ($asset && ($library = Libraries::get($plugin)) && isset($library['path'])) {
$asset = "{$library['path']}/webroot/{$asset}";
if (file_exists($asset)) {
diff --git a/controllers/BrowserController.php b/controllers/BrowserController.php
index 3ff6787..329f5f3 100644
--- a/controllers/BrowserController.php
+++ b/controllers/BrowserController.php
@@ -55,7 +55,9 @@ class BrowserController extends \lithium\action\Controller {
* @link http://www.faqs.org/rfcs/rfc2396.html
*/
public function view() {
- $library = DocExtractor::library($this->request->lib);
+ if (!$library = DocExtractor::library($this->request->lib)) {
+ return $this->render('../errors/not_found');
+ }
$name = $library['prefix'] . join('\\', func_get_args());
$object = DocExtractor::get($this->request->lib, $name, array(
diff --git a/extensions/analysis/DocExtractor.php b/extensions/analysis/DocExtractor.php
index 2c9a985..490066f 100644
--- a/extensions/analysis/DocExtractor.php
+++ b/extensions/analysis/DocExtractor.php
@@ -46,7 +46,10 @@ class DocExtractor extends \lithium\core\StaticObject {
public static function library($name, array $options = array()) {
$defaults = array('docs' => 'config/docs.json');
$options += $defaults;
- $config = Libraries::get($name);
+
+ if (!$config = Libraries::get($name)) {
+ return array();
+ }
if (file_exists($file = "{$config['path']}/{$options['docs']}")) {
$config += (array) json_decode(file_get_contents($file));
@@ -55,8 +58,18 @@ class DocExtractor extends \lithium\core\StaticObject {
}
protected static function _method(array $object, array $data, array $options = array()) {
- $lines = Inspector::lines($info['file'], range($data['start'], $data['end']));
- return array('source' => join("\n", $lines)) + $object;
+ if (!$data) {
+ return array();
+ }
+ $lines = Inspector::lines($data['file'], range($data['start'], $data['end']));
+ $object = array('source' => join("\n", $lines)) + $object;
+ $object += array('tags' => isset($data['tags']) ? $data['tags'] : array());
+
+ if (isset($object['tags']['return'])) {
+ list($type, $text) = explode(' ', $object['tags']['return'], 2) + array('', '');
+ $object['return'] = compact('type', 'text');
+ }
+ return $object;
}
protected static function _namespace(array $object, array $data, array $options = array()) {
@@ -105,7 +118,7 @@ class DocExtractor extends \lithium\core\StaticObject {
}
});
sort($proto['subClasses']);
- return $proto + $object;
+ return $proto + $object + array('tags' => isset($data['tags']) ? $data['tags'] : array());
}
protected static function _property(array $object, array $data, array $options = array()) {
diff --git a/views/browser/view.html.php b/views/browser/view.html.php
index 662eaed..a6eb314 100644
--- a/views/browser/view.html.php
+++ b/views/browser/view.html.php
@@ -12,18 +12,6 @@ $this->title($namespace);
array('library' => 'li3_docs')
); ?>
-<?php if ($object['description']) { ?>
- <p class="description markdown">
- <?=$t($this->docs->cleanup($object['description']), compact('scope')); ?>
- </p>
-<?php } ?>
-
-<?php if ($object['text']) { ?>
- <p class="text markdown">
- <?=$t($this->docs->cleanup($object['text']), compact('scope')); ?>
- </p>
-<?php } ?>
-
<?php // Related items ?>
<?php if (isset($object['tags']['see'])) { ?>
<h4><?=$t('Related', array('scope' => 'li3_docs')); ?></h4>
@@ -34,6 +22,12 @@ $this->title($namespace);
</ul>
<?php } ?>
+<?=$this->view()->render(
+ array('element' => 'links'),
+ compact('namespace', 'object', 'scope'),
+ array('library' => 'li3_docs')
+); ?>
+
<?php // Object subclasses ?>
<?php if ($object['subClasses']) { ?>
<h4><?=$t('Subclasses', array('scope' => 'li3_docs')); ?></h4>
diff --git a/views/elements/class.html.php b/views/elements/class.html.php
index 57c1161..54a5978 100644
--- a/views/elements/class.html.php
+++ b/views/elements/class.html.php
@@ -7,6 +7,7 @@
</span>
<?php } ?>
+<?php if ($object['properties'] || ($object['methods'] && $object['methods']->count())) { ?>
<div class="contents">
<?php // Object properties ?>
<?php if ($object['properties']) { ?>
@@ -30,3 +31,16 @@
</ul>
<?php } ?>
</div>
+<?php } ?>
+
+<?php if ($object['description']) { ?>
+ <p class="description markdown">
+ <?=$t($this->docs->cleanup($object['description']), compact('scope')); ?>
+ </p>
+<?php } ?>
+
+<?php if ($object['text']) { ?>
+ <p class="text markdown">
+ <?=$t($this->docs->cleanup($object['text']), compact('scope')); ?>
+ </p>
+<?php } ?>
diff --git a/views/elements/links.html.php b/views/elements/links.html.php
new file mode 100644
index 0000000..acfd424
--- /dev/null
+++ b/views/elements/links.html.php
@@ -0,0 +1,14 @@
+<?php if (isset($object['tags']['link'])) { ?>
+ <h4><?=$t('Links', array('scope' => 'li3_docs')); ?></h4>
+ <ul class="links">
+ <?php foreach ((array) $object['tags']['link'] as $url) { ?>
+ <?php
+ $title = $url;
+ if (strpos($url, ' ')) {
+ list($url, $title) = array_map('trim', explode(' ', $url, 2));
+ }
+ ?>
+ <li><?=$this->html->link($title, $url); ?></li>
+ <?php } ?>
+ </ul>
+<?php } ?>
diff --git a/views/elements/method.html.php b/views/elements/method.html.php
index c0400d3..95b3704 100644
--- a/views/elements/method.html.php
+++ b/views/elements/method.html.php
@@ -1,13 +1,24 @@
+<?php if ($object['description']) { ?>
+ <p class="description markdown">
+ <?=$t($this->docs->cleanup($object['description']), compact('scope')); ?>
+ </p>
+<?php } ?>
+
+<?php if ($object['text']) { ?>
+ <p class="text markdown">
+ <?=$t($this->docs->cleanup($object['text']), compact('scope')); ?>
+ </p>
+<?php } ?>
<?php // Method parameters ?>
<?php if (isset($object['tags']['params'])) { ?>
<h4><?=$t('Parameters', array('scope' => 'li3_docs')); ?></h4>
<ul class="parameters">
- <?php foreach ($object['info']['tags']['params'] as $name => $data) { ?>
+ <?php foreach ((array) $object['tags']['params'] as $name => $data) { ?>
<li>
<span class="type"><?=$data['type']; ?></span>
<?=$name; ?>
- <span class="description markdown">
+ <span class="parameter text markdown">
<?=$t($this->docs->cleanup($data['text']), compact('scope')); ?>
</span>
</li>
@@ -18,9 +29,9 @@
<?php // Method return value ?>
<?php if (isset($object['return'])) { ?>
<h4><?=$t('Returns', array('scope' => 'li3_docs')); ?></h4>
- <span class="type"><?=$object['info']['return']['type']; ?></span>
+ <span class="type"><?=$object['return']['type']; ?></span>
<span class="return markdown">
- <?=$t($this->docs->cleanup($object['info']['return']['text']), compact('scope')); ?>
+ <?=$t($this->docs->cleanup($object['return']['text']), compact('scope')); ?>
</span>
<?php } ?>
diff --git a/views/elements/namespace.html.php b/views/elements/namespace.html.php
index f2c7266..2951df2 100644
--- a/views/elements/namespace.html.php
+++ b/views/elements/namespace.html.php
@@ -12,3 +12,15 @@
</ul>
</div>
<?php } ?>
+
+<?php if ($object['description']) { ?>
+ <p class="description markdown">
+ <?=$t($this->docs->cleanup($object['description']), compact('scope')); ?>
+ </p>
+<?php } ?>
+
+<?php if ($object['text']) { ?>
+ <p class="text markdown">
+ <?=$t($this->docs->cleanup($object['text']), compact('scope')); ?>
+ </p>
+<?php } ?>
diff --git a/views/elements/property.html.php b/views/elements/property.html.php
index e69de29..863cab1 100644
--- a/views/elements/property.html.php
+++ b/views/elements/property.html.php
@@ -0,0 +1,11 @@
+<?php if ($object['description']) { ?>
+ <p class="description markdown">
+ <?=$t($this->docs->cleanup($object['description']), compact('scope')); ?>
+ </p>
+<?php } ?>
+
+<?php if ($object['text']) { ?>
+ <p class="text markdown">
+ <?=$t($this->docs->cleanup($object['text']), compact('scope')); ?>
+ </p>
+<?php } ?>
diff --git a/views/errors/not_found.html.php b/views/errors/not_found.html.php
new file mode 100644
index 0000000..88afe45
--- /dev/null
+++ b/views/errors/not_found.html.php
@@ -0,0 +1,3 @@
+<h2>Object not found</h2>
+
+<?=$this->html->link('Back to index', array('library' => 'li3_docs')); ?>
\ No newline at end of file