Skip to content

Commit

Permalink
Allow Smallrye config sections to have no properties
Browse files Browse the repository at this point in the history
This may happen when a config class has all its properties
grouped under sub-sections, but we still want to produce
`.md` files from the top-level javadoc.

This is a pre-requisite to projectnessie#8558
  • Loading branch information
dimas-b committed Jul 5, 2024
1 parent 0205bd0 commit 7da1bfd
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -139,20 +139,22 @@ public boolean run(DocletEnvironment environment) {
}

List<SmallRyeConfigPropertyInfo> properties = configSection.properties();
SmallRyeConfigPropertyInfo first = properties.get(0);
if (first.firstIsSectionDoc()) {
SmallRyeConfigPropertyInfo first = properties.isEmpty() ? null : properties.get(0);
if (first != null && first.firstIsSectionDoc()) {
MarkdownTypeFormatter typeFormatter =
new MarkdownTypeFormatter(first.propertyElement(), first.doc());
writer.println(typeFormatter.description().trim());
writer.println();
}

writer.println("| Property | Default Value | Type | Description |");
writer.println("|----------|---------------|------|-------------|");
properties.forEach(
prop ->
writeProperty(
prop, writer, configSection.prefix() + '.', smallryeConfigs, environment));
if (!properties.isEmpty()) {
writer.println("| Property | Default Value | Type | Description |");
writer.println("|----------|---------------|------|-------------|");
properties.forEach(
prop ->
writeProperty(
prop, writer, configSection.prefix() + '.', smallryeConfigs, environment));
}
} catch (IOException ex) {
throw new RuntimeException(ex);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,12 +71,10 @@ public List<SmallRyeConfigSection> buildConfigSections(DocletEnvironment env) {

additionalPrefixes.forEach(
(k, v) -> {
if (!v.isEmpty()) {
if (k.equals(mapping.prefix)) {
sections.add(new SmallRyeConfigSection(k, v, mapping.element, mapping.typeComment));
} else {
sections.add(new SmallRyeConfigSection(mapping.prefix + '.' + k, v, null, null));
}
if (k.equals(mapping.prefix)) {
sections.add(new SmallRyeConfigSection(k, v, mapping.element, mapping.typeComment));
} else {
sections.add(new SmallRyeConfigSection(mapping.prefix + '.' + k, v, null, null));
}
});
}
Expand Down

0 comments on commit 7da1bfd

Please sign in to comment.