html.mako revision 1dd4ecb0ea0589610b3616459b707c2898889153
1## -*- coding: utf-8 -*-
2<!DOCTYPE html>
3<html>
4<!-- Copyright (C) 2012 The Android Open Source Project
5
6     Licensed under the Apache License, Version 2.0 (the "License");
7     you may not use this file except in compliance with the License.
8     You may obtain a copy of the License at
9
10          http://www.apache.org/licenses/LICENSE-2.0
11
12     Unless required by applicable law or agreed to in writing, software
13     distributed under the License is distributed on an "AS IS" BASIS,
14     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15     See the License for the specific language governing permissions and
16     limitations under the License.
17-->
18<head>
19  <!-- automatically generated from html.mako. do NOT edit directly -->
20  <meta charset="utf-8" />
21  <title>Android Camera HAL3.0 Properties</title>
22  <style type="text/css">
23     body { background-color: #f7f7f7; font-family: Roboto, sans-serif;}
24     h1 { color: #333333; }
25     h2 { color: #333333; }
26     a:link { color: #258aaf; text-decoration: none}
27     a:hover { color: #459aaf; text-decoration: underline }
28     a:visited { color: #154a5f; text-decoration: none}
29    .section { color: #eeeeee; font-size: 1.5em; font-weight: bold; background-color: #888888; padding: 0.5em 0em 0.5em 0.5em; border-width: thick thin thin thin; border-color: #111111 #777777 #777777 #777777}
30    .kind { color: #eeeeee; font-size: 1.2em; font-weight: bold; padding-left: 1.5em; background-color: #aaaaaa }
31    .entry { background-color: #f0f0f0 }
32    .entries_header { background-color: #dddddd; text-align: center}
33
34    /* toc style */
35    .toc_section_header { font-size:1.3em;  }
36    .toc_kind_header { font-size:1.2em;  }
37
38    /* table column sizes */
39    table { border-collapse:collapse; table-layout: fixed; width: 100%; word-wrap: break-word }
40    td,th { border: 1px solid; border-color: #aaaaaa; padding-left: 0.5em; padding-right: 0.5em }
41    .th_name { width: 20% }
42    .th_units { width: 10% }
43    .th_tags { width: 5% }
44    .th_notes { width: 25% }
45    .th_type { width: 20% }
46    .th_description { width: 20% }
47    .th_range { width: 10% }
48    td { font-size: 0.9em; }
49
50    /* hide the first thead, we need it there only to enforce column sizes */
51    .thead_dummy { visibility: hidden; }
52
53    /* Entry flair */
54    .entry_name { color: #333333; padding-left:1.0em; font-size:1.1em; font-family: monospace; }
55
56    /* Entry type flair */
57    .entry_type_name { font-size:1.1em; color: #669900; font-weight: bold;}
58    .entry_type_name_enum:after { color: #669900; font-weight: bold; content:" (enum)" }
59    .entry_type_visibility { font-weight: bolder; padding-left:1em}
60    .entry_type_enum_name { font-family: monospace; font-weight: bolder; }
61    .entry_type_enum_notes:before { content:" - " }
62    .entry_type_enum_value:before { content:" = " }
63    .entry_type_enum_value { font-family: monospace; }
64    .entry ul { margin: 0 0 0 0; list-style-position: inside; padding-left: 0.5em; }
65    .entry ul li { padding: 0 0 0 0; margin: 0 0 0 0;}
66
67    /* Entry visibility flair */
68
69    /* Entry tags flair */
70    .entry_tags ul { list-style-type: none; }
71
72
73    /* TODO: generate abbr element for each tag link? */
74    /* TODO for each x.y.z try to link it to the entry */
75
76  </style>
77
78  <style>
79
80    {
81      /* broken...
82         supposedly there is a bug in chrome that it lays out tables before
83         it knows its being printed, so the page-break-* styles are ignored
84         */
85        tr { page-break-after: always; page-break-inside: avoid; }
86    }
87
88  </style>
89</head>
90
91<%!
92  import re
93  import textwrap
94  from metadata_helpers import md
95  from metadata_helpers import IMAGE_SRC_METADATA
96
97  import bs4
98
99  # insert word break hints for the browser
100  def wbr(text):
101    def wbr_filter(text):
102        new_txt = text
103
104        # for johnyOrange.appleCider.redGuardian also insert wbr before the caps
105        # => johny<wbr>Orange.apple<wbr>Cider.red<wbr>Guardian
106        for words in text.split(" "):
107          if len(words.split(".")) >= 3: # match only x.y.z
108            addwbr = lambda x: i.isupper() and ("<wbr>" + i) or i
109            new_word = "".join([addwbr(i) for i in words])
110            new_txt = new_txt.replace(words, new_word)
111
112        # e.g. X/Y/Z -> X/<wbr>Y/<wbr>/Z. also for X.Y.Z, X_Y_Z.
113        # but don't insert <wbr> for HTML, e.g. </p> stays </p>
114        new_txt = re.sub(r'([^<])([.|/|_/,])', r"\1\2<wbr>", new_txt)
115
116        return new_txt
117
118    # Do not mangle HTML when doing the replace.
119    soup = bs4.BeautifulSoup(text)
120    wbr_tag = soup.new_tag('wbr')
121
122    for navigable_string in soup.findAll(text=True):
123        parent = navigable_string.parent
124
125        # Insert each 'text<wbr>foo' before the old '$text$foo'
126        for split_string in wbr_filter(navigable_string).split("<wbr>"):
127            navigable_string.insert_before(split_string)
128            navigable_string.insert_before(wbr_tag)
129
130        # Remove the old unmodified text
131        navigable_string.extract()
132
133    return soup.decode()
134
135  # insert line breaks after every two \n\n
136  def br(text):
137    return re.sub(r"(\r?\n)(\r?\n)", r"\1<br>\2<br>", text)
138
139  # Render as markdown, and do HTML-doc-specific rewrites
140  def md_html(text):
141    # prepend the image directory path to each <img src="...">
142    return md(text, IMAGE_SRC_METADATA)
143%>
144
145<body>
146  <h1>Android Camera HAL3.0 Properties</h1>
147\
148<%def name="insert_toc_body(node)">
149  % for nested in node.namespaces:
150${    insert_toc_body(nested)}
151  % endfor
152  % for entry in node.merged_entries:
153            <li><a href="#${entry.kind}_${entry.name}">${entry.name}</a></li>
154  % endfor
155</%def>
156
157  <h2>Table of Contents</h2>
158  <ul class="toc">
159    <li><a href="#tag_index" class="toc_section_header">Tags</a></li>
160% for root in metadata.outer_namespaces:
161  % for section in root.sections:
162    <li>
163      <span class="toc_section_header"><a href="#section_${section.name}">${section.name}</a></span>
164      <ul class="toc_section">
165      % for kind in section.merged_kinds: # dynamic,static,controls
166        <li>
167          <span class="toc_kind_header">${kind.name}</span>
168          <ul class="toc_section">\
169${          insert_toc_body(kind)}\
170          </ul>
171        </li>
172      % endfor
173      </ul> <!-- toc_section -->
174    </li>
175  % endfor
176% endfor
177  </ul>
178
179
180  <h1>Properties</h1>
181  <table class="properties">
182
183    <thead class="thead_dummy">
184      <tr>
185        <th class="th_name">Property Name</th>
186        <th class="th_type">Type</th>
187        <th class="th_description">Description</th>
188        <th class="th_units">Units</th>
189        <th class="th_range">Range</th>
190        <th class="th_notes">Notes</th>
191        <th class="th_tags">Tags</th>
192      </tr>
193    </thead> <!-- so that the first occurrence of thead is not
194                         above the first occurrence of tr -->
195% for root in metadata.outer_namespaces:
196<!-- <namespace name="${root.name}"> -->
197  % for section in root.sections:
198  <tr><td colspan="7" id="section_${section.name}" class="section">${section.name}</td></tr>
199
200    % if section.description is not None:
201      <tr class="description"><td>${section.description}</td></tr>
202    % endif
203
204    % for kind in section.merged_kinds: # dynamic,static,controls
205      <tr><td colspan="7" class="kind">${kind.name}</td></tr>
206
207      <thead class="entries_header">
208        <tr>
209          <th class="th_name">Property Name</th>
210          <th class="th_type">Type</th>
211          <th class="th_description">Description</th>
212          <th class="th_units">Units</th>
213          <th class="th_range">Range</th>
214          <th class="th_notes">Notes</th>
215          <th class="th_tags">Tags</th>
216        </tr>
217      </thead>
218
219      <tbody>
220
221        <%def name="insert_body(node)">
222            % for nested in node.namespaces:
223                ${insert_namespace(nested)}
224            % endfor
225
226            % for entry in node.merged_entries:
227                ${insert_entry(entry)}
228            % endfor
229        </%def>
230
231        <%def name="insert_namespace(namespace)">
232            ${insert_body(namespace)}
233        </%def>
234
235        <%def name="insert_entry(prop)">
236        % if False: #prop.is_clone():
237            <clone entry="${prop.name}" kind="${prop.target_kind}">
238
239              % if prop.notes is not None:
240                <notes>${prop.notes | h,wbr}</notes>
241              % endif
242
243              % for tag in prop.tags:
244                <tag id="${tag.id}" />
245              % endfor
246
247            </clone>
248        % else:
249          <tr class="entry" id="${prop.kind}_${prop.name}">
250            <td class="entry_name">${prop.name | wbr}</td>
251            <td class="entry_type">
252              % if prop.enum:
253                <span class="entry_type_name entry_type_name_enum">${prop.type}</span>
254              % else:
255                <span class="entry_type_name">${prop.type}</span>
256              % endif
257              % if prop.container is not None:
258                <span class="entry_type_container">x</span>
259              % endif
260
261              % if prop.container == 'array':
262                <span class="entry_type_array">
263                  ${" x ".join(prop.container_sizes)}
264                </span>
265              % elif prop.container == 'tuple':
266                <ul class="entry_type_tuple">
267                % for val in prop.tuple_values:
268                  <li>${val}</li>
269                % endfor
270                </ul>
271              % endif
272              <span class="entry_type_visibility"> [${prop.applied_visibility}${" as %s" %prop.typedef.name if prop.typedef else ""}]</span>
273              % if prop.type_notes is not None:
274                <div class="entry_type_notes">${prop.type_notes | wbr}</div>
275              % endif
276
277              % if prop.enum:
278                <ul class="entry_type_enum">
279                  % for value in prop.enum.values:
280                  <li>
281                    <span class="entry_type_enum_name">${value.name}</span>
282                  % if value.optional:
283                    <span class="entry_type_enum_optional">optional</span>
284                  % endif:
285                  % if value.id is not None:
286                    <span class="entry_type_enum_value">${value.id}</span>
287                  % endif
288                  % if value.notes is not None:
289                    <span class="entry_type_enum_notes">${value.notes | wbr}</span>
290                  % endif
291                  </li>
292                  % endfor
293                </ul>
294              % endif
295
296            </td> <!-- entry_type -->
297
298            <td class="entry_description">
299            % if prop.description is not None:
300              ${prop.description | md_html, wbr}
301            % endif
302            </td>
303
304            <td class="entry_units">
305            % if prop.units is not None:
306              ${prop.units | wbr}
307            % endif
308            </td>
309
310            <td class="entry_range">
311            % if prop.range is not None:
312              ${prop.range | wbr}
313            % endif
314            </td>
315
316            <td class="entry_notes">
317            % if prop.notes is not None:
318              ${prop.notes | md_html, wbr}
319            % endif
320            </td>
321
322            <td class="entry_tags">
323            % if next(prop.tags, None):
324              <ul class="entry_tags">
325              % for tag in prop.tags:
326                  <li><a href="#tag_${tag.id}">${tag.id}</a></li>
327              % endfor
328              </ul>
329            % endif
330            </td>
331
332          </tr> <!-- end of entry -->
333        % endif
334        </%def>
335
336        ${insert_body(kind)}
337
338      <!-- end of kind -->
339      </tbody>
340    % endfor # for each kind
341
342  <!-- end of section -->
343  % endfor
344<!-- </namespace> -->
345% endfor
346  </table>
347
348  <div class="tags" id="tag_index">
349    <h2>Tags</h2>
350    <ul>
351    % for tag in metadata.tags:
352      <li id="tag_${tag.id}">${tag.id} - ${tag.description}
353        <ul class="tags_entries">
354        % for prop in tag.entries:
355          <li><a href="#${prop.kind}_${prop.name}">${prop.name}</a> (${prop.kind})</li>
356        % endfor
357        </ul>
358      </li> <!-- tag_${tag.id} -->
359    % endfor
360    </ul>
361  </div>
362
363  [ <a href="#">top</a> ]
364
365</body>
366</html>
367