This commit is contained in:
Waylon Walker 2022-03-31 20:20:07 -05:00
commit 38355d2442
No known key found for this signature in database
GPG key ID: 66E2BF2B4190EFE4
9083 changed files with 1225834 additions and 0 deletions

View file

@ -0,0 +1,104 @@
/* CSS for type check coverage reports */
/*
Used by both summary and file.
*/
body {
font-family: "Helvetica Neue", sans-serif;
}
/*
Used only by summary.
*/
h1 {
text-align: center;
font-size: 135%;
margin: 20px;
}
table.summary {
border-collapse: collapse;
margin-left: 7%;
margin-right: 7%;
width: 85%;
}
table caption {
margin: 1em;
}
table.summary, tr.summary, th.summary, td.summary {
border: 1px solid #aaa;
}
th.summary, td.summary {
padding: 0.4em;
}
td.summary a {
text-decoration: none;
}
.summary-quality-0 {
background-color: #dfd;
}
.summary-quality-1 {
background-color: #ffa;
}
.summary-quality-2 {
background-color: #faa;
}
td.summary-filename, th.summary-filename {
text-align: left;
}
td.summary-filename {
width: 50%;
}
.summary-precision {
text-align: center;
}
.summary-lines {
text-align: center;
}
/*
Used only by file.
*/
td.table-lines {
text-align: right;
padding-right: 0.5em;
}
td.table-code { }
span.lineno {
text-align: right;
}
a:link.lineno, a:visited.lineno {
color: #999; text-decoration: none;
}
a:hover.lineno, a:active.lineno {
color: #000; text-decoration: underline;
}
.line-empty, .line-precise {
background-color: #dfd;
}
.line-imprecise {
background-color: #ffa;
}
.line-any, .line-unanalyzed {
background-color: #faa;
}

View file

@ -0,0 +1,81 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- vim: set sts=2 sw=2: -->
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:param name="ext" select="'xml'"/>
<xsl:output method="html"/>
<xsl:variable name="xml_stylesheet_pi" select="string(//processing-instruction('xml-stylesheet'))"/>
<xsl:variable name="stylesheet_name" select="substring($xml_stylesheet_pi, 23, string-length($xml_stylesheet_pi) - 28)"/>
<xsl:template match="/mypy-report-index">
<html>
<head>
<link rel="stylesheet" type="text/css" href="{$stylesheet_name}.css"/>
</head>
<body>
<h1>Mypy Type Check Coverage Summary</h1>
<table class="summary">
<caption>Summary from <xsl:value-of select="@name"/></caption>
<thead>
<tr class="summary">
<th class="summary">File</th>
<th class="summary">Imprecision</th>
<th class="summary">Lines</th>
</tr>
</thead>
<tfoot>
<xsl:variable name="bad_lines" select="sum(file/@imprecise|file/@any)"/>
<xsl:variable name="total_lines" select="sum(file/@total)"/>
<xsl:variable name="global_score" select="$bad_lines div ($total_lines + not(number($total_lines)))"/>
<xsl:variable name="global_quality" select="string(number(number($global_score) &gt; 0.00) + number(number($global_score) &gt;= 0.20))"/>
<tr class="summary summary-quality-{$global_quality}">
<th class="summary summary-filename">Total</th>
<th class="summary summary-precision"><xsl:value-of select="format-number($global_score, '0.00%')"/> imprecise</th>
<th class="summary summary-lines"><xsl:value-of select="$total_lines"/> LOC</th>
</tr>
</tfoot>
<tbody>
<xsl:for-each select="file">
<xsl:variable name="local_score" select="(@imprecise + @any) div (@total + not(number(@total)))"/>
<xsl:variable name="local_quality" select="string(number(number($local_score) &gt; 0.00) + number(number($local_score) &gt;= 0.20))"/>
<tr class="summary summary-quality-{$local_quality}">
<td class="summary summary-filename"><a href="{$ext}/{@name}.{$ext}"><xsl:value-of select="@module"/></a></td>
<td class="summary summary-precision"><xsl:value-of select="format-number($local_score, '0.00%')"/> imprecise</td>
<td class="summary summary-lines"><xsl:value-of select="@total"/> LOC</td>
</tr>
</xsl:for-each>
</tbody>
</table>
</body>
</html>
</xsl:template>
<xsl:template match="/mypy-report-file">
<html>
<head>
<link rel="stylesheet" type="text/css" href="{$stylesheet_name}.css"/>
</head>
<body>
<h2><xsl:value-of select="@module"/></h2>
<table>
<caption><xsl:value-of select="@name"/></caption>
<tbody>
<tr>
<td class="table-lines">
<pre>
<xsl:for-each select="line">
<span id="L{@number}" class="lineno"><a class="lineno" href="#L{@number}"><xsl:value-of select="@number"/></a></span><xsl:text>&#10;</xsl:text>
</xsl:for-each>
</pre>
</td>
<td class="table-code">
<pre>
<xsl:for-each select="line">
<span class="line-{@precision}" title="{@any_info}"><xsl:value-of select="@content"/></span><xsl:text>&#10;</xsl:text>
</xsl:for-each>
</pre>
</td>
</tr>
</tbody>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>

