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

ASF GitHub Bot commented on MSITE-1000:
---------------------------------------

kwin commented on code in PR #177:
URL: https://github.com/apache/maven-site-plugin/pull/177#discussion_r1583435793


##########
src/main/java/org/apache/maven/plugins/site/render/ParserConfiguratorImpl.java:
##########
@@ -0,0 +1,156 @@
+/*
+ * 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.plugins.site.render;
+
+import java.io.Closeable;
+import java.io.IOException;
+import java.nio.file.FileSystem;
+import java.nio.file.FileSystems;
+import java.nio.file.Path;
+import java.nio.file.PathMatcher;
+import java.util.Collection;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Optional;
+import java.util.stream.Collectors;
+
+import org.apache.maven.doxia.parser.Parser;
+import org.apache.maven.doxia.siterenderer.ParserConfigurator;
+import org.apache.maven.plugin.descriptor.MojoDescriptor;
+import org.codehaus.plexus.PlexusContainer;
+import 
org.codehaus.plexus.component.configurator.ComponentConfigurationException;
+import org.codehaus.plexus.component.configurator.ComponentConfigurator;
+import 
org.codehaus.plexus.component.repository.exception.ComponentLifecycleException;
+import 
org.codehaus.plexus.component.repository.exception.ComponentLookupException;
+import org.codehaus.plexus.configuration.PlexusConfiguration;
+
+/**
+ * Configures a parser based on a {@link PlexusConfiguration} for a particular 
parser id and optionally matching one of multiple patterns.
+ * It internally leverages the {@link ComponentConfigurator} for calling the 
right methods inside the parser implementation.
+ */
+public class ParserConfiguratorImpl implements ParserConfigurator, Closeable {
+
+    private static final class ParserConfigurationKey {
+
+        ParserConfigurationKey(String parserId, PlexusConfiguration 
patternsConfiguration) {
+            this(parserId, 
PlexusConfigurationUtils.getStringArrayValues(patternsConfiguration));
+        }
+
+        ParserConfigurationKey(String parserId, Collection<String> patterns) {
+            this.parserId = parserId;
+            // lazily populate all matchers
+            matchers = patterns.stream()
+                    .map(p -> FileSystems.getDefault().getPathMatcher(p))
+                    .collect(Collectors.toList());

Review Comment:
   Hopefully the javadoc comment on the affected parameter is clear enough. I 
really don't want to rely on plexus classes for the ant pattern support.





> Allow parametrisation of Doxia parser per file
> ----------------------------------------------
>
>                 Key: MSITE-1000
>                 URL: https://issues.apache.org/jira/browse/MSITE-1000
>             Project: Maven Site Plugin
>          Issue Type: New Feature
>          Components: doxia integration
>            Reporter: Konrad Windszus
>            Assignee: Konrad Windszus
>            Priority: Major
>
> Currently only the attributes used for rendering the site can be 
> parameterized in 
> https://maven.apache.org/plugins/maven-site-plugin/site-mojo.html#attributes. 
> There is no possibility to configure the parser in 
> https://github.com/apache/maven-doxia-sitetools/blob/dacaa552c1b8e89eed84db0f43b6b0a72be91d0c/doxia-site-renderer/src/main/java/org/apache/maven/doxia/siterenderer/DefaultSiteRenderer.java#L322
>  per document.
> This would be nice in the context of 
> https://issues.apache.org/jira/browse/DOXIA-722 where generation of anchors 
> should be switched on/off for certain documents. Also generation of comments 
> may be desirable for certain documents.
> I propose the following additional plugin goal parameter:
> {code}
> <parserConfigurations>
>   <parserConfiguration>
>     <patterns>
>       <pattern>**/apt/**</pattern>
>     </patterns>
>     <emitAnchorsForIndexableEntries>false</emitAnchorsForIndexableEntries>
>     <emitComments>true</emitComments>
>   </parserConfiguration>
> <parserConfigurations>
> {code}
> where {{parserConfigurations}} is an array of a complex type with (include) 
> patterns on the source path (String array) and boolean methods for features.
>   



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

Reply via email to