Skip to content

Commit 654f8be

Browse files
committed
[MSITE-1000] Introduce parser configuration parameter
1 parent d78b8da commit 654f8be

File tree

2 files changed

+79
-0
lines changed

2 files changed

+79
-0
lines changed

src/main/java/org/apache/maven/plugins/site/render/AbstractSiteRenderingMojo.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,13 @@ public abstract class AbstractSiteRenderingMojo extends AbstractSiteDescriptorMo
9494
@Parameter
9595
private Map<String, Object> attributes;
9696

97+
/**
98+
* Parser configurations (per document file paths).
99+
* @since 4.0.0
100+
*/
101+
@Parameter
102+
private List<ParserConfiguration> parserConfigurations;
103+
97104
/**
98105
* Site renderer.
99106
*/
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
package org.apache.maven.plugins.site.render;
20+
21+
import java.util.LinkedList;
22+
import java.util.List;
23+
24+
import org.apache.maven.shared.utils.io.MatchPattern;
25+
import org.apache.maven.shared.utils.io.MatchPatterns;
26+
27+
public class ParserConfiguration {
28+
29+
/**
30+
* List of {@link MatchPattern} strings. If not set this configurations applies to all documents.
31+
*/
32+
private final List<String> patterns;
33+
/**
34+
* @see {@link Parser#setEmitComments(boolean)}
35+
*/
36+
private boolean emitComments;
37+
/**
38+
* @see {@link Parser#setEmitAnchorsForIndexableEntries(boolean)}
39+
*/
40+
private boolean emitAnchorsForIndexableEntries;
41+
42+
public ParserConfiguration() {
43+
patterns = new LinkedList<>();
44+
}
45+
46+
public boolean isEmitComments() {
47+
return emitComments;
48+
}
49+
50+
public void setEmitComments(boolean emitComments) {
51+
this.emitComments = emitComments;
52+
}
53+
54+
public boolean isEmitAnchorsForIndexableEntries() {
55+
return emitAnchorsForIndexableEntries;
56+
}
57+
58+
public void setEmitAnchorsForIndexableEntries(boolean emitAnchorsForIndexableEntries) {
59+
this.emitAnchorsForIndexableEntries = emitAnchorsForIndexableEntries;
60+
}
61+
62+
public void addPattern(String pattern) {
63+
patterns.add(pattern);
64+
}
65+
66+
public MatchPatterns getPatterns() {
67+
if (patterns.isEmpty()) {
68+
return MatchPatterns.from("**");
69+
}
70+
return MatchPatterns.from(patterns.toArray(new String[0]));
71+
}
72+
}

0 commit comments

Comments
 (0)