Skip to content

Commit

Permalink
Config Doc - Use a common pattern for formatting data
Browse files Browse the repository at this point in the history
  • Loading branch information
gsmet authored and danielsoro committed Sep 20, 2024
1 parent dee8bc1 commit a22271a
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

import io.quarkus.annotation.processor.documentation.config.model.ConfigProperty;
import io.quarkus.annotation.processor.documentation.config.model.ConfigSection;
import io.quarkus.annotation.processor.documentation.config.model.Extension;
import io.quarkus.annotation.processor.documentation.config.model.JavadocElements.JavadocElement;
import io.quarkus.annotation.processor.documentation.config.util.Types;

Expand Down Expand Up @@ -185,6 +186,14 @@ String formatSectionTitle(ConfigSection configSection) {
return javadoc.substring(0, dotIndex);
}

String formatName(Extension extension) {
if (extension.name() == null) {
return extension.artifactId();
}

return extension.name();
}

/**
* Note that this is extremely brittle. Apparently, colons breaks the tooltips but if escaped with \, the \ appears in the
* output.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -438,22 +438,28 @@ private static Engine initializeQuteEngine(AsciidocFormatter asciidocFormatter)
.build())
.addValueResolver(ValueResolver.builder()
.applyToBaseClass(ConfigProperty.class)
.applyToName("typeDescription")
.applyToName("formatTypeDescription")
.applyToNoParameters()
.resolveSync(ctx -> asciidocFormatter.formatTypeDescription((ConfigProperty) ctx.getBase()))
.build())
.addValueResolver(ValueResolver.builder()
.applyToBaseClass(ConfigProperty.class)
.applyToName("description")
.applyToName("formatDescription")
.applyToNoParameters()
.resolveSync(ctx -> asciidocFormatter.formatDescription((ConfigProperty) ctx.getBase()))
.build())
.addValueResolver(ValueResolver.builder()
.applyToBaseClass(ConfigSection.class)
.applyToName("title")
.applyToName("formatTitle")
.applyToNoParameters()
.resolveSync(ctx -> asciidocFormatter.formatSectionTitle((ConfigSection) ctx.getBase()))
.build())
.addValueResolver(ValueResolver.builder()
.applyToBaseClass(Extension.class)
.applyToName("formatName")
.applyToNoParameters()
.resolveSync(ctx -> asciidocFormatter.formatName((Extension) ctx.getBase()))
.build())
.build();

engine.putTemplate("configReference.qute.adoc",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ icon:lock[title=Fixed at build time] Configuration property fixed at build time
|===
{#for extensionConfigRootsEntry in configRootsByExtensions}

h|{extensionConfigRootsEntry.key.name.or(extensionConfigRootsEntry.key.artifactId)}
h|{extensionConfigRootsEntry.key.formatName.escapeCellContent}
h|Type
h|Default

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ a|{#if configProperty.phase.fixedAtBuildTime}icon:lock[title=Fixed at build time

[.description]
--
{configProperty.description.escapeCellContent.or("")}
{configProperty.formatDescription.escapeCellContent.or("")}
{#envVar configProperty /}
--
{#if configProperty.enum}a{/if}|{configProperty.typeDescription}
{#if configProperty.enum}a{/if}|{configProperty.formatTypeDescription.escapeCellContent.or("")}
|{#if configProperty.defaultValue}`{configProperty.defaultValue.escapeCellContent}`{#else if !configProperty.optional}required icon:exclamation-circle[title=Configuration property is required]{/if}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
h|[[{configSection.toAnchor(extension)}]] {configSection.title.escapeCellContent}
h|[[{configSection.toAnchor(extension)}]] {configSection.formatTitle.escapeCellContent}
h|Type
h|Default

Expand Down

0 comments on commit a22271a

Please sign in to comment.