|
| 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 | + <xsl:text disable-output-escaping='yes'><!DOCTYPE html> </xsl:text> |
| 10 | + <html> |
| 11 | + <head> |
| 12 | + <link rel="stylesheet" type="text/css" href="{$stylesheet_name}.css"/> |
| 13 | + </head> |
| 14 | + <body> |
| 15 | + <h1>Mypy Type Check Coverage Summary</h1> |
| 16 | + <table class="summary"> |
| 17 | + <caption>Summary from <xsl:value-of select="@name"/></caption> |
| 18 | + <thead> |
| 19 | + <tr class="summary"> |
| 20 | + <th class="summary">File</th> |
| 21 | + <th class="summary">Imprecision</th> |
| 22 | + <th class="summary">Lines</th> |
| 23 | + </tr> |
| 24 | + </thead> |
| 25 | + <tfoot> |
| 26 | + <xsl:variable name="bad_lines" select="sum(file/@imprecise|file/@any)"/> |
| 27 | + <xsl:variable name="total_lines" select="sum(file/@total)"/> |
| 28 | + <xsl:variable name="global_score" select="$bad_lines div ($total_lines + not(number($total_lines)))"/> |
| 29 | + <xsl:variable name="global_quality" select="string(number(number($global_score) > 0.00) + number(number($global_score) >= 0.20))"/> |
| 30 | + <tr class="summary summary-quality-{$global_quality}"> |
| 31 | + <th class="summary summary-filename">Total</th> |
| 32 | + <th class="summary summary-precision"><xsl:value-of select="format-number($global_score, '0.00%')"/> imprecise</th> |
| 33 | + <th class="summary summary-lines"><xsl:value-of select="$total_lines"/> LOC</th> |
| 34 | + </tr> |
| 35 | + </tfoot> |
| 36 | + <tbody> |
| 37 | + <xsl:for-each select="file"> |
| 38 | + <xsl:variable name="local_score" select="(@imprecise + @any) div (@total + not(number(@total)))"/> |
| 39 | + <xsl:variable name="local_quality" select="string(number(number($local_score) > 0.00) + number(number($local_score) >= 0.20))"/> |
| 40 | + <tr class="summary summary-quality-{$local_quality}"> |
| 41 | + <td class="summary summary-filename"><a href="{$ext}/{@name}.{$ext}"><xsl:value-of select="@module"/></a></td> |
| 42 | + <td class="summary summary-precision"><xsl:value-of select="format-number($local_score, '0.00%')"/> imprecise</td> |
| 43 | + <td class="summary summary-lines"><xsl:value-of select="@total"/> LOC</td> |
| 44 | + </tr> |
| 45 | + </xsl:for-each> |
| 46 | + </tbody> |
| 47 | + </table> |
| 48 | + </body> |
| 49 | + </html> |
| 50 | + </xsl:template> |
| 51 | + <xsl:template match="/mypy-report-file"> |
| 52 | + <xsl:text disable-output-escaping='yes'><!DOCTYPE html> </xsl:text> |
| 53 | + <html> |
| 54 | + <head> |
| 55 | + <link rel="stylesheet" type="text/css" href="{$stylesheet_name}.css"/> |
| 56 | + </head> |
| 57 | + <body> |
| 58 | + <h2><xsl:value-of select="@module"/></h2> |
| 59 | + <table> |
| 60 | + <caption><xsl:value-of select="@name"/></caption> |
| 61 | + <tbody> |
| 62 | + <tr> |
| 63 | + <td class="table-lines"> |
| 64 | + <pre> |
| 65 | + <xsl:for-each select="line"> |
| 66 | + <span id="L{@number}" class="lineno"><a class="lineno" href="#L{@number}"><xsl:value-of select="@number"/></a></span><xsl:text> </xsl:text> |
| 67 | + </xsl:for-each> |
| 68 | + </pre> |
| 69 | + </td> |
| 70 | + <td class="table-code"> |
| 71 | + <pre> |
| 72 | + <xsl:for-each select="line"> |
| 73 | + <span class="line-{@precision}"> |
| 74 | + <xsl:for-each select="char"> |
| 75 | + <xsl:if test="@typestr!=''"> |
| 76 | + <span class="type-char"> |
| 77 | + <xsl:value-of select="@content"/> |
| 78 | + <span class="type-tooltip"> |
| 79 | + <xsl:value-of select="@typestr"/> |
| 80 | + </span> |
| 81 | + </span> |
| 82 | + </xsl:if> |
| 83 | + <xsl:if test="@typestr=''"> |
| 84 | + <xsl:value-of select="@content"/> |
| 85 | + </xsl:if> |
| 86 | + </xsl:for-each> |
| 87 | + </span> |
| 88 | + <xsl:text> </xsl:text> |
| 89 | + </xsl:for-each> |
| 90 | + </pre> |
| 91 | + </td> |
| 92 | + </tr> |
| 93 | + </tbody> |
| 94 | + </table> |
| 95 | + </body> |
| 96 | + </html> |
| 97 | + </xsl:template> |
| 98 | +</xsl:stylesheet> |
0 commit comments