mirror of
https://github.com/boostorg/boostbook.git
synced 2025-05-09 23:13:58 +00:00
Compare formatted XML files in the Doxygen test.
Comparing formatted XML files makes the comparison less sensitive to whitespace and newline differences between XML documents, and also makes the subsequent diff more informative, if any differences are found.
This commit is contained in:
parent
5bdebb90a4
commit
fe6f1a818f
1
test/doxygen/.gitignore
vendored
1
test/doxygen/.gitignore
vendored
@ -1 +1,2 @@
|
||||
html
|
||||
autodoc.xml
|
||||
|
@ -1,10 +1,12 @@
|
||||
|
||||
# Copyright 2009 Daniel James.
|
||||
# Copyright 2024 Andrey Semashev
|
||||
# Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
using boostbook ;
|
||||
using doxygen ;
|
||||
import xsltproc ;
|
||||
import make ;
|
||||
import os ;
|
||||
|
||||
doxygen autodoc
|
||||
@ -14,13 +16,22 @@ doxygen autodoc
|
||||
<xsl:param>"boost.doxygen.reftitle=Example Reference"
|
||||
;
|
||||
|
||||
# Applies format.xsl to an XML file to reduce potential newline/whitespace
|
||||
# differences and make the subsequent diff more informative.
|
||||
rule format-xml ( target : source : properties * )
|
||||
{
|
||||
xsltproc.xslt $(target) : $(source) format.xsl : $(properties) ;
|
||||
}
|
||||
|
||||
make autodoc.xml.formatted : autodoc.xml : format-xml ;
|
||||
make autodoc.gold.formatted : autodoc.gold : format-xml ;
|
||||
|
||||
if [ os.name ] = NT
|
||||
{
|
||||
actions compare
|
||||
{
|
||||
comp /A $(>[1]) $(>[2]) && echo "Stamped" >$(<)
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -30,7 +41,7 @@ else
|
||||
}
|
||||
}
|
||||
|
||||
make check : autodoc.xml autodoc.gold : @compare ;
|
||||
make check : autodoc.xml.formatted autodoc.gold.formatted : @compare ;
|
||||
|
||||
boostbook standalone
|
||||
:
|
||||
|
52
test/doxygen/format.xsl
Normal file
52
test/doxygen/format.xsl
Normal file
@ -0,0 +1,52 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
Copyright (c) 2024 Andrey Semashev
|
||||
|
||||
Distributed under the Boost Software License, Version 1.0.
|
||||
(See accompanying file LICENSE_1_0.txt or copy at
|
||||
http://www.boost.org/LICENSE_1_0.txt)
|
||||
-->
|
||||
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
|
||||
<xsl:output method="xml" encoding="utf-8"/>
|
||||
<xsl:param name="indent-step" select="' '"/>
|
||||
|
||||
<xsl:template match="processing-instruction() | comment()">
|
||||
<xsl:param name="indent" select="''"/>
|
||||
|
||||
<xsl:text> </xsl:text><!-- Newline -->
|
||||
<xsl:value-of select="$indent"/>
|
||||
<xsl:copy/>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="text()">
|
||||
<xsl:param name="indent" select="''"/>
|
||||
|
||||
<xsl:if test="normalize-space(.) != ''">
|
||||
<xsl:text> </xsl:text><!-- Newline -->
|
||||
<xsl:value-of select="$indent"/>
|
||||
<xsl:value-of select="normalize-space(.)"/>
|
||||
</xsl:if>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="*">
|
||||
<xsl:param name="indent" select="''"/>
|
||||
|
||||
<xsl:text> </xsl:text><!-- Newline -->
|
||||
<xsl:value-of select="$indent"/>
|
||||
<xsl:choose>
|
||||
<xsl:when test="count(./*) > 0">
|
||||
<xsl:copy>
|
||||
<xsl:copy-of select="@*"/>
|
||||
<xsl:apply-templates>
|
||||
<xsl:with-param name="indent" select="concat($indent, $indent-step)"/>
|
||||
</xsl:apply-templates>
|
||||
<xsl:text> </xsl:text><!-- Newline -->
|
||||
<xsl:value-of select="$indent"/>
|
||||
</xsl:copy>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:copy-of select="."/>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:template>
|
||||
</xsl:stylesheet>
|
Loading…
x
Reference in New Issue
Block a user