builder:DefaultRuleReadmeLoader: show 'reason' instead for disabled rules
This commit is contained in:
parent
b70b7c4a5a
commit
1fa27f2071
1 changed files with 15 additions and 8 deletions
|
@ -23,14 +23,21 @@ class DefaultRuleReadmeLoader implements RuleReadmeLoader {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Stream<String> load(final Rule rule) {
|
public Stream<String> load(final Rule rule) {
|
||||||
|
if (rule.isEnabled()) {
|
||||||
try {
|
try {
|
||||||
final Path resolve = templateProperties.getReadmeFragments()
|
final Path resolve = templateProperties.getReadmeFragments()
|
||||||
.resolve(rule.getName() + ".md");
|
.resolve(rule.getName() + ".md");
|
||||||
log.info("Loading fragment: {}", resolve);
|
log.info("Loading fragment: {}", resolve);
|
||||||
return Stream.concat(Stream.of(String.format("%n#### [%s](%s)", rule.getName(), rule.getUri())),
|
return Stream.concat(Stream.of(formatRuleHeader(rule)), Files.lines(resolve));
|
||||||
Files.lines(resolve));
|
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
return Stream.empty();
|
return Stream.empty();
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
return Stream.of(formatRuleHeader(rule), "", rule.getReason());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private String formatRuleHeader(final Rule rule) {
|
||||||
|
return String.format("%n#### [%s](%s)", rule.getName(), rule.getUri());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue