File 3731-docgen-Restrict-title-name-class-to-only-be-name-and.patch of Package erlang

From 6e6775b22b0ab1efd181ae04423a0ab0f9b473fe Mon Sep 17 00:00:00 2001
From: Lukas Larsson <lukas@erlang.org>
Date: Wed, 15 Sep 2021 17:12:27 +0200
Subject: [PATCH 11/12] docgen: Restrict title-name class to only be name and
 not erlang prefix

We do this in order to ease parsing of the content of webcrawlers.
---
 lib/erl_docgen/priv/xsl/db_html.xsl | 26 ++++++++++++++++++++++++--
 1 file changed, 24 insertions(+), 2 deletions(-)

diff --git a/lib/erl_docgen/priv/xsl/db_html.xsl b/lib/erl_docgen/priv/xsl/db_html.xsl
index 1fedb53fea..dce99474d3 100644
--- a/lib/erl_docgen/priv/xsl/db_html.xsl
+++ b/lib/erl_docgen/priv/xsl/db_html.xsl
@@ -266,12 +266,34 @@
           <xsl:with-param name="id" select="$id"/>
         </xsl:call-template>
       </div>
-      <div class="title-name">
+      <xsl:variable name="name">
         <xsl:apply-templates mode="local_type">
 	  <xsl:with-param name="local_types" select="$local_types"/>
 	  <xsl:with-param name="global_types" select="$global_types"/>
         </xsl:apply-templates>
-      </div>
+      </xsl:variable>
+      <!-- We do not include the erlang: prefix in what is selected by
+           .title-name. This is so that webcrawlers can select the true
+           function name, i.e. decode_packet instead of erlang:decode_packet.
+      -->
+      <xsl:variable name="head" select="exsl:node-set($name)/text()[1]"/>
+      <xsl:variable name="tail" select="exsl:node-set($name)/node()[position() > 1]"/>
+      <xsl:choose>
+        <xsl:when test="substring($head,1,7) = 'erlang:'">
+          <div>
+            <xsl:text>erlang:</xsl:text>
+            <span class="title-name">
+              <xsl:value-of select="substring-after($head,':')"/>
+              <xsl:copy-of select="$tail"/>
+            </span>
+          </div>
+        </xsl:when>
+        <xsl:otherwise>
+          <span class="title-name">
+            <xsl:copy-of select="$name"/>
+          </span>
+        </xsl:otherwise>
+      </xsl:choose>
       <xsl:if test="string-length($since) > 0">
         <div class="title-since">
 	  <span class="since"><xsl:value-of select="$since"/>
-- 
2.31.1

openSUSE Build Service is sponsored by