[doc] Surround the delimiter with spaces, so that the browser can

wrap the default value of multi properties nicely.
This commit is contained in:
Andreas Dangel
2018-04-28 12:05:31 +02:00
parent 529d2da054
commit 9ca83da878
2 changed files with 11 additions and 4 deletions

View File

@ -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<List<?>> multiPropertyDescriptor = (PropertyDescriptor<List<?>>) propertyDescriptor;
MultiValuePropertyDescriptor<List<?>> multiPropertyDescriptor = (MultiValuePropertyDescriptor<List<?>>) 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()

View File

@ -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|<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:**
@ -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|<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:**