# HG changeset patch
# User Nick Wellnhofer <wellnhofer@aevum.de>
# Date 1661346586 -7200
#      Wed Aug 24 15:09:46 2022 +0200
# Node ID da4f4ca5002ad17f6aabe20fa6fe9c120ed0da92
# Parent  bc2fe3d350cbd819ff9d9081a2aa65e3cd55839e
Improve cross-references in API docs

Also cross-reference keywords followed by a period. This is still a hack
but catches quite a few more keywords.

diff --git a/doc/devhelp/html.xsl b/doc/devhelp/html.xsl
--- a/doc/devhelp/html.xsl
+++ b/doc/devhelp/html.xsl
@@ -14,6 +14,20 @@
       <xsl:when test="$ref">
         <a href="libxml2-{$ref/@file}.html#{$ref/@name}"><xsl:value-of select="$token"/></a>
       </xsl:when>
+      <!-- TODO: This hack only works for tokens followed by a period. -->
+      <xsl:when test="substring($token, string-length($token)) = '.'">
+        <xsl:variable name="token2" select="substring($token, 1, string-length($token) - 1)"/>
+        <xsl:variable name="ref2" select="key('symbols', $token2)"/>
+        <xsl:choose>
+          <xsl:when test="$ref2">
+            <a href="libxml2-{$ref2/@file}.html#{$ref2/@name}"><xsl:value-of select="$token2"/></a>
+            <xsl:text>.</xsl:text>
+          </xsl:when>
+          <xsl:otherwise>
+            <xsl:value-of select="$token"/>
+          </xsl:otherwise>
+        </xsl:choose>
+      </xsl:when>
       <xsl:otherwise>
         <xsl:value-of select="$token"/>
       </xsl:otherwise>