diff --git a/pmd-doc/src/main/java/net/sourceforge/pmd/docs/RuleDocGenerator.java b/pmd-doc/src/main/java/net/sourceforge/pmd/docs/RuleDocGenerator.java index ba2cc61918..6fd710ec7e 100644 --- a/pmd-doc/src/main/java/net/sourceforge/pmd/docs/RuleDocGenerator.java +++ b/pmd-doc/src/main/java/net/sourceforge/pmd/docs/RuleDocGenerator.java @@ -28,6 +28,7 @@ import java.util.TreeMap; import java.util.logging.Level; import java.util.logging.Logger; import java.util.regex.Matcher; +import java.util.regex.Pattern; import org.apache.commons.io.FilenameUtils; import org.apache.commons.lang3.StringUtils; @@ -435,8 +436,14 @@ public class RuleDocGenerator { if (propertyDescriptor.defaultValue() != null) { if (propertyDescriptor.isMultiValue()) { @SuppressWarnings("unchecked") // multi valued properties are using a List - PropertyDescriptor> multiPropertyDescriptor = (PropertyDescriptor>) propertyDescriptor; + MultiValuePropertyDescriptor> multiPropertyDescriptor = (MultiValuePropertyDescriptor>) propertyDescriptor; defaultValue = multiPropertyDescriptor.asDelimitedString(multiPropertyDescriptor.defaultValue()); + + // surround the delimiter with spaces, so that the browser can wrap + // the value nicely + defaultValue = defaultValue.replaceAll(Pattern.quote( + String.valueOf(multiPropertyDescriptor.multiValueDelimiter())), + " " + multiPropertyDescriptor.multiValueDelimiter() + " "); } else { defaultValue = String.valueOf(propertyDescriptor.defaultValue()); } @@ -447,7 +454,7 @@ public class RuleDocGenerator { MultiValuePropertyDescriptor multiValuePropertyDescriptor = (MultiValuePropertyDescriptor) propertyDescriptor; multiValued = "yes. Delimiter is '" - + multiValuePropertyDescriptor.multiValueDelimiter() + "'"; + + multiValuePropertyDescriptor.multiValueDelimiter() + "'."; } lines.add("|" + propertyDescriptor.name() diff --git a/pmd-doc/src/test/resources/expected/sample.md b/pmd-doc/src/test/resources/expected/sample.md index 0a1a49c7d3..63d5b57f0d 100644 --- a/pmd-doc/src/test/resources/expected/sample.md +++ b/pmd-doc/src/test/resources/expected/sample.md @@ -63,7 +63,7 @@ public class JumbledIncrementerRule1 { |Name|Default Value|Description|Multivalued| |----|-------------|-----------|-----------| |sampleAdditionalProperty|the value|This is a additional property for tests|no| -|sampleMultiStringProperty|Value1\|Value2|Test property with multiple strings|yes. Delimiter is '\|'| +|sampleMultiStringProperty|Value1 \| Value2|Test property with multiple strings|yes. Delimiter is '\|'.| |sampleDeprecatedProperty|test|Deprecated This is a sample deprecated property for tests|no| **Use this rule by referencing it:** @@ -201,7 +201,7 @@ public class JumbledIncrementerRule1 { |Name|Default Value|Description|Multivalued| |----|-------------|-----------|-----------| |sampleAdditionalProperty|the value|This is a additional property for tests|no| -|sampleMultiStringProperty|Value1\|Value2|Test property with multiple strings|yes. Delimiter is '\|'| +|sampleMultiStringProperty|Value1 \| Value2|Test property with multiple strings|yes. Delimiter is '\|'.| |sampleDeprecatedProperty|test|Deprecated This is a sample deprecated property for tests|no| **Use this rule by referencing it:**