Author: paul
Date: 2006-11-17 16:50:07 +0100 (Fri, 17 Nov 2006)
New Revision: 3965
Log:
r12161@frost: paul | 2006-11-17 09:49:54 -0600
make file.check-listing to look for long programlisting lines.
Added:
trunk/make.d/xml-listing
trunk/xsl.d/check-listing.xsl
Modified:
trunk/make.d/vars-docbook
trunk/refman-4.1/Makefile
trunk/refman-5.0/Makefile
trunk/refman-5.1/Makefile
Property changes on: trunk
___________________________________________________________________
Name: svk:merge
- 4767c598-dc10-0410-bea0-d01b485662eb:/mysqldoc-local/mysqldoc/trunk:15744
7d8d2c4e-af1d-0410-ab9f-b038ce55645b:/mysqldoc-local/mysqldoc:12151
b5ec3a16-e900-0410-9ad2-d183a3acac99:/mysqldoc-local/mysqldoc/trunk:14218
bf112a9c-6c03-0410-a055-ad865cd57414:/mysqldoc-local/mysqldoc/trunk:11932
+ 4767c598-dc10-0410-bea0-d01b485662eb:/mysqldoc-local/mysqldoc/trunk:15744
7d8d2c4e-af1d-0410-ab9f-b038ce55645b:/mysqldoc-local/mysqldoc:12161
b5ec3a16-e900-0410-9ad2-d183a3acac99:/mysqldoc-local/mysqldoc/trunk:14218
bf112a9c-6c03-0410-a055-ad865cd57414:/mysqldoc-local/mysqldoc/trunk:11757
Modified: trunk/make.d/vars-docbook
===================================================================
--- trunk/make.d/vars-docbook 2006-11-17 14:59:10 UTC (rev 3964)
+++ trunk/make.d/vars-docbook 2006-11-17 15:50:07 UTC (rev 3965)
Changed blocks: 1, Lines Added: 5, Lines Deleted: 0; 589 bytes
@@ -294,6 +294,11 @@
EXTRACT_TITLES_XSL = $(XSL_DIR)/extract-titles.xsl
EXTRACT_TITLES_XSL_DEPS = $(EXTRACT_TITLES_XSL)
+# Transform that checks <programlisting> line lengths
+
+CHECK_LISTING_XSL = $(XSL_DIR)/check-listing.xsl
+CHECK_LISTING_XSL_DEPS = $(CHECK_LISTING_XSL)
+
# ----------------------------------------------------------------------
# Make macros
Added: trunk/make.d/xml-listing
===================================================================
--- trunk/make.d/xml-listing (rev 0)
+++ trunk/make.d/xml-listing 2006-11-17 15:50:07 UTC (rev 3965)
Changed blocks: 1, Lines Added: 7, Lines Deleted: 0; 442 bytes
@@ -0,0 +1,7 @@
+# Check <programlisting> line lengths
+
+%.check-listing: %.xml $(CHECK_LISTING_XSL_DEPS)
+ $(XSLTPROC) $(CHECK_LISTING_XSL) $<
+
+help::
+ @echo "make file.check-listing - check <programlisting> line lengths"
Modified: trunk/refman-4.1/Makefile
===================================================================
--- trunk/refman-4.1/Makefile 2006-11-17 14:59:10 UTC (rev 3964)
+++ trunk/refman-4.1/Makefile 2006-11-17 15:50:07 UTC (rev 3965)
Changed blocks: 1, Lines Added: 1, Lines Deleted: 0; 419 bytes
@@ -143,6 +143,7 @@
include $(MAKE_DIR)/xml-titles
include $(MAKE_DIR)/fragment-files
include $(MAKE_DIR)/xml-depend
+include $(MAKE_DIR)/xml-listing
# Import directory specific extensions
Modified: trunk/refman-5.0/Makefile
===================================================================
--- trunk/refman-5.0/Makefile 2006-11-17 14:59:10 UTC (rev 3964)
+++ trunk/refman-5.0/Makefile 2006-11-17 15:50:07 UTC (rev 3965)
Changed blocks: 1, Lines Added: 1, Lines Deleted: 0; 419 bytes
@@ -152,6 +152,7 @@
include $(MAKE_DIR)/xml-titles
include $(MAKE_DIR)/fragment-files
include $(MAKE_DIR)/xml-depend
+include $(MAKE_DIR)/xml-listing
# Import directory specific extensions
Modified: trunk/refman-5.1/Makefile
===================================================================
--- trunk/refman-5.1/Makefile 2006-11-17 14:59:10 UTC (rev 3964)
+++ trunk/refman-5.1/Makefile 2006-11-17 15:50:07 UTC (rev 3965)
Changed blocks: 1, Lines Added: 1, Lines Deleted: 0; 419 bytes
@@ -151,6 +151,7 @@
include $(MAKE_DIR)/xml-titles
include $(MAKE_DIR)/fragment-files
include $(MAKE_DIR)/xml-depend
+include $(MAKE_DIR)/xml-listing
# Import directory specific extensions
Added: trunk/xsl.d/check-listing.xsl
===================================================================
--- trunk/xsl.d/check-listing.xsl (rev 0)
+++ trunk/xsl.d/check-listing.xsl 2006-11-17 15:50:07 UTC (rev 3965)
Changed blocks: 1, Lines Added: 151, Lines Deleted: 0; 5366 bytes
@@ -0,0 +1,151 @@
+<?xml version="1.0"?>
+
+<!--
+ check-listing.xsl - check <programlisting> element line lengths
+
+ - Flag lines in <programlisting> elements longer than 72 characters.
+ - If the <programlisting> occurs within a list, substract 5 from maximum
+ allowable length for each nesting level.
+ - If the element is the *first* content element in a section, the maximum
+ line length is 60. We identify these elements based on the hueristic that
+ they'll immediately follow one of the <remark role="help-syntax"/> or
+ <remark role="help-syntax-begin"/> help markup tags. If a section is
+ missing help markup, it won't be identified properly. Perhaps a
+ more reliable means of identifying these <programlisting> elements
+ would be to find those that immediately follow <title> after ignoring
+ <remark>, <indexterm>, and possibly other elements.
+
+ Paul DuBois
+ paul@stripped
+ 2006-11-17
+-->
+
+<xsl:stylesheet
+ version="1.0"
+ xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
+
+<xsl:output method="text"/>
+
+<!--
+ Parameters:
+ - Maximum allowable line length
+ - Amount to decrement max length per nesting level
+ - Maximum allowable line length for listings that are first content element
+ in the containing section
+-->
+<xsl:param name="max.line.length" select="72"/>
+<xsl:param name="nesting.decrement" select="5"/>
+<xsl:param name="max.initial.listing.line.length" select="60"/>
+
+<!-- newline variable that contains a newline character -->
+<xsl:variable name="newline" select="'
'"/>
+
+<!--
+<xsl:template match="/">
+ <xsl:apply-templates select="//programlisting"/>
+</xsl:template>
+-->
+<xsl:template match="/ | *">
+ <xsl:apply-templates select="*"/>
+</xsl:template>
+
+<!--
+<xsl:template match="programlisting[preceding-sibling::*[1][self::remark[@role='help-syntax']]]">
+<xsl:message>FIRST LISTING:
+<xsl:value-of select="."/>
+</xsl:message>
+</xsl:template>
+-->
+
+<!--
+ programlisting
+ - Render body of programlisting into a variable (text only, no tags)
+ - Determine current max line length, taking list nesting into account
+ ("list" includes itemizedlist, orderedlist, variablelist)
+ - Pass body and line length to template that checks length of each line,
+ printing those that are two long; renderg result into a variable.
+ - If the variable is non-empty,
+-->
+
+<xsl:template match="programlisting">
+ <xsl:variable name="body">
+ <xsl:value-of select="."/>
+ </xsl:variable>
+ <xsl:variable name="nesting.depth">
+ <xsl:value-of select="count(ancestor::itemizedlist
+ |ancestor::orderedlist
+ |ancestor::variablelist)"
+ />
+ </xsl:variable>
+ <xsl:variable name="adjusted.line.length">
+ <xsl:choose>
+ <xsl:when test="preceding-sibling::*[1][
+ self::remark[@role='help-syntax']
+ |self::remark[@role='help-syntax-begin']
+ ]">
+ <xsl:value-of select="$max.initial.listing.line.length"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of select="$max.line.length
+ - ($nesting.decrement * $nesting.depth)"
+ />
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:variable>
+<!--
+ <xsl:value-of select="$adjusted.line.length"/>
+ <xsl:value-of select="$newline"/>
+ <xsl:value-of select="."/>
+-->
+ <xsl:variable name="long.lines">
+ <xsl:call-template name="check.listing">
+ <xsl:with-param name="body" select="$body"/>
+ <xsl:with-param name="line.length" select="$adjusted.line.length"/>
+ </xsl:call-template>
+ </xsl:variable>
+ <xsl:if test="string-length($long.lines)">
+ <xsl:text>-----</xsl:text>
+ <xsl:value-of select="$newline"/>
+ <xsl:text>Listing::</xsl:text>
+ <xsl:value-of select="$newline"/>
+ <xsl:value-of select="$body"/>
+ <xsl:value-of select="$newline"/>
+ <xsl:text>Maximum length: </xsl:text>
+ <xsl:value-of select="$adjusted.line.length"/>
+ <xsl:if test="$nesting.depth > 0">
+ <xsl:text> (nesting depth: </xsl:text>
+ <xsl:value-of select="$nesting.depth"/>
+ <xsl:text>)</xsl:text>
+ </xsl:if>
+ <xsl:value-of select="$newline"/>
+ <xsl:text>Too-long lines: </xsl:text>
+ <xsl:value-of select="$newline"/>
+ <xsl:value-of select="$long.lines"/>
+ </xsl:if>
+</xsl:template>
+
+<xsl:template name="check.listing">
+ <xsl:param name="body"/>
+ <xsl:param name="line.length"/>
+
+ <xsl:variable name="next" select="substring-before($body, '
')"/>
+ <xsl:variable name="rest" select="substring-after($body, '
')"/>
+
+ <!-- print next line of listing if too long (show length)-->
+ <xsl:if test="string-length($next) > $line.length">
+ <xsl:value-of select="string-length($next)"/>
+ <xsl:text>:</xsl:text>
+ <xsl:value-of select="$next"/>
+ <xsl:value-of select="$newline"/>
+ </xsl:if>
+
+ <!-- recurse to print rest if anything remains -->
+ <xsl:if test="$rest">
+ <xsl:call-template name="check.listing">
+ <xsl:with-param name="body" select="$rest"/>
+ <xsl:with-param name="line.length" select="$line.length"/>
+ </xsl:call-template>
+ </xsl:if>
+</xsl:template>
+
+</xsl:stylesheet>
| Thread |
|---|
| • svn commit - mysqldoc@docsrva: r3965 - in trunk: . make.d refman-4.1 refman-5.0 refman-5.1 xsl.d | paul | 17 Nov |