Ticket #2675: parser_tags_diff

File parser_tags_diff, 4.6 kB (added by toby.collett@…, 20 months ago)

adds custom tags for filtering documentation

Line 
1Index: docscripts/plugins/output/dojo.php
2===================================================================
3--- docscripts/plugins/output/dojo.php  (revision 7906)
4+++ docscripts/plugins/output/dojo.php  (working copy)
5@@ -126,6 +126,12 @@
6                                else {
7                                        $flat_list[$item_name]['summary'] = '';
8                                }
9+        if (!empty($item_content['meta']['tags'])) {
10+          $flat_list[$item_name]['tags'] = $item_content['meta']['tags'];
11+        }
12+        else {
13+          $flat_list[$item_name]['tags'] = '';
14+        }
15 
16                                if (!empty($item_content['meta']['description'])) {
17                                        $flat_list[$item_name]['description'] = $item_content['meta']['description'];
18@@ -186,6 +192,13 @@
19           $summary = $item->appendChild($document->createElement('summary'));
20           $summary->appendChild($document->createTextNode($item_content['meta']['summary']));
21         }
22+        if ($item_content['meta']['tags']) {
23+          $tags = $item->appendChild($document->createElement('tags'));
24+          foreach ($item_content['meta']['tags'] as $tag_name) {
25+            $tag = $tags->appendChild($document->createElement('tag'));
26+            $tag->setAttribute('name', $tag_name);
27+          }
28+        }
29         if ($item_content['meta']['parameters']) {
30           $parameters = $item->appendChild($document->createElement('parameters'));
31           foreach ($item_content['meta']['parameters'] as $parameter_name => $parameter_content) {
32Index: docscripts/docparser.php
33===================================================================
34--- docscripts/docparser.php    (revision 7906)
35+++ docscripts/docparser.php    (working copy)
36@@ -166,6 +166,10 @@
37       if ($object->getBlockComment('summary')) {
38         $output[$package_name]['meta']['functions'][$name]['meta']['summary'] = $object->getBlockComment('summary');
39       }
40+      if ($object->getBlockComment('tags')) {
41+        if (preg_match_all('%\b[a-zA-Z0-9_]+%', $this->getBlockComment('tags'), $matches,PREG_PATTERN_ORDER))
42+            $output[$package_name]['meta']['functions'][$name]['meta']['tags'] = $matches[0];
43+      }
44       if ($object->getBlockComment('description')) {
45         $output[$package_name]['meta']['functions'][$name]['meta']['description'] = $object->getBlockComment('description');
46       }
47Index: docscripts/inc/DojoFunctionDeclare.php
48===================================================================
49--- docscripts/inc/DojoFunctionDeclare.php      (revision 7906)
50+++ docscripts/inc/DojoFunctionDeclare.php      (working copy)
51@@ -240,6 +240,7 @@
52     }
53     
54     $this->addBlockCommentKey('summary');
55+    $this->addBlockCommentKey('tags');
56     $this->addBlockCommentKey('description');
57                $this->addBlockCommentKey('returns');
58     
59@@ -271,6 +272,14 @@
60       if ($key == 'summary') {
61         $output[$package_name]['meta']['functions'][$function_name]['meta']['summary'] = $this->getBlockComment($key);
62       }
63+      elseif ($key == 'tags') {
64+        echo "Parsing Tags\n";
65+        if (preg_match_all('%\b[a-zA-Z0-9_]+%', $this->getBlockComment($key), $matches,PREG_PATTERN_ORDER))
66+        {
67+          print_r($matches);
68+          $output[$package_name]['meta']['functions'][$function_name]['meta']['tags'] = $matches[0];
69+        }
70+      }
71       elseif ($key == 'description') {
72         $output[$package_name]['meta']['functions'][$function_name]['meta']['description'] = $this->getBlockComment($key);
73       }
74Index: docscripts/inc/DojoObject.php
75===================================================================
76--- docscripts/inc/DojoObject.php       (revision 7906)
77+++ docscripts/inc/DojoObject.php       (working copy)
78@@ -156,7 +156,8 @@
79     }
80 
81                $this->addBlockCommentKey('summary');
82-               $this->addBlockCommentKey('description');
83+    $this->addBlockCommentKey('tags');
84+    $this->addBlockCommentKey('description');
85 
86     foreach ($variables as $key) {
87       if ($comment = $this->getBlockComment($key)) {
88@@ -169,7 +170,11 @@
89                if (!$this->isAnonymous() && $comment = $this->getBlockComment('summary')) {
90                        $output[$package_name]['meta'][$item_type][$name]['meta']['summary'] = $comment;
91                }
92-               if (!$this->isAnonymous() && $comment = $this->getBlockComment('description')) {
93+    if (!$this->isAnonymous() && $comment = $this->getBlockComment('tags')) {
94+      if (preg_match_all('%\b[a-zA-Z0-9_]+%', $this->getBlockComment('tags'), $matches,PREG_PATTERN_ORDER))
95+          $output[$package_name]['meta'][$item_type][$name]['meta']['tags'] = $matches[0];
96+    }
97+    if (!$this->isAnonymous() && $comment = $this->getBlockComment('description')) {
98                        $output[$package_name]['meta'][$item_type][$name]['meta']['description'] = $comment;
99                }
100   }
101@@ -191,4 +196,4 @@
102   }
103 }
104 
105-?>
106\ No newline at end of file
107+?>