Skip to content

Commit

Permalink
[MSITE-1000] Introduce parser configuration parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
kwin committed Dec 30, 2023
1 parent d78b8da commit a3ef3ae
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,12 @@ public abstract class AbstractSiteRenderingMojo extends AbstractSiteDescriptorMo
@Parameter
private Map<String, Object> attributes;

/**
* Parser configurations (per document file paths).
* @since 4.0.0
*/
@Parameter
private List<ParserConfiguration> parserConfigurations;
/**
* Site renderer.
*/
Expand Down
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]));
}

}

0 comments on commit a3ef3ae

Please sign in to comment.