Author: mvidner Date: Tue Jul 29 09:10:38 2008 New Revision: 49471 URL: http://svn.opensuse.org/viewcvs/yast?rev=49471&view=rev Log: Changes to assist a straightforward mapping between source code usage and reference docs URLs: list::reduce should be .../ycp/list/reduce.html, not .../YCPListBuiltins_reduce.html - Added a disambiguation chapter to provide links from add.html to add-list.html and add-map.html - This requires processing the entire document at once, not chapter-wise, so adjusted for that too. - In a @builtin @id, dot "." is used instead of quad "::" to delimit namespaces. They are output as subdirectories. Modified: trunk/devtools/docbook/stylesheets/ydoc.xsl Modified: trunk/devtools/docbook/stylesheets/ydoc.xsl URL: http://svn.opensuse.org/viewcvs/yast/trunk/devtools/docbook/stylesheets/ydoc... ============================================================================== --- trunk/devtools/docbook/stylesheets/ydoc.xsl (original) +++ trunk/devtools/docbook/stylesheets/ydoc.xsl Tue Jul 29 09:10:38 2008 @@ -1,53 +1,93 @@ -<?xml version="1.0" encoding="ISO-8859-1"?> +<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE xsl:stylesheet [ -<!ENTITY undocumented "[DOCS MISSING]"> +<!ENTITY undocumented ""> +<!ENTITY undocumented2 "[DOCS MISSING]"> ]> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> - <xsl:output method="xml" indent="yes" encoding="ISO-8859-1"/> + <xsl:output method="xml" indent="yes" encoding="UTF-8" /> <xsl:template match="/"> xsl:apply-templates/ + <xsl:call-template name="disambiguate" /> </xsl:template> - <xsl:template match="entries"> - <reference> - <xsl:attribute name="id"> - <xsl:value-of select="entries_item/filename"/> - </xsl:attribute> - <title> - <xsl:value-of select="entries_item/file_summary"/> - </title> - <xsl:for-each select="entries_item"> - <xsl:sort order="ascending" select="./names/names_item"/> - <xsl:apply-templates select="."/> - </xsl:for-each> + + <!-- googled "xslt grouping": + http://www.jenitennison.com/xslt/grouping/muenchian.html --> + <xsl:key name="entries-by-file" match="entries_item" use="filename" /> + <xsl:key name="entries-by-name" match="entries_item" use="names/names_item" /> + + <xsl:template match="yast2doc/entries"> + <xsl:for-each select="entries_item [ + count(. | key('entries-by-file', filename)[1]) = 1 + ]"> + <xsl:sort select="filename" /> + + <reference id="{filename}"> + <title> + <xsl:value-of select="file_summary"/> + </title> + <xsl:for-each select="key('entries-by-file', filename)"> + <xsl:sort select="names/names_item"/> + <xsl:apply-templates select="."/> + </xsl:for-each> </reference> + + </xsl:for-each> </xsl:template> + <xsl:template name="refentry-id-chunk-meta"> + <xsl:param name="use-id" select="/.." /> - <xsl:template match="entries_item"> - <refentry> - <xsl:attribute name="id"> - <xsl:if test="type != 'widget'"> - <xsl:value-of select="filename"/> - xsl:text_</xsl:text> - </xsl:if> + <!-- dirsep must be allowed in IDs --> + <xsl:variable name="dirsep">.</xsl:variable> + <xsl:variable name="id"> xsl:choose - <xsl:when test="id != ''"> - <xsl:value-of select="id"/> + <xsl:when test="$use-id != ''"> + <xsl:value-of select="$use-id"/> </xsl:when> xsl:otherwise <xsl:call-template name="replace-substring"> <xsl:with-param name="from" select="'::'" /> - <xsl:with-param name="to" select="'_'" /> + <xsl:with-param name="to" select="$dirsep" /> <xsl:with-param name="value" select="names/names_item"/> </xsl:call-template> </xsl:otherwise> - </xsl:choose> - <xsl:if test="type = 'widget'"> - xsl:text_widget</xsl:text> - </xsl:if> - </xsl:attribute> + </xsl:choose> + </xsl:variable> + <xsl:variable name="dir"> + <xsl:if test="contains($id, $dirsep)"> + <xsl:value-of select="substring-before($id, $dirsep)" /> + </xsl:if> + </xsl:variable> + <xsl:variable name="filename"> + xsl:choose + <xsl:when test="contains($id, $dirsep)"> + <xsl:value-of select="substring-after($id, $dirsep)" /> + </xsl:when> + xsl:otherwise + <xsl:value-of select="$id" /> + </xsl:otherwise> + </xsl:choose> + </xsl:variable> + + <xsl:attribute name="id"> + <xsl:value-of select="$id" /> + </xsl:attribute> + + <!-- produce file names according to yastdoc rules --> + <xsl:if test="$dir != ''"> + <xsl:processing-instruction name="dbhtml"> + xsl:textdir="</xsl:text> + <xsl:value-of select="$dir" /> + xsl:text"</xsl:text> + </xsl:processing-instruction> + </xsl:if> + <xsl:processing-instruction name="dbhtml"> + xsl:textfilename="</xsl:text> + <xsl:value-of select="$filename" /> + xsl:text.html"</xsl:text> + </xsl:processing-instruction> <refmeta> <refentrytitle> <xsl:if test="namespace != ''"> @@ -56,8 +96,21 @@ </xsl:if> <xsl:value-of select="names/names_item"/> </refentrytitle> - <manvolnum>3</manvolnum> + <manvolnum> + <xsl:value-of select="file_summary"/> + xsl:text, </xsl:text> + <xsl:value-of select="$filename" /> + </manvolnum> </refmeta> + </xsl:template> + + <xsl:template match="entries_item"> + + <refentry> + <xsl:call-template name="refentry-id-chunk-meta"> + <xsl:with-param name="use-id" select="id" /> + </xsl:call-template> + <refnamediv> <xsl:for-each select="names/names_item"> <refname> @@ -378,6 +431,45 @@ </xsl:if> </xsl:template> + <!-- create add.html for add-list.html and add-map.html --> + <xsl:template name="disambiguate"> + <reference id="Disambiguation"> + <title>Disambiguation</title> + + <!-- id!='' assumes all duplicates have id defined. --> + <xsl:for-each select="yast2doc/entries/entries_item [ + id != '' and + count(. | key('entries-by-name', names/names_item)[1]) = 1]"> + <xsl:sort select="names/names_item" /> + + <refentry> + <xsl:call-template name="refentry-id-chunk-meta" /> + + <refnamediv> + <refname> + <xsl:value-of select="names/names_item"/> + </refname> + <refpurpose>disambiguation</refpurpose> + </refnamediv> + + <refsect1> + <title>Variants</title> + <simplelist> + <xsl:for-each select="key('entries-by-name', names/names_item)"> + <xsl:sort select="id" /> + <member> + <xref linkend="{id}" /> + </member> + </xsl:for-each> + </simplelist> + </refsect1> + + </refentry> + + </xsl:for-each> + </reference> + </xsl:template> + <xsl:template name="html-replace-entities"> <xsl:param name="text" /> <xsl:param name="attrs" /> -- To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org For additional commands, e-mail: yast-commit+help@opensuse.org