mypy-html.xslt 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. <?xml version="1.0" encoding="utf-8"?>
  2. <!-- vim: set sts=2 sw=2: -->
  3. <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  4. <xsl:param name="ext" select="'xml'"/>
  5. <xsl:output method="html"/>
  6. <xsl:variable name="xml_stylesheet_pi" select="string(//processing-instruction('xml-stylesheet'))"/>
  7. <xsl:variable name="stylesheet_name" select="substring($xml_stylesheet_pi, 23, string-length($xml_stylesheet_pi) - 28)"/>
  8. <xsl:template match="/mypy-report-index">
  9. <html>
  10. <head>
  11. <link rel="stylesheet" type="text/css" href="{$stylesheet_name}.css"/>
  12. </head>
  13. <body>
  14. <h1>Mypy Type Check Coverage Summary</h1>
  15. <table class="summary">
  16. <caption>Summary from <xsl:value-of select="@name"/></caption>
  17. <thead>
  18. <tr class="summary">
  19. <th class="summary">File</th>
  20. <th class="summary">Imprecision</th>
  21. <th class="summary">Lines</th>
  22. </tr>
  23. </thead>
  24. <tfoot>
  25. <xsl:variable name="bad_lines" select="sum(file/@imprecise|file/@any)"/>
  26. <xsl:variable name="total_lines" select="sum(file/@total)"/>
  27. <xsl:variable name="global_score" select="$bad_lines div ($total_lines + not(number($total_lines)))"/>
  28. <xsl:variable name="global_quality" select="string(number(number($global_score) &gt; 0.00) + number(number($global_score) &gt;= 0.20))"/>
  29. <tr class="summary summary-quality-{$global_quality}">
  30. <th class="summary summary-filename">Total</th>
  31. <th class="summary summary-precision"><xsl:value-of select="format-number($global_score, '0.00%')"/> imprecise</th>
  32. <th class="summary summary-lines"><xsl:value-of select="$total_lines"/> LOC</th>
  33. </tr>
  34. </tfoot>
  35. <tbody>
  36. <xsl:for-each select="file">
  37. <xsl:variable name="local_score" select="(@imprecise + @any) div (@total + not(number(@total)))"/>
  38. <xsl:variable name="local_quality" select="string(number(number($local_score) &gt; 0.00) + number(number($local_score) &gt;= 0.20))"/>
  39. <tr class="summary summary-quality-{$local_quality}">
  40. <td class="summary summary-filename"><a href="{$ext}/{@name}.{$ext}"><xsl:value-of select="@module"/></a></td>
  41. <td class="summary summary-precision"><xsl:value-of select="format-number($local_score, '0.00%')"/> imprecise</td>
  42. <td class="summary summary-lines"><xsl:value-of select="@total"/> LOC</td>
  43. </tr>
  44. </xsl:for-each>
  45. </tbody>
  46. </table>
  47. </body>
  48. </html>
  49. </xsl:template>
  50. <xsl:template match="/mypy-report-file">
  51. <html>
  52. <head>
  53. <link rel="stylesheet" type="text/css" href="{$stylesheet_name}.css"/>
  54. </head>
  55. <body>
  56. <h2><xsl:value-of select="@module"/></h2>
  57. <table>
  58. <caption><xsl:value-of select="@name"/></caption>
  59. <tbody>
  60. <tr>
  61. <td class="table-lines">
  62. <pre>
  63. <xsl:for-each select="line">
  64. <span id="L{@number}" class="lineno"><a class="lineno" href="#L{@number}"><xsl:value-of select="@number"/></a></span><xsl:text>&#10;</xsl:text>
  65. </xsl:for-each>
  66. </pre>
  67. </td>
  68. <td class="table-code">
  69. <pre>
  70. <xsl:for-each select="line">
  71. <span class="line-{@precision}" title="{@any_info}"><xsl:value-of select="@content"/></span><xsl:text>&#10;</xsl:text>
  72. </xsl:for-each>
  73. </pre>
  74. </td>
  75. </tr>
  76. </tbody>
  77. </table>
  78. </body>
  79. </html>
  80. </xsl:template>
  81. </xsl:stylesheet>