aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLars Thorsen <[email protected]>2011-09-26 10:56:27 +0200
committerLars Thorsen <[email protected]>2011-09-26 10:56:27 +0200
commitabc8c8c9c18eaaec117f737389ed190e206c67f1 (patch)
tree4d61ba88cb963c30b153f829d390677a0623e99d
parent3992f3308fd2d84e46f930e4181ee29d2389ff96 (diff)
parentd5a4fc889fa358da380ec967075132b998fa8cbf (diff)
downloadotp-abc8c8c9c18eaaec117f737389ed190e206c67f1.tar.gz
otp-abc8c8c9c18eaaec117f737389ed190e206c67f1.tar.bz2
otp-abc8c8c9c18eaaec117f737389ed190e206c67f1.zip
Merge branch 'lars/erl_docgen/fix-eix-files-for-specs/OTP-9562' into dev
* lars/erl_docgen/fix-eix-files-for-specs/OTP-9562: [erl_docgen] Fix eix file generation for new function spec references
-rw-r--r--lib/erl_docgen/priv/xsl/db_eix.xsl180
-rw-r--r--make/otp_release_targets.mk4
2 files changed, 137 insertions, 47 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>%% &#10;%% 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>"}},&#10;[&#10;</xsl:text>
- <xsl:apply-templates select="funcs">
- <xsl:with-param name="mod" select="module"/>
- </xsl:apply-templates>
+ <xsl:apply-templates select="funcs"/>
<xsl:text>]}.&#10;</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>"]}.&#10;</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>"}}, [&#10;</xsl:text>
- <xsl:apply-templates select="funcs">
- <xsl:with-param name="mod" select="lib"/>
- </xsl:apply-templates>
+ <xsl:apply-templates select="funcs"/>
<xsl:text>]}.&#10;</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>"]}.&#10;</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>&#10;</xsl:text>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:text>,&#10;</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/make/otp_release_targets.mk b/make/otp_release_targets.mk
index 8058e634d4..229612630d 100644
--- a/make/otp_release_targets.mk
+++ b/make/otp_release_targets.mk
@@ -74,10 +74,10 @@ ifneq ($(XML_FILES),)
# ----------------------------------------------------
# Generation of application index data
# ----------------------------------------------------
-$(HTMLDIR)/$(APPLICATION).eix: $(XML_FILES)
+$(HTMLDIR)/$(APPLICATION).eix: $(XML_FILES) $(SPECS_FILES)
date=`date +"%B %e %Y"`; \
$(XSLTPROC) --stringparam docgen "$(DOCGEN)" \
- --stringparam gendate "$$date" --stringparam appname "$(APPLICATION)" --stringparam appver "$(VSN)" --xinclude \
+ --stringparam gendate "$$date" --stringparam appname "$(APPLICATION)" --stringparam appver "$(VSN)" --xinclude $(TOP_SPECS_PARAM) \
-path $(DOCGEN)/priv/docbuilder_dtd -path $(DOCGEN)/priv/dtd_html_entities $(DOCGEN)/priv/xsl/db_eix.xsl book.xml > $@
docs: $(HTMLDIR)/$(APPLICATION).eix