From 7dd3a259585b50f3d450d68e480eb3da8d19e70b Mon Sep 17 00:00:00 2001 From: Slawomir Jaranowski Date: Wed, 27 Dec 2023 11:06:52 +0100 Subject: [PATCH] [MPLUGIN-499] Add deprecate description in parameters table (#250) --- maven-plugin-report-plugin/pom.xml | 1 + .../it/plugin-report-annotations/verify.bsh | 55 ------------------- .../plugin-report-annotations/verify.groovy | 42 ++++++++++++++ .../src/it/plugin-report/verify.groovy | 11 +++- .../plugin/plugin/report/GoalRenderer.java | 28 ++++++---- .../plugin/report/PluginOverviewRenderer.java | 21 +++++-- .../main/resources/plugin-report.properties | 4 +- .../resources/plugin-report_de.properties | 4 +- .../resources/plugin-report_fr.properties | 4 +- .../resources/plugin-report_sv.properties | 4 +- 10 files changed, 95 insertions(+), 79 deletions(-) delete mode 100644 maven-plugin-report-plugin/src/it/plugin-report-annotations/verify.bsh create mode 100644 maven-plugin-report-plugin/src/it/plugin-report-annotations/verify.groovy diff --git a/maven-plugin-report-plugin/pom.xml b/maven-plugin-report-plugin/pom.xml index f7143f0b5..99e392b15 100644 --- a/maven-plugin-report-plugin/pom.xml +++ b/maven-plugin-report-plugin/pom.xml @@ -241,6 +241,7 @@ org.apache.maven.plugins maven-invoker-plugin + true src/it ${project.build.directory}/it setup diff --git a/maven-plugin-report-plugin/src/it/plugin-report-annotations/verify.bsh b/maven-plugin-report-plugin/src/it/plugin-report-annotations/verify.bsh deleted file mode 100644 index e884269ea..000000000 --- a/maven-plugin-report-plugin/src/it/plugin-report-annotations/verify.bsh +++ /dev/null @@ -1,55 +0,0 @@ -/* - * 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. - */ - -import java.io.*; -import java.util.*; -import java.util.regex.*; - -try -{ - File siteDir = new File( basedir, "target/site" ); - System.out.println( "Checking for existence of site directory: " + siteDir ); - if ( !siteDir.isDirectory() ) - { - System.out.println( "FAILED!" ); - return false; - } - - String[] expectedFiles = { - "noop-mojo.html", - "report-mojo.html", - }; - for ( String path : expectedFiles ) - { - File file = new File( siteDir, path ); - System.out.println( "Checking for existence of doc file: " + file ); - if ( !file.isFile() || file.length() <= 0 ) - { - System.out.println( "FAILED!" ); - return false; - } - } -} -catch( Throwable t ) -{ - t.printStackTrace(); - return false; -} - -return true; diff --git a/maven-plugin-report-plugin/src/it/plugin-report-annotations/verify.groovy b/maven-plugin-report-plugin/src/it/plugin-report-annotations/verify.groovy new file mode 100644 index 000000000..281cbbd3c --- /dev/null +++ b/maven-plugin-report-plugin/src/it/plugin-report-annotations/verify.groovy @@ -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('
Deprecated. You don\'t use test goals, do you?

') +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('
Deprecated.
Just testing.

') == 2 + diff --git a/maven-plugin-report-plugin/src/it/plugin-report/verify.groovy b/maven-plugin-report-plugin/src/it/plugin-report/verify.groovy index 2f24cb8ae..f77584dc8 100644 --- a/maven-plugin-report-plugin/src/it/plugin-report/verify.groovy +++ b/maven-plugin-report-plugin/src/it/plugin-report/verify.groovy @@ -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' ) @@ -29,6 +28,10 @@ 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('
Deprecated. You don\'t use test goals, do you?

') +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() @@ -36,3 +39,9 @@ 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('
Deprecated.
Just testing.

') == 2 diff --git a/maven-plugin-report-plugin/src/main/java/org/apache/maven/plugin/plugin/report/GoalRenderer.java b/maven-plugin-report-plugin/src/main/java/org/apache/maven/plugin/plugin/report/GoalRenderer.java index eac6c0c7d..62d38c150 100644 --- a/maven-plugin-report-plugin/src/main/java/org/apache/maven/plugin/plugin/report/GoalRenderer.java +++ b/maven-plugin-report-plugin/src/main/java/org/apache/maven/plugin/plugin/report/GoalRenderer.java @@ -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"); @@ -304,13 +302,7 @@ private void renderParameterDetails(Iterator 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)); @@ -355,6 +347,20 @@ private void renderParameterDetails(Iterator 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(); diff --git a/maven-plugin-report-plugin/src/main/java/org/apache/maven/plugin/plugin/report/PluginOverviewRenderer.java b/maven-plugin-report-plugin/src/main/java/org/apache/maven/plugin/plugin/report/PluginOverviewRenderer.java index 9b772fc12..a601bd508 100644 --- a/maven-plugin-report-plugin/src/main/java/org/apache/maven/plugin/plugin/report/PluginOverviewRenderer.java +++ b/maven-plugin-report-plugin/src/main/java/org/apache/maven/plugin/plugin/report/PluginOverviewRenderer.java @@ -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; @@ -148,15 +149,27 @@ private void renderGoalsSection(boolean hasMavenReport) { } } - String description; + sink.tableCell(); if (StringUtils.isNotEmpty(mojo.getDeprecated())) { - description = "" + getI18nString("goal.deprecated") + " " + 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_(); } diff --git a/maven-plugin-report-plugin/src/main/resources/plugin-report.properties b/maven-plugin-report-plugin/src/main/resources/plugin-report.properties index c94797313..1a3fb266a 100644 --- a/maven-plugin-report-plugin/src/main/resources/plugin-report.properties +++ b/maven-plugin-report-plugin/src/main/resources/plugin-report.properties @@ -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 @@ -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=Deprecated. {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 diff --git a/maven-plugin-report-plugin/src/main/resources/plugin-report_de.properties b/maven-plugin-report-plugin/src/main/resources/plugin-report_de.properties index a4975f11b..06831a33b 100644 --- a/maven-plugin-report-plugin/src/main/resources/plugin-report_de.properties +++ b/maven-plugin-report-plugin/src/main/resources/plugin-report_de.properties @@ -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 diff --git a/maven-plugin-report-plugin/src/main/resources/plugin-report_fr.properties b/maven-plugin-report-plugin/src/main/resources/plugin-report_fr.properties index e430ab38a..548fcd9ba 100644 --- a/maven-plugin-report-plugin/src/main/resources/plugin-report_fr.properties +++ b/maven-plugin-report-plugin/src/main/resources/plugin-report_fr.properties @@ -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 diff --git a/maven-plugin-report-plugin/src/main/resources/plugin-report_sv.properties b/maven-plugin-report-plugin/src/main/resources/plugin-report_sv.properties index f4b89b988..0c4fde5b4 100644 --- a/maven-plugin-report-plugin/src/main/resources/plugin-report_sv.properties +++ b/maven-plugin-report-plugin/src/main/resources/plugin-report_sv.properties @@ -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