4 * @file util/createdoxygen.php
5 * @brief Adds a doxygen header to functions
8 if (count($_SERVER["argv"]) < 2)
9 die("usage: createdoxygen.php file\n");
11 $file = $_SERVER["argv"][1];
12 $data = file_get_contents($file);
14 $lines = explode("\n", $data);
18 foreach ($lines AS $line) {
19 $line = rtrim(trim($line, "\r"));
21 if (strstr(strtolower($line), "function")) {
22 $detect = strtolower(trim($line));
23 $detect = implode(" ", explode(" ", $detect));
27 if (substr($detect, 0, 9) == "function ")
30 if (substr($detect, 0, 17) == "private function ")
33 if (substr($detect, 0, 23) == "public static function ")
36 if (substr($detect, 0, 10) == "function (")
39 if ($found and (trim($previous) == "*/"))
42 if ($found and !strstr($detect, "{"))
46 echo add_documentation($line);
54 * @brief Adds a doxygen header
56 * @param string $line The current line of the document
58 * @return string added doxygen header
60 function add_documentation($line) {
62 $trimmed = ltrim($line);
63 $length = strlen($line) - strlen($trimmed);
64 $space = substr($line, 0, $length);
66 $block = $space."/**\n".
67 $space." * @brief \n".
71 $left = strpos($line, "(");
72 $line = substr($line, $left + 1);
74 $right = strpos($line, ")");
75 $line = trim(substr($line, 0, $right));
78 $parameters = explode(",", $line);
79 foreach ($parameters AS $parameter) {
80 $parameter = trim($parameter);
81 $splitted = explode("=", $parameter);
83 $block .= $space." * @param ".trim($splitted[0], "& ")."\n";
85 if (count($parameters) > 0)
86 $block .= $space." *\n";
89 $block .= $space." * @return \n".