Skip to content

Commit

Permalink
[MPLUGIN-499] Add deprecate description in parameters table (#250)
Browse files Browse the repository at this point in the history
  • Loading branch information
slawekjaranowski authored Dec 27, 2023
1 parent 9bb13f0 commit 7dd3a25
Show file tree
Hide file tree
Showing 10 changed files with 95 additions and 79 deletions.
1 change: 1 addition & 0 deletions maven-plugin-report-plugin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,7 @@
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-invoker-plugin</artifactId>
<configuration>
<showErrors>true</showErrors>
<projectsDirectory>src/it</projectsDirectory>
<cloneProjectsTo>${project.build.directory}/it</cloneProjectsTo>
<preBuildHookScript>setup</preBuildHookScript>
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

assert new File( basedir, 'target/site/noop-mojo.html' ).isFile()
assert new File( basedir, 'target/site/report-mojo.html' ).isFile()

def pluginInfo = new File( basedir, 'target/site/plugin-info.html' )
assert pluginInfo.isFile()

assert !pluginInfo.text.contains('Memory')
assert !pluginInfo.text.contains('Disk Space')
// check JDK and Maven requirements
assert pluginInfo.text.contains('1.8')
assert pluginInfo.text.contains('3.2.5')

// deprecated info and description
assert pluginInfo.text.contains('<div><strong>Deprecated.</strong> You don\'t use test goals, do you?</div><br />')
assert pluginInfo.text.contains('Does nothing.')


def noopMojo = new File( basedir, 'target/site/noop-mojo.html' )
assert noopMojo.isFile()

// deprecated in table and details
assert noopMojo.text.count('<div><strong>Deprecated.</strong><br />Just testing.</div><br />') == 2

11 changes: 10 additions & 1 deletion maven-plugin-report-plugin/src/it/plugin-report/verify.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
* under the License.
*/

assert new File( basedir, 'target/site/noop-mojo.html' ).isFile()
assert new File( basedir, 'target/site/report-mojo.html' ).isFile()

def pluginInfo = new File( basedir, 'target/site/plugin-info.html' )
Expand All @@ -29,10 +28,20 @@ assert !pluginInfo.text.contains('Disk Space')
assert pluginInfo.text.contains('1.8')
assert pluginInfo.text.contains('3.2.5')

// deprecated info and description
assert pluginInfo.text.contains('<div><strong>Deprecated.</strong> You don\'t use test goals, do you?</div><br />')
assert pluginInfo.text.contains('Does nothing.')

assert new File( basedir, 'target/site/de/noop-mojo.html' ).isFile()
assert new File( basedir, 'target/site/de/report-mojo.html' ).isFile()
assert new File( basedir, 'target/site/de/plugin-info.html' ).isFile()

assert new File( basedir, 'target/site/fr/noop-mojo.html' ).isFile()
assert new File( basedir, 'target/site/fr/report-mojo.html' ).isFile()
assert new File( basedir, 'target/site/fr/plugin-info.html' ).isFile()

def noopMojo = new File( basedir, 'target/site/noop-mojo.html' )
assert noopMojo.isFile()

// deprecated in table and details
assert noopMojo.text.count('<div><strong>Deprecated.</strong><br />Just testing.</div><br />') == 2
Original file line number Diff line number Diff line change
Expand Up @@ -274,10 +274,8 @@ private void renderParameterOverviewTableRow(Parameter parameter) {
sink.tableCell();
String description;
String context = "Parameter " + parameter.getName() + " in goal " + descriptor.getGoal();
if (StringUtils.isNotEmpty(parameter.getDeprecated())) {
String deprecated = getXhtmlWithValidatedLinks(parameter.getDescription(), context);
description = format("parameter.deprecated", deprecated);
} else if (StringUtils.isNotEmpty(parameter.getDescription())) {
renderDeprecatedParameterDescription(parameter.getDeprecated(), context);
if (StringUtils.isNotEmpty(parameter.getDescription())) {
description = getXhtmlWithValidatedLinks(parameter.getDescription(), context);
} else {
description = getI18nString("nodescription");
Expand All @@ -304,13 +302,7 @@ private void renderParameterDetails(Iterator<Parameter> parameters) {
startSection(format("parameter.name", parameter.getName()));
sink.anchor_();
String context = "Parameter " + parameter.getName() + " in goal " + descriptor.getGoal();
if (StringUtils.isNotEmpty(parameter.getDeprecated())) {
sink.division();
String deprecated = getXhtmlWithValidatedLinks(parameter.getDeprecated(), context);
sink.rawText(format("parameter.deprecated", deprecated));
sink.division_();
}

renderDeprecatedParameterDescription(parameter.getDeprecated(), context);
sink.division();
if (StringUtils.isNotEmpty(parameter.getDescription())) {
sink.rawText(getXhtmlWithValidatedLinks(parameter.getDescription(), context));
Expand Down Expand Up @@ -355,6 +347,20 @@ private void renderParameterDetails(Iterator<Parameter> parameters) {
endSection();
}

private void renderDeprecatedParameterDescription(String deprecated, String context) {
if (StringUtils.isNotEmpty(deprecated)) {
String deprecatedXhtml = getXhtmlWithValidatedLinks(deprecated, context);
sink.division();
sink.inline(Semantics.STRONG);
sink.text(getI18nString("parameter.deprecated"));
sink.inline_();
sink.lineBreak();
sink.rawText(deprecatedXhtml);
sink.division_();
sink.lineBreak();
}
}

private void renderTableCellDetail(String nameKey, String value) {
if (StringUtils.isNotEmpty(value)) {
sink.lineBreak();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import org.apache.commons.lang3.StringUtils;
import org.apache.maven.doxia.markup.Markup;
import org.apache.maven.doxia.sink.Sink;
import org.apache.maven.doxia.sink.impl.SinkEventAttributeSet;
import org.apache.maven.model.Plugin;
import org.apache.maven.model.Prerequisites;
import org.apache.maven.plugin.descriptor.MojoDescriptor;
Expand Down Expand Up @@ -148,15 +149,27 @@ private void renderGoalsSection(boolean hasMavenReport) {
}
}

String description;
sink.tableCell();
if (StringUtils.isNotEmpty(mojo.getDeprecated())) {
description = "<strong>" + getI18nString("goal.deprecated") + "</strong> " + mojo.getDeprecated();
} else if (StringUtils.isNotEmpty(mojo.getDescription())) {
sink.division();
sink.inline(SinkEventAttributeSet.Semantics.STRONG);
sink.text(getI18nString("goal.deprecated"));
sink.text(".");
sink.inline_();
sink.text(" ");
sink.rawText(mojo.getDeprecated());
sink.division_();
sink.lineBreak();
}

String description;
if (StringUtils.isNotEmpty(mojo.getDescription())) {
description = mojo.getDescription();
} else {
description = getI18nString("goal.nodescription");
}
tableCell(description, true);
sink.rawText(description);
sink.tableCell_();
sink.tableRow_();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ report.plugin.goals.column.isMavenReport=Report?
report.plugin.goals.column.description=Description

report.plugin.goal.nodescription=No description.
report.plugin.goal.deprecated=Deprecated.
report.plugin.goal.deprecated=Deprecated
report.plugin.goal.notice.prefix=Note
report.plugin.goal.notice.isMavenReport=This goal should be used as a Maven report.
report.plugin.goal.fullname=Full name
Expand Down Expand Up @@ -64,7 +64,7 @@ report.plugin.goal.parameter.name=<{0}>
report.plugin.goal.parameter.defaultValue=Default
report.plugin.goal.parameter.property=User Property
report.plugin.goal.parameter.alias=Alias
report.plugin.goal.parameter.deprecated=<strong>Deprecated.</strong> {0}
report.plugin.goal.parameter.deprecated=Deprecated.
report.plugin.goal.parameter.type=Type
report.plugin.goal.parameter.required=Required
report.plugin.goal.parameter.expression=Expression
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ report.plugin.goals.column.goal=Goal
report.plugin.goals.column.isMavenReport=Bericht?
report.plugin.goals.column.description=Beschreibung
report.plugin.goal.nodescription=Keine Beschreibung.
report.plugin.goal.deprecated=Missbilligt.

report.plugin.goal.deprecated=Missbilligt
report.plugin.goal.parameter.deprecated=Missbilligt.
report.plugin.goal.yes=Ja
report.plugin.goal.no=Nein

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ report.plugin.goals.column.goal=Goal
report.plugin.goals.column.isMavenReport=Rapport?
report.plugin.goals.column.description=Description
report.plugin.goal.nodescription=Pas de description.
report.plugin.goal.deprecated=Obsol\u00E8te.

report.plugin.goal.deprecated=Obsol\u00E8te
report.plugin.goal.parameter.deprecated=Obsol\u00E8te.
report.plugin.goal.yes=Oui
report.plugin.goal.no=Non

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ report.plugin.goals.column.goal=M\u00E5l
report.plugin.goals.column.isMavenReport=Rapport?
report.plugin.goals.column.description=Beskrivning
report.plugin.goal.nodescription=Ingen beskrivning.
report.plugin.goal.deprecated=F\u00F6r\u00E5ldrat.

report.plugin.goal.deprecated=F\u00F6r\u00E5ldrat
report.plugin.goal.parameter.deprecated=F\u00F6r\u00E5ldrat.
report.plugin.goal.yes=Ja
report.plugin.goal.no=Nej

Expand Down

0 comments on commit 7dd3a25

Please sign in to comment.