-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[MSITE-1000] Introduce parser configuration parameter
- Loading branch information
Showing
2 changed files
with
61 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 55 additions & 0 deletions
55
src/main/java/org/apache/maven/plugins/site/render/ParserConfiguration.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
package org.apache.maven.plugins.site.render; | ||
|
||
import java.util.LinkedList; | ||
import java.util.List; | ||
|
||
import org.apache.maven.doxia.parser.Parser; | ||
import org.apache.maven.shared.utils.io.MatchPattern; | ||
import org.apache.maven.shared.utils.io.MatchPatterns; | ||
|
||
public class ParserConfiguration { | ||
|
||
/** | ||
* List of {@link MatchPattern} strings. If not set this configurations applies to all documents. | ||
*/ | ||
private final List<String> patterns; | ||
/** | ||
* @see {@link Parser#setEmitComments(boolean)} | ||
*/ | ||
private boolean emitComments; | ||
/** | ||
* @see {@link Parser#setEmitAnchorsForIndexableEntries(boolean)} | ||
*/ | ||
private boolean emitAnchorsForIndexableEntries; | ||
|
||
public ParserConfiguration() { | ||
patterns = new LinkedList<>(); | ||
} | ||
public boolean isEmitComments() { | ||
return emitComments; | ||
} | ||
|
||
public void setEmitComments(boolean emitComments) { | ||
this.emitComments = emitComments; | ||
} | ||
|
||
public boolean isEmitAnchorsForIndexableEntries() { | ||
return emitAnchorsForIndexableEntries; | ||
} | ||
|
||
public void setEmitAnchorsForIndexableEntries(boolean emitAnchorsForIndexableEntries) { | ||
this.emitAnchorsForIndexableEntries = emitAnchorsForIndexableEntries; | ||
} | ||
|
||
public void addPattern(String pattern ) { | ||
patterns.add(pattern); | ||
} | ||
|
||
public MatchPatterns getPatterns() { | ||
if (patterns.isEmpty()) { | ||
return MatchPatterns.from("**"); | ||
} | ||
return MatchPatterns.from(patterns.toArray(new String[0])); | ||
} | ||
|
||
} |