Skip to content

Commit c990f04

Browse files
Docgen tweaks
* When emitting default values, format as "Default: <value>" * When default is "", emit as "<unspecified>" * Add link to hocon wiki page when referencing HOCON.
1 parent dc6b2ae commit c990f04

File tree

4 files changed

+126
-121
lines changed

4 files changed

+126
-121
lines changed

engine/src/main/java/com/datastax/dsbulk/engine/internal/OptionUtils.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,11 @@ private static String getSanitizedDescription(String longName, ConfigValue value
115115
// Those sorts of instances are preceded by ", so don't replace those.
116116

117117
desc = desc.replaceAll(" +", " ").replaceAll("([^\"])\\*\\*", "$1").trim();
118-
desc += "\nDefaults to " + value.render(ConfigRenderOptions.concise()) + ".";
118+
String defaultValue = value.render(ConfigRenderOptions.concise());
119+
if (defaultValue.equals("\"\"")) {
120+
defaultValue = "<unspecified>";
121+
}
122+
desc += "\nDefault: " + defaultValue;
119123
return desc;
120124
}
121125
}

engine/src/main/java/com/datastax/dsbulk/engine/internal/SettingsDocumentor.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -257,10 +257,11 @@ private static String getSanitizedDescription(ConfigValue value) {
257257
.map(s -> s.length() > 0 ? s.substring(1) : s)
258258
.collect(Collectors.joining("\n"));
259259
if (value.valueType() != ConfigValueType.OBJECT) {
260-
desc +=
261-
String.format(
262-
"%n%nDefaults to **%s**.",
263-
value.render(ConfigRenderOptions.concise()).replace("*", "\\*"));
260+
String defaultValue = value.render(ConfigRenderOptions.concise()).replace("*", "\\*");
261+
if (defaultValue.equals("\"\"")) {
262+
defaultValue = "&lt;unspecified&gt;";
263+
}
264+
desc += String.format("%n%nDefault: **%s**.", defaultValue);
264265
}
265266
return desc;
266267
}

engine/src/main/resources/reference.conf

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -545,7 +545,7 @@ dsbulk {
545545
#
546546
# In unload workflows, only the first string specified here will be used: when a row cell contains a `null` value, then it will be replaced with that word and forwarded as such to the connector.
547547
#
548-
# The default value – `""` – means that in load workflows, empty strings are converted to `null`s, and in unload workflows, `null`s are converted to empty strings.
548+
# By default, empty strings are converted to `null`s in load workflows, and conversely `null`s are converted to empty strings in unload workflows.
549549
nullStrings: ""
550550

551551
# Whether or not to map `null` input values to "unset" in the database, meaning don't modify a potentially pre-existing value of this field for this row.
@@ -563,7 +563,7 @@ dsbulk {
563563
#
564564
# If not specified, the loader will apply a strict one-to-one mapping between the source fields and the database table. If that is not what you want, then you must supply an explicit mapping.
565565
#
566-
# Mappings should be specified as a HOCON map of the following form:
566+
# Mappings should be specified as a HOCON map (https://github.com/typesafehub/config/blob/master/HOCON.md) of the following form:
567567
#
568568
# - Indexed data sources: `0 = col1, 1 = col2, 2 = col3`, where `0`, `1`, `2`, etc. are the zero-based indices of fields in the source data; and `col1`, `col2`, `col3` are bound variable names in the insert statement.
569569
# - Mapped data sources: `fieldA = col1, fieldB = col2, fieldC = col3`, where `fieldA`, `fieldB`, `fieldC`, etc. are field names in the source data; and `col1`, `col2`, `col3` are bound variable names in the insert statement.
@@ -582,7 +582,7 @@ dsbulk {
582582
# - If the connector is capable of reporting the record metadata accurately (for example, some database connectors might be able to inspect the target table's metadata), then this section is only required if you want to override some field types as reported by the connector.
583583
# - If the connector is not capable of reporting the record metadata accurately (for example, file connectors usually cannot report such information), then all fields are assumed to be of type `String`. If this is not correct, then you need to provide the correct type information here.
584584
#
585-
# Field metadata should be specified as a HOCON map of the following form:
585+
# Field metadata should be specified as a HOCON map (https://github.com/typesafehub/config/blob/master/HOCON.md) of the following form:
586586
#
587587
# - Indexed data sources: `0 = java.lang.String, 1 = java.lang.Double`, where `0`, `1`, etc. are the zero-based indices of fields in the source data; and the values are the expected types for each field.
588588
# - Mapped data sources: `fieldA = java.lang.String, fieldB = java.lang.Double`, where `fieldA`, `fieldB`, etc. are field names in the source data; and the values are the expected types for each field.

0 commit comments

Comments
 (0)