Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add copy button for configuration properties in config tables #44403

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
import io.quarkus.maven.config.doc.generator.GenerationReport;
import io.quarkus.maven.config.doc.generator.GenerationReport.GenerationViolation;
import io.quarkus.qute.Engine;
import io.quarkus.qute.EngineBuilder;
import io.quarkus.qute.ReflectionValueResolver;
import io.quarkus.qute.UserTagSectionHelper;
import io.quarkus.qute.ValueResolver;
Expand Down Expand Up @@ -296,7 +297,7 @@ public FileVisitResult preVisitDirectory(Path dir, BasicFileAttributes attrs) th
}

private static Engine initializeQuteEngine(Formatter formatter, Format format, String theme) {
Engine engine = Engine.builder()
EngineBuilder engineBuilder = Engine.builder()
.addDefaults()
.addSectionHelper(new UserTagSectionHelper.Factory("configProperty", "configProperty"))
.addSectionHelper(new UserTagSectionHelper.Factory("configSection", "configSection"))
Expand Down Expand Up @@ -402,9 +403,13 @@ private static Engine initializeQuteEngine(Formatter formatter, Format format, S
.applyToName("formatName")
.applyToNoParameters()
.resolveSync(ctx -> formatter.formatName((Extension) ctx.getBase()))
.build())
.build();
.build());

if (format == Format.asciidoc) {
engineBuilder.addSectionHelper(new UserTagSectionHelper.Factory("propertyCopyButton", "propertyCopyButton"));
}

Engine engine = engineBuilder.build();
engine.putTemplate("configReference",
engine.parse(getTemplate("templates", format, theme, "configReference", false)));
engine.putTemplate("allConfig",
Expand All @@ -420,6 +425,11 @@ private static Engine initializeQuteEngine(Formatter formatter, Format format, S
engine.putTemplate("memorySizeNote",
engine.parse(getTemplate("templates", format, theme, "memorySizeNote", true)));

if (format == Format.asciidoc) {
engine.putTemplate("propertyCopyButton",
engine.parse(getTemplate("templates", format, theme, "propertyCopyButton", true)));
}

return engine;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
a|{#if configProperty.phase.fixedAtBuildTime}icon:lock[title=Fixed at build time]{/if} [[{configProperty.toAnchor(extension, additionalAnchorPrefix)}]] [.property-path]##link:#{configProperty.toAnchor(extension, additionalAnchorPrefix)}[`{configProperty.path.property}`]##
{#propertyCopyButton configProperty.path.property /}

{#for additionalPath in configProperty.additionalPaths}

`{additionalPath.property}`
{#propertyCopyButton additionalPath.property /}
{/for}

[.description]
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
ifdef::add-copy-button-to-config-props[]
config_property_copy_button:+++{it}+++[]
endif::add-copy-button-to-config-props[]