summaryrefslogtreecommitdiff
path: root/utils/rockbox_api/gen_html.php
diff options
context:
space:
mode:
Diffstat (limited to 'utils/rockbox_api/gen_html.php')
-rwxr-xr-xutils/rockbox_api/gen_html.php110
1 files changed, 110 insertions, 0 deletions
diff --git a/utils/rockbox_api/gen_html.php b/utils/rockbox_api/gen_html.php
new file mode 100755
index 0000000000..34e124f411
--- /dev/null
+++ b/utils/rockbox_api/gen_html.php
@@ -0,0 +1,110 @@
1#!/usr/bin/php
2<?
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$inh = parse_documentation($input);
13
14@mkdir("output");
15
16$h = fopen("output/index.html", "w");
17
18fwrite($h, '<html><head><link href="layout.css" rel="stylesheet" type="text/css" /><title>Plugin API - INDEX</title></head><body>');
19
20fwrite($h, "<h1>Plugin API reference</h1>");
21fwrite($h, "<ul>");
22
23foreach($inh as $group_name => $group)
24{
25 if(strlen($group_name) > 0)
26 {
27 fwrite($h, '<li>'.ucwords($group_name)."<ul>");
28
29 foreach($group as $el_name => $el)
30 fwrite($h, "<li><a href=\"".get_group($group_name).".html#".get_func($el_name)."\">".$el_name."</a></li>");
31
32 fwrite($h, "</ul></li>");
33 }
34}
35fwrite($h, "</ul></body></html>");
36
37fclose($h);
38
39$menu = '<ul><li><a href="index.html">INDEX</a></li><ul>';
40$_menu = array();
41foreach($inh as $group_name => $group)
42{
43 if(strlen($group_name) > 0)
44 $_menu[strtolower($group_name)] = '<li><a href="'.get_group($group_name).'.html">'.ucwords($group_name).'</a></li>';
45}
46
47ksort($_menu);
48$menu .= implode("\n", $_menu);
49$menu .= "</ul></ul>";
50
51foreach($inh as $group_name => $group)
52{
53 $h = fopen("output/".get_group($group_name).".html", "w");
54
55 fwrite($h, '<html><head><link href="layout.css" rel="stylesheet" type="text/css" /><title>Plugin API - '.ucwords($group_name).'</title></head><body>');
56 fwrite($h, '<div id="menu">'.ucwords($menu).'</div>');
57 fwrite($h, '<div id="content">');
58 fwrite($h, '<a link="top"></a>');
59
60 fwrite($h, "<h2>".ucwords($group_name)."</h2>");
61 fwrite($h, '<span class="group">');
62 foreach($group as $func_name => $func)
63 {
64 fwrite($h, '<a id="'.get_func($func_name).'"></a>');
65
66 fwrite($h, "<h3>$func_name</h3>");
67
68 if(strlen($func["description"][0]) > 0)
69 fwrite($h, do_markup($func["description"][0])."<br /><br />");
70
71 if(isset($func["param"]))
72 {
73 $params = "";
74 foreach($func["param"] as $param)
75 {
76 $param = trim($param);
77 $p1 = substr($param, 0, strpos($param, " "));
78 $p2 = substr($param, strpos($param, " "));
79 if(strlen($p1) > 0 && strlen($p2) > 0)
80 $params .= '<dt>'.$p1.'</dt><dd> '.do_markup($p2).'</dd>';
81 }
82
83 if(strlen($params) > 0)
84 {
85 fwrite($h, '<span class="extra">Parameters:</span><dl>');
86 fwrite($h, $params);
87 fwrite($h, "</dl>");
88 }
89 }
90
91 if(isset($func["return"]) && strlen($func["return"][0]) > 0)
92 fwrite($h, '<span class="extra">Returns:</span> '.do_markup($func["return"][0]).'<br /><br />');
93
94 if(isset($func["conditions"]))
95 fwrite($h, '<span class="extra">Conditions:</span> '.$func["conditions"][0].'<br /><br />');
96
97 if(isset($func["see"]))
98 fwrite($h, '<span class="see">Also see '.do_see_markup(explode(" ", trim($func["see"][0]))).'</span><br /><br />');
99
100 fwrite($h, '<a href="#top" class="top">To top</a><hr />');
101 }
102 fwrite($h, "</span>");
103
104 fwrite($h, "</div></body></html>");
105
106 fclose($h);
107}
108
109copy("layout.css", "output/layout.css");
110?> \ No newline at end of file