Update layout for options in guides (#9658)

This commit is contained in:
Stian Thorgersen 2022-01-20 14:21:23 +01:00 committed by GitHub
parent 3dd97f3f2f
commit b8d3c12a08
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 61 additions and 42 deletions

View file

@ -1,28 +1,17 @@
<#import "/templates/guide.adoc" as template>
<#import "/templates/options.adoc" as opts>
<@template.guide
title="All configuration"
summary="All the configuration you will ever need and want">
<#list ctx.options.categories as category>
<#assign categoryOptions=ctx.options.getValues(category)>
<#if categoryOptions?has_content>
== ${category.heading}
|===
|Key|CLI|ENV|Description|Default|Values
<#list categoryOptions as option>
|${option.key}
|${option.keyCli}
|${option.keyEnv}
|${option.description}
|${option.defaultValue!}
|${option.expectedValues?join(", ")}
<#if option?has_next>
</#if>
</#list>
|===
<@opts.list options=categoryOptions></@opts.list>
</#if>
</#list>
</@template.guide>

View file

@ -1,3 +1,5 @@
<#import "/templates/options.adoc" as opts>
<#macro guide title summary priority=999 includedOptions="">
:guide-id: ${id}
:guide-title: ${title}
@ -12,20 +14,6 @@
<#if includedOptions?has_content>
== Relevant options
|===
|Key|CLI|ENV|Description|Default|Values
<#list ctx.options.getOptions(includedOptions) as option>
|${option.key}
|${option.keyCli}
|${option.keyEnv}
|${option.description}
|${option.defaultValue!}
|${option.expectedValues?join(", ")}
<#if option?has_next>
</#if>
</#list>
|===
<@opts.list options=ctx.options.getOptions(includedOptions)></@opts.list>
</#if>
</#macro>

View file

@ -3,3 +3,30 @@
* ${expectedValue}
</#list>
</#macro>
<#macro list options>
[cols="12a,4,4,1",role="options"]
|===
| |Type|Default|
<#list options as option>
|
[.options-key]#${option.key}#
[.options-description]#${option.description}#
[#option-extended-${option.key},role="options-extended"]
!===
!<#if option.descriptionExtended?has_content>[.options-description-extended]#${option.descriptionExtended!}#</#if>
![.options-description-example]#*CLI:* `${option.keyCli}`#
![.options-description-example]#*Env:* `${option.keyEnv}`#
!===
|<#if option.expectedValues?has_content>[.options-type]#${option.expectedValues?join(", ")}#</#if>
|<#if option.defaultValue?has_content>[.options-default]#${option.defaultValue!}#</#if>
|<#if option.build>icon:lock[role=options-build]</#if>
</#list>
|===
</#macro>

View file

@ -41,7 +41,7 @@ public class Options {
return this.options.values().stream().filter(o -> o.getKey().matches(r)).collect(Collectors.toList());
}
public static class Option {
public class Option {
private String key;
private ConfigCategory category;
@ -76,7 +76,22 @@ public class Options {
}
public String getDescription() {
int i = description.indexOf('.');
if (i == -1) {
return description;
} else {
return description.substring(0, i + 1).trim();
}
}
public String getDescriptionExtended() {
int i = description.indexOf('.');
if (i == -1) {
return null;
} else {
String extended = description.substring(i + 1).trim();
return extended.length() > 0 ? extended : null;
}
}
public String getDefaultValue() {

View file

@ -300,7 +300,7 @@ public final class Picocli {
private static void addFeatureOptions(CommandSpec commandSpec) {
ArgGroupSpec.Builder featureGroupBuilder = ArgGroupSpec.builder()
.heading(ConfigCategory.FEATURE.getHeading())
.heading(ConfigCategory.FEATURE.getHeading() + ":")
.order(ConfigCategory.FEATURE.getOrder())
.validate(false);
@ -341,7 +341,7 @@ public final class Picocli {
}
ArgGroupSpec.Builder argGroupBuilder = ArgGroupSpec.builder()
.heading(category.getHeading())
.heading(category.getHeading() + ":")
.order(category.getOrder())
.validate(false);

View file

@ -2,15 +2,15 @@ package org.keycloak.quarkus.runtime.configuration.mappers;
public enum ConfigCategory {
// ordered by name asc
CLUSTERING("Cluster:", 10),
DATABASE("Database:", 20),
FEATURE("Feature:", 30),
HOSTNAME("Hostname:", 40),
HTTP("HTTP/TLS:", 50),
METRICS("Metrics:", 60),
PROXY("Proxy:", 70),
VAULT("Vault:", 80),
GENERAL("General:", 999);
CLUSTERING("Cluster", 10),
DATABASE("Database", 20),
FEATURE("Feature", 30),
HOSTNAME("Hostname", 40),
HTTP("HTTP/TLS", 50),
METRICS("Metrics", 60),
PROXY("Proxy", 70),
VAULT("Vault", 80),
GENERAL("General", 999);
private final String heading;