Skip to content

Commit a3ef3ae

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

File tree

2 files changed

+61
-0
lines changed

2 files changed

+61
-0
lines changed

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,12 @@ 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;
97103
/**
98104
* Site renderer.
99105
*/
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
package org.apache.maven.plugins.site.render;
2+
3+
import java.util.LinkedList;
4+
import java.util.List;
5+
6+
import org.apache.maven.doxia.parser.Parser;
7+
import org.apache.maven.shared.utils.io.MatchPattern;
8+
import org.apache.maven.shared.utils.io.MatchPatterns;
9+
10+
public class ParserConfiguration {
11+
12+
/**
13+
* List of {@link MatchPattern} strings. If not set this configurations applies to all documents.
14+
*/
15+
private final List<String> patterns;
16+
/**
17+
* @see {@link Parser#setEmitComments(boolean)}
18+
*/
19+
private boolean emitComments;
20+
/**
21+
* @see {@link Parser#setEmitAnchorsForIndexableEntries(boolean)}
22+
*/
23+
private boolean emitAnchorsForIndexableEntries;
24+
25+
public ParserConfiguration() {
26+
patterns = new LinkedList<>();
27+
}
28+
public boolean isEmitComments() {
29+
return emitComments;
30+
}
31+
32+
public void setEmitComments(boolean emitComments) {
33+
this.emitComments = emitComments;
34+
}
35+
36+
public boolean isEmitAnchorsForIndexableEntries() {
37+
return emitAnchorsForIndexableEntries;
38+
}
39+
40+
public void setEmitAnchorsForIndexableEntries(boolean emitAnchorsForIndexableEntries) {
41+
this.emitAnchorsForIndexableEntries = emitAnchorsForIndexableEntries;
42+
}
43+
44+
public void addPattern(String pattern ) {
45+
patterns.add(pattern);
46+
}
47+
48+
public MatchPatterns getPatterns() {
49+
if (patterns.isEmpty()) {
50+
return MatchPatterns.from("**");
51+
}
52+
return MatchPatterns.from(patterns.toArray(new String[0]));
53+
}
54+
55+
}

0 commit comments

Comments
 (0)