Skip to content

Commit fb2dc10

Browse files
committed
Fix refentry-generate-{name,title}
Fix #568 Close #569 This PR takes a slightly different approach than the one proposed in #569, mostly in order to avoid introduce a backwards incompatible change by removing a parameter.
1 parent f4846f0 commit fb2dc10

11 files changed

Lines changed: 87 additions & 7 deletions

File tree

buildSrc/src/main/groovy/org/docbook/xsltng/gradle/TestGenerator.groovy

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,13 +141,31 @@ class TestGenerator {
141141
.withParameters([
142142
'glossary-collection': "${fProjectDir}/src/test/resources/glosscollection.xml"])
143143

144+
testEnvironments.create('refentry-name')
145+
.withParameters([
146+
'refentry-generate-name': true,
147+
'refentry-generate-title': false])
148+
149+
testEnvironments.create('refentry-title')
150+
.withParameters([
151+
'refentry-generate-name': false,
152+
'refentry-generate-title': true])
153+
154+
testEnvironments.create('refentry-neither')
155+
.withParameters([
156+
'refentry-generate-name': false,
157+
'refentry-generate-title': false])
158+
144159
testConfigurations.create('unwrapped').withEnvironments(['unwrap'])
145160
testConfigurations.create('transclude').withEnvironments(['transclude'])
146161
testConfigurations.create('local').withEnvironments(['local'])
147162
testConfigurations.create('colors').withEnvironments(['colors'])
148163
testConfigurations.create('ptoc').withEnvironments(['ptoc'])
149164
testConfigurations.create('a11y').withEnvironments(['a11y'])
150165
testConfigurations.create('glossary-collection').withEnvironments(['glossary-collection'])
166+
testConfigurations.create('refentry-name').withEnvironments(['refentry-name'])
167+
testConfigurations.create('refentry-title').withEnvironments(['refentry-title'])
168+
testConfigurations.create('refentry-neither').withEnvironments(['refentry-neither'])
151169

152170
def regexList = []
153171
['fit\\.': 'fit',
@@ -161,6 +179,9 @@ class TestGenerator {
161179
'glossary\\.00[1,2,3,4,5,6]': 'glossary-collection', // Not 7, 8, or 9!
162180
'glossary\\.01': 'glossary-collection',
163181
'book\\.014': 'book-014',
182+
'refentry-name\\.': 'refentry-name',
183+
'refentry-title\\.': 'refentry-title',
184+
'refentry-neither\\.': 'refentry-neither'
164185
].each { entry ->
165186
Pattern pat = ~"^.*${entry.key}.*\$"
166187
regexList.add(new Tuple(pat, testConfigurations.find(entry.value)))

src/guide/xml/ref-params.xml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3553,8 +3553,9 @@ the provided grammar.
35533553
<refsection>
35543554
<title>Description</title>
35553555
<para>If <parameter>refentry-generate-name</parameter> is true, the
3556-
title of the refentry page will be the word “Name”. Otherwise it will
3557-
be the title of the subject of the reference page. Generally, exactly one
3556+
title of the refentry page will be the word “Name”. Otherwise its value
3557+
depends on the setting of <parameter>refentry-generate-title</parameter>.
3558+
Generally, exactly one
35583559
of <parameter>refentry-generate-name</parameter> or
35593560
<parameter>refentry-generate-title</parameter> should
35603561
<glossterm baseform="is true">be true</glossterm>.
@@ -3566,7 +3567,7 @@ of <parameter>refentry-generate-name</parameter> or
35663567
<refmeta>
35673568
<fieldsynopsis>
35683569
<varname>refentry-generate-title</varname>
3569-
<initializer>true()</initializer>
3570+
<initializer>false()</initializer>
35703571
</fieldsynopsis>
35713572
</refmeta>
35723573
<refnamediv>

src/main/xslt/modules/refentry.xsl

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
<xsl:apply-templates select="." mode="m:attributes"/>
3232

3333
<xsl:choose>
34-
<xsl:when test="$refentry-generate-name">
34+
<xsl:when test="f:is-true($refentry-generate-name)">
3535
<header>
3636
<h2>
3737
<xsl:apply-templates select="." mode="m:gentext">
@@ -42,7 +42,7 @@
4242
</header>
4343
</xsl:when>
4444

45-
<xsl:when test="$refentry-generate-title">
45+
<xsl:when test="f:is-true($refentry-generate-title)">
4646
<header>
4747
<h2>
4848
<xsl:choose>
@@ -59,6 +59,10 @@
5959
</h2>
6060
</header>
6161
</xsl:when>
62+
63+
<xsl:otherwise>
64+
<!-- You don't get a title at all -->
65+
</xsl:otherwise>
6266
</xsl:choose>
6367

6468
<p>
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<!DOCTYPE html><html xmlns="http://www.w3.org/1999/xhtml" class="no-js"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"/><script>(function(H){H.className=H.className.replace(/\bno-js\b/,'js')})(document.documentElement)</script><title>Article wrapper</title><meta name="viewport" content="width=device-width, initial-scale=1.0"/><link href="https://purl.org/dc/elements/1.1/" rel="schema.dc"/><meta content="2011-04-22T17:02:00-06:00" name="dc.modified"/><meta content="DocBook xslTNG" name="generator"/><link href="./css/docbook.css" rel="stylesheet" media="screen"/></head><body class="home"><nav class="top"></nav><main><article class="article component"><header><h1>Article wrapper</h1></header><section id="minimal" class="component refentry"><div id="minimal_refnamediv1" class="refnamediv"><header><h2>Name</h2></header><p><span class="refname">Minimal</span><span class="refpurpose"><span class="refpurpose-sep"> — </span><span class="refpurpose-text">Test of a minimal RefEntry</span><span class="refpurpose-punc">.</span></span></p></div><section id="minimal_rs1_1" class="refsect1"><header><h2>Description</h2></header><p>This is a minimal RefEntry.</p></section></section></article></main><nav class="bottom"></nav></body></html>
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<!DOCTYPE html><html xmlns="http://www.w3.org/1999/xhtml" class="no-js"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"/><script>(function(H){H.className=H.className.replace(/\bno-js\b/,'js')})(document.documentElement)</script><title>Article wrapper</title><meta name="viewport" content="width=device-width, initial-scale=1.0"/><link href="https://purl.org/dc/elements/1.1/" rel="schema.dc"/><meta content="2011-04-22T17:02:00-06:00" name="dc.modified"/><meta content="DocBook xslTNG" name="generator"/><link href="./css/docbook.css" rel="stylesheet" media="screen"/></head><body class="home"><nav class="top"></nav><main><article class="article component"><header><h1>Article wrapper</h1></header><section id="minimal" class="component refentry"><div id="minimal_refnamediv1" class="refnamediv"><p><span class="refname">Minimal</span><span class="refpurpose"><span class="refpurpose-sep"> — </span><span class="refpurpose-text">Test of a minimal RefEntry</span><span class="refpurpose-punc">.</span></span></p></div><section id="minimal_rs1_1" class="refsect1"><header><h2>Description</h2></header><p>This is a minimal RefEntry.</p></section></section></article></main><nav class="bottom"></nav></body></html>
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<!DOCTYPE html><html xmlns="http://www.w3.org/1999/xhtml" class="no-js"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"/><script>(function(H){H.className=H.className.replace(/\bno-js\b/,'js')})(document.documentElement)</script><title>Article wrapper</title><meta name="viewport" content="width=device-width, initial-scale=1.0"/><link href="https://purl.org/dc/elements/1.1/" rel="schema.dc"/><meta content="2011-04-22T17:02:00-06:00" name="dc.modified"/><meta content="DocBook xslTNG" name="generator"/><link href="./css/docbook.css" rel="stylesheet" media="screen"/></head><body class="home"><nav class="top"></nav><main><article class="article component"><header><h1>Article wrapper</h1></header><section id="minimal" class="component refentry"><div id="minimal_refnamediv1" class="refnamediv"><header><h2><span class="refentrytitle">Minimal Title</span></h2></header><p><span class="refname">Minimal</span><span class="refpurpose"><span class="refpurpose-sep"> — </span><span class="refpurpose-text">Test of a minimal RefEntry</span><span class="refpurpose-punc">.</span></span></p></div><section id="minimal_rs1_1" class="refsect1"><header><h2>Description</h2></header><p>This is a minimal RefEntry.</p></section></section></article></main><nav class="bottom"></nav></body></html>
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<!DOCTYPE html><html xmlns="http://www.w3.org/1999/xhtml" class="no-js"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"/><script>(function(H){H.className=H.className.replace(/\bno-js\b/,'js')})(document.documentElement)</script><title>Unit Test: refentry.011</title><meta name="viewport" content="width=device-width, initial-scale=1.0"/><link href="https://purl.org/dc/elements/1.1/" rel="schema.dc"/><meta content="2011-04-22T17:02:00-06:00" name="dc.modified"/><meta content="DocBook xslTNG" name="generator"/><link href="./css/docbook.css" rel="stylesheet" media="screen"/><script src="./js/copy-verbatim.js" defer="defer"></script></head><body class="home"><nav class="top"></nav><main><article class="article component"><header><h1>Unit Test: refentry.011</h1></header><p>This <code class="tag tag-element">refentry</code> has no title but does have
1+
<!DOCTYPE html><html xmlns="http://www.w3.org/1999/xhtml" class="no-js"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"/><script>(function(H){H.className=H.className.replace(/\bno-js\b/,'js')})(document.documentElement)</script><title>Unit Test: refentry.013</title><meta name="viewport" content="width=device-width, initial-scale=1.0"/><link href="https://purl.org/dc/elements/1.1/" rel="schema.dc"/><meta content="2011-04-22T17:02:00-06:00" name="dc.modified"/><meta content="DocBook xslTNG" name="generator"/><link href="./css/docbook.css" rel="stylesheet" media="screen"/><script src="./js/copy-verbatim.js" defer="defer"></script></head><body class="home"><nav class="top"></nav><main><article class="article component"><header><h1>Unit Test: refentry.013</h1></header><p>This <code class="tag tag-element">refentry</code> has no title but does have
22
<code class="tag tag-element">refdescriptor</code>.</p><section id="printf" class="component refentry"><div id="printf_refnamediv1" class="refnamediv"><header><h2>Name</h2></header><p><span class="refdescriptor">print*</span><span class="refpurpose"><span class="refpurpose-sep"> — </span><span class="refpurpose-text">print formatted output</span><span class="refpurpose-punc">.</span></span></p></div><section id="printf_refsynopsisdiv1" class="refsynopsisdiv"><header><h2>Synopsis</h2></header><div class="funcsynopsis"><div class="pre-wrap funcsynopsisinfo-wrap"><pre class="funcsynopsisinfo verbatim"><code>#include &lt;stdio.h&gt;</code></pre></div><div class="funcprototype"><div><span class="funcdef">int <span class="function">printf</span></span><span class="arglist">(<span><span class="parameter">format</span><span>, </span></span><span></span>);</span></div><div class="paramdef">const char *<span class="parameter">format</span>;</div><div class="paramdef">...;</div></div><div class="funcprototype"><table class="prototype"><tbody><tr><td><span class="funcdef">int <span class="function">fprintf</span></span>(</td><td class="paramdef"><span class="parameter">strm</span>,</td></tr><tr><td rowspan="2"></td><td class="paramdef"><span class="parameter">format</span>,</td></tr><tr><td class="paramdef">);</td></tr></tbody></table><table class="params"><tbody><tr class="paramdef"><td>FILE *</td><td><span class="parameter">strm</span></td></tr><tr class="paramdef"><td>const char *</td><td><span class="parameter">format</span></td></tr><tr class="paramdef"><td></td><td></td></tr></tbody></table></div><div class="funcprototype"><div><span class="funcdef">int <span class="function">sprintf</span></span><span class="arglist">(<span><span class="parameter">s</span><span>, </span></span><span><span class="parameter">format</span><span>, </span></span><span></span>);</span></div><div class="paramdef">char *<span class="parameter">s</span>;</div><div class="paramdef">const char *<span class="parameter">format</span>;</div><div class="paramdef">...;</div></div></div></section><section id="printf_rs1_1" class="refsect1"><header><h2>Description</h2></header><p><code class="function">printf</code> places output on the standard
33
output stream stdout.
44
</p><p></p></section></section></article></main><nav class="bottom"></nav></body></html>
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<article xmlns="http://docbook.org/ns/docbook" version="5.0">
3+
<title>Article wrapper</title>
4+
<refentry xml:id="minimal">
5+
<refmeta>
6+
<refentrytitle>Minimal Title</refentrytitle>
7+
</refmeta>
8+
<refnamediv>
9+
<refname>Minimal</refname>
10+
<refpurpose>Test of a minimal RefEntry</refpurpose>
11+
</refnamediv>
12+
<refsect1>
13+
<title>Description</title>
14+
<para>This is a minimal RefEntry.</para>
15+
</refsect1>
16+
</refentry>
17+
</article>
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<article xmlns="http://docbook.org/ns/docbook" version="5.0">
3+
<title>Article wrapper</title>
4+
<refentry xml:id="minimal">
5+
<refmeta>
6+
<refentrytitle>Minimal Title</refentrytitle>
7+
</refmeta>
8+
<refnamediv>
9+
<refname>Minimal</refname>
10+
<refpurpose>Test of a minimal RefEntry</refpurpose>
11+
</refnamediv>
12+
<refsect1>
13+
<title>Description</title>
14+
<para>This is a minimal RefEntry.</para>
15+
</refsect1>
16+
</refentry>
17+
</article>
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<article xmlns="http://docbook.org/ns/docbook" version="5.0">
3+
<title>Article wrapper</title>
4+
<refentry xml:id="minimal">
5+
<refmeta>
6+
<refentrytitle>Minimal Title</refentrytitle>
7+
</refmeta>
8+
<refnamediv>
9+
<refname>Minimal</refname>
10+
<refpurpose>Test of a minimal RefEntry</refpurpose>
11+
</refnamediv>
12+
<refsect1>
13+
<title>Description</title>
14+
<para>This is a minimal RefEntry.</para>
15+
</refsect1>
16+
</refentry>
17+
</article>

0 commit comments

Comments
 (0)