diff options
Diffstat (limited to 'lib/erl_docgen/priv')
-rw-r--r-- | lib/erl_docgen/priv/xsl/db_eix.xsl | 180 | ||||
-rw-r--r-- | lib/erl_docgen/priv/xsl/db_man.xsl | 132 | ||||
-rw-r--r-- | lib/erl_docgen/priv/xsl/db_pdf.xsl | 21 | ||||
-rw-r--r-- | lib/erl_docgen/priv/xsl/db_pdf_params.xsl | 4 |
4 files changed, 252 insertions, 85 deletions
diff --git a/lib/erl_docgen/priv/xsl/db_eix.xsl b/lib/erl_docgen/priv/xsl/db_eix.xsl index 4545322bc2..7a648ddfd7 100644 --- a/lib/erl_docgen/priv/xsl/db_eix.xsl +++ b/lib/erl_docgen/priv/xsl/db_eix.xsl @@ -22,10 +22,16 @@ <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" + xmlns:exsl="http://exslt.org/common" + extension-element-prefixes="exsl" xmlns:fn="http://www.w3.org/2005/02/xpath-functions"> <xsl:output method="text" encoding="UTF-8" indent="no"/> + <xsl:param name="specs_file" select="''"/> + <xsl:variable name="i" select="document($specs_file)"></xsl:variable> + + <!-- Book --> <xsl:template match="/book"> <xsl:text>%% %% Search data file for </xsl:text><xsl:value-of select="$appname"/><xsl:text> </xsl:text><xsl:value-of select="$appver"/> @@ -50,9 +56,7 @@ <xsl:template match="erlref"> <xsl:text>{"</xsl:text><xsl:value-of select="module"/><xsl:text>.html", {function, {"</xsl:text><xsl:value-of select="$appname"/> <xsl:text>", "</xsl:text><xsl:value-of select="module"/><xsl:text>"}}, [ </xsl:text> - <xsl:apply-templates select="funcs"> - <xsl:with-param name="mod" select="module"/> - </xsl:apply-templates> + <xsl:apply-templates select="funcs"/> <xsl:text>]}. </xsl:text> <xsl:text>{"</xsl:text><xsl:value-of select="module"/><xsl:text>.html", {module, "</xsl:text> <xsl:value-of select="$appname"/><xsl:text>"}, ["</xsl:text><xsl:value-of select="module"/><xsl:text>"]}. </xsl:text> @@ -62,9 +66,7 @@ <xsl:template match="cref"> <xsl:text>{"</xsl:text><xsl:value-of select="lib"/><xsl:text>.html", {function, {"</xsl:text><xsl:value-of select="$appname"/> <xsl:text>", "</xsl:text><xsl:value-of select="lib"/><xsl:text>"}}, [ </xsl:text> - <xsl:apply-templates select="funcs"> - <xsl:with-param name="mod" select="lib"/> - </xsl:apply-templates> + <xsl:apply-templates select="funcs"/> <xsl:text>]}. </xsl:text> <xsl:text>{"</xsl:text><xsl:value-of select="lib"/><xsl:text>.html", {clib, "</xsl:text> <xsl:value-of select="$appname"/><xsl:text>"}, ["</xsl:text><xsl:value-of select="lib"/><xsl:text>"]}. </xsl:text> @@ -91,69 +93,157 @@ <!-- Funcs --> <xsl:template match="funcs"> - <xsl:param name="mod"/> <xsl:variable name="lastfuncsblock"> <xsl:value-of select="position() = last()"/> </xsl:variable> <xsl:apply-templates select="func/name"> - <xsl:with-param name="mod" select="$mod"/> <xsl:with-param name="lastfuncsblock" select="$lastfuncsblock"/> </xsl:apply-templates> </xsl:template> + <xsl:template match="name"> + <xsl:param name="lastfuncsblock"/> + <xsl:choose> + <!-- @arity is mandatory when referring to a specification --> + <xsl:when test="string-length(@arity) > 0"> + <xsl:call-template name="spec_name"/> + </xsl:when> + <xsl:otherwise> + <xsl:call-template name="name"/> + </xsl:otherwise> + </xsl:choose> + </xsl:template> + <xsl:template name="err"> + <xsl:param name="f"/> + <xsl:param name="m"/> + <xsl:param name="n"/> + <xsl:param name="a"/> + <xsl:param name="s"/> + <xsl:message terminate="yes"> + Error <xsl:if test="$f != ''">in <xsl:value-of select ="$f"/>:</xsl:if> + <xsl:if test="$m != ''"><xsl:value-of select ="$m"/>:</xsl:if> + <xsl:value-of select="$n"/> + <xsl:if test="$a != ''">/<xsl:value-of + select ="$a"/></xsl:if>: <xsl:value-of select="$s"/> + </xsl:message> + </xsl:template> + <xsl:template name="find_spec"> + <xsl:variable name="curModule" select="ancestor::erlref/module"/> + <xsl:variable name="mod" select="@mod"/> + <xsl:variable name="name" select="@name"/> + <xsl:variable name="arity" select="@arity"/> + <xsl:variable name="clause_i" select="@clause_i"/> + <xsl:variable name="spec0" select= + "$i/specs/module[@name=$curModule]/spec + [name=$name and arity=$arity + and (string-length($mod) = 0 or module = $mod)]"/> + <xsl:variable name="spec" select="$spec0[string-length($clause_i) = 0 + or position() = $clause_i]"/> - <xsl:template match="name"> - <xsl:param name="mod"/> + <xsl:if test="count($spec) != 1"> + <xsl:variable name="why"> + <xsl:choose> + <xsl:when test="count($spec) > 1">ambiguous spec</xsl:when> + <xsl:when test="count($spec) = 0">unknown spec</xsl:when> + </xsl:choose> + </xsl:variable> + <xsl:call-template name="err"> + <xsl:with-param name="f" select="$curModule"/> + <xsl:with-param name="m" select="$mod"/> + <xsl:with-param name="n" select="$name"/> + <xsl:with-param name="a" select="$arity"/> + <xsl:with-param name="s" select="$why"/> + </xsl:call-template> + </xsl:if> + <xsl:copy-of select="$spec"/> + </xsl:template> + + + <xsl:template name="spec_name"> + <xsl:param name="lastfuncsblock"/> + <xsl:variable name="fname" select="@name"/> + <xsl:variable name="arity" select="@arity"/> + <xsl:variable name="spec0"> + <xsl:call-template name="find_spec"/> + </xsl:variable> + <xsl:variable name="spec" select="exsl:node-set($spec0)/spec"/> + + <xsl:variable name="tmpstring"> + <xsl:value-of select="substring-before($spec/contract/clause/head, ' ->')"/> + </xsl:variable> + + <xsl:text> {"</xsl:text><xsl:value-of select="$fname"/> + <xsl:text>", "</xsl:text><xsl:value-of select="$tmpstring"/> + <xsl:text>", "</xsl:text><xsl:value-of select="$fname"/> + <xsl:text>-</xsl:text><xsl:value-of select="$arity"/><xsl:text>"}</xsl:text> + + <xsl:choose> + <xsl:when test="($lastfuncsblock = 'true') and (position() = last())"> + <xsl:text> </xsl:text> + </xsl:when> + <xsl:otherwise> + <xsl:text>, </xsl:text> + </xsl:otherwise> + </xsl:choose> + + </xsl:template> + + + <xsl:template name="name"> <xsl:param name="lastfuncsblock"/> <xsl:variable name="tmpstring"> <xsl:value-of select="substring-before(substring-after(., '('), '->')"/> - </xsl:variable> + </xsl:variable> + <xsl:variable name="ustring"> <xsl:choose> - <xsl:when test="string-length($tmpstring) > 0"> - <xsl:call-template name="remove-paren"> - <xsl:with-param name="string" select="$tmpstring"/> - </xsl:call-template> - </xsl:when> - <xsl:otherwise> - <xsl:call-template name="remove-paren"> - <xsl:with-param name="string" select="substring-after(., '(')"/> - </xsl:call-template> - </xsl:otherwise> + <xsl:when test="string-length($tmpstring) > 0"> + <xsl:call-template name="remove-paren"> + <xsl:with-param name="string" select="$tmpstring"/> + </xsl:call-template> + </xsl:when> + <xsl:otherwise> + <xsl:call-template name="remove-paren"> + <xsl:with-param name="string" select="substring-after(., '(')"/> + </xsl:call-template> + </xsl:otherwise> </xsl:choose> - </xsl:variable> + </xsl:variable> + <xsl:variable name="arity"> <xsl:call-template name="calc-arity"> - <xsl:with-param name="string" select="substring-before($ustring, ')')"/> - <xsl:with-param name="no-of-pars" select="0"/> + <xsl:with-param name="string" select="substring-before($ustring, ')')"/> + <xsl:with-param name="no-of-pars" select="0"/> </xsl:call-template> - </xsl:variable> + </xsl:variable> + <xsl:variable name="fname"> <xsl:choose> - <xsl:when test="ancestor::cref"> - <xsl:value-of select="substring-before(nametext, '(')"/> - </xsl:when> - <xsl:when test="ancestor::erlref"> - <xsl:variable name="fname1"> - <xsl:value-of select="substring-before(., '(')"/> - </xsl:variable> - <xsl:variable name="fname2"> - <xsl:value-of select="substring-after($fname1, 'erlang:')"/> - </xsl:variable> - <xsl:choose> - <xsl:when test="string-length($fname2) > 0"> - <xsl:value-of select="$fname2"/> - </xsl:when> - <xsl:otherwise> - <xsl:value-of select="$fname1"/> - </xsl:otherwise> - </xsl:choose> - </xsl:when> + <xsl:when test="ancestor::cref"> + <xsl:value-of select="substring-before(nametext, '(')"/> + </xsl:when> + <xsl:when test="ancestor::erlref"> + <xsl:variable name="fname1"> + <xsl:value-of select="substring-before(., '(')"/> + </xsl:variable> + <xsl:variable name="fname2"> + <xsl:value-of select="substring-after($fname1, 'erlang:')"/> + </xsl:variable> + <xsl:choose> + <xsl:when test="string-length($fname2) > 0"> + <xsl:value-of select="$fname2"/> + </xsl:when> + <xsl:otherwise> + <xsl:value-of select="$fname1"/> + </xsl:otherwise> + </xsl:choose> + </xsl:when> </xsl:choose> - </xsl:variable> + </xsl:variable> + <xsl:text> {"</xsl:text><xsl:value-of select="$fname"/> <xsl:text>", "</xsl:text><xsl:value-of select="$fname"/> <xsl:text>(</xsl:text><xsl:value-of select="normalize-space($tmpstring)"/> diff --git a/lib/erl_docgen/priv/xsl/db_man.xsl b/lib/erl_docgen/priv/xsl/db_man.xsl index 8db4714249..1df96caa36 100644 --- a/lib/erl_docgen/priv/xsl/db_man.xsl +++ b/lib/erl_docgen/priv/xsl/db_man.xsl @@ -25,12 +25,12 @@ xmlns:exsl="http://exslt.org/common" extension-element-prefixes="exsl"> - <xsl:preserve-space elements="code pre"/> + <xsl:preserve-space elements="code pre p"/> <xsl:strip-space elements="*"/> <xsl:output method="text" encoding="UTF-8" indent="no"/> <!-- Start of Dialyzer type/spec tags. See also the templates - matching "name" and "seealso" + matching "name", "seealso" and "br" --> <!-- Note: specs data for *one* module (as opposed to html and pdf) --> @@ -137,8 +137,8 @@ (there is no spec with more than one clause) --> <xsl:if test="count($clause/guard) > 0 or count($type) > 0"> <xsl:text> .RS</xsl:text> - <xsl:text> .TP</xsl:text> - <xsl:text> Types</xsl:text> + <xsl:text> .TP 3</xsl:text> + <xsl:text> Types: </xsl:text> <xsl:choose> <xsl:when test="$output_subtypes"> @@ -223,10 +223,13 @@ <xsl:for-each select="$subtype"> <xsl:variable name="tname" select="typename"/> - <xsl:text> </xsl:text> - <xsl:apply-templates select="string"/> - <xsl:text> .br</xsl:text> - <xsl:apply-templates select="$type_desc[@variable = $tname]"/> + <xsl:variable name="string" select="string"/> + <xsl:if test="string-length($string) > 0"> + <xsl:text> </xsl:text> + <xsl:apply-templates select="$string"/> + <xsl:text> .br</xsl:text> + <xsl:apply-templates select="$type_desc[@variable = $tname]"/> + </xsl:if> </xsl:for-each> </xsl:template> @@ -319,8 +322,7 @@ </xsl:template> <xsl:template match="typehead"> - <xsl:text> .nf </xsl:text> - <xsl:text> .B </xsl:text> + <xsl:text> .nf </xsl:text> <xsl:apply-templates/> <xsl:text> .br</xsl:text> <xsl:text> .fi</xsl:text> @@ -345,6 +347,13 @@ <xsl:text> .br</xsl:text> </xsl:template> + <!-- The name of data types --> + <xsl:template match="marker"> + <xsl:if test="string-length(.) != 0"> + <xsl:text>\fB</xsl:text><xsl:apply-templates/><xsl:text>\fR\&</xsl:text> + </xsl:if> + </xsl:template> + <!-- Used both in <datatype> and in <func>! --> <xsl:template match="anno"> <xsl:variable name="curModule" select="ancestor::erlref/module"/> @@ -465,13 +474,13 @@ <xsl:text> .TP 2 </xsl:text> <xsl:text>* </xsl:text> <xsl:apply-templates/> - <xsl:text> .LP </xsl:text> + <xsl:text> .LP</xsl:text> </xsl:template> <xsl:template match="taglist"> <xsl:text> .RS 2</xsl:text> <xsl:apply-templates select="tag|item"/> - <xsl:text> .RE </xsl:text> + <xsl:text> .RE</xsl:text> </xsl:template> <xsl:template match="taglist/tag"> @@ -494,7 +503,7 @@ </xsl:when> <xsl:otherwise> <xsl:text> .RS 2</xsl:text> - <xsl:text> .LP .LP </xsl:text> + <xsl:text> .LP </xsl:text> <xsl:value-of select="$content"/> <xsl:text> .RE</xsl:text> </xsl:otherwise> @@ -503,18 +512,42 @@ <!-- Note --> <xsl:template match="note"> - <xsl:text> .SS Note:</xsl:text> + <xsl:text> .LP </xsl:text> + <xsl:text> .RS -4</xsl:text> + <xsl:text> .B </xsl:text> + <xsl:text>Note:</xsl:text> + <xsl:text> .RE</xsl:text> <xsl:apply-templates/> <xsl:text> </xsl:text> </xsl:template> <!-- Warning --> <xsl:template match="warning"> - <xsl:text> .SS Warning:</xsl:text> + <xsl:text> .LP </xsl:text> + <xsl:text> .RS -4</xsl:text> + <xsl:text> .B </xsl:text> + <xsl:text>Warning:</xsl:text> + <xsl:text> .RE</xsl:text> <xsl:apply-templates/> <xsl:text> </xsl:text> </xsl:template> + <xsl:template match="warning/p | note/p"> + <xsl:variable name="content"> + <xsl:text> </xsl:text> + <xsl:apply-templates/> + </xsl:variable> + <xsl:choose> + <xsl:when test="position() = 1"> + <xsl:value-of select="$content"/> + </xsl:when> + <xsl:otherwise> + <xsl:text> .LP</xsl:text> + <xsl:value-of select="$content"/> + </xsl:otherwise> + </xsl:choose> + </xsl:template> + <!-- Paragraph --> <xsl:template match="p"> <xsl:text> .LP </xsl:text> @@ -529,7 +562,16 @@ </xsl:template> <xsl:template match="br"> - <xsl:text> .br </xsl:text> + <xsl:choose> + <xsl:when test="ancestor::head"> + <!-- The header of Dialyzer specs. + .B makes next line appear in bold face --> + <xsl:text> .B </xsl:text> + </xsl:when> + <xsl:otherwise> + <xsl:text> .br </xsl:text> + </xsl:otherwise> + </xsl:choose> </xsl:template> <xsl:template match="c"> @@ -547,17 +589,17 @@ <!-- Code --> <xsl:template match="code"> <xsl:text> .LP </xsl:text> - <xsl:text> .nf </xsl:text> + <xsl:text>.nf </xsl:text> <xsl:apply-templates/> - <xsl:text> .fi </xsl:text> + <xsl:text> .fi</xsl:text> </xsl:template> <!-- Pre --> <xsl:template match="pre"> <xsl:text> .LP </xsl:text> - <xsl:text> .nf </xsl:text> + <xsl:text>.nf </xsl:text> <xsl:apply-templates/> - <xsl:text> .fi </xsl:text> + <xsl:text> .fi</xsl:text> </xsl:template> @@ -715,8 +757,8 @@ <!-- The case where @name != 0 is taken care of in "type_name" --> <xsl:if test="string-length(@name) = 0 and string-length(@variable) = 0"> <xsl:text> .RS</xsl:text> - <xsl:text> .TP</xsl:text> - <xsl:text> Types</xsl:text> + <xsl:text> .TP 3</xsl:text> + <xsl:text> Types: </xsl:text> <xsl:apply-templates/> <xsl:text> .RE</xsl:text> </xsl:if> @@ -788,7 +830,36 @@ <!-- Replace ' by \&' ans . by \&. --> <xsl:template match="text()"> <xsl:variable name="startstring"> - <xsl:value-of select="normalize-space()"/><xsl:text> </xsl:text> + <xsl:value-of select="normalize-space()"/> + </xsl:variable> + <!-- 'C' is just any character but whitespace --> + <xsl:variable name="tmp" select="normalize-space(concat('C',.,'C'))"/> + <xsl:variable name="space_before"> + <xsl:choose> + <!-- '<p>A<marker id="swamp"/> swamp</p>' does not work; instead: + '<p>A <marker id="swamp"/>swamp</p>' --> + <xsl:when test="starts-with($tmp, 'C ') + and not (string(preceding-sibling::*[position()=1]) = '' + and parent::p)"> + <!-- and not (position() = 1 and parent::p)"> --> + <xsl:text> </xsl:text> + </xsl:when> + <xsl:otherwise> + <xsl:text/> + </xsl:otherwise> + </xsl:choose> + </xsl:variable> + <xsl:variable name="space_after"> + <xsl:choose> + <xsl:when test="substring($tmp, string-length($tmp)-1,1) = ' ' + and $startstring != '' + and not (position() = last() and parent::p)"> + <xsl:text> </xsl:text> + </xsl:when> + <xsl:otherwise> + <xsl:text/> + </xsl:otherwise> + </xsl:choose> </xsl:variable> <xsl:variable name="rep1"> <xsl:call-template name="replace-string"> @@ -804,11 +875,16 @@ <xsl:with-param name="with" select=""\&'"" /> </xsl:call-template> </xsl:variable> - <xsl:call-template name="replace-string"> - <xsl:with-param name="text" select="$rep2" /> - <xsl:with-param name="replace" select=""."" /> - <xsl:with-param name="with" select=""\&."" /> - </xsl:call-template> + <xsl:variable name="reply"> + <xsl:call-template name="replace-string"> + <xsl:with-param name="text" select="$rep2" /> + <xsl:with-param name="replace" select=""."" /> + <xsl:with-param name="with" select=""\&."" /> + </xsl:call-template> + </xsl:variable> + <xsl:value-of select="$space_before"/> + <xsl:value-of select="$reply"/> + <xsl:value-of select="$space_after"/> </xsl:template> <!-- Template replace-string is borrowed at http://www.dpawson.co.uk/xsl/sect2/replace.html --> diff --git a/lib/erl_docgen/priv/xsl/db_pdf.xsl b/lib/erl_docgen/priv/xsl/db_pdf.xsl index 35f6349f70..48a7a026c1 100644 --- a/lib/erl_docgen/priv/xsl/db_pdf.xsl +++ b/lib/erl_docgen/priv/xsl/db_pdf.xsl @@ -732,22 +732,23 @@ <xsl:template name="bookmarks1"> <xsl:param name="entries"/> <xsl:if test="$entries != ''"> + <xsl:for-each select="$entries"> - <fo:bookmark internal-destination="{generate-id(/book/parts/part)}" - starting-state="hide"> - <fo:bookmark-title>User's Guide</fo:bookmark-title> - - <xsl:for-each select="$entries"> + <fo:bookmark internal-destination="{generate-id(header/title)}" + starting-state="hide"> + <fo:bookmark-title><xsl:value-of select="header/title"/></fo:bookmark-title> + <xsl:call-template name="bookmarks2"> <xsl:with-param name="entries" select="chapter[header/title]"/> </xsl:call-template> - </xsl:for-each> - - </fo:bookmark> + + </fo:bookmark> + </xsl:for-each> </xsl:if> </xsl:template> + <xsl:template name="bookmarks2"> <xsl:param name="entries"/> <xsl:for-each select="$entries"> @@ -934,9 +935,9 @@ <xsl:template match="part"> <xsl:variable name="partnum"><xsl:number level="any" from="book" count="part|application"/></xsl:variable> - <fo:block xsl:use-attribute-sets="h1" id="{generate-id()}"> + <fo:block xsl:use-attribute-sets="h1" id="{generate-id(header/title)}"> <xsl:value-of select="$partnum"/>    - <xsl:text>User's Guide</xsl:text> + <xsl:value-of select="header/title"/> </fo:block> <xsl:apply-templates select="description"> diff --git a/lib/erl_docgen/priv/xsl/db_pdf_params.xsl b/lib/erl_docgen/priv/xsl/db_pdf_params.xsl index 3dfecf8b74..4d9c08d0c3 100644 --- a/lib/erl_docgen/priv/xsl/db_pdf_params.xsl +++ b/lib/erl_docgen/priv/xsl/db_pdf_params.xsl @@ -3,7 +3,7 @@ # # %CopyrightBegin% # - # Copyright Ericsson AB 2009-2010. All Rights Reserved. + # Copyright Ericsson AB 2009-2011. All Rights Reserved. # # The contents of this file are subject to the Erlang Public License, # Version 1.1, (the "License"); you may not use this file except in @@ -29,7 +29,7 @@ <!-- Fixed strings --> <xsl:variable name="companyname"><xsl:value-of select="/book/header/copyright/holder"/></xsl:variable> - <xsl:variable name="copyright">Copyright © <xsl:value-of select="/book/header/copyright/year[1]"/><xsl:text>-</xsl:text><xsl:value-of select="substring-after(substring-after($gendate, ' '), ' ')"/></xsl:variable> + <xsl:variable name="copyright">Copyright © <xsl:value-of select="/book/header/copyright/year[1]"/><xsl:text>-</xsl:text><xsl:value-of select="substring-after(normalize-space(substring-after($gendate, ' ')), ' ')"/></xsl:variable> <!-- FIXME: remove when appendix creation has been fixed --> <!-- xsl:variable name="appendix_title"--> |