A modern Music Player Daemon based on Rockbox open source high quality audio player
libadwaita
audio
rust
zig
deno
mpris
rockbox
mpd
1#!/usr/bin/php
2<?php
3require_once("functions.php");
4
5function get_group($text)
6{
7 return str_replace(array(" ", "/"), "_", $text);
8}
9
10$input = file_get_contents($argv[1]);
11
12$mypath = $_SERVER['SCRIPT_FILENAME'];
13$mypath = substr($mypath, 0, strrpos($mypath, "/"))."/";
14
15$inh = parse_documentation($input);
16
17@mkdir("output");
18
19$index_tpl = file_get_contents($mypath."index.tpl");
20
21$group_data = array();
22$group_tpl = get_tpl_part(array("%GROUP_START%", "%GROUP_END%"), $index_tpl);
23$func_tpl = get_tpl_part(array("%FUNCTION_START%", "%FUNCTION_END%"), $index_tpl);
24
25foreach($inh as $group_name => $group)
26{
27 if(strlen($group_name) > 0)
28 {
29 $func_data = array();
30 foreach($group as $el_name => $el)
31 $func_data[] = str_replace(array("%GROUP%", "%FUNCTION%", "%FUNCTION_NAME%"),
32 array(get_group($group_name), get_func($el_name), $el_name),
33 $func_tpl);
34
35 $tmp = str_replace("%GROUP_NAME%", ucwords($group_name), $group_tpl);
36 $group_data[] = ereg_replace("%FUNCTION_START%.*%FUNCTION_END%", implode("\n", $func_data), $tmp);
37 }
38}
39
40$index_tpl = ereg_replace("%GROUP_START%.*%GROUP_END%", implode("", $group_data), $index_tpl);
41file_put_contents("output/index.html", $index_tpl);
42
43$menu_tpl = file_get_contents($mypath."menu.tpl");
44$group_tpl = get_tpl_part(array("%GROUP_START%", "%GROUP_END%"), $menu_tpl);
45
46$menu = array();
47foreach($inh as $group_name => $group)
48{
49 if(strlen($group_name) > 0)
50 $menu[strtolower($group_name)] = str_replace(array("%GROUP%", "%GROUP_NAME%"),
51 array(get_group($group_name), ucwords($group_name)),
52 $group_tpl);
53}
54ksort($menu);
55
56$menu = ereg_replace("%GROUP_START%.*%GROUP_END%", implode("", $menu), $menu_tpl);
57
58$section_tpl = file_get_contents($mypath."section.tpl");
59
60$func_tpl = get_tpl_part(array("%FUNCTION_START%", "%FUNCTION_END%"), $section_tpl);
61$description_tpl = get_tpl_part(array("%DESCRIPTION_START%", "%DESCRIPTION_END%"), $section_tpl);
62$parameter_tpl = get_tpl_part(array("%PARAMETER_START%", "%PARAMETER_END%"), $section_tpl);
63$parameters_tpl = get_tpl_part(array("%PARAMETERS_START%", "%PARAMETERS_END%"), $section_tpl);
64$return_tpl = get_tpl_part(array("%RETURN_START%", "%RETURN_END%"), $section_tpl);
65$conditions_tpl = get_tpl_part(array("%CONDITIONS_START%", "%CONDITIONS_END%"), $section_tpl);
66$see_tpl = get_tpl_part(array("%SEE_START%", "%SEE_END%"), $section_tpl);
67
68foreach($inh as $group_name => $group)
69{
70 $section_data = str_replace(array("%MENU%", "%GROUP_NAME%"), array($menu, ucwords($group_name)), $section_tpl);
71
72 $funcs_data = array();
73 foreach($group as $func_name => $func)
74 {
75 $func_data = str_replace(array("%FUNCTION_NAME%", "%FUNCTION%"), array(get_func($func_name), $func_name), $func_tpl);
76
77 if(strlen($func["description"][0]) > 0)
78 $func_data = ereg_replace("%DESCRIPTION_START%.*%DESCRIPTION_END%",
79 str_replace("%FUNCTION_DESCRIPTION%", do_markup($func["description"][0]), $description_tpl),
80 $func_data);
81 else
82 $func_data = ereg_replace("%DESCRIPTION_START%.*%DESCRIPTION_END%", "", $func_data);
83
84 if(isset($func["param"]))
85 {
86 $params_data = array();
87 foreach($func["param"] as $param)
88 {
89 $param = trim($param);
90 $p1 = substr($param, 0, strpos($param, " "));
91 $p2 = do_markup(substr($param, strpos($param, " ")));
92
93 if(strlen($p1) > 0 && strlen($p2) > 0)
94 $params_data[] = str_replace(array("%PARAM1%", "%PARAM2%"), array($p1, $p2), $parameters_tpl);
95 }
96
97
98 if(count($params_data) > 0)
99 $func_data = ereg_replace("%PARAMETER_START%.*%PARAMETER_END%",
100 ereg_replace("%PARAMETERS_START%.*%PARAMETERS_END%", implode("\n", $params_data), $parameter_tpl),
101 $func_data);
102 else
103 $func_data = ereg_replace("%PARAMETER_START%.*%PARAMETER_END%", "", $func_data);
104 }
105 else
106 $func_data = ereg_replace("%PARAMETER_START%.*%PARAMETER_END%", "", $func_data);
107
108 if(isset($func["return"]) && strlen($func["return"][0]) > 0)
109 $func_data = ereg_replace("%RETURN_START%.*%RETURN_END%",
110 str_replace("%RETURN%", do_markup($func["return"][0]), $return_tpl),
111 $func_data);
112 else
113 $func_data = ereg_replace("%RETURN_START%.*%RETURN_END%", "", $func_data);
114
115 if(isset($func["conditions"]))
116 $func_data = ereg_replace("%CONDITIONS_START%.*%CONDITIONS_END%",
117 str_replace("%CONDITIONS%", $func["conditions"][0], $conditions_tpl),
118 $func_data);
119 else
120 $func_data = ereg_replace("%CONDITIONS_START%.*%CONDITIONS_END%", "", $func_data);
121
122 if(isset($func["see"]))
123 $func_data = ereg_replace("%SEE_START%.*%SEE_END%",
124 str_replace("%SEE%", do_see_markup(explode(" ", trim($func["see"][0]))), $see_tpl),
125 $func_data);
126 else
127 $func_data = ereg_replace("%SEE_START%.*%SEE_END%", "", $func_data);
128
129 $funcs_data[] = $func_data;
130 }
131 $section_data = ereg_replace("%FUNCTION_START%.*%FUNCTION_END%", implode("", $funcs_data), $section_data);
132
133 file_put_contents("output/".get_group($group_name).".html", $section_data);
134}
135
136copy($mypath."layout.css", "output/layout.css");
137?>