Skip to content

Commit 97bdee4

Browse files
Copilotslachiewicz
andcommitted
Successfully migrate XdocGenerator to Doxia Sink API with XDOC 2.0 output
Co-authored-by: slachiewicz <6705942+slachiewicz@users.noreply.github.com>
1 parent 62210a5 commit 97bdee4

File tree

3 files changed

+24
-44
lines changed

3 files changed

+24
-44
lines changed

modello-plugins/modello-plugin-xdoc/src/main/java/org/codehaus/modello/plugin/xdoc/XdocGenerator.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,8 @@ private void writeFieldsTable(Sink sink, List<ModelField> fields, boolean elemen
289289
return;
290290
}
291291

292-
sink.table(null);
292+
// Workaround: Doxia Sink's table() method doesn't seem to output <table> tag
293+
sink.rawText("<table>");
293294

294295
sink.tableRow();
295296

@@ -440,7 +441,7 @@ private void writeFieldsTable(Sink sink, List<ModelField> fields, boolean elemen
440441
sink.tableRow_();
441442
}
442443

443-
sink.table_();
444+
sink.rawText("</table>");
444445
}
445446

446447
/**

modello-plugins/modello-plugin-xdoc/src/test/java/org/codehaus/modello/plugin/xdoc/XdocGeneratorTest.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -180,12 +180,13 @@ private void checkInternalLinks(String filename) throws Exception {
180180
Assert.assertTrue("should find some '<a href=' links", hrefs.size() > 0);
181181

182182
Set<String> names = new HashSet<String>();
183-
p = Pattern.compile("<a name=\"(class_[^\"]+)\"", Pattern.CASE_INSENSITIVE | Pattern.MULTILINE);
183+
// Support both XDOC 1.0 (<a name=) and XDOC 2.0 (<a id=) formats
184+
p = Pattern.compile("<a (?:name|id)=\"(class_[^\"]+)\"", Pattern.CASE_INSENSITIVE | Pattern.MULTILINE);
184185
m = p.matcher(content);
185186
while (m.find()) {
186187
names.add(m.group(1));
187188
}
188-
Assert.assertTrue("should find some '<a name=' anchor definitions", names.size() > 0);
189+
Assert.assertTrue("should find some '<a name=' or '<a id=' anchor definitions", names.size() > 0);
189190

190191
hrefs.removeAll(names);
191192
if (hrefs.size() > 0) {
Lines changed: 18 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,26 @@
1-
<?xml version="1.0"?>
2-
<!-- =================== DO NOT EDIT THIS FILE ==================== -->
3-
<!-- Generated by Modello, -->
4-
<!-- any modifications will be overwritten. -->
5-
<!-- ============================================================== -->
6-
<document>
7-
<properties>
8-
<title>Modello Java Mojo Test Model</title>
9-
</properties>
10-
<body>
11-
<section name="Modello Java Mojo Test Model">
12-
<p>No description.</p>
13-
<source>
1+
<?xml version="1.0" encoding="UTF-8"?><document xmlns="http://maven.apache.org/XDOC/2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/XDOC/2.0 https://maven.apache.org/xsd/xdoc-2.0.xsd"><properties>
2+
<title>Modello Java Mojo Test Model</title></properties>
3+
<body><section name="Modello Java Mojo Test Model">
4+
<p>No description.</p>
5+
<pre>
146
&lt;<a href="#class_model">model</a>&gt;
157
&lt;extend/&gt;
168
&lt;/model&gt;
17-
</source>
18-
<a name="class_model"/>
19-
<subsection name="model">
20-
<p>Whether this proxy configuration is the active one. Note: While the type of this field is <code>String</code> for technical reasons, the semantic type is actually <code>boolean</code>.
9+
</pre><a id="class_model"></a><subsection name="model">
10+
<p>Whether this proxy configuration is the active one. Note: While the type of this field is <code>String</code> for technical reasons, the semantic type is actually <code>boolean</code>.
2111
<br />
2212
This is a description in HTML4
2313
<br />
2414
<strong>NOTE: </strong> HTML linebreak should be converted to selfclosing XML-tag
2515
<br />
26-
<p><b>Since</b>: Maven 3</p></p>
27-
<table>
28-
<tr>
29-
<th>Element</th>
30-
<th>Type</th>
31-
<th>Since</th>
32-
<th>Description</th>
33-
</tr>
34-
<tr>
35-
<td>
36-
<code>extend</code>
37-
</td>
38-
<td>
39-
<code>String</code>
40-
</td>
41-
<td>1.0.0</td>
42-
<td>No description.</td>
43-
</tr>
44-
</table>
45-
</subsection>
46-
</section>
47-
</body>
48-
</document>
16+
<p><b>Since</b>: Maven 3</p></p><table>
17+
<tr>
18+
<th>Element</th>
19+
<th>Type</th>
20+
<th>Since</th>
21+
<th>Description</th></tr>
22+
<tr>
23+
<td><code>extend</code></td>
24+
<td><code>String</code></td>
25+
<td>1.0.0</td>
26+
<td>No description.</td></tr></table></subsection></section></body></document>

0 commit comments

Comments
 (0)