Skip to content

Commit 679d822

Browse files
authored
[MPLUGIN-442] Generate goal documentation leveraging Sink API (#225)
Drop XDoc intermediate format
1 parent b7138b0 commit 679d822

File tree

25 files changed

+1235
-1621
lines changed

25 files changed

+1235
-1621
lines changed

maven-plugin-report-plugin/pom.xml

+6-4
Original file line numberDiff line numberDiff line change
@@ -77,10 +77,6 @@
7777
<groupId>org.apache.maven.plugin-tools</groupId>
7878
<artifactId>maven-plugin-tools-api</artifactId>
7979
</dependency>
80-
<dependency>
81-
<groupId>org.apache.maven.plugin-tools</groupId>
82-
<artifactId>maven-plugin-tools-generators</artifactId>
83-
</dependency>
8480

8581
<!-- doxia -->
8682
<dependency>
@@ -95,6 +91,12 @@
9591
<artifactId>maven-reporting-impl</artifactId>
9692
</dependency>
9793

94+
<dependency>
95+
<groupId>org.apache.commons</groupId>
96+
<artifactId>commons-lang3</artifactId>
97+
<version>3.8.1</version>
98+
<!--same version as used by doxia site renderer -->
99+
</dependency>
98100
<!-- plexus -->
99101
<dependency>
100102
<groupId>org.codehaus.plexus</groupId>

maven-plugin-report-plugin/src/it/mplugin-191/verify.groovy

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
File pluginInfo = new File( basedir, "target/site/plugin-info.html" );
1919
assert pluginInfo.isFile()
2020

21-
File touchMojo = new File( basedir, "target/generated-site/xdoc/touch-mojo.xml" );
21+
File touchMojo = new File( basedir, "target/site/touch-mojo.html" );
2222
assert touchMojo.isFile()
2323

2424
return true;

maven-plugin-report-plugin/src/it/mplugin-319_report-since/verify.groovy

+3-3
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,11 @@
1616
* specific language governing permissions and limitations
1717
* under the License.
1818
*/
19-
assert new File( basedir, 'target/generated-site' ).exists()
19+
assert new File( basedir, 'target/site/noop-mojo.html' ).exists()
2020

21-
content = new File( basedir, 'target/generated-site/xdoc/noop-mojo.xml' ).text
21+
content = new File( basedir, 'target/site/noop-mojo.html' ).text
2222

23-
assert content.contains( '<li>Since version: <code>1.0</code></li>' )
23+
assert content.contains( '<li>Since version: <code>1.0</code>.</li>' )
2424
assert content.contains( '<td><code>-</code></td>' )
2525
assert content.contains( '<td><code>1.1</code></td>' )
2626
assert content.contains( '<li><strong>Since</strong>: <code>1.1</code></li>' )

maven-plugin-report-plugin/src/it/mplugin-394_report-encoding/verify.groovy

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
* under the License.
1818
*/
1919

20-
generated = new File( basedir, "target/generated-site/xdoc/test-mojo.xml").getText("UTF-8")
20+
generated = new File( basedir, "target/site/test-mojo.html").getText("UTF-8")
2121

2222
assert generated.contains("Mojo-Description with some non-ASCII characters: €àáâãäåæòóôõöø")
2323
assert generated.contains("Parameter-Description with some non-ASCII characters: ÈÉÊË€")

maven-plugin-report-plugin/src/it/plugin-report-with-javadoc-links/verify.groovy

+5-5
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,13 @@ def mojoDoc = new File( basedir, 'target/site/test-mojo.html' )
2121

2222
assert mojoDoc.isFile()
2323

24-
assert mojoDoc.text.contains('<b>See also:</b> <a class="externalLink" href="https://docs.oracle.com/javase/8/docs/api/java/util/Collections.html">java.util.Collections</a></div>') // mojo description see javadoc tag
24+
assert mojoDoc.text.contains('<strong>See also:</strong> <a href="https://docs.oracle.com/javase/8/docs/api/java/util/Collections.html">java.util.Collections</a>') // mojo description see javadoc tag
2525

2626
assert mojoDoc.text.contains('beans parameter leveraging <a href="apidocs/org/SimpleBean.html"><code>SimpleBean</code></a>.') // parameter description
27-
assert mojoDoc.text.contains('<td><code><a href="apidocs/org/SimpleBean.html">Collection&lt;SimpleBean&gt;</a></code></td>') // type link in parameter overview
28-
assert mojoDoc.text.contains('<li><b>Type</b>: <code><a href="apidocs/org/SimpleBean.html">java.util.Collection&lt;org.SimpleBean&gt;</a></code></li>') // type link in parameter details
27+
assert mojoDoc.text.contains('<td><a href="apidocs/org/SimpleBean.html"><code>Collection&lt;SimpleBean&gt;</code></a></td>') // type link in parameter overview
28+
assert mojoDoc.text.contains('<li><strong>Type</strong>: <a href="apidocs/org/SimpleBean.html"><code>java.util.Collection&lt;org.SimpleBean&gt;</code></a></li>') // type link in parameter details
2929

30-
assert mojoDoc.text.contains('<div>invalid javadoc reference <code>org.apache.maven.artifact.Artifact</code>.</div>') // second parameter description with link being removed (as no javadoc site associated)
30+
assert mojoDoc.text.contains('invalid javadoc reference <code>org.apache.maven.artifact.Artifact</code>') // second parameter description with link being removed (as no javadoc site associated)
3131

3232
// the third parameter contains an invalid link (as the internal link validation has been switched off)
33-
assert mojoDoc.text.contains(' <code><a href="apidocs/org/internal/PrivateBean.html">org.internal.PrivateBean</a></code>')
33+
assert mojoDoc.text.contains(' <a href="apidocs/org/internal/PrivateBean.html"><code>org.internal.PrivateBean</code></a>')
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
package org.apache.maven.plugin.plugin.report;
20+
21+
import java.util.Locale;
22+
23+
import org.apache.maven.doxia.sink.Sink;
24+
import org.apache.maven.project.MavenProject;
25+
import org.apache.maven.reporting.AbstractMavenReportRenderer;
26+
import org.codehaus.plexus.i18n.I18N;
27+
28+
/** Base class for all reports generated by the plugin report plugin. */
29+
public abstract class AbstractPluginReportRenderer extends AbstractMavenReportRenderer {
30+
31+
private static final String RESOURCE_BASENAME = "plugin-report";
32+
33+
private final I18N i18n;
34+
35+
protected final Locale locale;
36+
37+
protected final MavenProject project;
38+
39+
protected AbstractPluginReportRenderer(Sink sink, Locale locale, I18N i18n, MavenProject project) {
40+
super(sink);
41+
this.i18n = i18n;
42+
this.locale = locale;
43+
this.project = project;
44+
}
45+
46+
@Override
47+
public String getTitle() {
48+
return getI18nString("title");
49+
}
50+
51+
/**
52+
* Returns
53+
* @param key The key .
54+
* @return The translated string.
55+
*/
56+
protected String getI18nString(String key) {
57+
return getI18nString(getI18nSection(), key);
58+
}
59+
60+
/**
61+
* @param section The section.
62+
* @param key The key to translate.
63+
* @return the translated key.
64+
*/
65+
protected String getI18nString(String section, String key) {
66+
return i18n.getString(RESOURCE_BASENAME, locale, "report." + section + '.' + key);
67+
}
68+
69+
/**
70+
*
71+
* @return the key prefix to be used with every key. Is prepended by {@code report.}.
72+
*/
73+
protected abstract String getI18nSection();
74+
}

0 commit comments

Comments
 (0)