Home | History | Annotate | Download | only in res
      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                 <script type="text/javascript">
     25                     function toggleVisibility(id) {
     26                         element = document.getElementById(id); 
     27                         if (element.style.display == "none") {
     28                             element.style.display = ""; 
     29                         } else { 
     30                             element.style.display = "none";
     31                         } 
     32                     }
     33                 </script>
     34                 <style type="text/css">
     35                     body {
     36                         background-color: #CCCCCC;
     37                         font-family: sans-serif;
     38                         margin: 10px;
     39                     }
     40 
     41                     .info {
     42                         margin-bottom: 10px;
     43                     }
     44 
     45                     .apks, .package, .class {
     46                         cursor: pointer;
     47                         text-decoration: underline;
     48                     }
     49 
     50                     .packageDetails {
     51                         padding-left: 20px;
     52                     }
     53 
     54                     .classDetails {
     55                         padding-left: 40px;
     56                     }
     57 
     58                     .method {
     59                         font-family: courier;
     60                         white-space: nowrap;
     61                     }
     62 
     63                     .red {
     64                         background-color: #FF6666;
     65                     }
     66 
     67                     .yellow {
     68                         background-color: #FFFF66;
     69                     }
     70 
     71                     .green {
     72                         background-color: #66FF66;
     73                     }
     74 
     75                     .deprecated {
     76                         text-decoration: line-through;
     77                     }
     78                 </style>
     79             </head>
     80             <body>
     81                 <h1><xsl:value-of select="api-coverage/@title" /></h1>
     82                 <div class="info">
     83                     Generated: <xsl:value-of select="api-coverage/@generatedTime" />
     84                 </div>
     85                 <div class="total">
     86                     Total:&nbsp;<xsl:value-of select="api-coverage/total/@coveragePercentage" />%
     87                 &nbsp;(<xsl:value-of select="api-coverage/total/@numCovered" />/<xsl:value-of select="api-coverage/total/@numTotal" />)
     88                 </div>
     89                 <div class="apks" onclick="toggleVisibility('sourceApks')">
     90                     Source APKs (<xsl:value-of select="count(api-coverage/debug/sources/apk)" />)
     91                 </div>
     92                 <div id="sourceApks" style="display: none">
     93                     <ul>
     94                         <xsl:for-each select="api-coverage/debug/sources/apk">
     95                             <li><xsl:value-of select="@path" /></li>
     96                         </xsl:for-each>
     97                     </ul>
     98                 </div>
     99                 <ul>
    100                     <xsl:for-each select="api-coverage/api/package">
    101                         <xsl:call-template name="packageOrClassListItem">
    102                             <xsl:with-param name="bulletClass" select="'package'" />
    103                         </xsl:call-template>
    104                         <div class="packageDetails" id="{@name}" style="display: none">
    105                             <ul>
    106                                 <xsl:for-each select="class">
    107                                     <xsl:call-template name="packageOrClassListItem">
    108                                         <xsl:with-param name="bulletClass" select="'class'" />
    109                                     </xsl:call-template>
    110                                     <div class="classDetails" id="{@name}" style="display: none">
    111                                         <xsl:for-each select="constructor">
    112                                             <xsl:call-template name="methodListItem" />
    113                                         </xsl:for-each>
    114                                         <xsl:for-each select="method">
    115                                             <xsl:call-template name="methodListItem" />
    116                                         </xsl:for-each>
    117                                     </div>
    118                                 </xsl:for-each>
    119                             </ul>
    120                         </div>
    121                     </xsl:for-each>
    122                 </ul>
    123             </body>
    124         </html>
    125     </xsl:template>
    126     
    127     <xsl:template name="packageOrClassListItem">
    128         <xsl:param name="bulletClass" />
    129 
    130         <xsl:variable name="colorClass">
    131             <xsl:choose>
    132                 <xsl:when test="@coveragePercentage &lt;= 50">red</xsl:when>
    133                 <xsl:when test="@coveragePercentage &lt;= 80">yellow</xsl:when>
    134                 <xsl:otherwise>green</xsl:otherwise>
    135             </xsl:choose>
    136         </xsl:variable>
    137         
    138         <xsl:variable name="deprecatedClass">
    139             <xsl:choose>
    140                 <xsl:when test="@deprecated = 'true'">deprecated</xsl:when>
    141                 <xsl:otherwise></xsl:otherwise>
    142             </xsl:choose>
    143         </xsl:variable>
    144 
    145         <li class="{$bulletClass}" onclick="toggleVisibility('{@name}')">
    146             <span class="{$colorClass} {$deprecatedClass}">
    147                 <b><xsl:value-of select="@name" /></b>
    148                 &nbsp;<xsl:value-of select="@coveragePercentage" />%
    149                 &nbsp;(<xsl:value-of select="@numCovered" />/<xsl:value-of select="@numTotal" />)
    150             </span>
    151         </li>   
    152     </xsl:template>
    153   
    154   <xsl:template name="methodListItem">
    155 
    156     <xsl:variable name="deprecatedClass">
    157         <xsl:choose>
    158             <xsl:when test="@deprecated = 'true'">deprecated</xsl:when>
    159             <xsl:otherwise></xsl:otherwise>
    160         </xsl:choose>
    161     </xsl:variable>
    162 
    163     <span class="method {$deprecatedClass}">
    164       <xsl:choose>
    165         <xsl:when test="@covered = 'true'">[X]</xsl:when>
    166         <xsl:otherwise>[ ]</xsl:otherwise>
    167       </xsl:choose>
    168       <xsl:if test="@returnType != ''">&nbsp;<xsl:value-of select="@returnType" /></xsl:if>
    169       <b>&nbsp;<xsl:value-of select="@name" /></b><xsl:call-template name="formatParameters" />
    170     </span>
    171     <br />
    172   </xsl:template>
    173 
    174   <xsl:template name="formatParameters">(<xsl:for-each select="parameter">
    175       <xsl:value-of select="@type" />
    176       <xsl:if test="not(position() = last())">,&nbsp;</xsl:if>
    177     </xsl:for-each>)
    178   </xsl:template>
    179   
    180 </xsl:stylesheet>
    181 
    182