Whamcloud - gitweb
LUDOC-13: diff works for doc changes. 09/1909/7
authorRichard Henwood <rhenwood@whamcloud.com>
Fri, 30 Dec 2011 21:31:23 +0000 (15:31 -0600)
committerRichard Henwood <rhenwood@whamcloud.com>
Thu, 5 Jan 2012 21:29:58 +0000 (15:29 -0600)
make diff now creates a annotated html file highlighting the differences between
master and review manual builds.

Signed-off-by: Richard Henwood <rhenwood@whamcloud.com>
Change-Id: Iec9a83b162697e17e894486c54090fbd406c2dff

Makefile
tools/diff.py

index b97f6ec..6fa2c86 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -5,7 +5,9 @@ TMP?=/tmp
 
 TGT_BASE=lustre_manual
 MASTER_URL=http://build.whamcloud.com/job/lustre-manual/lastSuccessfulBuild/
-MASTER_XHTML=$(MASTER_URL)/artifact/_out/$(TGT_BASE).xhtml
+MASTER_URL_LAB=http://build.lab.whamcloud.com:8080/job/lustre-manual/lastSuccessfulBuild/
+MASTER_XHTML=$(MASTER_URL)/artifact/$(TGT_BASE).xhtml
+MASTER_XHTML_LAB=$(MASTER_URL_LAB)/artifact/$(TGT_BASE).xhtml
 TGT_MASTER=$(TMP)/mastermanual
 
 
@@ -23,7 +25,7 @@ XSL=$(or $(shell ls -d $(XSL_UBN) 2> /dev/null), \
         $(shell ls -d $(XSL_MAC) 2> /dev/null))
 
 .PHONY: all
-all: clean xhtml html pdf
+all: clean check xhtml html pdf diff
 
 .PHONY: check
 check: $(SRC_XML)
@@ -53,19 +55,20 @@ pdf: $(TGT_BASE).pdf
 # get the git hash for the last successful build of the manual
 .PHONY: mastermanual.revision
 mastermanual.revision:
-       wget -O mastermanual.index $(MASTER_URL)
+       wget -O mastermanual.index $(MASTER_URL) || wget -O mastermanual.index $(MASTER_URL_LAB)
        awk '/Revision/ { print $$NF }' mastermanual.index > mastermanual.revision
 
 # only fetch the full manual if we don't have it or the manual changed
 $(TGT_MASTER).xhtml: mastermanual.revision
        if ! cmp -s mastermanual.revision $(TGT_MASTER).revision ; then\
-               wget -O $(TGT_MASTER).xhtml $(MASTER_XHTML) && \
+               (wget -O $(TGT_MASTER).xhtml $(MASTER_XHTML) || \
+               wget -O $(TGT_MASTER).xhtml $(MASTER_XHTML_LAB)) && \
                mv mastermanual.revision $(TGT_MASTER).revision;\
        fi
 
 .PHONY: diff
 diff: $(TGT_BASE).xhtml $(TGT_MASTER).xhtml
-       ./tools/diff.py $(TGT_MASTER).xhtml $(TGT_BASE).xhtml > $(TGT_BASE).diff
+       ./tools/diff.py $(TGT_MASTER).xhtml $(TGT_BASE).xhtml > $(TGT_BASE).diff.html
 
 
 .PHONY: push
index 0c8036c..f407784 100755 (executable)
@@ -21,11 +21,22 @@ def textDiff(a, b):
             # @@ need to do something more complicated here
             # call textDiff but not for html, but for some html... ugh
             # gonna cop-out for now
-            out.append('<span class="replace" style="background-color: Pink; text-decoration: line-through;">'+''.join(a[e[1]:e[2]]) + '</span><span class="insert" style="background-color: PaleGreen;">'+''.join(b[e[3]:e[4]])+"</span>")
+            # I've put this hack in to try accomodate id's generated by docbook compilation. RJH 30/12/2011
+            if '<a id="id' in a[e[1]:e[2]][0] or \
+                    '<a href="#id' in a[e[1]:e[2]][0] or \
+                    '<a id="ftn.id' in a[e[1]:e[2]][0] or \
+                    '<a class="indexterm" href="#id' in a[e[1]:e[2]][0] or \
+                    '<a id="id' in b[e[3]:e[4]][0] or \
+                    '<a href="#id' in b[e[3]:e[4]][0] or \
+                    '<a id="ftn.id' in b[e[3]:e[4]][0] or \
+                    '<a class="indexterm" href="#id' in b[e[3]:e[4]][0]:
+                out.append(''.join(b[e[3]:e[4]]))
+            else:
+                out.append('<a name="change"><span class="replace" style="background-color: Pink; text-decoration: line-through;">'+''.join(a[e[1]:e[2]]) + '</span><span class="insert" style="background-color: PaleGreen;">'+''.join(b[e[3]:e[4]])+"</span></a>")
         elif e[0] == "delete":
-            out.append('<span class="del" style="background-color: Pink; text-decoration: line-through;">' + ''.join(a[e[1]:e[2]]) + "</span>")
+            out.append('<a name="change"><span class="del" style="background-color: Pink; text-decoration: line-through;">' + ''.join(a[e[1]:e[2]]) + "</span></a>")
         elif e[0] == "insert":
-            out.append('<span class="ins" style="background-color: PaleGreen;">'+''.join(b[e[3]:e[4]]) + "</span>")
+            out.append('<a name="change"><span class="ins" style="background-color: PaleGreen;">'+''.join(b[e[3]:e[4]]) + "</span></a>")
         elif e[0] == "equal":
             out.append(''.join(b[e[3]:e[4]]))
         else: