|
@@ -43,7 +43,10 @@ use \Sami\Reflection\InterfaceReflection as InterfaceReflection;
|
|
|
* $sami["twig"]->addExtension(new Markdown\SamiTwigExtension());
|
|
|
* ```
|
|
|
*
|
|
|
+ * @see Twig_Extension
|
|
|
+ * @see Sami
|
|
|
* @see example.conf.php
|
|
|
+ *
|
|
|
* @author Joachim M. Giaever (joachim[]giaever.org)
|
|
|
* @version 0.1
|
|
|
*/
|
|
@@ -170,8 +173,24 @@ class SamiTwigExtension extends \Twig_Extension {
|
|
|
);
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * Returns todo-tag for Reflection.
|
|
|
+ *
|
|
|
+ * @param Reflection $refl Reflection to get todo tag from.
|
|
|
+ * @return array|null Null on empty
|
|
|
+ */
|
|
|
public static function todo(Reflection $refl) {
|
|
|
- return (empty($todo = $refl->getTodo())) ? $todo : null;
|
|
|
+ return empty($todo = $refl->getTodo()) ? $todo : null;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Returns see-tag for Reflection.
|
|
|
+ *
|
|
|
+ * @param Reflection $refl Reflection to get see-tag from.
|
|
|
+ * @return array|null Null on empty
|
|
|
+ */
|
|
|
+ public static function see(Reflection $refl) {
|
|
|
+ return empty($see = $refl->getTags("see")) ? $see : null;
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -343,8 +362,9 @@ class SamiTwigExtension extends \Twig_Extension {
|
|
|
*
|
|
|
* This hints is typically what a method returns, e.g `string`, `bool` etc.
|
|
|
*
|
|
|
- * Method works similar as @see param_hint
|
|
|
+ * Method works similar as `param_hint`.
|
|
|
*
|
|
|
+ * @see self::param_hint
|
|
|
* @param \Sami\Reflection\MethodReflection $method
|
|
|
* @param bool $link = false
|
|
|
* @return string
|
|
@@ -414,6 +434,7 @@ class SamiTwigExtension extends \Twig_Extension {
|
|
|
* access function name(paramterers [= "value"]);
|
|
|
* ```
|
|
|
*
|
|
|
+ * @see param_hint
|
|
|
* @param \Sami\Reflection\MethodReflection $method Method reflection
|
|
|
* @param bool $incname Adds default parameter values on true
|
|
|
* @return string
|
|
@@ -573,17 +594,24 @@ class SamiTwigExtension extends \Twig_Extension {
|
|
|
|
|
|
// Create descriptions
|
|
|
foreach ($methods as $method) {
|
|
|
- $details[] = sprintf("\n##### %s `%s`\n```php\n%s function %s\n```%s%s%s%s%s%s\n---\n",
|
|
|
+ $details[] = sprintf("\n##### %s `%s`\n```php\n%s function %s\n```%s%s%s%s%s%s%s\n---\n",
|
|
|
$method->getName(), $method->getClass()->getName(),
|
|
|
self::method_access($method),
|
|
|
self::method_signature($method),
|
|
|
+ (function() use ($method) {
|
|
|
+ if (!empty($see = self::see($method))) {
|
|
|
+ return "\nSee also:\n* " . self::join($see, "* ") . "\n";
|
|
|
+ }
|
|
|
+
|
|
|
+ return null;
|
|
|
+ })(),
|
|
|
|
|
|
// Method description, padded left with > (block/indent)
|
|
|
(function() use ($method) {
|
|
|
- if (empty(self::long_description($method)))
|
|
|
- return null;
|
|
|
+ if (!empty($desc = self::long_description($method)))
|
|
|
+ return "\n " . $desc . "\n";
|
|
|
|
|
|
- return "\n " . self::long_description($method) . "\n";
|
|
|
+ return null;
|
|
|
})(),
|
|
|
|
|
|
// TODO: Debug this. No output?
|
|
@@ -624,11 +652,11 @@ class SamiTwigExtension extends \Twig_Extension {
|
|
|
return null;
|
|
|
|
|
|
// Return exceptions padded whith > and linked to...
|
|
|
- return "\n> Throws: " . (function() use ($method) {
|
|
|
+ return "\nThrows: " . (function() use ($method) {
|
|
|
$links = array();
|
|
|
foreach($method->getExceptions() as $Exception)
|
|
|
$links[] = self::href($Exception[0]->getShortName(), $Exception[0]->getName(), false, "Exception: " . $Exception[0]->getName());
|
|
|
- return "\n> * " . join("\n> * ", $links) . "\n";
|
|
|
+ return "\n* " . self::join($links, "* ") . "\n";
|
|
|
})();
|
|
|
})(),
|
|
|
|
|
@@ -663,7 +691,7 @@ class SamiTwigExtension extends \Twig_Extension {
|
|
|
public static function render_class(ClassReflection $class) {
|
|
|
|
|
|
return sprintf(
|
|
|
- "\n### %s `%s`\n%s%s%s",
|
|
|
+ "\n### %s `%s`\n%s%s%s%s",
|
|
|
$class->getShortName(),
|
|
|
$class->getNamespace(),
|
|
|
|
|
@@ -716,6 +744,13 @@ class SamiTwigExtension extends \Twig_Extension {
|
|
|
return "\n" . self::long_description($class) . "\n";
|
|
|
})(),
|
|
|
|
|
|
+ (function() use ($class) {
|
|
|
+ if (!empty($see = self::see($class)))
|
|
|
+ return "\nAlso see:\n* " . self::join($see, "* ") . "\n";
|
|
|
+
|
|
|
+ return null;
|
|
|
+ })(),
|
|
|
+
|
|
|
self::render_methods($class->getMethods())
|
|
|
);
|
|
|
}
|