mirror of
https://github.com/friendica/friendica
synced 2025-04-27 13:50:12 +00:00
Added some documentation, script to generate a basic doxygen header
This commit is contained in:
parent
16b92af71f
commit
fab48926d0
2 changed files with 552 additions and 9 deletions
82
util/createdoxygen.php
Executable file
82
util/createdoxygen.php
Executable file
|
@ -0,0 +1,82 @@
|
|||
#!/usr/bin/php
|
||||
<?php
|
||||
if (count($_SERVER["argv"]) < 2)
|
||||
die("usage: createdoxygen.php file\n");
|
||||
|
||||
$file = $_SERVER["argv"][1];
|
||||
$data = file_get_contents($file);
|
||||
|
||||
$lines = explode("\n", $data);
|
||||
|
||||
$previous = "";
|
||||
|
||||
foreach ($lines AS $line) {
|
||||
$line = rtrim(trim($line, "\r"));
|
||||
|
||||
if (strstr(strtolower($line), "function")) {
|
||||
$detect = strtolower(trim($line));
|
||||
$detect = implode(" ", explode(" ", $detect));
|
||||
|
||||
$found = false;
|
||||
|
||||
if (substr($detect, 0, 9) == "function ")
|
||||
$found = true;
|
||||
|
||||
if (substr($detect, 0, 17) == "private function ")
|
||||
$found = true;
|
||||
|
||||
if (substr($detect, 0, 23) == "public static function ")
|
||||
$found = true;
|
||||
|
||||
if (substr($detect, 0, 10) == "function (")
|
||||
$found = false;
|
||||
|
||||
if ($found and (trim($previous) == "*/"))
|
||||
$found = false;
|
||||
|
||||
if ($found and !strstr($detect, "{"))
|
||||
$found = false;
|
||||
|
||||
if ($found) {
|
||||
echo add_documentation($line);
|
||||
}
|
||||
}
|
||||
echo $line."\n";
|
||||
$previous = $line;
|
||||
}
|
||||
|
||||
function add_documentation($line) {
|
||||
|
||||
$trimmed = ltrim($line);
|
||||
$length = strlen($line) - strlen($trimmed);
|
||||
$space = substr($line, 0, $length);
|
||||
|
||||
$block = $space."/**\n".
|
||||
$space." * @brief \n".
|
||||
$space." *\n"; /**/
|
||||
|
||||
|
||||
$left = strpos($line, "(");
|
||||
$line = substr($line, $left + 1);
|
||||
|
||||
$right = strpos($line, ")");
|
||||
$line = trim(substr($line, 0, $right));
|
||||
|
||||
if ($line != "") {
|
||||
$parameters = explode(",", $line);
|
||||
foreach ($parameters AS $parameter) {
|
||||
$parameter = trim($parameter);
|
||||
$splitted = explode("=", $parameter);
|
||||
|
||||
$block .= $space." * @param ".trim($splitted[0], "& ")."\n";
|
||||
}
|
||||
if (count($parameters) > 0)
|
||||
$block .= $space." *\n";
|
||||
}
|
||||
|
||||
$block .= $space." * @return \n".
|
||||
$space." */\n";
|
||||
|
||||
return $block;
|
||||
}
|
||||
?>
|
Loading…
Add table
Add a link
Reference in a new issue