File 1087-erl_docgen-Fix-github-links-and-title-links-to-work-.patch of Package erlang

From 900c719b04c3f039d2dd41ec6a73d955d76251e6 Mon Sep 17 00:00:00 2001
From: Lukas Larsson <lukas@erlang.org>
Date: Fri, 30 Oct 2020 17:51:09 +0100
Subject: [PATCH 1/4] erl_docgen: Fix github links and title links to work
 again

---
 lib/erl_docgen/priv/css/otp_doc.css | 37 ++++++++++++++++----
 lib/erl_docgen/priv/xsl/db_html.xsl | 53 +++++++++++++++++------------
 2 files changed, 62 insertions(+), 28 deletions(-)

diff --git a/lib/erl_docgen/priv/css/otp_doc.css b/lib/erl_docgen/priv/css/otp_doc.css
index 8ac02dcd96..d3e26f30e5 100644
--- a/lib/erl_docgen/priv/css/otp_doc.css
+++ b/lib/erl_docgen/priv/css/otp_doc.css
@@ -294,22 +294,47 @@ th {
     outline: none;
 }
 
-.ghlink {
-    margin-left: -2.7em; /* .pencil.font-size + .pencil.padding.left + .pencil.padding.right = 2.7 */
+.ghlink-before {
+    margin-left: -4em;
     visibility: hidden;
 }
 
-.pencil:before {
+.pencil-before:before {
     transform: rotateZ(90deg);
+    display: inline-block;
     content: "\270E";
     color: #1a1a1a !important;
-    font-weight: bold;
     font-size: 1.5em;
-    padding: .3em .6em .6em;
-    line-height: 1em;
     font-family: mono;
 }
 
+.paperclip-before:before {
+    display: inline-block;
+    content: "\1F517";
+    padding-left: 1em;
+    padding-right: .3em;
+}
+
+.ghlink-after {
+    visibility: hidden;
+}
+
+.pencil-after:after {
+    display: inline-block;
+    transform: rotate(90deg);
+    content: "\270E";
+    color: #1a1a1a !important;
+    font-size: 1.5em;
+    font-family: mono;
+}
+
+.paperclip-after:after {
+    display: inline-block;
+    content: "\1F517";
+    padding-right: .3em;
+    padding-left: .7em;
+}
+
 hr{
   border: 0;
   border-top: 1px solid #aaa;
diff --git a/lib/erl_docgen/priv/xsl/db_html.xsl b/lib/erl_docgen/priv/xsl/db_html.xsl
index f495bdd371..9b7a0c392a 100644
--- a/lib/erl_docgen/priv/xsl/db_html.xsl
+++ b/lib/erl_docgen/priv/xsl/db_html.xsl
@@ -227,10 +227,10 @@
 	<xsl:variable name="local_types"
 		      select="../type[string-length(@name) > 0]"/>
 	  <xsl:apply-templates select="$spec/contract/clause/head">
-          <xsl:with-param name="ghlink" select="ancestor-or-self::*[@ghlink]/@ghlink"/>
-	  <xsl:with-param name="local_types" select="$local_types"/>
-	  <xsl:with-param name="global_types" select="$global_types"/>
-	  <xsl:with-param name="since" select="$since"/>
+            <xsl:with-param name="ghlink" select="ancestor-or-self::*[@ghlink]/@ghlink"/>
+	    <xsl:with-param name="local_types" select="$local_types"/>
+	    <xsl:with-param name="global_types" select="$global_types"/>
+	    <xsl:with-param name="since" select="$since"/>
 	  </xsl:apply-templates>
       </xsl:when>
     </xsl:choose>
@@ -241,7 +241,8 @@
     <xsl:param name="local_types"/>
     <xsl:param name="global_types"/>
     <xsl:param name="since"/>
-    <xsl:variable name="id" select="concat(concat(concat(concat(../../../name,'-'),../../../arity),'-'),generate-id(.))"/>
+    <xsl:variable name="mfa" select="concat(concat(../../../name,'-'),../../../arity)"/>
+    <xsl:variable name="id" select="concat(concat($mfa,'-'),generate-id(.))"/>
     <table class="func-table">
     <tr class="func-tr">
     <td class="func-td">
@@ -249,6 +250,7 @@
            onMouseOver="document.getElementById('ghlink-{$id}').style.visibility = 'visible';"
            onMouseOut="document.getElementById('ghlink-{$id}').style.visibility = 'hidden';">
 	<xsl:call-template name="ghlink">
+          <xsl:with-param name="mfa" select="$mfa"/>
           <xsl:with-param name="ghlink" select="$ghlink"/>
           <xsl:with-param name="id" select="$id"/>
 	</xsl:call-template>
@@ -2406,39 +2408,46 @@
     <xsl:variable name="id" select="concat(concat($link,'-'), generate-id(.))"/>
     <span onMouseOver="document.getElementById('ghlink-{$id}').style.visibility = 'visible';"
           onMouseOut="document.getElementById('ghlink-{$id}').style.visibility = 'hidden';">
-      <xsl:call-template name="ghlink">
-          <xsl:with-param name="id" select="$id"/>
-          <xsl:with-param name="ghlink" select="$ghlink"/>
-      </xsl:call-template>
-      <a class="title_link" name="{$link}" href="#{$link}">
-	<xsl:choose>
+      <!-- <hej> -->
+      <!--   <xsl:value-of select="ancestor-or-self::*[@ghlink]"/> -->
+      <!-- </hej> -->
+      <a class="title_link" name="{$link}">
+        <xsl:choose>
 	  <xsl:when test="$title = 'APPLY'">
 	    <xsl:apply-templates/>   <!-- like <ret> and <nametext> -->
 	  </xsl:when>
 	  <xsl:otherwise>
 	    <xsl:value-of select="$title"/>
 	  </xsl:otherwise>
-	</xsl:choose>
+        </xsl:choose>
       </a>
+      <xsl:call-template name="ghlink">
+        <xsl:with-param name="mfa" select="$link"/>
+        <xsl:with-param name="id" select="$id"/>
+        <xsl:with-param name="ghlink" select="$ghlink"/>
+        <xsl:with-param name="where" select="'after'"/>
+      </xsl:call-template>
     </span>
   </xsl:template>
 
   <xsl:template name="ghlink">
+    <xsl:param name="mfa"/>
     <xsl:param name="id"/>
     <xsl:param name="ghlink" select="ancestor-or-self::*[@ghlink][position() = 1]/@ghlink"/>
-    <xsl:choose>
-      <xsl:when test="string-length($ghlink) > 0">
-        <span id="ghlink-{$id}" class="ghlink">
+    <xsl:param name="where" select="'before'"/>
+    <span id="ghlink-{$id}" class="ghlink-{$where}">
+      <a href="#{$mfa}" title="Link to this place!">
+        <span class="paperclip-{$where}"/>
+      </a>
+      <xsl:choose>
+        <xsl:when test="string-length($ghlink) > 0">
           <a href="https://github.com/erlang/otp/edit/{$ghlink}"
              title="Found an issue with the documentation? Fix it by clicking here!">
-            <span class="pencil"/>
+            <span class="pencil-{$where}"/>
           </a>
-        </span>
-      </xsl:when>
-      <xsl:otherwise>
-        <span id="ghlink-{$id}"/>
-      </xsl:otherwise>
-    </xsl:choose>
+        </xsl:when>
+      </xsl:choose>
+    </span>
   </xsl:template>
 
   <!-- Desc -->
-- 
2.26.2

openSUSE Build Service is sponsored by