forked from phoedos/pmd
[doc] Surround the delimiter with spaces, so that the browser can
wrap the default value of multi properties nicely.
This commit is contained in:
@ -28,6 +28,7 @@ import java.util.TreeMap;
|
|||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
import org.apache.commons.io.FilenameUtils;
|
import org.apache.commons.io.FilenameUtils;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
@ -435,8 +436,14 @@ public class RuleDocGenerator {
|
|||||||
if (propertyDescriptor.defaultValue() != null) {
|
if (propertyDescriptor.defaultValue() != null) {
|
||||||
if (propertyDescriptor.isMultiValue()) {
|
if (propertyDescriptor.isMultiValue()) {
|
||||||
@SuppressWarnings("unchecked") // multi valued properties are using a List
|
@SuppressWarnings("unchecked") // multi valued properties are using a List
|
||||||
PropertyDescriptor<List<?>> multiPropertyDescriptor = (PropertyDescriptor<List<?>>) propertyDescriptor;
|
MultiValuePropertyDescriptor<List<?>> multiPropertyDescriptor = (MultiValuePropertyDescriptor<List<?>>) propertyDescriptor;
|
||||||
defaultValue = multiPropertyDescriptor.asDelimitedString(multiPropertyDescriptor.defaultValue());
|
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 {
|
} else {
|
||||||
defaultValue = String.valueOf(propertyDescriptor.defaultValue());
|
defaultValue = String.valueOf(propertyDescriptor.defaultValue());
|
||||||
}
|
}
|
||||||
@ -447,7 +454,7 @@ public class RuleDocGenerator {
|
|||||||
MultiValuePropertyDescriptor<?> multiValuePropertyDescriptor =
|
MultiValuePropertyDescriptor<?> multiValuePropertyDescriptor =
|
||||||
(MultiValuePropertyDescriptor<?>) propertyDescriptor;
|
(MultiValuePropertyDescriptor<?>) propertyDescriptor;
|
||||||
multiValued = "yes. Delimiter is '"
|
multiValued = "yes. Delimiter is '"
|
||||||
+ multiValuePropertyDescriptor.multiValueDelimiter() + "'";
|
+ multiValuePropertyDescriptor.multiValueDelimiter() + "'.";
|
||||||
}
|
}
|
||||||
|
|
||||||
lines.add("|" + propertyDescriptor.name()
|
lines.add("|" + propertyDescriptor.name()
|
||||||
|
@ -63,7 +63,7 @@ public class JumbledIncrementerRule1 {
|
|||||||
|Name|Default Value|Description|Multivalued|
|
|Name|Default Value|Description|Multivalued|
|
||||||
|----|-------------|-----------|-----------|
|
|----|-------------|-----------|-----------|
|
||||||
|sampleAdditionalProperty|the value|This is a additional property for tests|no|
|
|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|<span style="border-radius: 0.25em; color: #fff; padding: 0.2em 0.6em 0.3em; display: inline; background-color: #d9534f; font-size: 75%;">Deprecated</span> This is a sample deprecated property for tests|no|
|
|sampleDeprecatedProperty|test|<span style="border-radius: 0.25em; color: #fff; padding: 0.2em 0.6em 0.3em; display: inline; background-color: #d9534f; font-size: 75%;">Deprecated</span> This is a sample deprecated property for tests|no|
|
||||||
|
|
||||||
**Use this rule by referencing it:**
|
**Use this rule by referencing it:**
|
||||||
@ -201,7 +201,7 @@ public class JumbledIncrementerRule1 {
|
|||||||
|Name|Default Value|Description|Multivalued|
|
|Name|Default Value|Description|Multivalued|
|
||||||
|----|-------------|-----------|-----------|
|
|----|-------------|-----------|-----------|
|
||||||
|sampleAdditionalProperty|the value|This is a additional property for tests|no|
|
|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|<span style="border-radius: 0.25em; color: #fff; padding: 0.2em 0.6em 0.3em; display: inline; background-color: #d9534f; font-size: 75%;">Deprecated</span> This is a sample deprecated property for tests|no|
|
|sampleDeprecatedProperty|test|<span style="border-radius: 0.25em; color: #fff; padding: 0.2em 0.6em 0.3em; display: inline; background-color: #d9534f; font-size: 75%;">Deprecated</span> This is a sample deprecated property for tests|no|
|
||||||
|
|
||||||
**Use this rule by referencing it:**
|
**Use this rule by referencing it:**
|
||||||
|
Reference in New Issue
Block a user