[yelp-tools] yelp-check: Added command to check Mallard page IDs



commit a43c830b303c117214201d4af37e67baa6e455e5
Author: Shaun McCance <shaunm gnome org>
Date:   Sat Jul 13 16:36:53 2013 -0400

    yelp-check: Added command to check Mallard page IDs

 tools/yelp-check.in |   52 +++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 52 insertions(+), 0 deletions(-)
---
diff --git a/tools/yelp-check.in b/tools/yelp-check.in
index a258290..f566a37 100755
--- a/tools/yelp-check.in
+++ b/tools/yelp-check.in
@@ -85,6 +85,7 @@ yelp_usage () {
         echo "Commands:"
         echo "  comments      Print the editorial comments in a document"
         echo "  hrefs         Find broken external links in a document"
+        echo "  ids           Find Mallard page IDs that do not match file names"
         echo "  links         Find broken xref or linkend links in a document"
         echo "  orphans       Find orphaned pages in a Mallard document"
         echo "  status        Report the status of Mallard pages"
@@ -99,6 +100,14 @@ yelp_usage_hrefs () {
         echo "  broken ulink or XLink links in FILES in a DocBook document."
     ) 1>&2
 }
+yelp_usage_ids () {
+    (
+        echo "Usage: yelp-check ids <FILES>"
+        echo ""
+        echo "  Find pages in a Mallard document whose page ID does not match"
+        echo "  the base file name of the page file."
+    ) 1>&2
+}
 yelp_usage_links () {
     (
         echo "Usage: yelp-check links <FILES>"
@@ -242,6 +251,46 @@ yelp_hrefs () {
     done
 }
 
+yelp_ids_page () {
+    pageid=$((
+        echo '<xsl:stylesheet'
+        echo ' xmlns:xsl="http://www.w3.org/1999/XSL/Transform";'
+        echo ' xmlns:mal="http://projectmallard.org/1.0/";'
+        echo ' version="1.0">'
+        echo '<xsl:output method="text"/>'
+        echo '<xsl:template match="/mal:page">'
+        echo '<xsl:value-of select="@id"/>'
+        echo '</xsl:template>'
+        echo '</xsl:stylesheet>'
+    ) | xsltproc --xinclude - "$1")
+    if [ "$pageid.page" != `basename "$1"` ]; then
+        if [ `dirname "$1"` = '.' ]; then
+            echo `basename "$1"`": $pageid"
+        else
+            echo "$1: $pageid"
+        fi
+        exit 1
+    fi
+}
+
+yelp_ids () {
+    if [ "$#" = "0" -o "x$1" = "x--help" ]; then
+        yelp_usage_ids
+        exit 1
+    fi
+    ret=0
+    for xml in "$@"; do
+        if [ -d "$xml" ]; then
+            for page in "$xml"/*.page; do
+                yelp_ids_page "$page" || ret=$?
+            done
+        else
+            yelp_ids_page "$xml" || ret=$?
+        fi
+    done
+    exit $ret
+}
+
 yelp_links_db () {
     (
         echo '<xsl:stylesheet'
@@ -621,6 +670,9 @@ case "x$cmd" in
     "xhrefs")
         yelp_hrefs "$@"
         ;;
+    "xids")
+        yelp_ids "$@"
+        ;;
     "xlinks")
         yelp_links "$@"
         ;;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]