diff options
author | William S Fulton <wsf@fultondesigns.co.uk> | 2020-09-08 21:29:25 +0100 |
---|---|---|
committer | William S Fulton <wsf@fultondesigns.co.uk> | 2020-09-08 22:15:12 +0100 |
commit | 524b13a5a3c90ada5c3a794ed46cb661e6f2cb1f (patch) | |
tree | 8a203bb91a01c43d0b5d0c59f56ecd7aaaed8356 | |
parent | e59d91656d4d963f2357b140d114279441364e84 (diff) | |
download | swig-524b13a5a3c90ada5c3a794ed46cb661e6f2cb1f.tar.gz |
Add tool to compare old and new html files
-rwxr-xr-x | SphinxDocs/docdiffer.sh | 71 |
1 files changed, 71 insertions, 0 deletions
diff --git a/SphinxDocs/docdiffer.sh b/SphinxDocs/docdiffer.sh new file mode 100755 index 000000000..37d287e32 --- /dev/null +++ b/SphinxDocs/docdiffer.sh @@ -0,0 +1,71 @@ +#!/bin/bash + +# Tool to help diff the old and new documentation. +# Old documentation is in Doc/Manual/*.html +# New documentation is in SphinxDocs/source/Manual/*.rst + +# Before running install appropriate tools: +# sudo apt install pandoc python3-docutils html2text + +set -e + +usage() { + echo "Tool to help diff the old and new documentation:" + echo "Usage:" + echo " $0 [-d=<toolname>] | [-n] <name>" + echo " -n do not run a difftool" + echo " -d=<toolname> set difftool name to <toolname>, default is diff" + echo " <name> the basename of a documentation file, such as 'Java'" + exit 1 +} + +difftool=diff + +for i in "$@" +do + case $i in + --no-diff|-n) + difftool="" + shift + ;; + --difftool=*|-d=*) + difftool="${i#*=*}" + shift + ;; + -*) + usage + ;; + *) + file=$i + shift + ;; + esac +done + +if [[ -z "$file" ]] ; then + usage +fi + +# Remove chapter numbering in old html file +cp ../Doc/Manual/$file.html /tmp/$file-old.html +python ../Doc/Manual/makechap-no-numbering.py /tmp/$file-old.html 0 > /dev/null + +# Did not use html2text --body-width=0 as not available in Ubuntu's html2text +# https://github.com/aaronsw/html2text probably should be used +html2text /tmp/$file-old.html > /tmp/$file-old.txt +rst2html ../SphinxDocs/source/Manual/$file.rst > /tmp/$file-new.html + +# The sed below removes one * in headings. +# Done because the original html headings are one more than in the original than the new html. +# For example, H2 is used in original html and H1 is used in new html. +# H1 generates one more * after converted to text. +cat /tmp/$file-new.html | html2text | sed -e 's/^\*\*\*\(.*\)\*\*\*$/**\1**/' > /tmp/$file-new.txt + +if [[ -z "$difftool" ]] ; then + echo "Now run a diff tool such as:" + echo "diff /tmp/$file-old.txt /tmp/$file-new.txt" +else + echo "Running: $difftool /tmp/$file-old.txt /tmp/$file-new.txt" + $difftool /tmp/$file-old.txt /tmp/$file-new.txt +fi + |