Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

First steps in getting diffs working again #763

Merged
merged 3 commits into from Feb 12, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions .travis.yml
Expand Up @@ -3,5 +3,8 @@ language: java
install: true
script: ./gradlew --stacktrace

before_install:
- tools/difftools.sh

after_success:
- tools/travis-publish-spec.sh
20 changes: 15 additions & 5 deletions build.gradle
Expand Up @@ -80,6 +80,15 @@ def getenv(String name) {
}
}

def deltaxml() {
def dxml = new File("deltaxml")
if (dxml.exists() && dxml.isDirectory()) {
return "diff"
} else {
return ""
}
}

// ======================================================================
// Make sure that some build artifacts get published so that they
// can be used by the build process for the steps
Expand Down Expand Up @@ -175,6 +184,10 @@ task overview(dependsOn: [ "xproc_schemas", "spec_schemas",
param("travis-tag", getenv("TRAVIS_TAG"))

option("style", new File("tools/xsl/xproc-specs.xsl"))
option("diff", deltaxml())
option("specid", "overview")
option("diffloc", new File("build/dist/overview/diff.html").getAbsolutePath())

pipeline "tools/xpl/formatspec.xpl"
}
buildspecs.dependsOn "overview"
Expand Down Expand Up @@ -212,8 +225,8 @@ task xproc(dependsOn: [ "xproc_schemas", "spec_schemas",
param("travis-tag", getenv("TRAVIS_TAG"))

option("style", new File("tools/xsl/xproc-specs.xsl"))
option("diffkey", getenv("DELTAXML_DIFF_KEY"))
option("webid", "xproc")
option("diff", deltaxml())
option("specid", "xproc")
option("diffloc", new File("build/dist/xproc/diff.html").getAbsolutePath())

pipeline "tools/xpl/formatspec.xpl"
Expand All @@ -238,9 +251,6 @@ task xproc_pdf_xform(dependsOn: [ "xproc" ], type: DocBookTask) {

option("style", new File("tools/xsl/xproc-pdf.xsl"))
option("postprocess", new File("tools/xsl/post-pdf.xsl"))
option("diffkey", getenv("DELTAXML_DIFF_KEY"))
option("webid", "xproc")
option("diffloc", new File("build/dist/xproc/diff.html").getAbsolutePath())

pipeline "tools/xpl/pdfspec.xpl"
}
Expand Down
Binary file added tools/difftools.enc
Binary file not shown.
7 changes: 7 additions & 0 deletions tools/difftools.sh
@@ -0,0 +1,7 @@
#!/bin/bash

if [ "$DIFFPASSPHRASE" != "" ]; then
openssl aes-256-cbc -d -k $DIFFPASSPHRASE -in tools/difftools.enc -out diff.tar.gz
tar zxf diff.tar.gz
rm -f diff.tar.gz
fi
65 changes: 40 additions & 25 deletions tools/xpl/formatspec.xpl
Expand Up @@ -13,9 +13,9 @@
</p:output>
<p:serialization port="result" indent="false" method="xhtml"/>
<p:option name="style" select="'dbspec.xsl'"/>
<p:option name="diffkey" select="''"/>
<p:option name="webid" select="'xproc'"/>
<p:option name="diffloc" select="'/tmp/diff.html'"/>
<p:option name="diffloc" select="'build/diff.html'"/>
<p:option name="diff" select="''"/>
<p:option name="specid" select="''"/>

<p:import href="https://cdn.docbook.org/release/latest/xslt/base/pipelines/docbook.xpl"/>

Expand Down Expand Up @@ -56,32 +56,47 @@
select="substring-after(
/c:result/c:env[@name='TRAVIS_REPO_SLUG']/@value,
'/')"/>
<p:with-param name="auto-diff" select="$diffkey != ''"/>
<p:with-param name="auto-diff" select="$diff != '' and $specid != ''"/>
</dbp:docbook>

<p:wrap match="/" wrapper="c:body"/>
<p:add-attribute match="/c:body" attribute-name="content-type"
attribute-value="application/xml+html"/>

<p:escape-markup/>

<p:wrap match="/" wrapper="c:request"/>
<p:add-attribute match="/c:request" attribute-name="method"
attribute-value="post"/>
<p:add-attribute match="/c:request" attribute-name="href">
<p:with-option name="attribute-value"
select="concat('https://dataapi.nwalsh.com/dxml/cgi-bin/deltaxml.pl?',
'key=', $diffkey, '&amp;webid=', $webid)"/>
</p:add-attribute>

<p:choose>
<p:when test="$diffkey != ''">
<p:http-request/>
<p:unescape-markup/>
<p:unwrap match="/c:body"/>
<p:store method="html">
<p:with-option name="href" select="$diffloc"/>
<p:when test="$diff != '' and $specid != ''"
xmlns:html="http://www.w3.org/1999/xhtml">
<!-- The id values on paragraphs that contain code often change;
these changed ids confuse the diff tool. Just remove them.
It might break a link or two, but it's worth it for clean
differences.
-->
<p:delete match="html:p[//html:code]/@id">
<p:input port="source">
<p:document href="http://spec.xproc.org/master/head/xproc/"/>
</p:input>
</p:delete>
<p:store name="fix1">
<p:with-option name="href" select="concat('../../build/', $specid, '-current.html')"/>
</p:store>

<p:delete match="html:p[//html:code]/@id" cx:depends-on="fix1">
<p:input port="source">
<p:pipe step="format-docbook" port="result"/>
</p:input>
</p:delete>
<p:store name="fix2">
<p:with-option name="href" select="concat('../../build/', $specid, '-updated.html')"/>
</p:store>

<!-- This is exec'd instead of cx:delta-xml'd because the newest version
of Delta XML seems to require SaxonPE which it ships with but
we don't have. :-( -->
<p:exec command="java" result-is-xml="false" cx:depends-on="fix2">
<p:input port="source"><p:empty/></p:input>
<p:with-option name="args"
select="concat('-jar deltaxml/command-10.0.0.jar compare xhtml ',
'build/', $specid, '-current.html build/', $specid, '-updated.html ', $diffloc)">
<p:empty/>
</p:with-option>
</p:exec>
<p:sink/>
</p:when>
<p:otherwise>
<p:sink/>
Expand Down