[ 
https://issues.apache.org/jira/browse/MPLUGIN-442?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17769565#comment-17769565
 ] 

ASF GitHub Bot commented on MPLUGIN-442:
----------------------------------------

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


##########
maven-plugin-report-plugin/src/main/java/org/apache/maven/plugin/plugin/report/GoalRenderer.java:
##########
@@ -0,0 +1,544 @@
+/*
+ * 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("<a 
href=\\\"([^\\\"]*)\\\">(.*?)</a>");
+
+    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);
+    }

Review Comment:
   Fixed



##########
maven-plugin-report-plugin/src/main/java/org/apache/maven/plugin/plugin/report/PluginReport.java:
##########
@@ -229,403 +195,34 @@ public String getOutputName() {
     }
 
     /**
-     * Generate the mojos documentation, as xdoc files.
+     * Generate the mojos' documentation with the {@link #getSinkFactory()}
      *
      * @param pluginDescriptor not null
      * @param locale           not null
      * @throws MavenReportException if any
+     * @throws IOException
      */
     private void generateMojosDocumentation(PluginDescriptor pluginDescriptor, 
Locale locale)
             throws MavenReportException {
-        try {
-            File outputDir;
-            if (!locale.equals(SiteTool.DEFAULT_LOCALE)) {
-                outputDir = new File(new File(generatedSiteDirectory, 
locale.toString()), "xdoc");
-            } else {
-                outputDir = new File(generatedSiteDirectory, "xdoc");
-            }
-            outputDir.mkdirs();
-
-            PluginXdocGenerator generator = new PluginXdocGenerator(
-                    getProject(), locale, getReportOutputDirectory(), 
disableInternalJavadocLinkValidation);
-            PluginToolsRequest pluginToolsRequest = new 
DefaultPluginToolsRequest(getProject(), pluginDescriptor);
-            generator.execute(outputDir, pluginToolsRequest);
-        } catch (GeneratorException e) {
-            throw new MavenReportException("Error writing plugin 
documentation", e);
-        }
-    }
-
-    /**
-     * Generates an overview page with the list of goals
-     * and a link to the goal's page.
-     */
-    static class PluginOverviewRenderer extends AbstractMavenReportRenderer {
-        private final I18N i18n;
-
-        private final Locale locale;
-
-        private final MavenProject project;
-
-        private final List<RequirementsHistory> requirementsHistories;
-
-        private final PluginDescriptor pluginDescriptor;
-
-        private final boolean hasExtensionsToLoad;
-
-        /**
-         * @param sink                  not null
-         * @param i18n                  not null
-         * @param locale                not null
-         * @param project               not null
-         * @param requirementsHistories not null
-         * @param pluginDescriptor      not null
-         */
-        PluginOverviewRenderer(
-                Sink sink,
-                I18N i18n,
-                Locale locale,
-                MavenProject project,
-                List<RequirementsHistory> requirementsHistories,
-                PluginDescriptor pluginDescriptor,
-                boolean hasExtensionsToLoad) {
-            super(sink);
-
-            this.i18n = i18n;
-
-            this.locale = locale;
-
-            this.project = project;
-
-            this.requirementsHistories = requirementsHistories;
-
-            this.pluginDescriptor = pluginDescriptor;
-
-            this.hasExtensionsToLoad = hasExtensionsToLoad;
-        }
-
-        @Override
-        public String getTitle() {
-            return getI18nString("title");
-        }
-
-        /**
-         * @param key The key.
-         * @return The translated string.
-         */
-        protected String getI18nString(String key) {
-            return i18n.getString("plugin-report", locale, "report.plugin." + 
key);
-        }
-
-        /**
-         * {@inheritDoc}
-         */
-        @Override
-        protected void renderBody() {
-            startSection(getTitle());
-
-            if (!(pluginDescriptor.getMojos() != null
-                    && pluginDescriptor.getMojos().size() > 0)) {
-                paragraph(getI18nString("goals.nogoal"));
-                endSection();
-                return;
-            }
-
-            paragraph(getI18nString("goals.intro"));
-
-            boolean hasMavenReport = false;
-            for (MojoDescriptor mojo : pluginDescriptor.getMojos()) {
-                if (GeneratorUtils.isMavenReport(mojo.getImplementation(), 
project)) {
-                    hasMavenReport = true;
-                }
-            }
-
-            startTable();
-
-            String goalColumnName = getI18nString("goals.column.goal");
-            String isMavenReport = getI18nString("goals.column.isMavenReport");
-            String descriptionColumnName = 
getI18nString("goals.column.description");
-            if (hasMavenReport) {
-                tableHeader(new String[] {goalColumnName, isMavenReport, 
descriptionColumnName});
-            } else {
-                tableHeader(new String[] {goalColumnName, 
descriptionColumnName});
-            }
-
-            List<MojoDescriptor> mojos = new ArrayList<>();
-            mojos.addAll(pluginDescriptor.getMojos());
-            PluginUtils.sortMojos(mojos);
-            for (MojoDescriptor mojo : mojos) {
-                String goalName = mojo.getFullGoalName();
-
-                /*
-                 * Added ./ to define a relative path
-                 * @see 
AbstractMavenReportRenderer#getValidHref(java.lang.String)
-                 */
-                String goalDocumentationLink = "./" + mojo.getGoal() + 
"-mojo.html";
-
-                String description;
-                if (StringUtils.isNotEmpty(mojo.getDeprecated())) {
-                    description = "<strong>" + 
getI18nString("goal.deprecated") + "</strong> " + mojo.getDeprecated();
-                } else if (StringUtils.isNotEmpty(mojo.getDescription())) {
-                    description = mojo.getDescription();
-                } else {
-                    description = getI18nString("goal.nodescription");
-                }
-
-                sink.tableRow();
-                tableCell(createLinkPatternedText(goalName, 
goalDocumentationLink));
-                if (hasMavenReport) {
-                    if (GeneratorUtils.isMavenReport(mojo.getImplementation(), 
project)) {
-                        tableCell(getI18nString("isReport"));
-                    } else {
-                        tableCell(getI18nString("isNotReport"));
-                    }
-                }
-                tableCell(description, true);
-                sink.tableRow_();
-            }
-
-            endTable();
-
-            startSection(getI18nString("systemrequirements"));
 
-            paragraph(getI18nString("systemrequirements.intro"));
-
-            startTable();
-
-            String maven = discoverMavenRequirement(project, pluginDescriptor);
-            sink.tableRow();
-            tableCell(getI18nString("systemrequirements.maven"));
-            tableCell((maven != null ? maven : 
getI18nString("systemrequirements.nominimum")));
-            sink.tableRow_();
-
-            String jdk = discoverJdkRequirement(project, pluginDescriptor);
-            sink.tableRow();
-            tableCell(getI18nString("systemrequirements.jdk"));
-            tableCell((jdk != null ? jdk : 
getI18nString("systemrequirements.nominimum")));
-            sink.tableRow_();
-
-            endTable();
-
-            endSection();
-
-            renderRequirementsHistories();
-
-            renderUsageSection(hasMavenReport);
-
-            endSection();
-        }
-
-        private void renderRequirementsHistories() {
-            if (requirementsHistories.isEmpty()) {
-                return;
-            }
-
-            startSection(getI18nString("systemrequirements.history"));
-            paragraph(getI18nString("systemrequirements.history.intro"));
-
-            startTable();
-            tableHeader(new String[] {
-                getI18nString("systemrequirements.history.version"),
-                getI18nString("systemrequirements.history.maven"),
-                getI18nString("systemrequirements.history.jdk")
-            });
-
-            requirementsHistories.forEach(requirementsHistory -> {
-                sink.tableRow();
-                tableCell(requirementsHistory.getVersion());
-                tableCell(requirementsHistory.getMaven());
-                tableCell(requirementsHistory.getJdk());
-                sink.tableRow_();
-            });
-            endTable();
-
-            endSection();
-        }
-
-        /**
-         * Render the section about the usage of the plugin.
-         *
-         * @param hasMavenReport If the plugin has a report or not
-         */
-        private void renderUsageSection(boolean hasMavenReport) {
-            startSection(getI18nString("usage"));
-
-            // Configuration
-            paragraph(getI18nString("usage.intro"));
-
-            StringBuilder sb = new StringBuilder();
-            sb.append("<project>").append(Markup.EOL);
-            sb.append("  ...").append(Markup.EOL);
-            sb.append("  <build>").append(Markup.EOL);
-            sb.append("    <!

> Get rid of deprecated XDoc format
> ---------------------------------
>
>                 Key: MPLUGIN-442
>                 URL: https://issues.apache.org/jira/browse/MPLUGIN-442
>             Project: Maven Plugin Tools
>          Issue Type: Bug
>          Components: Plugin Plugin
>            Reporter: Konrad Windszus
>            Assignee: Konrad Windszus
>            Priority: Major
>
> At some time in the future m-site-p/doxia will no longer support XDoc 
> (compare with 
> https://issues.apache.org/jira/browse/DOXIA-569?focusedCommentId=17634481&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-17634481).
>  Therefore the "report" goal should be converted to create "markdown" for the 
> plugin goal documentation pages instead of "XDoc" in 
> https://github.com/apache/maven-plugin-tools/blob/master/maven-plugin-tools-generators/src/main/java/org/apache/maven/tools/plugin/generator/PluginXdocGenerator.java.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to