fuzev2: prevent button light flickering when accessing µSD
[kugel-rb.git] / utils / rockbox_api / gen_html.php
blobd85d5f86b4ebd08b0e9b392521f2aa5e36decd08
1 #!/usr/bin/php
2 <?
3 require_once("functions.php");
5 function get_group($text)
7 return str_replace(array(" ", "/"), "_", $text);
10 $input = file_get_contents($argv[1]);
12 $mypath = $_SERVER['SCRIPT_FILENAME'];
13 $mypath = substr($mypath, 0, strrpos($mypath, "/"))."/";
15 $inh = parse_documentation($input);
17 @mkdir("output");
19 $index_tpl = file_get_contents($mypath."index.tpl");
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);
25 foreach($inh as $group_name => $group)
27 if(strlen($group_name) > 0)
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);
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);
40 $index_tpl = ereg_replace("%GROUP_START%.*%GROUP_END%", implode("", $group_data), $index_tpl);
41 file_put_contents("output/index.html", $index_tpl);
43 $menu_tpl = file_get_contents($mypath."menu.tpl");
44 $group_tpl = get_tpl_part(array("%GROUP_START%", "%GROUP_END%"), $menu_tpl);
46 $menu = array();
47 foreach($inh as $group_name => $group)
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);
54 ksort($menu);
56 $menu = ereg_replace("%GROUP_START%.*%GROUP_END%", implode("", $menu), $menu_tpl);
58 $section_tpl = file_get_contents($mypath."section.tpl");
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);
68 foreach($inh as $group_name => $group)
70 $section_data = str_replace(array("%MENU%", "%GROUP_NAME%"), array($menu, ucwords($group_name)), $section_tpl);
72 $funcs_data = array();
73 foreach($group as $func_name => $func)
75 $func_data = str_replace(array("%FUNCTION_NAME%", "%FUNCTION%"), array(get_func($func_name), $func_name), $func_tpl);
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);
84 if(isset($func["param"]))
86 $params_data = array();
87 foreach($func["param"] as $param)
89 $param = trim($param);
90 $p1 = substr($param, 0, strpos($param, " "));
91 $p2 = do_markup(substr($param, strpos($param, " ")));
93 if(strlen($p1) > 0 && strlen($p2) > 0)
94 $params_data[] = str_replace(array("%PARAM1%", "%PARAM2%"), array($p1, $p2), $parameters_tpl);
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);
105 else
106 $func_data = ereg_replace("%PARAMETER_START%.*%PARAMETER_END%", "", $func_data);
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);
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);
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);
129 $funcs_data[] = $func_data;
131 $section_data = ereg_replace("%FUNCTION_START%.*%FUNCTION_END%", implode("", $funcs_data), $section_data);
133 file_put_contents("output/".get_group($group_name).".html", $section_data);
136 copy($mypath."layout.css", "output/layout.css");