Re: [PR] [MPLUGIN-442] Generate goal documentation leveraging Sink API [maven-plugin-tools]

2023-12-25 Thread via GitHub


michael-o commented on code in PR #225:
URL: 
https://github.com/apache/maven-plugin-tools/pull/225#discussion_r1436150696


##
maven-plugin-report-plugin/src/main/java/org/apache/maven/plugin/plugin/report/GoalRenderer.java:
##
@@ -0,0 +1,526 @@
+/*
+ * 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.
+ */
+package org.apache.maven.plugin.plugin.report;
+
+import java.io.File;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.text.MessageFormat;
+import java.util.AbstractMap.SimpleEntry;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Locale;
+import java.util.Map;
+import java.util.Optional;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+import java.util.stream.Collectors;
+
+import org.apache.commons.lang3.StringUtils;
+import org.apache.maven.doxia.sink.Sink;
+import org.apache.maven.doxia.sink.impl.SinkEventAttributeSet.Semantics;
+import org.apache.maven.doxia.util.HtmlTools;
+import org.apache.maven.plugin.descriptor.MojoDescriptor;
+import org.apache.maven.plugin.descriptor.Parameter;
+import org.apache.maven.plugin.logging.Log;
+import org.apache.maven.project.MavenProject;
+import org.apache.maven.tools.plugin.EnhancedParameterWrapper;
+import org.apache.maven.tools.plugin.ExtendedMojoDescriptor;
+import org.apache.maven.tools.plugin.javadoc.JavadocLinkGenerator;
+import org.apache.maven.tools.plugin.util.PluginUtils;
+import org.codehaus.plexus.i18n.I18N;
+
+public class GoalRenderer extends AbstractPluginReportRenderer {
+
+/** Regular expression matching an XHTML link with group 1 = link target, 
group 2 = link label. */
+private static final Pattern HTML_LINK_PATTERN = Pattern.compile("(.*?)");
+
+/** The directory where the generated site is written. Used for resolving 
relative links to javadoc. */
+private final File reportOutputDirectory;
+
+private final MojoDescriptor descriptor;
+private final boolean disableInternalJavadocLinkValidation;
+
+private final Log log;
+
+public GoalRenderer(
+Sink sink,
+I18N i18n,
+Locale locale,
+MavenProject project,
+MojoDescriptor descriptor,
+File reportOutputDirectory,
+boolean disableInternalJavadocLinkValidation,
+Log log) {
+super(sink, locale, i18n, project);
+this.reportOutputDirectory = reportOutputDirectory;
+this.descriptor = descriptor;
+this.disableInternalJavadocLinkValidation = 
disableInternalJavadocLinkValidation;
+this.log = log;
+}
+
+@Override
+public String getTitle() {
+return descriptor.getFullGoalName();
+}
+
+@Override
+protected void renderBody() {
+startSection(descriptor.getFullGoalName());
+renderReportNotice();
+renderDescription("fullname", descriptor.getPluginDescriptor().getId() 
+ ":" + descriptor.getGoal(), false);
+
+String context = "goal " + descriptor.getGoal();
+if (StringUtils.isNotEmpty(descriptor.getDeprecated())) {
+renderDescription("deprecated", 
getXhtmlWithValidatedLinks(descriptor.getDeprecated(), context), true);
+}
+if (StringUtils.isNotEmpty(descriptor.getDescription())) {
+renderDescription("description", 
getXhtmlWithValidatedLinks(descriptor.getDescription(), context), true);
+} else {
+renderDescription("description", getI18nString("nodescription"), 
false);
+}
+renderAttributes();
+
+List parameterList = filterParameters(
+descriptor.getParameters() != null ? 
descriptor.getParameters() : Collections.emptyList());
+if (parameterList.isEmpty()) {
+startSection(getI18nString("parameters"));
+sink.paragraph();
+sink.text(getI18nString("noParameter"));
+sink.paragraph_();
+endSection();
+} else {
+renderParameterOverviewTable(
+getI18nString("requiredParameters"),
+
parameterList.stream().filter(Parameter::isRequired).iterator());
+

Re: [PR] [MPLUGIN-442] Generate goal documentation leveraging Sink API [maven-plugin-tools]

2023-12-25 Thread via GitHub


kwin commented on code in PR #225:
URL: 
https://github.com/apache/maven-plugin-tools/pull/225#discussion_r1436150361


##
maven-plugin-report-plugin/src/main/java/org/apache/maven/plugin/plugin/report/GoalRenderer.java:
##
@@ -0,0 +1,526 @@
+/*
+ * 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.
+ */
+package org.apache.maven.plugin.plugin.report;
+
+import java.io.File;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.text.MessageFormat;
+import java.util.AbstractMap.SimpleEntry;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Locale;
+import java.util.Map;
+import java.util.Optional;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+import java.util.stream.Collectors;
+
+import org.apache.commons.lang3.StringUtils;
+import org.apache.maven.doxia.sink.Sink;
+import org.apache.maven.doxia.sink.impl.SinkEventAttributeSet.Semantics;
+import org.apache.maven.doxia.util.HtmlTools;
+import org.apache.maven.plugin.descriptor.MojoDescriptor;
+import org.apache.maven.plugin.descriptor.Parameter;
+import org.apache.maven.plugin.logging.Log;
+import org.apache.maven.project.MavenProject;
+import org.apache.maven.tools.plugin.EnhancedParameterWrapper;
+import org.apache.maven.tools.plugin.ExtendedMojoDescriptor;
+import org.apache.maven.tools.plugin.javadoc.JavadocLinkGenerator;
+import org.apache.maven.tools.plugin.util.PluginUtils;
+import org.codehaus.plexus.i18n.I18N;
+
+public class GoalRenderer extends AbstractPluginReportRenderer {
+
+/** Regular expression matching an XHTML link with group 1 = link target, 
group 2 = link label. */
+private static final Pattern HTML_LINK_PATTERN = Pattern.compile("(.*?)");
+
+/** The directory where the generated site is written. Used for resolving 
relative links to javadoc. */
+private final File reportOutputDirectory;
+
+private final MojoDescriptor descriptor;
+private final boolean disableInternalJavadocLinkValidation;
+
+private final Log log;
+
+public GoalRenderer(
+Sink sink,
+I18N i18n,
+Locale locale,
+MavenProject project,
+MojoDescriptor descriptor,
+File reportOutputDirectory,
+boolean disableInternalJavadocLinkValidation,
+Log log) {
+super(sink, locale, i18n, project);
+this.reportOutputDirectory = reportOutputDirectory;
+this.descriptor = descriptor;
+this.disableInternalJavadocLinkValidation = 
disableInternalJavadocLinkValidation;
+this.log = log;
+}
+
+@Override
+public String getTitle() {
+return descriptor.getFullGoalName();
+}
+
+@Override
+protected void renderBody() {
+startSection(descriptor.getFullGoalName());
+renderReportNotice();
+renderDescription("fullname", descriptor.getPluginDescriptor().getId() 
+ ":" + descriptor.getGoal(), false);
+
+String context = "goal " + descriptor.getGoal();
+if (StringUtils.isNotEmpty(descriptor.getDeprecated())) {
+renderDescription("deprecated", 
getXhtmlWithValidatedLinks(descriptor.getDeprecated(), context), true);
+}
+if (StringUtils.isNotEmpty(descriptor.getDescription())) {
+renderDescription("description", 
getXhtmlWithValidatedLinks(descriptor.getDescription(), context), true);
+} else {
+renderDescription("description", getI18nString("nodescription"), 
false);
+}
+renderAttributes();
+
+List parameterList = filterParameters(
+descriptor.getParameters() != null ? 
descriptor.getParameters() : Collections.emptyList());
+if (parameterList.isEmpty()) {
+startSection(getI18nString("parameters"));
+sink.paragraph();
+sink.text(getI18nString("noParameter"));
+sink.paragraph_();
+endSection();
+} else {
+renderParameterOverviewTable(
+getI18nString("requiredParameters"),
+
parameterList.stream().filter(Parameter::isRequired).iterator());
+

Re: [PR] [MPLUGIN-442] Generate goal documentation leveraging Sink API [maven-plugin-tools]

2023-12-25 Thread via GitHub


kwin commented on code in PR #225:
URL: 
https://github.com/apache/maven-plugin-tools/pull/225#discussion_r1436150361


##
maven-plugin-report-plugin/src/main/java/org/apache/maven/plugin/plugin/report/GoalRenderer.java:
##
@@ -0,0 +1,526 @@
+/*
+ * 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.
+ */
+package org.apache.maven.plugin.plugin.report;
+
+import java.io.File;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.text.MessageFormat;
+import java.util.AbstractMap.SimpleEntry;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Locale;
+import java.util.Map;
+import java.util.Optional;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+import java.util.stream.Collectors;
+
+import org.apache.commons.lang3.StringUtils;
+import org.apache.maven.doxia.sink.Sink;
+import org.apache.maven.doxia.sink.impl.SinkEventAttributeSet.Semantics;
+import org.apache.maven.doxia.util.HtmlTools;
+import org.apache.maven.plugin.descriptor.MojoDescriptor;
+import org.apache.maven.plugin.descriptor.Parameter;
+import org.apache.maven.plugin.logging.Log;
+import org.apache.maven.project.MavenProject;
+import org.apache.maven.tools.plugin.EnhancedParameterWrapper;
+import org.apache.maven.tools.plugin.ExtendedMojoDescriptor;
+import org.apache.maven.tools.plugin.javadoc.JavadocLinkGenerator;
+import org.apache.maven.tools.plugin.util.PluginUtils;
+import org.codehaus.plexus.i18n.I18N;
+
+public class GoalRenderer extends AbstractPluginReportRenderer {
+
+/** Regular expression matching an XHTML link with group 1 = link target, 
group 2 = link label. */
+private static final Pattern HTML_LINK_PATTERN = Pattern.compile("(.*?)");
+
+/** The directory where the generated site is written. Used for resolving 
relative links to javadoc. */
+private final File reportOutputDirectory;
+
+private final MojoDescriptor descriptor;
+private final boolean disableInternalJavadocLinkValidation;
+
+private final Log log;
+
+public GoalRenderer(
+Sink sink,
+I18N i18n,
+Locale locale,
+MavenProject project,
+MojoDescriptor descriptor,
+File reportOutputDirectory,
+boolean disableInternalJavadocLinkValidation,
+Log log) {
+super(sink, locale, i18n, project);
+this.reportOutputDirectory = reportOutputDirectory;
+this.descriptor = descriptor;
+this.disableInternalJavadocLinkValidation = 
disableInternalJavadocLinkValidation;
+this.log = log;
+}
+
+@Override
+public String getTitle() {
+return descriptor.getFullGoalName();
+}
+
+@Override
+protected void renderBody() {
+startSection(descriptor.getFullGoalName());
+renderReportNotice();
+renderDescription("fullname", descriptor.getPluginDescriptor().getId() 
+ ":" + descriptor.getGoal(), false);
+
+String context = "goal " + descriptor.getGoal();
+if (StringUtils.isNotEmpty(descriptor.getDeprecated())) {
+renderDescription("deprecated", 
getXhtmlWithValidatedLinks(descriptor.getDeprecated(), context), true);
+}
+if (StringUtils.isNotEmpty(descriptor.getDescription())) {
+renderDescription("description", 
getXhtmlWithValidatedLinks(descriptor.getDescription(), context), true);
+} else {
+renderDescription("description", getI18nString("nodescription"), 
false);
+}
+renderAttributes();
+
+List parameterList = filterParameters(
+descriptor.getParameters() != null ? 
descriptor.getParameters() : Collections.emptyList());
+if (parameterList.isEmpty()) {
+startSection(getI18nString("parameters"));
+sink.paragraph();
+sink.text(getI18nString("noParameter"));
+sink.paragraph_();
+endSection();
+} else {
+renderParameterOverviewTable(
+getI18nString("requiredParameters"),
+
parameterList.stream().filter(Parameter::isRequired).iterator());
+

Re: [PR] [MPLUGIN-442] Generate goal documentation leveraging Sink API [maven-plugin-tools]

2023-12-25 Thread via GitHub


slawekjaranowski commented on code in PR #225:
URL: 
https://github.com/apache/maven-plugin-tools/pull/225#discussion_r1436150142


##
maven-plugin-report-plugin/src/main/java/org/apache/maven/plugin/plugin/report/GoalRenderer.java:
##
@@ -0,0 +1,526 @@
+/*
+ * 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.
+ */
+package org.apache.maven.plugin.plugin.report;
+
+import java.io.File;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.text.MessageFormat;
+import java.util.AbstractMap.SimpleEntry;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Locale;
+import java.util.Map;
+import java.util.Optional;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+import java.util.stream.Collectors;
+
+import org.apache.commons.lang3.StringUtils;
+import org.apache.maven.doxia.sink.Sink;
+import org.apache.maven.doxia.sink.impl.SinkEventAttributeSet.Semantics;
+import org.apache.maven.doxia.util.HtmlTools;
+import org.apache.maven.plugin.descriptor.MojoDescriptor;
+import org.apache.maven.plugin.descriptor.Parameter;
+import org.apache.maven.plugin.logging.Log;
+import org.apache.maven.project.MavenProject;
+import org.apache.maven.tools.plugin.EnhancedParameterWrapper;
+import org.apache.maven.tools.plugin.ExtendedMojoDescriptor;
+import org.apache.maven.tools.plugin.javadoc.JavadocLinkGenerator;
+import org.apache.maven.tools.plugin.util.PluginUtils;
+import org.codehaus.plexus.i18n.I18N;
+
+public class GoalRenderer extends AbstractPluginReportRenderer {
+
+/** Regular expression matching an XHTML link with group 1 = link target, 
group 2 = link label. */
+private static final Pattern HTML_LINK_PATTERN = Pattern.compile("(.*?)");
+
+/** The directory where the generated site is written. Used for resolving 
relative links to javadoc. */
+private final File reportOutputDirectory;
+
+private final MojoDescriptor descriptor;
+private final boolean disableInternalJavadocLinkValidation;
+
+private final Log log;
+
+public GoalRenderer(
+Sink sink,
+I18N i18n,
+Locale locale,
+MavenProject project,
+MojoDescriptor descriptor,
+File reportOutputDirectory,
+boolean disableInternalJavadocLinkValidation,
+Log log) {
+super(sink, locale, i18n, project);
+this.reportOutputDirectory = reportOutputDirectory;
+this.descriptor = descriptor;
+this.disableInternalJavadocLinkValidation = 
disableInternalJavadocLinkValidation;
+this.log = log;
+}
+
+@Override
+public String getTitle() {
+return descriptor.getFullGoalName();
+}
+
+@Override
+protected void renderBody() {
+startSection(descriptor.getFullGoalName());
+renderReportNotice();
+renderDescription("fullname", descriptor.getPluginDescriptor().getId() 
+ ":" + descriptor.getGoal(), false);
+
+String context = "goal " + descriptor.getGoal();
+if (StringUtils.isNotEmpty(descriptor.getDeprecated())) {
+renderDescription("deprecated", 
getXhtmlWithValidatedLinks(descriptor.getDeprecated(), context), true);
+}
+if (StringUtils.isNotEmpty(descriptor.getDescription())) {
+renderDescription("description", 
getXhtmlWithValidatedLinks(descriptor.getDescription(), context), true);
+} else {
+renderDescription("description", getI18nString("nodescription"), 
false);
+}
+renderAttributes();
+
+List parameterList = filterParameters(
+descriptor.getParameters() != null ? 
descriptor.getParameters() : Collections.emptyList());
+if (parameterList.isEmpty()) {
+startSection(getI18nString("parameters"));
+sink.paragraph();
+sink.text(getI18nString("noParameter"));
+sink.paragraph_();
+endSection();
+} else {
+renderParameterOverviewTable(
+getI18nString("requiredParameters"),
+
parameterList.stream().filter(Parameter::isRequired).iterator());
+

Re: [PR] [MPLUGIN-442] Generate goal documentation leveraging Sink API [maven-plugin-tools]

2023-10-08 Thread via GitHub


kwin merged PR #225:
URL: https://github.com/apache/maven-plugin-tools/pull/225


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscr...@maven.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



Re: [PR] [MPLUGIN-442] Generate goal documentation leveraging Sink API [maven-plugin-tools]

2023-10-08 Thread via GitHub


kwin commented on code in PR #225:
URL: 
https://github.com/apache/maven-plugin-tools/pull/225#discussion_r1349712534


##
maven-plugin-report-plugin/src/main/java/org/apache/maven/plugin/plugin/report/GoalRenderer.java:
##
@@ -0,0 +1,533 @@
+/*
+ * 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.
+ */
+package org.apache.maven.plugin.plugin.report;
+
+import java.io.File;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.text.MessageFormat;
+import java.util.AbstractMap.SimpleEntry;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Locale;
+import java.util.Map;
+import java.util.Optional;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+import java.util.stream.Collectors;
+
+import org.apache.commons.lang3.StringUtils;
+import org.apache.maven.doxia.sink.Sink;
+import org.apache.maven.doxia.sink.impl.SinkEventAttributeSet.Semantics;
+import org.apache.maven.doxia.util.HtmlTools;
+import org.apache.maven.plugin.descriptor.MojoDescriptor;
+import org.apache.maven.plugin.descriptor.Parameter;
+import org.apache.maven.plugin.logging.Log;
+import org.apache.maven.project.MavenProject;
+import org.apache.maven.tools.plugin.EnhancedParameterWrapper;
+import org.apache.maven.tools.plugin.ExtendedMojoDescriptor;
+import org.apache.maven.tools.plugin.javadoc.JavadocLinkGenerator;
+import org.apache.maven.tools.plugin.util.PluginUtils;
+import org.codehaus.plexus.i18n.I18N;
+
+public class GoalRenderer extends AbstractPluginReportRenderer {
+
+/** Regular expression matching an XHTML link with group 1 = link target, 
group 2 = link label. */
+private static final Pattern HTML_LINK_PATTERN = Pattern.compile("(.*?)");
+
+/** The directory where the generated site is written. Used for resolving 
relative links to javadoc. */
+private final File reportOutputDirectory;
+
+private final MojoDescriptor descriptor;
+private final boolean disableInternalJavadocLinkValidation;
+
+private final Log log;
+
+public GoalRenderer(
+Sink sink,
+I18N i18n,
+Locale locale,
+MavenProject project,
+MojoDescriptor descriptor,
+File reportOutputDirectory,
+boolean disableInternalJavadocLinkValidation,
+Log log) {
+super(sink, locale, i18n, project);
+this.reportOutputDirectory = reportOutputDirectory;
+this.descriptor = descriptor;
+this.disableInternalJavadocLinkValidation = 
disableInternalJavadocLinkValidation;
+this.log = log;
+}
+
+@Override
+public String getTitle() {
+return descriptor.getFullGoalName();
+}
+
+@Override
+protected void renderBody() {
+startSection(descriptor.getFullGoalName());
+renderReportNotice();
+renderDescription("fullname", descriptor.getPluginDescriptor().getId() 
+ ":" + descriptor.getGoal(), false);
+
+String context = "goal " + descriptor.getGoal();
+if (StringUtils.isNotEmpty(descriptor.getDeprecated())) {
+renderDescription("deprecated", 
getXhtmlWithValidatedLinks(descriptor.getDeprecated(), context), true);
+}
+if (StringUtils.isNotEmpty(descriptor.getDescription())) {
+renderDescription("description", 
getXhtmlWithValidatedLinks(descriptor.getDescription(), context), true);
+} else {
+renderDescription("description", getI18nString("nodescription"), 
false);
+}
+renderAttributes();
+
+List parameterList = filterParameters(
+descriptor.getParameters() != null ? 
descriptor.getParameters() : Collections.emptyList());
+if (parameterList.isEmpty()) {
+startSection(getI18nString("parameters"));
+sink.paragraph();
+sink.text(getI18nString("noParameter"));
+sink.paragraph_();
+endSection();
+} else {
+renderParameterOverviewTable(
+getI18nString("requiredParameters"),
+
parameterList.stream().filter(Parameter::isRequired).iterator());
+

Re: [PR] [MPLUGIN-442] Generate goal documentation leveraging Sink API [maven-plugin-tools]

2023-10-08 Thread via GitHub


kwin commented on code in PR #225:
URL: 
https://github.com/apache/maven-plugin-tools/pull/225#discussion_r1349712534


##
maven-plugin-report-plugin/src/main/java/org/apache/maven/plugin/plugin/report/GoalRenderer.java:
##
@@ -0,0 +1,533 @@
+/*
+ * 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.
+ */
+package org.apache.maven.plugin.plugin.report;
+
+import java.io.File;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.text.MessageFormat;
+import java.util.AbstractMap.SimpleEntry;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Locale;
+import java.util.Map;
+import java.util.Optional;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+import java.util.stream.Collectors;
+
+import org.apache.commons.lang3.StringUtils;
+import org.apache.maven.doxia.sink.Sink;
+import org.apache.maven.doxia.sink.impl.SinkEventAttributeSet.Semantics;
+import org.apache.maven.doxia.util.HtmlTools;
+import org.apache.maven.plugin.descriptor.MojoDescriptor;
+import org.apache.maven.plugin.descriptor.Parameter;
+import org.apache.maven.plugin.logging.Log;
+import org.apache.maven.project.MavenProject;
+import org.apache.maven.tools.plugin.EnhancedParameterWrapper;
+import org.apache.maven.tools.plugin.ExtendedMojoDescriptor;
+import org.apache.maven.tools.plugin.javadoc.JavadocLinkGenerator;
+import org.apache.maven.tools.plugin.util.PluginUtils;
+import org.codehaus.plexus.i18n.I18N;
+
+public class GoalRenderer extends AbstractPluginReportRenderer {
+
+/** Regular expression matching an XHTML link with group 1 = link target, 
group 2 = link label. */
+private static final Pattern HTML_LINK_PATTERN = Pattern.compile("(.*?)");
+
+/** The directory where the generated site is written. Used for resolving 
relative links to javadoc. */
+private final File reportOutputDirectory;
+
+private final MojoDescriptor descriptor;
+private final boolean disableInternalJavadocLinkValidation;
+
+private final Log log;
+
+public GoalRenderer(
+Sink sink,
+I18N i18n,
+Locale locale,
+MavenProject project,
+MojoDescriptor descriptor,
+File reportOutputDirectory,
+boolean disableInternalJavadocLinkValidation,
+Log log) {
+super(sink, locale, i18n, project);
+this.reportOutputDirectory = reportOutputDirectory;
+this.descriptor = descriptor;
+this.disableInternalJavadocLinkValidation = 
disableInternalJavadocLinkValidation;
+this.log = log;
+}
+
+@Override
+public String getTitle() {
+return descriptor.getFullGoalName();
+}
+
+@Override
+protected void renderBody() {
+startSection(descriptor.getFullGoalName());
+renderReportNotice();
+renderDescription("fullname", descriptor.getPluginDescriptor().getId() 
+ ":" + descriptor.getGoal(), false);
+
+String context = "goal " + descriptor.getGoal();
+if (StringUtils.isNotEmpty(descriptor.getDeprecated())) {
+renderDescription("deprecated", 
getXhtmlWithValidatedLinks(descriptor.getDeprecated(), context), true);
+}
+if (StringUtils.isNotEmpty(descriptor.getDescription())) {
+renderDescription("description", 
getXhtmlWithValidatedLinks(descriptor.getDescription(), context), true);
+} else {
+renderDescription("description", getI18nString("nodescription"), 
false);
+}
+renderAttributes();
+
+List parameterList = filterParameters(
+descriptor.getParameters() != null ? 
descriptor.getParameters() : Collections.emptyList());
+if (parameterList.isEmpty()) {
+startSection(getI18nString("parameters"));
+sink.paragraph();
+sink.text(getI18nString("noParameter"));
+sink.paragraph_();
+endSection();
+} else {
+renderParameterOverviewTable(
+getI18nString("requiredParameters"),
+
parameterList.stream().filter(Parameter::isRequired).iterator());
+

Re: [PR] [MPLUGIN-442] Generate goal documentation leveraging Sink API [maven-plugin-tools]

2023-10-08 Thread via GitHub


michael-o commented on PR #225:
URL: 
https://github.com/apache/maven-plugin-tools/pull/225#issuecomment-1751952975

   See also https://github.com/checkstyle/checkstyle/pull/13016


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscr...@maven.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



Re: [PR] [MPLUGIN-442] Generate goal documentation leveraging Sink API [maven-plugin-tools]

2023-10-07 Thread via GitHub


michael-o commented on code in PR #225:
URL: 
https://github.com/apache/maven-plugin-tools/pull/225#discussion_r1349572491


##
maven-plugin-report-plugin/src/main/java/org/apache/maven/plugin/plugin/report/GoalRenderer.java:
##
@@ -0,0 +1,533 @@
+/*
+ * 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.
+ */
+package org.apache.maven.plugin.plugin.report;
+
+import java.io.File;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.text.MessageFormat;
+import java.util.AbstractMap.SimpleEntry;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Locale;
+import java.util.Map;
+import java.util.Optional;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+import java.util.stream.Collectors;
+
+import org.apache.commons.lang3.StringUtils;
+import org.apache.maven.doxia.sink.Sink;
+import org.apache.maven.doxia.sink.impl.SinkEventAttributeSet.Semantics;
+import org.apache.maven.doxia.util.HtmlTools;
+import org.apache.maven.plugin.descriptor.MojoDescriptor;
+import org.apache.maven.plugin.descriptor.Parameter;
+import org.apache.maven.plugin.logging.Log;
+import org.apache.maven.project.MavenProject;
+import org.apache.maven.tools.plugin.EnhancedParameterWrapper;
+import org.apache.maven.tools.plugin.ExtendedMojoDescriptor;
+import org.apache.maven.tools.plugin.javadoc.JavadocLinkGenerator;
+import org.apache.maven.tools.plugin.util.PluginUtils;
+import org.codehaus.plexus.i18n.I18N;
+
+public class GoalRenderer extends AbstractPluginReportRenderer {
+
+/** Regular expression matching an XHTML link with group 1 = link target, 
group 2 = link label. */
+private static final Pattern HTML_LINK_PATTERN = Pattern.compile("(.*?)");
+
+/** The directory where the generated site is written. Used for resolving 
relative links to javadoc. */
+private final File reportOutputDirectory;
+
+private final MojoDescriptor descriptor;
+private final boolean disableInternalJavadocLinkValidation;
+
+private final Log log;
+
+public GoalRenderer(
+Sink sink,
+I18N i18n,
+Locale locale,
+MavenProject project,
+MojoDescriptor descriptor,
+File reportOutputDirectory,
+boolean disableInternalJavadocLinkValidation,
+Log log) {
+super(sink, locale, i18n, project);
+this.reportOutputDirectory = reportOutputDirectory;
+this.descriptor = descriptor;
+this.disableInternalJavadocLinkValidation = 
disableInternalJavadocLinkValidation;
+this.log = log;
+}
+
+@Override
+public String getTitle() {
+return descriptor.getFullGoalName();
+}
+
+@Override
+protected void renderBody() {
+startSection(descriptor.getFullGoalName());
+renderReportNotice();
+renderDescription("fullname", descriptor.getPluginDescriptor().getId() 
+ ":" + descriptor.getGoal(), false);
+
+String context = "goal " + descriptor.getGoal();
+if (StringUtils.isNotEmpty(descriptor.getDeprecated())) {
+renderDescription("deprecated", 
getXhtmlWithValidatedLinks(descriptor.getDeprecated(), context), true);
+}
+if (StringUtils.isNotEmpty(descriptor.getDescription())) {
+renderDescription("description", 
getXhtmlWithValidatedLinks(descriptor.getDescription(), context), true);
+} else {
+renderDescription("description", getI18nString("nodescription"), 
false);
+}
+renderAttributes();
+
+List parameterList = filterParameters(
+descriptor.getParameters() != null ? 
descriptor.getParameters() : Collections.emptyList());
+if (parameterList.isEmpty()) {
+startSection(getI18nString("parameters"));
+sink.paragraph();
+sink.text(getI18nString("noParameter"));
+sink.paragraph_();
+endSection();
+} else {
+renderParameterOverviewTable(
+getI18nString("requiredParameters"),
+
parameterList.stream().filter(Parameter::isRequired).iterator());
+

Re: [PR] [MPLUGIN-442] Generate goal documentation leveraging Sink API [maven-plugin-tools]

2023-10-07 Thread via GitHub


kwin commented on code in PR #225:
URL: 
https://github.com/apache/maven-plugin-tools/pull/225#discussion_r1349572333


##
maven-plugin-report-plugin/src/main/java/org/apache/maven/plugin/plugin/report/GoalRenderer.java:
##
@@ -0,0 +1,533 @@
+/*
+ * 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.
+ */
+package org.apache.maven.plugin.plugin.report;
+
+import java.io.File;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.text.MessageFormat;
+import java.util.AbstractMap.SimpleEntry;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Locale;
+import java.util.Map;
+import java.util.Optional;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+import java.util.stream.Collectors;
+
+import org.apache.commons.lang3.StringUtils;
+import org.apache.maven.doxia.sink.Sink;
+import org.apache.maven.doxia.sink.impl.SinkEventAttributeSet.Semantics;
+import org.apache.maven.doxia.util.HtmlTools;
+import org.apache.maven.plugin.descriptor.MojoDescriptor;
+import org.apache.maven.plugin.descriptor.Parameter;
+import org.apache.maven.plugin.logging.Log;
+import org.apache.maven.project.MavenProject;
+import org.apache.maven.tools.plugin.EnhancedParameterWrapper;
+import org.apache.maven.tools.plugin.ExtendedMojoDescriptor;
+import org.apache.maven.tools.plugin.javadoc.JavadocLinkGenerator;
+import org.apache.maven.tools.plugin.util.PluginUtils;
+import org.codehaus.plexus.i18n.I18N;
+
+public class GoalRenderer extends AbstractPluginReportRenderer {
+
+/** Regular expression matching an XHTML link with group 1 = link target, 
group 2 = link label. */
+private static final Pattern HTML_LINK_PATTERN = Pattern.compile("(.*?)");
+
+/** The directory where the generated site is written. Used for resolving 
relative links to javadoc. */
+private final File reportOutputDirectory;
+
+private final MojoDescriptor descriptor;
+private final boolean disableInternalJavadocLinkValidation;
+
+private final Log log;
+
+public GoalRenderer(
+Sink sink,
+I18N i18n,
+Locale locale,
+MavenProject project,
+MojoDescriptor descriptor,
+File reportOutputDirectory,
+boolean disableInternalJavadocLinkValidation,
+Log log) {
+super(sink, locale, i18n, project);
+this.reportOutputDirectory = reportOutputDirectory;
+this.descriptor = descriptor;
+this.disableInternalJavadocLinkValidation = 
disableInternalJavadocLinkValidation;
+this.log = log;
+}
+
+@Override
+public String getTitle() {
+return descriptor.getFullGoalName();
+}
+
+@Override
+protected void renderBody() {
+startSection(descriptor.getFullGoalName());
+renderReportNotice();
+renderDescription("fullname", descriptor.getPluginDescriptor().getId() 
+ ":" + descriptor.getGoal(), false);
+
+String context = "goal " + descriptor.getGoal();
+if (StringUtils.isNotEmpty(descriptor.getDeprecated())) {
+renderDescription("deprecated", 
getXhtmlWithValidatedLinks(descriptor.getDeprecated(), context), true);
+}
+if (StringUtils.isNotEmpty(descriptor.getDescription())) {
+renderDescription("description", 
getXhtmlWithValidatedLinks(descriptor.getDescription(), context), true);
+} else {
+renderDescription("description", getI18nString("nodescription"), 
false);
+}
+renderAttributes();
+
+List parameterList = filterParameters(
+descriptor.getParameters() != null ? 
descriptor.getParameters() : Collections.emptyList());
+if (parameterList.isEmpty()) {
+startSection(getI18nString("parameters"));
+sink.paragraph();
+sink.text(getI18nString("noParameter"));
+sink.paragraph_();
+endSection();
+} else {
+renderParameterOverviewTable(
+getI18nString("requiredParameters"),
+
parameterList.stream().filter(Parameter::isRequired).iterator());
+

Re: [PR] [MPLUGIN-442] Generate goal documentation leveraging Sink API [maven-plugin-tools]

2023-10-07 Thread via GitHub


michael-o commented on code in PR #225:
URL: 
https://github.com/apache/maven-plugin-tools/pull/225#discussion_r1349572217


##
maven-plugin-report-plugin/src/main/java/org/apache/maven/plugin/plugin/report/GoalRenderer.java:
##
@@ -0,0 +1,533 @@
+/*
+ * 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.
+ */
+package org.apache.maven.plugin.plugin.report;
+
+import java.io.File;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.text.MessageFormat;
+import java.util.AbstractMap.SimpleEntry;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Locale;
+import java.util.Map;
+import java.util.Optional;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+import java.util.stream.Collectors;
+
+import org.apache.commons.lang3.StringUtils;
+import org.apache.maven.doxia.sink.Sink;
+import org.apache.maven.doxia.sink.impl.SinkEventAttributeSet.Semantics;
+import org.apache.maven.doxia.util.HtmlTools;
+import org.apache.maven.plugin.descriptor.MojoDescriptor;
+import org.apache.maven.plugin.descriptor.Parameter;
+import org.apache.maven.plugin.logging.Log;
+import org.apache.maven.project.MavenProject;
+import org.apache.maven.tools.plugin.EnhancedParameterWrapper;
+import org.apache.maven.tools.plugin.ExtendedMojoDescriptor;
+import org.apache.maven.tools.plugin.javadoc.JavadocLinkGenerator;
+import org.apache.maven.tools.plugin.util.PluginUtils;
+import org.codehaus.plexus.i18n.I18N;
+
+public class GoalRenderer extends AbstractPluginReportRenderer {
+
+/** Regular expression matching an XHTML link with group 1 = link target, 
group 2 = link label. */
+private static final Pattern HTML_LINK_PATTERN = Pattern.compile("(.*?)");
+
+/** The directory where the generated site is written. Used for resolving 
relative links to javadoc. */
+private final File reportOutputDirectory;
+
+private final MojoDescriptor descriptor;
+private final boolean disableInternalJavadocLinkValidation;
+
+private final Log log;
+
+public GoalRenderer(
+Sink sink,
+I18N i18n,
+Locale locale,
+MavenProject project,
+MojoDescriptor descriptor,
+File reportOutputDirectory,
+boolean disableInternalJavadocLinkValidation,
+Log log) {
+super(sink, locale, i18n, project);
+this.reportOutputDirectory = reportOutputDirectory;
+this.descriptor = descriptor;
+this.disableInternalJavadocLinkValidation = 
disableInternalJavadocLinkValidation;
+this.log = log;
+}
+
+@Override
+public String getTitle() {
+return descriptor.getFullGoalName();
+}
+
+@Override
+protected void renderBody() {
+startSection(descriptor.getFullGoalName());
+renderReportNotice();
+renderDescription("fullname", descriptor.getPluginDescriptor().getId() 
+ ":" + descriptor.getGoal(), false);
+
+String context = "goal " + descriptor.getGoal();
+if (StringUtils.isNotEmpty(descriptor.getDeprecated())) {
+renderDescription("deprecated", 
getXhtmlWithValidatedLinks(descriptor.getDeprecated(), context), true);
+}
+if (StringUtils.isNotEmpty(descriptor.getDescription())) {
+renderDescription("description", 
getXhtmlWithValidatedLinks(descriptor.getDescription(), context), true);
+} else {
+renderDescription("description", getI18nString("nodescription"), 
false);
+}
+renderAttributes();
+
+List parameterList = filterParameters(
+descriptor.getParameters() != null ? 
descriptor.getParameters() : Collections.emptyList());
+if (parameterList.isEmpty()) {
+startSection(getI18nString("parameters"));
+sink.paragraph();
+sink.text(getI18nString("noParameter"));
+sink.paragraph_();
+endSection();
+} else {
+renderParameterOverviewTable(
+getI18nString("requiredParameters"),
+
parameterList.stream().filter(Parameter::isRequired).iterator());
+

Re: [PR] [MPLUGIN-442] Generate goal documentation leveraging Sink API [maven-plugin-tools]

2023-10-07 Thread via GitHub


kwin commented on code in PR #225:
URL: 
https://github.com/apache/maven-plugin-tools/pull/225#discussion_r1349571929


##
maven-plugin-report-plugin/src/main/java/org/apache/maven/plugin/plugin/report/GoalRenderer.java:
##
@@ -0,0 +1,533 @@
+/*
+ * 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.
+ */
+package org.apache.maven.plugin.plugin.report;
+
+import java.io.File;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.text.MessageFormat;
+import java.util.AbstractMap.SimpleEntry;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Locale;
+import java.util.Map;
+import java.util.Optional;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+import java.util.stream.Collectors;
+
+import org.apache.commons.lang3.StringUtils;
+import org.apache.maven.doxia.sink.Sink;
+import org.apache.maven.doxia.sink.impl.SinkEventAttributeSet.Semantics;
+import org.apache.maven.doxia.util.HtmlTools;
+import org.apache.maven.plugin.descriptor.MojoDescriptor;
+import org.apache.maven.plugin.descriptor.Parameter;
+import org.apache.maven.plugin.logging.Log;
+import org.apache.maven.project.MavenProject;
+import org.apache.maven.tools.plugin.EnhancedParameterWrapper;
+import org.apache.maven.tools.plugin.ExtendedMojoDescriptor;
+import org.apache.maven.tools.plugin.javadoc.JavadocLinkGenerator;
+import org.apache.maven.tools.plugin.util.PluginUtils;
+import org.codehaus.plexus.i18n.I18N;
+
+public class GoalRenderer extends AbstractPluginReportRenderer {
+
+/** Regular expression matching an XHTML link with group 1 = link target, 
group 2 = link label. */
+private static final Pattern HTML_LINK_PATTERN = Pattern.compile("(.*?)");
+
+/** The directory where the generated site is written. Used for resolving 
relative links to javadoc. */
+private final File reportOutputDirectory;
+
+private final MojoDescriptor descriptor;
+private final boolean disableInternalJavadocLinkValidation;
+
+private final Log log;
+
+public GoalRenderer(
+Sink sink,
+I18N i18n,
+Locale locale,
+MavenProject project,
+MojoDescriptor descriptor,
+File reportOutputDirectory,
+boolean disableInternalJavadocLinkValidation,
+Log log) {
+super(sink, locale, i18n, project);
+this.reportOutputDirectory = reportOutputDirectory;
+this.descriptor = descriptor;
+this.disableInternalJavadocLinkValidation = 
disableInternalJavadocLinkValidation;
+this.log = log;
+}
+
+@Override
+public String getTitle() {
+return descriptor.getFullGoalName();
+}
+
+@Override
+protected void renderBody() {
+startSection(descriptor.getFullGoalName());
+renderReportNotice();
+renderDescription("fullname", descriptor.getPluginDescriptor().getId() 
+ ":" + descriptor.getGoal(), false);
+
+String context = "goal " + descriptor.getGoal();
+if (StringUtils.isNotEmpty(descriptor.getDeprecated())) {
+renderDescription("deprecated", 
getXhtmlWithValidatedLinks(descriptor.getDeprecated(), context), true);
+}
+if (StringUtils.isNotEmpty(descriptor.getDescription())) {
+renderDescription("description", 
getXhtmlWithValidatedLinks(descriptor.getDescription(), context), true);
+} else {
+renderDescription("description", getI18nString("nodescription"), 
false);
+}
+renderAttributes();
+
+List parameterList = filterParameters(
+descriptor.getParameters() != null ? 
descriptor.getParameters() : Collections.emptyList());
+if (parameterList.isEmpty()) {
+startSection(getI18nString("parameters"));
+sink.paragraph();
+sink.text(getI18nString("noParameter"));
+sink.paragraph_();
+endSection();
+} else {
+renderParameterOverviewTable(
+getI18nString("requiredParameters"),
+
parameterList.stream().filter(Parameter::isRequired).iterator());
+

Re: [PR] [MPLUGIN-442] Generate goal documentation leveraging Sink API [maven-plugin-tools]

2023-10-07 Thread via GitHub


kwin commented on code in PR #225:
URL: 
https://github.com/apache/maven-plugin-tools/pull/225#discussion_r1349571929


##
maven-plugin-report-plugin/src/main/java/org/apache/maven/plugin/plugin/report/GoalRenderer.java:
##
@@ -0,0 +1,533 @@
+/*
+ * 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.
+ */
+package org.apache.maven.plugin.plugin.report;
+
+import java.io.File;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.text.MessageFormat;
+import java.util.AbstractMap.SimpleEntry;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Locale;
+import java.util.Map;
+import java.util.Optional;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+import java.util.stream.Collectors;
+
+import org.apache.commons.lang3.StringUtils;
+import org.apache.maven.doxia.sink.Sink;
+import org.apache.maven.doxia.sink.impl.SinkEventAttributeSet.Semantics;
+import org.apache.maven.doxia.util.HtmlTools;
+import org.apache.maven.plugin.descriptor.MojoDescriptor;
+import org.apache.maven.plugin.descriptor.Parameter;
+import org.apache.maven.plugin.logging.Log;
+import org.apache.maven.project.MavenProject;
+import org.apache.maven.tools.plugin.EnhancedParameterWrapper;
+import org.apache.maven.tools.plugin.ExtendedMojoDescriptor;
+import org.apache.maven.tools.plugin.javadoc.JavadocLinkGenerator;
+import org.apache.maven.tools.plugin.util.PluginUtils;
+import org.codehaus.plexus.i18n.I18N;
+
+public class GoalRenderer extends AbstractPluginReportRenderer {
+
+/** Regular expression matching an XHTML link with group 1 = link target, 
group 2 = link label. */
+private static final Pattern HTML_LINK_PATTERN = Pattern.compile("(.*?)");
+
+/** The directory where the generated site is written. Used for resolving 
relative links to javadoc. */
+private final File reportOutputDirectory;
+
+private final MojoDescriptor descriptor;
+private final boolean disableInternalJavadocLinkValidation;
+
+private final Log log;
+
+public GoalRenderer(
+Sink sink,
+I18N i18n,
+Locale locale,
+MavenProject project,
+MojoDescriptor descriptor,
+File reportOutputDirectory,
+boolean disableInternalJavadocLinkValidation,
+Log log) {
+super(sink, locale, i18n, project);
+this.reportOutputDirectory = reportOutputDirectory;
+this.descriptor = descriptor;
+this.disableInternalJavadocLinkValidation = 
disableInternalJavadocLinkValidation;
+this.log = log;
+}
+
+@Override
+public String getTitle() {
+return descriptor.getFullGoalName();
+}
+
+@Override
+protected void renderBody() {
+startSection(descriptor.getFullGoalName());
+renderReportNotice();
+renderDescription("fullname", descriptor.getPluginDescriptor().getId() 
+ ":" + descriptor.getGoal(), false);
+
+String context = "goal " + descriptor.getGoal();
+if (StringUtils.isNotEmpty(descriptor.getDeprecated())) {
+renderDescription("deprecated", 
getXhtmlWithValidatedLinks(descriptor.getDeprecated(), context), true);
+}
+if (StringUtils.isNotEmpty(descriptor.getDescription())) {
+renderDescription("description", 
getXhtmlWithValidatedLinks(descriptor.getDescription(), context), true);
+} else {
+renderDescription("description", getI18nString("nodescription"), 
false);
+}
+renderAttributes();
+
+List parameterList = filterParameters(
+descriptor.getParameters() != null ? 
descriptor.getParameters() : Collections.emptyList());
+if (parameterList.isEmpty()) {
+startSection(getI18nString("parameters"));
+sink.paragraph();
+sink.text(getI18nString("noParameter"));
+sink.paragraph_();
+endSection();
+} else {
+renderParameterOverviewTable(
+getI18nString("requiredParameters"),
+
parameterList.stream().filter(Parameter::isRequired).iterator());
+

Re: [PR] [MPLUGIN-442] Generate goal documentation leveraging Sink API [maven-plugin-tools]

2023-10-07 Thread via GitHub


michael-o commented on code in PR #225:
URL: 
https://github.com/apache/maven-plugin-tools/pull/225#discussion_r1349571106


##
maven-plugin-report-plugin/src/main/java/org/apache/maven/plugin/plugin/report/GoalRenderer.java:
##
@@ -0,0 +1,533 @@
+/*
+ * 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.
+ */
+package org.apache.maven.plugin.plugin.report;
+
+import java.io.File;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.text.MessageFormat;
+import java.util.AbstractMap.SimpleEntry;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Locale;
+import java.util.Map;
+import java.util.Optional;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+import java.util.stream.Collectors;
+
+import org.apache.commons.lang3.StringUtils;
+import org.apache.maven.doxia.sink.Sink;
+import org.apache.maven.doxia.sink.impl.SinkEventAttributeSet.Semantics;
+import org.apache.maven.doxia.util.HtmlTools;
+import org.apache.maven.plugin.descriptor.MojoDescriptor;
+import org.apache.maven.plugin.descriptor.Parameter;
+import org.apache.maven.plugin.logging.Log;
+import org.apache.maven.project.MavenProject;
+import org.apache.maven.tools.plugin.EnhancedParameterWrapper;
+import org.apache.maven.tools.plugin.ExtendedMojoDescriptor;
+import org.apache.maven.tools.plugin.javadoc.JavadocLinkGenerator;
+import org.apache.maven.tools.plugin.util.PluginUtils;
+import org.codehaus.plexus.i18n.I18N;
+
+public class GoalRenderer extends AbstractPluginReportRenderer {
+
+/** Regular expression matching an XHTML link with group 1 = link target, 
group 2 = link label. */
+private static final Pattern HTML_LINK_PATTERN = Pattern.compile("(.*?)");
+
+/** The directory where the generated site is written. Used for resolving 
relative links to javadoc. */
+private final File reportOutputDirectory;
+
+private final MojoDescriptor descriptor;
+private final boolean disableInternalJavadocLinkValidation;
+
+private final Log log;
+
+public GoalRenderer(
+Sink sink,
+I18N i18n,
+Locale locale,
+MavenProject project,
+MojoDescriptor descriptor,
+File reportOutputDirectory,
+boolean disableInternalJavadocLinkValidation,
+Log log) {
+super(sink, locale, i18n, project);
+this.reportOutputDirectory = reportOutputDirectory;
+this.descriptor = descriptor;
+this.disableInternalJavadocLinkValidation = 
disableInternalJavadocLinkValidation;
+this.log = log;
+}
+
+@Override
+public String getTitle() {
+return descriptor.getFullGoalName();
+}
+
+@Override
+protected void renderBody() {
+startSection(descriptor.getFullGoalName());
+renderReportNotice();
+renderDescription("fullname", descriptor.getPluginDescriptor().getId() 
+ ":" + descriptor.getGoal(), false);
+
+String context = "goal " + descriptor.getGoal();
+if (StringUtils.isNotEmpty(descriptor.getDeprecated())) {
+renderDescription("deprecated", 
getXhtmlWithValidatedLinks(descriptor.getDeprecated(), context), true);
+}
+if (StringUtils.isNotEmpty(descriptor.getDescription())) {
+renderDescription("description", 
getXhtmlWithValidatedLinks(descriptor.getDescription(), context), true);
+} else {
+renderDescription("description", getI18nString("nodescription"), 
false);
+}
+renderAttributes();
+
+List parameterList = filterParameters(
+descriptor.getParameters() != null ? 
descriptor.getParameters() : Collections.emptyList());
+if (parameterList.isEmpty()) {
+startSection(getI18nString("parameters"));
+sink.paragraph();
+sink.text(getI18nString("noParameter"));
+sink.paragraph_();
+endSection();
+} else {
+renderParameterOverviewTable(
+getI18nString("requiredParameters"),
+
parameterList.stream().filter(Parameter::isRequired).iterator());
+

Re: [PR] [MPLUGIN-442] Generate goal documentation leveraging Sink API [maven-plugin-tools]

2023-10-07 Thread via GitHub


kwin commented on code in PR #225:
URL: 
https://github.com/apache/maven-plugin-tools/pull/225#discussion_r1349527396


##
maven-plugin-report-plugin/src/main/java/org/apache/maven/plugin/plugin/report/GoalRenderer.java:
##
@@ -0,0 +1,533 @@
+/*
+ * 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.
+ */
+package org.apache.maven.plugin.plugin.report;
+
+import java.io.File;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.text.MessageFormat;
+import java.util.AbstractMap.SimpleEntry;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Locale;
+import java.util.Map;
+import java.util.Optional;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+import java.util.stream.Collectors;
+
+import org.apache.commons.lang3.StringUtils;
+import org.apache.maven.doxia.sink.Sink;
+import org.apache.maven.doxia.sink.impl.SinkEventAttributeSet.Semantics;
+import org.apache.maven.doxia.util.HtmlTools;
+import org.apache.maven.plugin.descriptor.MojoDescriptor;
+import org.apache.maven.plugin.descriptor.Parameter;
+import org.apache.maven.plugin.logging.Log;
+import org.apache.maven.project.MavenProject;
+import org.apache.maven.tools.plugin.EnhancedParameterWrapper;
+import org.apache.maven.tools.plugin.ExtendedMojoDescriptor;
+import org.apache.maven.tools.plugin.javadoc.JavadocLinkGenerator;
+import org.apache.maven.tools.plugin.util.PluginUtils;
+import org.codehaus.plexus.i18n.I18N;
+
+public class GoalRenderer extends AbstractPluginReportRenderer {
+
+/** Regular expression matching an XHTML link with group 1 = link target, 
group 2 = link label. */
+private static final Pattern HTML_LINK_PATTERN = Pattern.compile("(.*?)");
+
+/** The directory where the generated site is written. Used for resolving 
relative links to javadoc. */
+private final File reportOutputDirectory;
+
+private final MojoDescriptor descriptor;
+private final boolean disableInternalJavadocLinkValidation;
+
+private final Log log;
+
+public GoalRenderer(
+Sink sink,
+I18N i18n,
+Locale locale,
+MavenProject project,
+MojoDescriptor descriptor,
+File reportOutputDirectory,
+boolean disableInternalJavadocLinkValidation,
+Log log) {
+super(sink, locale, i18n, project);
+this.reportOutputDirectory = reportOutputDirectory;
+this.descriptor = descriptor;
+this.disableInternalJavadocLinkValidation = 
disableInternalJavadocLinkValidation;
+this.log = log;
+}
+
+@Override
+public String getTitle() {
+return descriptor.getFullGoalName();
+}
+
+@Override
+protected void renderBody() {
+startSection(descriptor.getFullGoalName());
+renderReportNotice();
+renderDescription("fullname", descriptor.getPluginDescriptor().getId() 
+ ":" + descriptor.getGoal(), false);
+
+String context = "goal " + descriptor.getGoal();
+if (StringUtils.isNotEmpty(descriptor.getDeprecated())) {
+renderDescription("deprecated", 
getXhtmlWithValidatedLinks(descriptor.getDeprecated(), context), true);
+}
+if (StringUtils.isNotEmpty(descriptor.getDescription())) {
+renderDescription("description", 
getXhtmlWithValidatedLinks(descriptor.getDescription(), context), true);
+} else {
+renderDescription("description", getI18nString("nodescription"), 
false);
+}
+renderAttributes();
+
+List parameterList = filterParameters(
+descriptor.getParameters() != null ? 
descriptor.getParameters() : Collections.emptyList());
+if (parameterList.isEmpty()) {
+startSection(getI18nString("parameters"));
+sink.paragraph();
+sink.text(getI18nString("noParameter"));
+sink.paragraph_();
+endSection();
+} else {
+renderParameterOverviewTable(
+getI18nString("requiredParameters"),
+
parameterList.stream().filter(Parameter::isRequired).iterator());
+

Re: [PR] [MPLUGIN-442] Generate goal documentation leveraging Sink API [maven-plugin-tools]

2023-10-07 Thread via GitHub


kwin commented on code in PR #225:
URL: 
https://github.com/apache/maven-plugin-tools/pull/225#discussion_r1349527396


##
maven-plugin-report-plugin/src/main/java/org/apache/maven/plugin/plugin/report/GoalRenderer.java:
##
@@ -0,0 +1,533 @@
+/*
+ * 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.
+ */
+package org.apache.maven.plugin.plugin.report;
+
+import java.io.File;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.text.MessageFormat;
+import java.util.AbstractMap.SimpleEntry;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Locale;
+import java.util.Map;
+import java.util.Optional;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+import java.util.stream.Collectors;
+
+import org.apache.commons.lang3.StringUtils;
+import org.apache.maven.doxia.sink.Sink;
+import org.apache.maven.doxia.sink.impl.SinkEventAttributeSet.Semantics;
+import org.apache.maven.doxia.util.HtmlTools;
+import org.apache.maven.plugin.descriptor.MojoDescriptor;
+import org.apache.maven.plugin.descriptor.Parameter;
+import org.apache.maven.plugin.logging.Log;
+import org.apache.maven.project.MavenProject;
+import org.apache.maven.tools.plugin.EnhancedParameterWrapper;
+import org.apache.maven.tools.plugin.ExtendedMojoDescriptor;
+import org.apache.maven.tools.plugin.javadoc.JavadocLinkGenerator;
+import org.apache.maven.tools.plugin.util.PluginUtils;
+import org.codehaus.plexus.i18n.I18N;
+
+public class GoalRenderer extends AbstractPluginReportRenderer {
+
+/** Regular expression matching an XHTML link with group 1 = link target, 
group 2 = link label. */
+private static final Pattern HTML_LINK_PATTERN = Pattern.compile("(.*?)");
+
+/** The directory where the generated site is written. Used for resolving 
relative links to javadoc. */
+private final File reportOutputDirectory;
+
+private final MojoDescriptor descriptor;
+private final boolean disableInternalJavadocLinkValidation;
+
+private final Log log;
+
+public GoalRenderer(
+Sink sink,
+I18N i18n,
+Locale locale,
+MavenProject project,
+MojoDescriptor descriptor,
+File reportOutputDirectory,
+boolean disableInternalJavadocLinkValidation,
+Log log) {
+super(sink, locale, i18n, project);
+this.reportOutputDirectory = reportOutputDirectory;
+this.descriptor = descriptor;
+this.disableInternalJavadocLinkValidation = 
disableInternalJavadocLinkValidation;
+this.log = log;
+}
+
+@Override
+public String getTitle() {
+return descriptor.getFullGoalName();
+}
+
+@Override
+protected void renderBody() {
+startSection(descriptor.getFullGoalName());
+renderReportNotice();
+renderDescription("fullname", descriptor.getPluginDescriptor().getId() 
+ ":" + descriptor.getGoal(), false);
+
+String context = "goal " + descriptor.getGoal();
+if (StringUtils.isNotEmpty(descriptor.getDeprecated())) {
+renderDescription("deprecated", 
getXhtmlWithValidatedLinks(descriptor.getDeprecated(), context), true);
+}
+if (StringUtils.isNotEmpty(descriptor.getDescription())) {
+renderDescription("description", 
getXhtmlWithValidatedLinks(descriptor.getDescription(), context), true);
+} else {
+renderDescription("description", getI18nString("nodescription"), 
false);
+}
+renderAttributes();
+
+List parameterList = filterParameters(
+descriptor.getParameters() != null ? 
descriptor.getParameters() : Collections.emptyList());
+if (parameterList.isEmpty()) {
+startSection(getI18nString("parameters"));
+sink.paragraph();
+sink.text(getI18nString("noParameter"));
+sink.paragraph_();
+endSection();
+} else {
+renderParameterOverviewTable(
+getI18nString("requiredParameters"),
+
parameterList.stream().filter(Parameter::isRequired).iterator());
+

Re: [PR] [MPLUGIN-442] Generate goal documentation leveraging Sink API [maven-plugin-tools]

2023-10-07 Thread via GitHub


michael-o commented on code in PR #225:
URL: 
https://github.com/apache/maven-plugin-tools/pull/225#discussion_r1349506533


##
maven-plugin-report-plugin/src/main/java/org/apache/maven/plugin/plugin/report/GoalRenderer.java:
##
@@ -0,0 +1,533 @@
+/*
+ * 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.
+ */
+package org.apache.maven.plugin.plugin.report;
+
+import java.io.File;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.text.MessageFormat;
+import java.util.AbstractMap.SimpleEntry;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Locale;
+import java.util.Map;
+import java.util.Optional;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+import java.util.stream.Collectors;
+
+import org.apache.commons.lang3.StringUtils;
+import org.apache.maven.doxia.sink.Sink;
+import org.apache.maven.doxia.sink.impl.SinkEventAttributeSet.Semantics;
+import org.apache.maven.doxia.util.HtmlTools;
+import org.apache.maven.plugin.descriptor.MojoDescriptor;
+import org.apache.maven.plugin.descriptor.Parameter;
+import org.apache.maven.plugin.logging.Log;
+import org.apache.maven.project.MavenProject;
+import org.apache.maven.tools.plugin.EnhancedParameterWrapper;
+import org.apache.maven.tools.plugin.ExtendedMojoDescriptor;
+import org.apache.maven.tools.plugin.javadoc.JavadocLinkGenerator;
+import org.apache.maven.tools.plugin.util.PluginUtils;
+import org.codehaus.plexus.i18n.I18N;
+
+public class GoalRenderer extends AbstractPluginReportRenderer {
+
+/** Regular expression matching an XHTML link with group 1 = link target, 
group 2 = link label. */
+private static final Pattern HTML_LINK_PATTERN = Pattern.compile("(.*?)");
+
+/** The directory where the generated site is written. Used for resolving 
relative links to javadoc. */
+private final File reportOutputDirectory;
+
+private final MojoDescriptor descriptor;
+private final boolean disableInternalJavadocLinkValidation;
+
+private final Log log;
+
+public GoalRenderer(
+Sink sink,
+I18N i18n,
+Locale locale,
+MavenProject project,
+MojoDescriptor descriptor,
+File reportOutputDirectory,
+boolean disableInternalJavadocLinkValidation,
+Log log) {
+super(sink, locale, i18n, project);
+this.reportOutputDirectory = reportOutputDirectory;
+this.descriptor = descriptor;
+this.disableInternalJavadocLinkValidation = 
disableInternalJavadocLinkValidation;
+this.log = log;
+}
+
+@Override
+public String getTitle() {
+return descriptor.getFullGoalName();
+}
+
+@Override
+protected void renderBody() {
+startSection(descriptor.getFullGoalName());
+renderReportNotice();
+renderDescription("fullname", descriptor.getPluginDescriptor().getId() 
+ ":" + descriptor.getGoal(), false);
+
+String context = "goal " + descriptor.getGoal();
+if (StringUtils.isNotEmpty(descriptor.getDeprecated())) {
+renderDescription("deprecated", 
getXhtmlWithValidatedLinks(descriptor.getDeprecated(), context), true);
+}
+if (StringUtils.isNotEmpty(descriptor.getDescription())) {
+renderDescription("description", 
getXhtmlWithValidatedLinks(descriptor.getDescription(), context), true);
+} else {
+renderDescription("description", getI18nString("nodescription"), 
false);
+}
+renderAttributes();
+
+List parameterList = filterParameters(
+descriptor.getParameters() != null ? 
descriptor.getParameters() : Collections.emptyList());
+if (parameterList.isEmpty()) {
+startSection(getI18nString("parameters"));
+sink.paragraph();
+sink.text(getI18nString("noParameter"));
+sink.paragraph_();
+endSection();
+} else {
+renderParameterOverviewTable(
+getI18nString("requiredParameters"),
+
parameterList.stream().filter(Parameter::isRequired).iterator());
+

Re: [PR] [MPLUGIN-442] Generate goal documentation leveraging Sink API [maven-plugin-tools]

2023-10-06 Thread via GitHub


kwin commented on code in PR #225:
URL: 
https://github.com/apache/maven-plugin-tools/pull/225#discussion_r1348549616


##
maven-plugin-report-plugin/src/main/java/org/apache/maven/plugin/plugin/report/GoalRenderer.java:
##
@@ -0,0 +1,532 @@
+/*
+ * 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.
+ */
+package org.apache.maven.plugin.plugin.report;
+
+import java.io.File;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.text.MessageFormat;
+import java.util.AbstractMap.SimpleEntry;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Locale;
+import java.util.Map;
+import java.util.Optional;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+import java.util.stream.Collectors;
+
+import org.apache.commons.lang3.StringUtils;
+import org.apache.maven.doxia.sink.Sink;
+import org.apache.maven.doxia.sink.impl.SinkEventAttributeSet.Semantics;
+import org.apache.maven.doxia.util.HtmlTools;
+import org.apache.maven.plugin.descriptor.MojoDescriptor;
+import org.apache.maven.plugin.descriptor.Parameter;
+import org.apache.maven.plugin.logging.Log;
+import org.apache.maven.project.MavenProject;
+import org.apache.maven.tools.plugin.EnhancedParameterWrapper;
+import org.apache.maven.tools.plugin.ExtendedMojoDescriptor;
+import org.apache.maven.tools.plugin.javadoc.JavadocLinkGenerator;
+import org.apache.maven.tools.plugin.util.PluginUtils;
+import org.codehaus.plexus.i18n.I18N;
+
+public class GoalRenderer extends AbstractPluginReportRenderer {
+
+/** Regular expression matching an XHTML link with group 1 = link target, 
group 2 = link label. */
+private static final Pattern HTML_LINK_PATTERN = Pattern.compile("(.*?)");
+
+/** The directory where the generated site is written. Used for resolving 
relative links to javadoc. */
+private final File reportOutputDirectory;
+
+private final MojoDescriptor descriptor;
+private final boolean disableInternalJavadocLinkValidation;
+
+private final Log log;
+
+public GoalRenderer(
+Sink sink,
+I18N i18n,
+Locale locale,
+MavenProject project,
+MojoDescriptor descriptor,
+File reportOutputDirectory,
+boolean disableInternalJavadocLinkValidation,
+Log log) {
+super(sink, locale, i18n, project);
+this.reportOutputDirectory = reportOutputDirectory;
+this.descriptor = descriptor;
+this.disableInternalJavadocLinkValidation = 
disableInternalJavadocLinkValidation;
+this.log = log;
+}
+
+@Override
+public String getTitle() {
+return descriptor.getFullGoalName();
+}
+
+@Override
+protected void renderBody() {
+startSection(descriptor.getFullGoalName());
+renderReportNotice();
+renderDescription("fullname", descriptor.getPluginDescriptor().getId() 
+ ":" + descriptor.getGoal(), false);
+
+String context = "goal " + descriptor.getGoal();
+if (StringUtils.isNotEmpty(descriptor.getDeprecated())) {
+renderDescription("deprecated", 
getXhtmlWithValidatedLinks(descriptor.getDeprecated(), context), true);
+}
+if (StringUtils.isNotEmpty(descriptor.getDescription())) {
+renderDescription("description", 
getXhtmlWithValidatedLinks(descriptor.getDescription(), context), true);
+} else {
+renderDescription("description", getI18nString("nodescription"), 
false);
+}
+renderAttributes();
+
+List parameterList = filterParameters(
+descriptor.getParameters() != null ? 
descriptor.getParameters() : Collections.emptyList());
+if (parameterList.isEmpty()) {
+startSection(getI18nString("parameters"));
+sink.paragraph();
+sink.text(getI18nString("noParameter"));
+sink.paragraph_();
+endSection();
+} else {
+renderParameterOverviewTable(
+getI18nString("requiredParameters"),
+
parameterList.stream().filter(Parameter::isRequired).iterator());
+

Re: [PR] [MPLUGIN-442] Generate goal documentation leveraging Sink API [maven-plugin-tools]

2023-10-05 Thread via GitHub


michael-o commented on code in PR #225:
URL: 
https://github.com/apache/maven-plugin-tools/pull/225#discussion_r1347898698


##
maven-plugin-report-plugin/src/main/java/org/apache/maven/plugin/plugin/report/GoalRenderer.java:
##
@@ -0,0 +1,532 @@
+/*
+ * 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.
+ */
+package org.apache.maven.plugin.plugin.report;
+
+import java.io.File;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.text.MessageFormat;
+import java.util.AbstractMap.SimpleEntry;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Locale;
+import java.util.Map;
+import java.util.Optional;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+import java.util.stream.Collectors;
+
+import org.apache.commons.lang3.StringUtils;
+import org.apache.maven.doxia.sink.Sink;
+import org.apache.maven.doxia.sink.impl.SinkEventAttributeSet.Semantics;
+import org.apache.maven.doxia.util.HtmlTools;
+import org.apache.maven.plugin.descriptor.MojoDescriptor;
+import org.apache.maven.plugin.descriptor.Parameter;
+import org.apache.maven.plugin.logging.Log;
+import org.apache.maven.project.MavenProject;
+import org.apache.maven.tools.plugin.EnhancedParameterWrapper;
+import org.apache.maven.tools.plugin.ExtendedMojoDescriptor;
+import org.apache.maven.tools.plugin.javadoc.JavadocLinkGenerator;
+import org.apache.maven.tools.plugin.util.PluginUtils;
+import org.codehaus.plexus.i18n.I18N;
+
+public class GoalRenderer extends AbstractPluginReportRenderer {
+
+/** Regular expression matching an XHTML link with group 1 = link target, 
group 2 = link label. */
+private static final Pattern HTML_LINK_PATTERN = Pattern.compile("(.*?)");
+
+/** The directory where the generated site is written. Used for resolving 
relative links to javadoc. */
+private final File reportOutputDirectory;
+
+private final MojoDescriptor descriptor;
+private final boolean disableInternalJavadocLinkValidation;
+
+private final Log log;
+
+public GoalRenderer(
+Sink sink,
+I18N i18n,
+Locale locale,
+MavenProject project,
+MojoDescriptor descriptor,
+File reportOutputDirectory,
+boolean disableInternalJavadocLinkValidation,
+Log log) {
+super(sink, locale, i18n, project);
+this.reportOutputDirectory = reportOutputDirectory;
+this.descriptor = descriptor;
+this.disableInternalJavadocLinkValidation = 
disableInternalJavadocLinkValidation;
+this.log = log;
+}
+
+@Override
+public String getTitle() {
+return descriptor.getFullGoalName();
+}
+
+@Override
+protected void renderBody() {
+startSection(descriptor.getFullGoalName());
+renderReportNotice();
+renderDescription("fullname", descriptor.getPluginDescriptor().getId() 
+ ":" + descriptor.getGoal(), false);
+
+String context = "goal " + descriptor.getGoal();
+if (StringUtils.isNotEmpty(descriptor.getDeprecated())) {
+renderDescription("deprecated", 
getXhtmlWithValidatedLinks(descriptor.getDeprecated(), context), true);
+}
+if (StringUtils.isNotEmpty(descriptor.getDescription())) {
+renderDescription("description", 
getXhtmlWithValidatedLinks(descriptor.getDescription(), context), true);
+} else {
+renderDescription("description", getI18nString("nodescription"), 
false);
+}
+renderAttributes();
+
+List parameterList = filterParameters(
+descriptor.getParameters() != null ? 
descriptor.getParameters() : Collections.emptyList());
+if (parameterList.isEmpty()) {
+startSection(getI18nString("parameters"));
+sink.paragraph();
+sink.text(getI18nString("noParameter"));
+sink.paragraph_();
+endSection();
+} else {
+renderParameterOverviewTable(
+getI18nString("requiredParameters"),
+
parameterList.stream().filter(Parameter::isRequired).iterator());
+

Re: [PR] [MPLUGIN-442] Generate goal documentation leveraging Sink API [maven-plugin-tools]

2023-10-05 Thread via GitHub


kwin commented on code in PR #225:
URL: 
https://github.com/apache/maven-plugin-tools/pull/225#discussion_r1347773043


##
maven-plugin-report-plugin/src/main/java/org/apache/maven/plugin/plugin/report/GoalRenderer.java:
##
@@ -0,0 +1,543 @@
+/*
+ * 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.
+ */
+package org.apache.maven.plugin.plugin.report;
+
+import java.io.File;
+import java.io.IOException;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.text.MessageFormat;
+import java.util.AbstractMap.SimpleEntry;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Locale;
+import java.util.Map;
+import java.util.Optional;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+import java.util.stream.Collectors;
+
+import org.apache.commons.lang3.StringUtils;
+import org.apache.maven.doxia.sink.Sink;
+import org.apache.maven.doxia.sink.SinkFactory;
+import org.apache.maven.doxia.sink.impl.SinkEventAttributeSet.Semantics;
+import org.apache.maven.plugin.descriptor.MojoDescriptor;
+import org.apache.maven.plugin.descriptor.Parameter;
+import org.apache.maven.plugin.logging.Log;
+import org.apache.maven.project.MavenProject;
+import org.apache.maven.tools.plugin.EnhancedParameterWrapper;
+import org.apache.maven.tools.plugin.ExtendedMojoDescriptor;
+import org.apache.maven.tools.plugin.javadoc.JavadocLinkGenerator;
+import org.apache.maven.tools.plugin.util.PluginUtils;
+import org.codehaus.plexus.i18n.I18N;
+
+public class GoalRenderer extends AbstractPluginReportRenderer {
+
+/** Regular expression matching an XHTML link with group 1 = link target, 
group 2 = link label. */
+private static final Pattern HTML_LINK_PATTERN = Pattern.compile("(.*?)");
+
+public static GoalRenderer create(
+SinkFactory sinkFactory,
+File outputDirectory,
+I18N i18n,
+Locale locale,
+MavenProject project,
+MojoDescriptor descriptor,
+boolean disableInternalJavadocLinkValidation,
+Log log)
+throws IOException {
+String filename = descriptor.getGoal() + "-mojo.html";
+Sink sink = sinkFactory.createSink(outputDirectory, filename);
+return new GoalRenderer(
+sink, i18n, locale, project, descriptor, outputDirectory, 
disableInternalJavadocLinkValidation, log);
+}
+
+/** The directory where the generated site is written. Used for resolving 
relative links to javadoc. */
+private final File reportOutputDirectory;
+
+private final MojoDescriptor descriptor;
+private final boolean disableInternalJavadocLinkValidation;
+
+private final Log log;
+
+// only used from tests directly
+GoalRenderer(
+Sink sink,
+I18N i18n,
+Locale locale,
+MavenProject project,
+MojoDescriptor descriptor,
+File reportOutputDirectory,
+boolean disableInternalJavadocLinkValidation,
+Log log) {
+super(sink, locale, i18n, project);
+this.reportOutputDirectory = reportOutputDirectory;
+this.descriptor = descriptor;
+this.disableInternalJavadocLinkValidation = 
disableInternalJavadocLinkValidation;
+this.log = log;
+}
+
+@Override
+public String getTitle() {
+return descriptor.getFullGoalName();
+}
+
+@Override
+protected void renderBody() {
+startSection(descriptor.getFullGoalName());
+renderReportNotice();
+renderDescription(
+"goal.fullname", descriptor.getPluginDescriptor().getId() + 
":" + descriptor.getGoal(), false);
+
+String context = "goal " + descriptor.getGoal();
+if (StringUtils.isNotEmpty(descriptor.getDeprecated())) {
+renderDescription("goal.deprecated", 
getXhtmlWithValidatedLinks(descriptor.getDeprecated(), context), true);
+}
+if (StringUtils.isNotEmpty(descriptor.getDescription())) {
+renderDescription(
+"goal.description", 
getXhtmlWithValidatedLinks(descriptor.getDescription(), context), true);
+  

Re: [PR] [MPLUGIN-442] Generate goal documentation leveraging Sink API [maven-plugin-tools]

2023-10-05 Thread via GitHub


michael-o commented on code in PR #225:
URL: 
https://github.com/apache/maven-plugin-tools/pull/225#discussion_r1347660533


##
maven-plugin-report-plugin/src/main/java/org/apache/maven/plugin/plugin/report/GoalRenderer.java:
##
@@ -0,0 +1,543 @@
+/*
+ * 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.
+ */
+package org.apache.maven.plugin.plugin.report;
+
+import java.io.File;
+import java.io.IOException;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.text.MessageFormat;
+import java.util.AbstractMap.SimpleEntry;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Locale;
+import java.util.Map;
+import java.util.Optional;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+import java.util.stream.Collectors;
+
+import org.apache.commons.lang3.StringUtils;
+import org.apache.maven.doxia.sink.Sink;
+import org.apache.maven.doxia.sink.SinkFactory;
+import org.apache.maven.doxia.sink.impl.SinkEventAttributeSet.Semantics;
+import org.apache.maven.plugin.descriptor.MojoDescriptor;
+import org.apache.maven.plugin.descriptor.Parameter;
+import org.apache.maven.plugin.logging.Log;
+import org.apache.maven.project.MavenProject;
+import org.apache.maven.tools.plugin.EnhancedParameterWrapper;
+import org.apache.maven.tools.plugin.ExtendedMojoDescriptor;
+import org.apache.maven.tools.plugin.javadoc.JavadocLinkGenerator;
+import org.apache.maven.tools.plugin.util.PluginUtils;
+import org.codehaus.plexus.i18n.I18N;
+
+public class GoalRenderer extends AbstractPluginReportRenderer {
+
+/** Regular expression matching an XHTML link with group 1 = link target, 
group 2 = link label. */
+private static final Pattern HTML_LINK_PATTERN = Pattern.compile("(.*?)");
+
+public static GoalRenderer create(
+SinkFactory sinkFactory,
+File outputDirectory,
+I18N i18n,
+Locale locale,
+MavenProject project,
+MojoDescriptor descriptor,
+boolean disableInternalJavadocLinkValidation,
+Log log)
+throws IOException {
+String filename = descriptor.getGoal() + "-mojo.html";
+Sink sink = sinkFactory.createSink(outputDirectory, filename);
+return new GoalRenderer(
+sink, i18n, locale, project, descriptor, outputDirectory, 
disableInternalJavadocLinkValidation, log);
+}
+
+/** The directory where the generated site is written. Used for resolving 
relative links to javadoc. */
+private final File reportOutputDirectory;
+
+private final MojoDescriptor descriptor;
+private final boolean disableInternalJavadocLinkValidation;
+
+private final Log log;
+
+// only used from tests directly
+GoalRenderer(
+Sink sink,
+I18N i18n,
+Locale locale,
+MavenProject project,
+MojoDescriptor descriptor,
+File reportOutputDirectory,
+boolean disableInternalJavadocLinkValidation,
+Log log) {
+super(sink, locale, i18n, project);
+this.reportOutputDirectory = reportOutputDirectory;
+this.descriptor = descriptor;
+this.disableInternalJavadocLinkValidation = 
disableInternalJavadocLinkValidation;
+this.log = log;
+}
+
+@Override
+public String getTitle() {
+return descriptor.getFullGoalName();
+}
+
+@Override
+protected void renderBody() {
+startSection(descriptor.getFullGoalName());
+renderReportNotice();
+renderDescription(
+"goal.fullname", descriptor.getPluginDescriptor().getId() + 
":" + descriptor.getGoal(), false);
+
+String context = "goal " + descriptor.getGoal();
+if (StringUtils.isNotEmpty(descriptor.getDeprecated())) {
+renderDescription("goal.deprecated", 
getXhtmlWithValidatedLinks(descriptor.getDeprecated(), context), true);
+}
+if (StringUtils.isNotEmpty(descriptor.getDescription())) {
+renderDescription(
+"goal.description", 
getXhtmlWithValidatedLinks(descriptor.getDescription(), context), true);
+ 

Re: [PR] [MPLUGIN-442] Generate goal documentation leveraging Sink API [maven-plugin-tools]

2023-10-05 Thread via GitHub


kwin commented on code in PR #225:
URL: 
https://github.com/apache/maven-plugin-tools/pull/225#discussion_r1347628739


##
maven-plugin-report-plugin/src/main/java/org/apache/maven/plugin/plugin/report/GoalRenderer.java:
##
@@ -0,0 +1,543 @@
+/*
+ * 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.
+ */
+package org.apache.maven.plugin.plugin.report;
+
+import java.io.File;
+import java.io.IOException;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.text.MessageFormat;
+import java.util.AbstractMap.SimpleEntry;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Locale;
+import java.util.Map;
+import java.util.Optional;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+import java.util.stream.Collectors;
+
+import org.apache.commons.lang3.StringUtils;
+import org.apache.maven.doxia.sink.Sink;
+import org.apache.maven.doxia.sink.SinkFactory;
+import org.apache.maven.doxia.sink.impl.SinkEventAttributeSet.Semantics;
+import org.apache.maven.plugin.descriptor.MojoDescriptor;
+import org.apache.maven.plugin.descriptor.Parameter;
+import org.apache.maven.plugin.logging.Log;
+import org.apache.maven.project.MavenProject;
+import org.apache.maven.tools.plugin.EnhancedParameterWrapper;
+import org.apache.maven.tools.plugin.ExtendedMojoDescriptor;
+import org.apache.maven.tools.plugin.javadoc.JavadocLinkGenerator;
+import org.apache.maven.tools.plugin.util.PluginUtils;
+import org.codehaus.plexus.i18n.I18N;
+
+public class GoalRenderer extends AbstractPluginReportRenderer {
+
+/** Regular expression matching an XHTML link with group 1 = link target, 
group 2 = link label. */
+private static final Pattern HTML_LINK_PATTERN = Pattern.compile("(.*?)");
+
+public static GoalRenderer create(
+SinkFactory sinkFactory,
+File outputDirectory,
+I18N i18n,
+Locale locale,
+MavenProject project,
+MojoDescriptor descriptor,
+boolean disableInternalJavadocLinkValidation,
+Log log)
+throws IOException {
+String filename = descriptor.getGoal() + "-mojo.html";
+Sink sink = sinkFactory.createSink(outputDirectory, filename);
+return new GoalRenderer(
+sink, i18n, locale, project, descriptor, outputDirectory, 
disableInternalJavadocLinkValidation, log);
+}
+
+/** The directory where the generated site is written. Used for resolving 
relative links to javadoc. */
+private final File reportOutputDirectory;
+
+private final MojoDescriptor descriptor;
+private final boolean disableInternalJavadocLinkValidation;
+
+private final Log log;
+
+// only used from tests directly
+GoalRenderer(
+Sink sink,
+I18N i18n,
+Locale locale,
+MavenProject project,
+MojoDescriptor descriptor,
+File reportOutputDirectory,
+boolean disableInternalJavadocLinkValidation,
+Log log) {
+super(sink, locale, i18n, project);
+this.reportOutputDirectory = reportOutputDirectory;
+this.descriptor = descriptor;
+this.disableInternalJavadocLinkValidation = 
disableInternalJavadocLinkValidation;
+this.log = log;
+}
+
+@Override
+public String getTitle() {
+return descriptor.getFullGoalName();
+}
+
+@Override
+protected void renderBody() {
+startSection(descriptor.getFullGoalName());
+renderReportNotice();
+renderDescription(
+"goal.fullname", descriptor.getPluginDescriptor().getId() + 
":" + descriptor.getGoal(), false);
+
+String context = "goal " + descriptor.getGoal();
+if (StringUtils.isNotEmpty(descriptor.getDeprecated())) {
+renderDescription("goal.deprecated", 
getXhtmlWithValidatedLinks(descriptor.getDeprecated(), context), true);
+}
+if (StringUtils.isNotEmpty(descriptor.getDescription())) {
+renderDescription(
+"goal.description", 
getXhtmlWithValidatedLinks(descriptor.getDescription(), context), true);
+  

Re: [PR] [MPLUGIN-442] Generate goal documentation leveraging Sink API [maven-plugin-tools]

2023-10-03 Thread via GitHub


michael-o commented on code in PR #225:
URL: 
https://github.com/apache/maven-plugin-tools/pull/225#discussion_r1344460167


##
maven-plugin-report-plugin/src/main/java/org/apache/maven/plugin/plugin/report/GoalRenderer.java:
##
@@ -0,0 +1,543 @@
+/*
+ * 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.
+ */
+package org.apache.maven.plugin.plugin.report;
+
+import java.io.File;
+import java.io.IOException;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.text.MessageFormat;
+import java.util.AbstractMap.SimpleEntry;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Locale;
+import java.util.Map;
+import java.util.Optional;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+import java.util.stream.Collectors;
+
+import org.apache.commons.lang3.StringUtils;
+import org.apache.maven.doxia.sink.Sink;
+import org.apache.maven.doxia.sink.SinkFactory;
+import org.apache.maven.doxia.sink.impl.SinkEventAttributeSet.Semantics;
+import org.apache.maven.plugin.descriptor.MojoDescriptor;
+import org.apache.maven.plugin.descriptor.Parameter;
+import org.apache.maven.plugin.logging.Log;
+import org.apache.maven.project.MavenProject;
+import org.apache.maven.tools.plugin.EnhancedParameterWrapper;
+import org.apache.maven.tools.plugin.ExtendedMojoDescriptor;
+import org.apache.maven.tools.plugin.javadoc.JavadocLinkGenerator;
+import org.apache.maven.tools.plugin.util.PluginUtils;
+import org.codehaus.plexus.i18n.I18N;
+
+public class GoalRenderer extends AbstractPluginReportRenderer {
+
+/** Regular expression matching an XHTML link with group 1 = link target, 
group 2 = link label. */
+private static final Pattern HTML_LINK_PATTERN = Pattern.compile("(.*?)");
+
+public static GoalRenderer create(
+SinkFactory sinkFactory,
+File outputDirectory,
+I18N i18n,
+Locale locale,
+MavenProject project,
+MojoDescriptor descriptor,
+boolean disableInternalJavadocLinkValidation,
+Log log)
+throws IOException {
+String filename = descriptor.getGoal() + "-mojo.html";
+Sink sink = sinkFactory.createSink(outputDirectory, filename);
+return new GoalRenderer(
+sink, i18n, locale, project, descriptor, outputDirectory, 
disableInternalJavadocLinkValidation, log);
+}
+
+/** The directory where the generated site is written. Used for resolving 
relative links to javadoc. */
+private final File reportOutputDirectory;
+
+private final MojoDescriptor descriptor;
+private final boolean disableInternalJavadocLinkValidation;
+
+private final Log log;
+
+// only used from tests directly
+GoalRenderer(
+Sink sink,
+I18N i18n,
+Locale locale,
+MavenProject project,
+MojoDescriptor descriptor,
+File reportOutputDirectory,
+boolean disableInternalJavadocLinkValidation,
+Log log) {
+super(sink, locale, i18n, project);
+this.reportOutputDirectory = reportOutputDirectory;
+this.descriptor = descriptor;
+this.disableInternalJavadocLinkValidation = 
disableInternalJavadocLinkValidation;
+this.log = log;
+}
+
+@Override
+public String getTitle() {
+return descriptor.getFullGoalName();
+}
+
+@Override
+protected void renderBody() {
+startSection(descriptor.getFullGoalName());
+renderReportNotice();
+renderDescription(
+"goal.fullname", descriptor.getPluginDescriptor().getId() + 
":" + descriptor.getGoal(), false);
+
+String context = "goal " + descriptor.getGoal();
+if (StringUtils.isNotEmpty(descriptor.getDeprecated())) {
+renderDescription("goal.deprecated", 
getXhtmlWithValidatedLinks(descriptor.getDeprecated(), context), true);
+}
+if (StringUtils.isNotEmpty(descriptor.getDescription())) {
+renderDescription(
+"goal.description", 
getXhtmlWithValidatedLinks(descriptor.getDescription(), context), true);
+