mypy-txt.xslt 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  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" xmlns:math="http://exslt.org/math" xmlns:str="http://exslt.org/strings">
  4. <xsl:output method="text"/>
  5. <xsl:template match="/mypy-report-index">
  6. <!-- It's possible to output without the <xsl:text> but it's harder to control. -->
  7. <xsl:text>Mypy Type Check Coverage Summary&#10;</xsl:text>
  8. <xsl:text>================================&#10;</xsl:text>
  9. <xsl:text>&#10;</xsl:text>
  10. <xsl:text>Script: </xsl:text><xsl:value-of select="@name"/><xsl:text>&#10;</xsl:text>
  11. <xsl:text>&#10;</xsl:text>
  12. <xsl:variable name="max_module_width">
  13. <xsl:for-each select="file">
  14. <xsl:sort select="string-length(@module)" data-type="number"/>
  15. <xsl:if test="position() = last()">
  16. <xsl:value-of select="string-length(@module)"/>
  17. </xsl:if>
  18. </xsl:for-each>
  19. </xsl:variable>
  20. <xsl:variable name="max_imprecision_width" select="string-length('100.00% imprecise')"/>
  21. <xsl:variable name="max_loc_width" select="string-length(concat(sum(file/@total), ' LOC'))"/>
  22. <xsl:text>+-</xsl:text>
  23. <xsl:value-of select="str:padding($max_module_width, '-')"/>
  24. <xsl:text>-+-</xsl:text>
  25. <xsl:value-of select="str:padding($max_imprecision_width, '-')"/>
  26. <xsl:text>-+-</xsl:text>
  27. <xsl:value-of select="str:padding($max_loc_width, '-')"/>
  28. <xsl:text>-+&#10;</xsl:text>
  29. <xsl:text>| </xsl:text>
  30. <xsl:value-of select="'Module'"/>
  31. <xsl:value-of select="str:padding($max_module_width - string-length('Module'), ' ')"/>
  32. <xsl:text> | </xsl:text>
  33. <xsl:value-of select="'Imprecision'"/>
  34. <xsl:value-of select="str:padding($max_imprecision_width - string-length('Imprecision'), ' ')"/>
  35. <xsl:text> | </xsl:text>
  36. <xsl:value-of select="'Lines'"/>
  37. <xsl:value-of select="str:padding($max_loc_width - string-length('Lines'), ' ')"/>
  38. <xsl:text> |&#10;</xsl:text>
  39. <xsl:text>+-</xsl:text>
  40. <xsl:value-of select="str:padding($max_module_width, '-')"/>
  41. <xsl:text>-+-</xsl:text>
  42. <xsl:value-of select="str:padding($max_imprecision_width, '-')"/>
  43. <xsl:text>-+-</xsl:text>
  44. <xsl:value-of select="str:padding($max_loc_width, '-')"/>
  45. <xsl:text>-+&#10;</xsl:text>
  46. <xsl:for-each select="file">
  47. <xsl:variable name="score" select="(@imprecise + @any) div (@total + not(number(@total)))"/>
  48. <xsl:variable name="imprecision" select="concat(format-number($score, '0.00%'), ' imprecise')"/>
  49. <xsl:variable name="lines" select="concat(@total, ' LOC')"/>
  50. <xsl:text>| </xsl:text>
  51. <xsl:value-of select="@module"/>
  52. <xsl:value-of select="str:padding($max_module_width - string-length(@module), ' ')"/>
  53. <xsl:text> | </xsl:text>
  54. <xsl:value-of select="str:padding($max_imprecision_width - string-length($imprecision), ' ')"/>
  55. <xsl:value-of select="$imprecision"/>
  56. <xsl:text> | </xsl:text>
  57. <xsl:value-of select="str:padding($max_loc_width - string-length($lines), ' ')"/>
  58. <xsl:value-of select="$lines"/>
  59. <xsl:text> |&#10;</xsl:text>
  60. </xsl:for-each>
  61. <xsl:text>+-</xsl:text>
  62. <xsl:value-of select="str:padding($max_module_width, '-')"/>
  63. <xsl:text>-+-</xsl:text>
  64. <xsl:value-of select="str:padding($max_imprecision_width, '-')"/>
  65. <xsl:text>-+-</xsl:text>
  66. <xsl:value-of select="str:padding($max_loc_width, '-')"/>
  67. <xsl:text>-+&#10;</xsl:text>
  68. <xsl:variable name="total" select="sum(file/@total)"/>
  69. <xsl:variable name="score" select="(sum(file/@imprecise|file/@any)) div ($total + not(number($total)))"/>
  70. <xsl:variable name="imprecision" select="concat(format-number($score, '0.00%'), ' imprecise')"/>
  71. <xsl:variable name="lines" select="concat($total, ' LOC')"/>
  72. <xsl:text>| </xsl:text>
  73. <xsl:value-of select="'Total'"/>
  74. <xsl:value-of select="str:padding($max_module_width - string-length('Total'), ' ')"/>
  75. <xsl:text> | </xsl:text>
  76. <xsl:value-of select="str:padding($max_imprecision_width - string-length($imprecision), ' ')"/>
  77. <xsl:value-of select="$imprecision"/>
  78. <xsl:text> | </xsl:text>
  79. <xsl:value-of select="str:padding($max_loc_width - string-length($lines), ' ')"/>
  80. <xsl:value-of select="$lines"/>
  81. <xsl:text> |&#10;</xsl:text>
  82. <xsl:text>+-</xsl:text>
  83. <xsl:value-of select="str:padding($max_module_width, '-')"/>
  84. <xsl:text>-+-</xsl:text>
  85. <xsl:value-of select="str:padding($max_imprecision_width, '-')"/>
  86. <xsl:text>-+-</xsl:text>
  87. <xsl:value-of select="str:padding($max_loc_width, '-')"/>
  88. <xsl:text>-+&#10;</xsl:text>
  89. </xsl:template>
  90. </xsl:stylesheet>