diff --git a/docs/src/main/asciidoc/README.adoc b/docs/src/main/asciidoc/README.adoc index a2f94a4d..ac87e0c7 100644 --- a/docs/src/main/asciidoc/README.adoc +++ b/docs/src/main/asciidoc/README.adoc @@ -94,7 +94,9 @@ approach of generating documentation just add these plugins to your `docs` modul IMPORTANT: The order of plugin declaration is important! -In order for the build to generate the `adoc` file with all your configuration properties, your `docs` module should contain all the dependencies on the classpath, that you would want to scan for configuration properties. The file will be output to `${docsModule}/src/main/asciidoc/configprops.adoc` file. +In order for the build to generate the `adoc` file with all your configuration properties, your `docs` module should contain all the dependencies on the classpath, that you would want to scan for configuration properties. The file will be output to `${docsModule}/src/main/asciidoc/configprops.adoc` file (configurable via the `configprops.path` property). + +If you want to modify which of the configuration properties are put in the table, you can tweak the `configprops.inclusionPattern` pattern to include only a subset of the properties (e.g. `spring.sleuth.*`). Spring Cloud Build Docs comes with a set of attributes for asciidoctor that you can reuse. diff --git a/docs/src/main/groovy/org/springframework/cloud/internal/Main.groovy b/docs/src/main/groovy/org/springframework/cloud/internal/Main.groovy index 2d4588f3..bc101386 100644 --- a/docs/src/main/groovy/org/springframework/cloud/internal/Main.groovy +++ b/docs/src/main/groovy/org/springframework/cloud/internal/Main.groovy @@ -1,5 +1,7 @@ package org.springframework.cloud.internal +import java.util.regex.Pattern + import groovy.json.JsonSlurper import groovy.transform.CompileStatic @@ -14,10 +16,11 @@ class Main { @CompileStatic static void main(String... args) { String outputFile = args[0] - new Main().generate(outputFile) + String inclusionPattern = args.length > 0 ? args[1] : ".*" + new Main().generate(outputFile, inclusionPattern) } - void generate(String outputFile) { + void generate(String outputFile, String inclusionPattern) { println "Parsing all configuration metadata" Resource[] resources = new PathMatchingResourcePatternResolver() .getResources("classpath*:/META-INF/spring-configuration-metadata.json") @@ -25,17 +28,25 @@ class Main { TreeSet names = new TreeSet() def descriptions = [:] int count = 0 + int matchingPropertyCount = 0 + int propertyCount = 0 + Pattern pattern = Pattern.compile(inclusionPattern) resources.each { Resource resource -> if (resource.url.toString().contains("cloud")) { count++ def slurper = new JsonSlurper() slurper.parseText(resource.inputStream.text).properties.each { val -> + propertyCount++ + if (!pattern.matcher(val.name).matches()) { + return + } + matchingPropertyCount++ names.add val.name descriptions[val.name] = new ConfigValue(val.name, val.description, val.defaultValue) } } } - println "Found [${count}] Cloud projects configuration metadata jsons" + println "Found [${count}] Cloud projects configuration metadata jsons. [${matchingPropertyCount}/${propertyCount}] were matching the pattern [${inclusionPattern}]" println "Successfully built the description table" if (names.empty) { println("Will not update the table, since no configuration properties were found!") diff --git a/pom.xml b/pom.xml index 637547a4..99e01cd1 100644 --- a/pom.xml +++ b/pom.xml @@ -99,6 +99,7 @@ 3.2.10 1.8.1 ${project.basedir}/src/main/asciidoc/_configprops.adoc + .* @@ -1024,6 +1025,7 @@ org.springframework.cloud.internal.Main ${configprops.path} + ${configprops.inclusionPattern}