Skip to content

Commit

Permalink
Add more information about config option switches.
Browse files Browse the repository at this point in the history
Signed-off-by: Łukasz Dywicki <luke@code-house.org>
  • Loading branch information
splatch committed Feb 29, 2024
1 parent 8696538 commit c58c1cc
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 3 deletions.
Expand Up @@ -25,7 +25,9 @@
import com.github.jknack.handlebars.context.FieldValueResolver;
import com.github.jknack.handlebars.context.JavaBeanValueResolver;
import com.github.jknack.handlebars.context.MapValueResolver;
import com.github.jknack.handlebars.helper.ConditionalHelpers;
import com.github.jknack.handlebars.helper.DefaultHelperRegistry;
import com.github.jknack.handlebars.helper.StringHelpers;
import com.github.jknack.handlebars.io.ClassPathTemplateLoader;
import com.github.jknack.handlebars.io.URLTemplateSource;
import java.io.File;
Expand Down Expand Up @@ -97,13 +99,15 @@ protected void process(List<ConfigDescription> configDescriptions, List<ThingTyp
.collect(Collectors.toList());

HelperRegistry registry = new DefaultHelperRegistry();
registry.registerHelpers(ConditionalHelpers.class);
registry.registerHelper("channelTypeConfigDescriptor", new ChannelTypeConfigDescriptorHelper(configDescriptions));
registry.registerHelper("thingTypeConfigDescriptor", new ThingTypeConfigDescriptorHelper(configDescriptions));
registry.registerHelper("format", new FormatHelper());
Handlebars hbs = new Handlebars()
.with(new ClassPathTemplateLoader("/templates/"))
.with(EscapingStrategy.NOOP)
.with(registry);
StringHelpers.register(hbs);

Context context = Context.newBuilder(new DescriptorsContext(bridgeTypeDescriptors, thingTypeDescriptors, channelTypes, channelGroupTypes, configDescriptions))
.resolver(
Expand Down
@@ -1,9 +1,26 @@
[width="100%",caption="{{caption}}",cols="1,1,1,2"]
[width="100%",caption="{{caption}}",cols="1,2,1,2"]
|===
|Name | Type | Label ^|Description
{{#each config.parameters}}
| {{name}}
| {{type}}
| {{#if required}}**{{name}}**{{else}}{{name}}{{/if}}
a| {{type}}

{{#if defaultValue}}Default: {{defaultValue}}{{/if}}
{{#if readOnly}}Read only {{/if}}

{{#if or (eq type "INTEGER") (eq type "DECIMAL")}}
{{#if min}}Min: {{min}} {{/if}}
{{#if min}}Max: {{max}} {{/if}}
{{#if min}}Step: {{max}} {{/if}}
{{#if unit}}Unit: {{unit}} {{/if}}
{{/if}}
{{#if multiple}}Multiple {{/if}}
{{#if options}}
Valid options:
{{#each options}}
* `{{value}}`: {{label}}
{{/each}}
{{/if}}
| {{label}}
| {{description}}
{{/each}}
Expand Down

0 comments on commit c58c1cc

Please sign in to comment.