3 * Extracts modules and their documentation from php code.
\r
4 * @author Ulf Wendel <ulf.wendel@redsys.de>
\r
7 class PhpdocModuleParser extends PhpdocConstantParser {
\r
10 * Empty hash that shows the structure of a module.
\r
13 var $emptyModule = array(
\r
19 "functions" => array(),
\r
20 "consts" => array(),
\r
25 * List of tags allowed within a module doc comment.
\r
26 * @var array tagname => true
\r
28 var $moduleTags = array(
\r
30 "modulegroup" => true,
\r
38 "copyright" => true,
\r
43 "deprecated" => true,
\r
58 * Hash of all module groups
\r
61 var $moduleGroups = array();
\r
64 * Central module parsing function.
\r
66 * @param array Array of parsing data
\r
68 * @see analyseModuleDoc()
\r
70 function analyseModule($para) {
\r
72 $module = $this->analyseModuleDoc($para["modules"]);
\r
73 unset($para["modules"]);
\r
75 $this->moduleGroups[$module["group"]][] = $module["name"];
\r
77 reset($para["functions"]);
\r
78 while (list($k, $data)=each($para["functions"]))
\r
79 $module["functions"][strtolower($data["name"])] = $this->analyseFunction($data);
\r
80 unset($para["functions"]);
\r
82 reset($para["consts"]);
\r
83 while (list($k, $data)=each($para["consts"]))
\r
84 $module["consts"][strtolower($data["name"])] = $this->analyseConstant($data);
\r
85 unset($para["const"]);
\r
87 reset($para["uses"]);
\r
88 while (list($k, $data)=each($para["uses"]))
\r
89 $module["uses"][strtolower($data["file"])] = $this->analyseUse($data);
\r
92 } // end func analyseModule
\r
95 * Extracts the allowed documentation tags out of a module doc comment.
\r
97 * @param array Module paragraph
\r
100 function analyseModuleDoc($para) {
\r
102 $module = $this->emptyModule;
\r
103 $module["name"] = (""!=$para["name"]) ? $para["name"] : $this->currentFile;
\r
104 $module["group"] = (""!=$para["group"]) ? $para["group"] : $this->currentFile;
\r
106 if ("missing" == $para["status"]) {
\r
108 $msg = "The file '$this->currentFile' does not contain any classes and seems to lack a module doc comment.";
\r
109 $this->warn->addDocWarning($this->currentFile, "module", $module["name"], $msg, "missing");
\r
111 } else if ("tags missing" == $para["status"]) {
\r
113 $msg = "The module doc comment does not contain a @module or @modulegroup tag, the module gets names: '$this->currentFile'";
\r
114 $this->warn->addDocWarning($this->currentFile, "module", $module["name"], $msg, "missing");
\r
118 if (""!=$para["doc"]) {
\r
120 $tags = $this->getTags($para["doc"]);
\r
121 $module = $this->analyseTags($tags, $module, $this->moduleTags);
\r
123 list($msg, $module) = $this->checkParserErrors($module, "module");
\r
125 $this->warn->addDocWarning($this->currentFile, "module", $module["name"], $msg, "mismatch");
\r
127 list($shortdesc, $fulldesc) = $this->getDescription($para["doc"]);
\r
128 $module["sdesc"] = $shortdesc;
\r
129 $module["desc"] = $fulldesc;
\r
131 $module["undoc"] = false;
\r
134 unset($module["module"]);
\r
135 unset($module["modulegroup"]);
\r
138 } // end analyseModuleDoc
\r
140 } // end class PhpdocModuleParser
\r