#{key}"
if attr.key? 'type'
@@ -78,14 +78,23 @@ module Jekyll
TYPES.include? attr['type']
end
- markup << "
("
- markup << "#{type_link(attr['type'], component: component)})"
+ markup << "
#{type_link(attr['type'], component: component)}"
else
# Type is missing, which is required (unless we are in a list or template)
raise ArgumentError, "Configuration key '#{key}' is missing a type definition" \
unless ['list', 'template'].include? parent_type
end
+ defaultValue = ""
+ isDefault = false
+ if attr.key? 'default' and not attr['default'].to_s.empty?
+ isDefault = true
+ defaultValue = converter.convert(attr['default'].to_s)
+ elsif attr['type'].to_s.include? 'boolean'
+ # If the type is a boolean, a default key is required
+ raise ArgumentError, "Configuration key '#{key}' is a boolean type and"\
+ " therefore, requires a default."
+ end
if attr.key? 'required'
# Check if required is a valid value
@@ -93,41 +102,48 @@ module Jekyll
"true, false, inclusive or exclusive."\
unless [true, false, 'inclusive', 'exclusive'].include? attr['required']
- markup << "
(#{required_value(attr['required'])})"
+ isTrue = attr['required'].to_s == 'true'
+ startSymbol = isTrue ? '' : '('
+ endSymbol = isTrue ? '' : ')'
+ showDefault = isDefault && (defaultValue.length <= MIN_DEFAULT_LENGTH)
+ shortDefaultValue = ""
+ if showDefault
+ shortDefaultValue = defaultValue
+ shortDefaultValue.slice!("
")
+ shortDefaultValue.slice!("
")
+ shortDefaultValue = shortDefaultValue.strip
+ shortDefaultValue = ", default: " + shortDefaultValue
+ end
+
+ markup << "
#{startSymbol}#{required_value(attr['required'])}#{shortDefaultValue}#{endSymbol}"
end
+ markup << "
"
+
if attr.key? 'description'
- markup << "
#{converter.convert(attr['description'].to_s)}"
+ markup << "
#{converter.convert(attr['description'].to_s)}"
else
# Description is missing
raise ArgumentError, "Configuration key '#{key}' is missing a description."
end
- markup << ""
- if attr.key? 'default' and not attr['default'].to_s.empty?
- markup << "
\nDefault value: #{converter.convert(attr['default'].to_s)}
"
- elsif attr['type'].to_s.include? 'boolean'
- # Is the type is a boolean, a default key is required
- raise ArgumentError, "Configuration key '#{key}' is a boolean type and"\
- " therefore, requires a default."
+ if isDefault && defaultValue.length > MIN_DEFAULT_LENGTH
+ markup << "
\nDefault: #{defaultValue}
"
end
-
- markup << ""
+ markup << "
"
# Check for nested configuration variables
if attr.key? 'keys'
- markup << "