diff options
author | Micael Karlberg <[email protected]> | 2011-09-26 11:10:16 +0200 |
---|---|---|
committer | Micael Karlberg <[email protected]> | 2011-09-26 11:10:16 +0200 |
commit | f8f0c5a1bc435fbb9d816323f1f0abfe992a6e3e (patch) | |
tree | 88d99b425afb35fcaf7f9c804b874776f2ab7d66 /lib | |
parent | 225be8638c5d1ae82f83f00557c75cdf25ac6bbc (diff) | |
parent | 8aeee5940d632414afa15d7d85489220abc79547 (diff) | |
download | otp-f8f0c5a1bc435fbb9d816323f1f0abfe992a6e3e.tar.gz otp-f8f0c5a1bc435fbb9d816323f1f0abfe992a6e3e.tar.bz2 otp-f8f0c5a1bc435fbb9d816323f1f0abfe992a6e3e.zip |
Merge branch 'major' of super:otp into major
Diffstat (limited to 'lib')
-rw-r--r-- | lib/erl_docgen/priv/xsl/db_eix.xsl | 180 | ||||
-rw-r--r-- | lib/erl_docgen/priv/xsl/db_pdf.xsl | 21 | ||||
-rw-r--r-- | lib/erl_docgen/priv/xsl/db_pdf_params.xsl | 2 |
3 files changed, 147 insertions, 56 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_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..d2f0350cf1 100644 --- a/lib/erl_docgen/priv/xsl/db_pdf_params.xsl +++ b/lib/erl_docgen/priv/xsl/db_pdf_params.xsl @@ -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"--> |