View file

@ -0,0 +1,100 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- vim: set sts=2 sw=2: -->
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:math="http://exslt.org/math" xmlns:str="http://exslt.org/strings">
<xsl:output method="text"/>
<xsl:template match="/mypy-report-index">
<!-- It's possible to output without the <xsl:text> but it's harder to control. -->
<xsl:text>Mypy Type Check Coverage Summary&#10;</xsl:text>
<xsl:text>================================&#10;</xsl:text>
<xsl:text>&#10;</xsl:text>
<xsl:text>Script: </xsl:text><xsl:value-of select="@name"/><xsl:text>&#10;</xsl:text>
<xsl:text>&#10;</xsl:text>
<xsl:variable name="max_module_width">
<xsl:for-each select="file">
<xsl:sort select="string-length(@module)" data-type="number"/>
<xsl:if test="position() = last()">
<xsl:value-of select="string-length(@module)"/>
</xsl:if>
</xsl:for-each>
</xsl:variable>
<xsl:variable name="max_imprecision_width" select="string-length('100.00% imprecise')"/>
<xsl:variable name="max_loc_width" select="string-length(concat(sum(file/@total), ' LOC'))"/>
<xsl:text>+-</xsl:text>
<xsl:value-of select="str:padding($max_module_width, '-')"/>
<xsl:text>-+-</xsl:text>
<xsl:value-of select="str:padding($max_imprecision_width, '-')"/>
<xsl:text>-+-</xsl:text>
<xsl:value-of select="str:padding($max_loc_width, '-')"/>
<xsl:text>-+&#10;</xsl:text>
<xsl:text>| </xsl:text>
<xsl:value-of select="'Module'"/>
<xsl:value-of select="str:padding($max_module_width - string-length('Module'), ' ')"/>
<xsl:text> | </xsl:text>
<xsl:value-of select="'Imprecision'"/>
<xsl:value-of select="str:padding($max_imprecision_width - string-length('Imprecision'), ' ')"/>
<xsl:text> | </xsl:text>
<xsl:value-of select="'Lines'"/>
<xsl:value-of select="str:padding($max_loc_width - string-length('Lines'), ' ')"/>
<xsl:text> |&#10;</xsl:text>
<xsl:text>+-</xsl:text>
<xsl:value-of select="str:padding($max_module_width, '-')"/>
<xsl:text>-+-</xsl:text>
<xsl:value-of select="str:padding($max_imprecision_width, '-')"/>
<xsl:text>-+-</xsl:text>
<xsl:value-of select="str:padding($max_loc_width, '-')"/>
<xsl:text>-+&#10;</xsl:text>
<xsl:for-each select="file">
<xsl:variable name="score" select="(@imprecise + @any) div (@total + not(number(@total)))"/>
<xsl:variable name="imprecision" select="concat(format-number($score, '0.00%'), ' imprecise')"/>
<xsl:variable name="lines" select="concat(@total, ' LOC')"/>
<xsl:text>| </xsl:text>
<xsl:value-of select="@module"/>
<xsl:value-of select="str:padding($max_module_width - string-length(@module), ' ')"/>
<xsl:text> | </xsl:text>
<xsl:value-of select="str:padding($max_imprecision_width - string-length($imprecision), ' ')"/>
<xsl:value-of select="$imprecision"/>
<xsl:text> | </xsl:text>
<xsl:value-of select="str:padding($max_loc_width - string-length($lines), ' ')"/>
<xsl:value-of select="$lines"/>
<xsl:text> |&#10;</xsl:text>
</xsl:for-each>
<xsl:text>+-</xsl:text>
<xsl:value-of select="str:padding($max_module_width, '-')"/>
<xsl:text>-+-</xsl:text>
<xsl:value-of select="str:padding($max_imprecision_width, '-')"/>
<xsl:text>-+-</xsl:text>
<xsl:value-of select="str:padding($max_loc_width, '-')"/>
<xsl:text>-+&#10;</xsl:text>
<xsl:variable name="total" select="sum(file/@total)"/>
<xsl:variable name="score" select="(sum(file/@imprecise|file/@any)) div ($total + not(number($total)))"/>
<xsl:variable name="imprecision" select="concat(format-number($score, '0.00%'), ' imprecise')"/>
<xsl:variable name="lines" select="concat($total, ' LOC')"/>
<xsl:text>| </xsl:text>
<xsl:value-of select="'Total'"/>
<xsl:value-of select="str:padding($max_module_width - string-length('Total'), ' ')"/>
<xsl:text> | </xsl:text>
<xsl:value-of select="str:padding($max_imprecision_width - string-length($imprecision), ' ')"/>
<xsl:value-of select="$imprecision"/>
<xsl:text> | </xsl:text>
<xsl:value-of select="str:padding($max_loc_width - string-length($lines), ' ')"/>
<xsl:value-of select="$lines"/>
<xsl:text> |&#10;</xsl:text>
<xsl:text>+-</xsl:text>
<xsl:value-of select="str:padding($max_module_width, '-')"/>
<xsl:text>-+-</xsl:text>
<xsl:value-of select="str:padding($max_imprecision_width, '-')"/>
<xsl:text>-+-</xsl:text>
<xsl:value-of select="str:padding($max_loc_width, '-')"/>
<xsl:text>-+&#10;</xsl:text>
</xsl:template>
</xsl:stylesheet>

