1<?xml version="1.0" encoding="utf-8"?>
2<!--
3 * Copyright (C) 2010 The Android Open Source Project
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 *      http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 -->
17
18<!DOCTYPE xsl:stylesheet [ <!ENTITY nbsp "&#160;"> ]>
19<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
20    <xsl:output method="html" version="1.0" encoding="UTF-8" indent="yes" />
21    <xsl:template match="/">
22        <html>
23            <head>
24                <title><xsl:value-of select="api-coverage/@title" /></title>
25                <script type="text/javascript">
26                    function toggleVisibility(id) {
27                        element = document.getElementById(id);
28                        if (element.style.display == "none") {
29                            element.style.display = "";
30                        } else {
31                            element.style.display = "none";
32                        }
33                    }
34                </script>
35                <style type="text/css">
36                    body {
37                        background-color: #CCCCCC;
38                        font-family: sans-serif;
39                        margin: 10px;
40                    }
41
42                    .info {
43                        margin-bottom: 10px;
44                    }
45
46                    .apks, .package, .class {
47                        cursor: pointer;
48                        text-decoration: underline;
49                    }
50
51                    .packageDetails {
52                        padding-left: 20px;
53                    }
54
55                    .classDetails {
56                        padding-left: 40px;
57                    }
58
59                    .method {
60                        font-family: courier;
61                        white-space: nowrap;
62                    }
63
64                    .red {
65                        background-color: #FF6666;
66                    }
67
68                    .yellow {
69                        background-color: #FFFF66;
70                    }
71
72                    .green {
73                        background-color: #66FF66;
74                    }
75
76                    .deprecated {
77                        text-decoration: line-through;
78                    }
79                </style>
80            </head>
81            <body>
82                <h1><xsl:value-of select="api-coverage/@title" /></h1>
83                <div class="info">
84                    Generated: <xsl:value-of select="api-coverage/@generatedTime" />
85                </div>
86                <div class="total">
87                    Total:&nbsp;<xsl:value-of select="api-coverage/total/@coveragePercentage" />%
88                &nbsp;(<xsl:value-of select="api-coverage/total/@numCovered" />/<xsl:value-of select="api-coverage/total/@numTotal" />)
89                </div>
90                <div class="apks" onclick="toggleVisibility('sourceApks')">
91                    Source Modules (<xsl:value-of select="count(api-coverage/debug/sources/apk)" />)
92                </div>
93                <div id="sourceApks" style="display: none">
94                    <ul>
95                        <xsl:for-each select="api-coverage/debug/sources/apk">
96                            <li><xsl:value-of select="@path" /></li>
97                        </xsl:for-each>
98                    </ul>
99                </div>
100                <ul>
101                    <xsl:for-each select="api-coverage/api/package">
102                        <xsl:call-template name="packageOrClassListItem">
103                            <xsl:with-param name="bulletClass" select="'package'" />
104                            <xsl:with-param name="toggleId" select="@name" />
105                        </xsl:call-template>
106                        <div class="packageDetails" id="{@name}" style="display: none">
107                            <ul>
108                                <xsl:for-each select="class">
109                                    <xsl:variable name="packageClassId" select="concat(../@name, '.', @name)"/>
110                                    <xsl:call-template name="packageOrClassListItem">
111                                        <xsl:with-param name="bulletClass" select="'class'" />
112                                        <xsl:with-param name="toggleId" select="$packageClassId" />
113                                    </xsl:call-template>
114                                    <div class="classDetails" id="{$packageClassId}" style="display: none">
115                                        <xsl:for-each select="constructor">
116                                            <xsl:call-template name="methodListItem" />
117                                        </xsl:for-each>
118                                        <xsl:for-each select="method">
119                                            <xsl:call-template name="methodListItem" />
120                                        </xsl:for-each>
121                                    </div>
122                                </xsl:for-each>
123                            </ul>
124                        </div>
125                    </xsl:for-each>
126                </ul>
127            </body>
128        </html>
129    </xsl:template>
130
131    <xsl:template name="packageOrClassListItem">
132        <xsl:param name="bulletClass" />
133        <xsl:param name="toggleId"/>
134
135        <xsl:variable name="colorClass">
136            <xsl:choose>
137                <xsl:when test="@coveragePercentage &lt;= 50">red</xsl:when>
138                <xsl:when test="@coveragePercentage &lt;= 80">yellow</xsl:when>
139                <xsl:otherwise>green</xsl:otherwise>
140            </xsl:choose>
141        </xsl:variable>
142
143        <xsl:variable name="deprecatedClass">
144            <xsl:choose>
145                <xsl:when test="@deprecated = 'true'">deprecated</xsl:when>
146                <xsl:otherwise></xsl:otherwise>
147            </xsl:choose>
148        </xsl:variable>
149
150        <li class="{$bulletClass}" onclick="toggleVisibility('{$toggleId}')">
151            <span class="{$colorClass} {$deprecatedClass}">
152                <b><xsl:value-of select="@name" /></b>
153                &nbsp;<xsl:value-of select="@coveragePercentage" />%
154                &nbsp;(<xsl:value-of select="@numCovered" />/<xsl:value-of select="@numTotal" />)
155            </span>
156        </li>
157    </xsl:template>
158
159  <xsl:template name="methodListItem">
160
161    <xsl:variable name="deprecatedClass">
162        <xsl:choose>
163            <xsl:when test="@deprecated = 'true'">deprecated</xsl:when>
164            <xsl:otherwise></xsl:otherwise>
165        </xsl:choose>
166    </xsl:variable>
167
168    <span class="method {$deprecatedClass}">
169      <xsl:choose>
170        <xsl:when test="@covered = 'true'">[X]</xsl:when>
171        <xsl:otherwise>[ ]</xsl:otherwise>
172      </xsl:choose>
173      <xsl:if test="@visibility != ''">&nbsp;<xsl:value-of select="@visibility" /></xsl:if>
174      <xsl:if test="@abstract = 'true'">&nbsp;abstract</xsl:if>
175      <xsl:if test="@static = 'true'">&nbsp;static</xsl:if>
176      <xsl:if test="@final = 'true'">&nbsp;final</xsl:if>
177      <xsl:if test="@returnType != ''">&nbsp;<xsl:value-of select="@returnType" /></xsl:if>
178      <b>&nbsp;<xsl:value-of select="@name" /></b><xsl:call-template name="formatParameters" />
179    </span>
180    <br />
181  </xsl:template>
182
183  <xsl:template name="formatParameters">(<xsl:for-each select="parameter">
184      <xsl:value-of select="@type" />
185      <xsl:if test="not(position() = last())">,&nbsp;</xsl:if>
186    </xsl:for-each>)
187  </xsl:template>
188
189</xsl:stylesheet>
190
191