From dfd094371d284b0658c355d6a99377200da1aa05 Mon Sep 17 00:00:00 2001 From: Sandro Meier Date: Tue, 27 May 2014 13:33:50 +0200 Subject: [PATCH 1/2] Implement Tags for functions. --- Annotation/ApiDoc.php | 27 +++++++++++++++++++++++++++ Resources/public/css/screen.css | 12 ++++++++++++ Resources/views/method.html.twig | 5 +++++ Tests/Annotation/ApiDocTest.php | 31 +++++++++++++++++++++++++++++++ 4 files changed, 75 insertions(+) diff --git a/Annotation/ApiDoc.php b/Annotation/ApiDoc.php index dd3973d..08dc2e8 100644 --- a/Annotation/ApiDoc.php +++ b/Annotation/ApiDoc.php @@ -135,6 +135,11 @@ class ApiDoc */ private $statusCodes = array(); + /** + * @var array + */ + private $tags = array(); + public function __construct(array $data) { $this->resource = !empty($data['resource']) ? $data['resource'] : false; @@ -223,6 +228,16 @@ class ApiDoc $this->deprecated = $data['deprecated']; } + if (isset($data['tags'])) { + $tags = $data['tags']; + + if (!is_array($tags)) { + $tags = array($tags); + } + + $this->tags = $tags; + } + if (isset($data['https'])) { $this->https = $data['https']; } @@ -507,6 +522,14 @@ class ApiDoc return $this->requirements; } + /** + * @return array + */ + public function getTags() + { + return $this->tags; + } + /** * @param boolean $deprecated */ @@ -571,6 +594,10 @@ class ApiDoc $data['cache'] = $cache; } + if ($tags = $this->tags) { + $data['tags'] = $tags; + } + $data['https'] = $this->https; $data['authentication'] = $this->authentication; $data['authenticationRoles'] = $this->authenticationRoles; diff --git a/Resources/public/css/screen.css b/Resources/public/css/screen.css index 5ef8389..6f35974 100644 --- a/Resources/public/css/screen.css +++ b/Resources/public/css/screen.css @@ -296,6 +296,18 @@ li.operation a.heading h3 span.path { padding-left: 5px; } +li.operation a.heading h3 span.tag { + color: #FFFFFF; + font-size: 0.7em; + vertical-align: baseline; + background-color: #d9534f; + padding-bottom: 3px; + padding-left: 6px; + padding-right: 6px; + padding-top: 2px; + border-radius: 4px; +} + li.operation div.content { border: 1px solid #ddd; padding: 10px; diff --git a/Resources/views/method.html.twig b/Resources/views/method.html.twig index 53cf9ba..b4b4ac2 100644 --- a/Resources/views/method.html.twig +++ b/Resources/views/method.html.twig @@ -25,6 +25,11 @@ {% endif -%} {{ data.uri }} + {% if data.tags is defined %} + {% for tag in data.tags %} + {{ tag }} + {% endfor %} + {% endif %}