summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShaun McCance <shaunm@gnome.org>2011-05-23 12:15:16 -0400
committerShaun McCance <shaunm@gnome.org>2011-05-23 12:15:16 -0400
commit12b20239fff364777538129ac11d08f2a05c9ad1 (patch)
treeaa166105c726c7ae2633da913bf4f414ff4ea836
parentc6a5f8d46bf08983f730e2c8efd37be05d9a78e5 (diff)
downloadyelp-tools-12b20239fff364777538129ac11d08f2a05c9ad1.tar.gz
yelp-check: Mallard page status checker
-rwxr-xr-xtools/yelp-check.in97
-rw-r--r--xslt/Makefile.am1
-rw-r--r--xslt/mal-status.xsl81
3 files changed, 179 insertions, 0 deletions
diff --git a/tools/yelp-check.in b/tools/yelp-check.in
index cf38761..4c8006a 100755
--- a/tools/yelp-check.in
+++ b/tools/yelp-check.in
@@ -17,6 +17,7 @@
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
xsl_mal_link='@XSL_MAL_LINK@'
+xsl_mal_status='@DATADIR@/xslt/mal-status.xsl'
xsl_mal_rng='@DATADIR@/xslt/mal-rng.xsl'
urlencode () {
@@ -52,6 +53,7 @@ yelp_usage () {
echo "Commands:"
echo " orphans Find orphaned pages in a Mallard document"
echo " links Find broken xref links in a Mallard document"
+ echo " status Report the status of Mallard pages"
echo " validate Validate files against a DTD or RNG"
) 1>&2
}
@@ -77,6 +79,24 @@ yelp_usage_orphans () {
echo " -c CACHE Use the existing Mallard cache CACHE"
) 1>&2
}
+yelp_usage_status () {
+ (
+ echo "Usage: yelp-check status <FILES>"
+ echo ""
+ echo " Report the status of the Mallard page files <FILES>. Each"
+ echo " matching page is reporting along with its status."
+ echo ""
+ echo "Options:"
+ echo " --version VER Select revisions with the version attribute VER"
+ echo " --docversion VER Select revisions with the docversion attribute VER"
+ echo " --pkgversion VER Select revisions with the pkgversion attribute VER"
+ echo " --older DATE Only show pages older than DATE"
+ echo " --newer DATE Only show pages newer than DATE"
+ echo " --only STATUSES Only show pages whose status is in STATUSES"
+ echo " --except STATUSES Exclude pages whose status is in STATUSES"
+ echo "For --only and --except, STATUSES is a space-separated list."
+ ) 1>&2
+}
yelp_usage_validate () {
(
echo "Usage: yelp-check validate <FILES>"
@@ -144,6 +164,10 @@ yelp_links () {
;;
esac
done
+ if [ "$#" = "0" -o "x$1" = "x--help" ]; then
+ yelp_usage_links
+ exit 1
+ fi
if [ "x$check_cache_file" != "x" ]; then
check_cache_file=`(cd $(dirname "$check_cache_file") && pwd)`/`basename "$check_cache_file"`
else
@@ -214,6 +238,10 @@ yelp_orphans () {
;;
esac
done
+ if [ "$#" = "0" -o "x$1" = "x--help" ]; then
+ yelp_usage_orphans
+ exit 1
+ fi
if [ "x$check_cache_file" != "x" ]; then
check_cache_file=`(cd $(dirname "$check_cache_file") && pwd)`/`basename "$check_cache_file"`
else
@@ -241,6 +269,72 @@ yelp_orphans () {
exit $ret
}
+yelp_status () {
+ if [ "$#" = "0" -o "x$1" = "x--help" ]; then
+ yelp_usage_status
+ exit 1
+ fi
+ while [ "$#" != "0" ]; do
+ case "$1" in
+ "--version")
+ shift
+ check_version="$1"
+ shift
+ ;;
+ "--docversion")
+ shift
+ check_docversion="$1"
+ shift
+ ;;
+ "--pkgversion")
+ shift
+ check_pkgversion="$1"
+ shift
+ ;;
+ "--older")
+ shift
+ check_older="$1"
+ shift
+ ;;
+ "--newer")
+ shift
+ check_newer="$1"
+ shift
+ ;;
+ "--only")
+ shift
+ check_only="$1"
+ shift
+ ;;
+ "--except")
+ shift
+ check_except="$1"
+ shift
+ ;;
+ *)
+ break
+ ;;
+ esac
+ done
+ if [ "$#" = "0" -o "x$1" = "x--help" ]; then
+ yelp_usage_status
+ exit 1
+ fi
+ check_cache_file=`mktemp`
+ yelp-build cache -o "$check_cache_file" "$@"
+ xsltproc \
+ --stringparam version "$check_version" \
+ --stringparam docversion "$check_docversion" \
+ --stringparam pkgversion "$check_pkgversion" \
+ --stringparam newer "$check_newer" \
+ --stringparam older "$check_older" \
+ --stringparam only "$check_only" \
+ --stringparam except "$check_except" \
+ "$xsl_mal_status" "$check_cache_file"
+ rm "$check_cache_file"
+ return 0
+}
+
yelp_validate_page () {
# Using temp files because pipes create subshells, making it really
# hard to return the right exit status in a portable way.
@@ -315,6 +409,9 @@ case "x$cmd" in
"xorphans")
yelp_orphans "$@"
;;
+ "xstatus")
+ yelp_status "$@"
+ ;;
"xvalidate")
yelp_validate "$@"
;;
diff --git a/xslt/Makefile.am b/xslt/Makefile.am
index de4eee2..4d4aa7c 100644
--- a/xslt/Makefile.am
+++ b/xslt/Makefile.am
@@ -4,6 +4,7 @@ xsl_DATA = \
mal-epub.xsl \
mal-opf.xsl \
mal-ncx.xsl \
+ mal-status.xsl \
mal-rng.xsl
EXTRA_DIST = \
diff --git a/xslt/mal-status.xsl b/xslt/mal-status.xsl
new file mode 100644
index 0000000..11bf31d
--- /dev/null
+++ b/xslt/mal-status.xsl
@@ -0,0 +1,81 @@
+<xsl:stylesheet
+ xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+ xmlns:mal="http://projectmallard.org/1.0/"
+ xmlns:cache="http://projectmallard.org/cache/1.0/"
+ xmlns:exsl="http://exslt.org/common"
+ xmlns:dyn="http://exslt.org/dynamic"
+ exclude-result-prefixes="mal cache exsl dyn"
+ version="1.0">
+
+<xsl:output method="text"/>
+
+<xsl:param name="version" select="''"/>
+<xsl:param name="docversion" select="''"/>
+<xsl:param name="pkgversion" select="''"/>
+
+<xsl:param name="older" select="''"/>
+<xsl:param name="newer" select="''"/>
+
+<xsl:param name="only" select="''"/>
+<xsl:variable name="only_" select="concat(' ', $only, ' ')"/>
+<xsl:param name="except" select="''"/>
+<xsl:variable name="except_" select="concat(' ', $except, ' ')"/>
+
+<xsl:template match="/cache:cache">
+ <xsl:for-each select="mal:page">
+ <xsl:sort select="@id"/>
+ <xsl:variable name="select">
+ <xsl:text>mal:info/mal:revision</xsl:text>
+ <xsl:if test="$version != ''">
+ <xsl:text>[@version = '</xsl:text>
+ <xsl:value-of select="$version"/>
+ <xsl:text>']</xsl:text>
+ </xsl:if>
+ <xsl:if test="$docversion != ''">
+ <xsl:text>[@docversion = '</xsl:text>
+ <xsl:value-of select="$docversion"/>
+ <xsl:text>']</xsl:text>
+ </xsl:if>
+ <xsl:if test="$version != ''">
+ <xsl:text>[@pkgversion = '</xsl:text>
+ <xsl:value-of select="$pkgversion"/>
+ <xsl:text>']</xsl:text>
+ </xsl:if>
+ </xsl:variable>
+ <xsl:variable name="revision_">
+ <xsl:for-each select="dyn:evaluate($select)">
+ <xsl:sort select="@date" order="descending"/>
+ <xsl:if test="position() = 1">
+ <xsl:copy-of select="."/>
+ </xsl:if>
+ </xsl:for-each>
+ </xsl:variable>
+ <xsl:variable name="revision" select="exsl:node-set($revision_)/*"/>
+ <xsl:variable name="status">
+ <xsl:choose>
+ <xsl:when test="$revision and $revision/@status">
+ <xsl:value-of select="$revision/@status"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:text>none</xsl:text>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:variable>
+ <xsl:if test="$only = '' or contains($only_, concat(' ', $status, ' '))">
+ <xsl:if test="$except = '' or not(contains($except_, concat(' ', $status, ' ')))">
+ <xsl:if test="$older = '' or ($revision/@date and
+ (translate($revision/@date, '-', '') &lt; translate($older, '-', '')))">
+ <xsl:if test="$newer = '' or ($revision/@date and
+ (translate($revision/@date, '-', '') &gt; translate($newer, '-', '')))">
+ <xsl:value-of select="@id"/>
+ <xsl:text>: </xsl:text>
+ <xsl:value-of select="$status"/>
+ <xsl:text>&#x000A;</xsl:text>
+ </xsl:if>
+ </xsl:if>
+ </xsl:if>
+ </xsl:if>
+ </xsl:for-each>
+</xsl:template>
+
+</xsl:stylesheet>