File 2121-docgen-Allow-internal-docs-to-contain-both-modules-a.patch of Package erlang
From a5c02d138c2984aa08b286e1a433247be226438f Mon Sep 17 00:00:00 2001
From: Frej Drejhammar <frej.drejhammar@gmail.com>
Date: Tue, 23 Mar 2021 14:48:13 +0100
Subject: [PATCH 1/2] docgen: Allow internal docs to contain both modules and
chapters
If an application includes internal documentation which refers to both
modules and text in chapters, the xsl will produce two menus, one for
the modules and one for the chapters, which the CSS then will render
on top of each other making a real mess.
This is an attempt to avoid the described problem by introducing a new
menu template which is used when the internal documentation contains
both modules and chapters.
---
lib/erl_docgen/priv/xsl/db_html.xsl | 65 +++++++++++++++++++++++------
1 file changed, 53 insertions(+), 12 deletions(-)
diff --git a/lib/erl_docgen/priv/xsl/db_html.xsl b/lib/erl_docgen/priv/xsl/db_html.xsl
index 6862eaf41a..e4dd926a62 100644
--- a/lib/erl_docgen/priv/xsl/db_html.xsl
+++ b/lib/erl_docgen/priv/xsl/db_html.xsl
@@ -919,18 +919,26 @@
<xsl:with-param name="chapnum" select="$chapnum"/>
</xsl:call-template>
</xsl:if>
- <xsl:if test="(local-name() = 'internal' and descendant::chapter) or ((local-name() = 'chapter') and ancestor::internal)">
- <!-- .../internal or .../internal/chapter -->
- <xsl:call-template name="menu.internal.ug">
- <xsl:with-param name="chapnum" select="$chapnum"/>
- </xsl:call-template>
- </xsl:if>
- <xsl:if test="(local-name() = 'internal' and descendant::erlref) or (((local-name() = 'erlref') or (local-name() = 'comref') or (local-name() = 'cref') or (local-name() = 'fileref') or (local-name() = 'appref')) and ancestor::internal)">
- <!-- .../internal,.../internal/erlref, .../internal/comref or .../internal/cref or .../internal/fileref or .../internal/appref -->
- <xsl:call-template name="menu.internal.ref">
- <xsl:with-param name="curModule" select="$curModule"/>
- </xsl:call-template>
- </xsl:if>
+
+ <xsl:choose>
+ <!-- Ugly hack to avoid two menus when we have internal documentation covering both modules and chapters -->
+ <xsl:when test="((local-name() = 'internal' and descendant::chapter) or ((local-name() = 'chapter') and ancestor::internal)) and ((local-name() = 'internal' and descendant::erlref) or (((local-name() = 'erlref') or (local-name() = 'comref') or (local-name() = 'cref') or (local-name() = 'fileref') or (local-name() = 'appref')) and ancestor::internal))">
+ <xsl:call-template name="menu.internal.ug_ref">
+ </xsl:call-template>
+ </xsl:when>
+ <xsl:when test="(local-name() = 'internal' and descendant::chapter) or ((local-name() = 'chapter') and ancestor::internal)">
+ <!-- .../internal or .../internal/chapter -->
+ <xsl:call-template name="menu.internal.ug">
+ <xsl:with-param name="chapnum" select="$chapnum"/>
+ </xsl:call-template>
+ </xsl:when>
+ <xsl:when test="(local-name() = 'internal' and descendant::erlref) or (((local-name() = 'erlref') or (local-name() = 'comref') or (local-name() = 'cref') or (local-name() = 'fileref') or (local-name() = 'appref')) and ancestor::internal)">
+ <!-- .../internal,.../internal/erlref, .../internal/comref or .../internal/cref or .../internal/fileref or .../internal/appref -->
+ <xsl:call-template name="menu.internal.ref">
+ <xsl:with-param name="curModule" select="$curModule"/>
+ </xsl:call-template>
+ </xsl:when>
+ </xsl:choose>
<xsl:if test="(local-name() = 'application') or (((local-name() = 'erlref') or (local-name() = 'comref') or (local-name() = 'cref') or (local-name() = 'fileref') or (local-name() = 'appref')) and ancestor::application)">
<!-- .../application,.../application/erlref, .../application/comref or .../application/cref or .../application/fileref or .../application/appref -->
<xsl:call-template name="menu.ref">
@@ -1483,6 +1491,39 @@
</div>
</xsl:template>
+ <!-- Menu.internal.chapter combined when we have both modules and free-form chapters -->
+ <xsl:template name="menu.internal.ug_ref">
+ <div id="leftnav">
+ <div class="leftnav-tube">
+
+ <xsl:call-template name="erlang_logo"/>
+ <p class="section-title"><xsl:value-of select="/book/header/title"/></p>
+ <p class="section-subtitle">Internal Documentation</p>
+ <p class="section-version">Version <xsl:value-of select="$appver"/></p>
+
+ <xsl:call-template name="menu_top"/>
+
+ <xsl:call-template name="menu_middle"/>
+
+ <h3>Chapters</h3>
+
+ <ul class="flipMenu" imagepath="{$topdocdir}/js/flipmenu">
+ <xsl:call-template name="menu.chapter">
+ <xsl:with-param name="entries" select="/book/internals/internal/chapter[header/title]"/>
+ </xsl:call-template>
+ </ul>
+
+ <h3>Modules</h3>
+
+ <ul class="flipMenu">
+ <xsl:call-template name="menu.ref2">
+ <xsl:with-param name="entries" select="/book/internals/internal/erlref[module]|/book/internals/internal/cref[lib]|/book/internals/internal/comref[com]|/book/internals/internal/fileref[file]|/book/internals/internal/appref[app]"/>
+ <!--xsl:with-param name="genFuncMenu" select="true"/-->
+ </xsl:call-template>
+ </ul>
+ </div>
+ </div>
+ </xsl:template>
<!--Users Guide -->
--
2.26.2