View file

@ -0,0 +1,50 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- vim: set sts=2 sw=2: -->
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<!-- simple types -->
<xs:simpleType name="precision">
<xs:restriction base="xs:string">
<xs:enumeration value="empty"/>
<xs:enumeration value="unanalyzed"/>
<xs:enumeration value="precise"/>
<xs:enumeration value="imprecise"/>
<xs:enumeration value="any"/>
</xs:restriction>
</xs:simpleType>
<!-- root elements -->
<xs:element name="mypy-report-index">
<xs:complexType>
<xs:sequence>
<xs:element name="file" minOccurs="0" maxOccurs="unbounded">
<xs:complexType>
<xs:attribute name="name" type="xs:string" use="required"/>
<xs:attribute name="module" type="xs:string" use="required"/>
<xs:attribute name="total" type="xs:integer" use="required"/>
<xs:attribute name="empty" type="xs:integer" use="required"/>
<xs:attribute name="unanalyzed" type="xs:integer" use="required"/>
<xs:attribute name="precise" type="xs:integer" use="required"/>
<xs:attribute name="imprecise" type="xs:integer" use="required"/>
<xs:attribute name="any" type="xs:integer" use="required"/>
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute name="name" type="xs:string" use="required"/>
</xs:complexType>
</xs:element>
<xs:element name="mypy-report-file">
<xs:complexType>
<xs:sequence>
<xs:element name="line" minOccurs="0" maxOccurs="unbounded">
<xs:complexType>
<xs:attribute name="number" type="xs:integer" use="required"/>
<xs:attribute name="precision" type="precision" use="required"/>
<xs:attribute name="any_info" type="xs:string" use="optional"/>
<xs:attribute name="content" type="xs:string" use="required"/>
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute name="name" type="xs:string" use="required"/>
<xs:attribute name="module" type="xs:string" use="required"/>
</xs:complexType>
</xs:element>
</xs:schema>