From 947b4f9d8feb5e69bb331afed2197e9e77512860 Mon Sep 17 00:00:00 2001 From: Phillip Webb Date: Mon, 17 Mar 2014 00:04:57 -0700 Subject: [PATCH] Add properties syntax highlighting for docs Fixes gh-495 --- .../appendix-application-properties.adoc | 6 +-- .../src/main/asciidoc/build-tool-plugins.adoc | 2 +- spring-boot-docs/src/main/asciidoc/howto.adoc | 28 +++++------ .../asciidoc/production-ready-features.adoc | 46 +++++++++---------- .../main/asciidoc/spring-boot-features.adoc | 28 +++++------ .../src/main/docbook/xsl/xslthl-config.xml | 1 + .../main/docbook/xsl/xslthl/properties-hl.xml | 38 +++++++++++++++ 7 files changed, 94 insertions(+), 55 deletions(-) create mode 100644 spring-boot-docs/src/main/docbook/xsl/xslthl/properties-hl.xml diff --git a/spring-boot-docs/src/main/asciidoc/appendix-application-properties.adoc b/spring-boot-docs/src/main/asciidoc/appendix-application-properties.adoc index 581411be4db..91d0b28d995 100644 --- a/spring-boot-docs/src/main/asciidoc/appendix-application-properties.adoc +++ b/spring-boot-docs/src/main/asciidoc/appendix-application-properties.adoc @@ -37,7 +37,7 @@ spring.profiles= # comma list of active profiles spring.main.sources= spring.main.web-environment= # detect by default spring.main.show-bannder=true -spring.main.... # see class for all properties +spring.main....= # see class for all properties # LOGGING logging.path=/var/logs @@ -66,7 +66,7 @@ server.tomcat.max-threads = 0 # number of threads in protocol handler http.mappers.json-pretty-print=false # pretty print JSON spring.view.prefix= # MVC view prefix spring.view.suffix= # ... and suffix -spring.resources.cache-period # cache timeouts in headers sent to browser +spring.resources.cache-period= # cache timeouts in headers sent to browser # THYMELEAF (ThymeleafAutoConfiguration) spring.thymeleaf.prefix="classpath:/templates/" @@ -109,7 +109,7 @@ spring.datasource.max-active=100 # Advanced configuration... spring.datasource.max-idle=8 spring.datasource.min-idle=8 spring.datasource.initial-size=10 -spring.datasource.validation-query +spring.datasource.validation-query= spring.datasource.test-on-borrow=false spring.datasource.test-on-return=false diff --git a/spring-boot-docs/src/main/asciidoc/build-tool-plugins.adoc b/spring-boot-docs/src/main/asciidoc/build-tool-plugins.adoc index a5f84aa4dc6..724ab8e0fdf 100644 --- a/spring-boot-docs/src/main/asciidoc/build-tool-plugins.adoc +++ b/spring-boot-docs/src/main/asciidoc/build-tool-plugins.adoc @@ -146,7 +146,7 @@ The following configuration options are available for the `spring-boot:repackage |Name of the generated archive (defaults to `${project.build.finalName}`). |=== -|== + [[build-tool-plugins-maven-packaging-optional-params]] ==== Optional parameters diff --git a/spring-boot-docs/src/main/asciidoc/howto.adoc b/spring-boot-docs/src/main/asciidoc/howto.adoc index fae34ebf2ce..bf1a6631fcc 100644 --- a/spring-boot-docs/src/main/asciidoc/howto.adoc +++ b/spring-boot-docs/src/main/asciidoc/howto.adoc @@ -120,10 +120,10 @@ you create the application to modify its behavior. Or you can externalize the configuration using properties in `spring.main.*`. E.g. in `application.properties` you might have. -[indent=0,subs="verbatim,quotes,attributes"] +[source,properties,indent=0,subs="verbatim,quotes,attributes"] ---- - spring.main.web_environment: false - spring.main.show_banner: false + spring.main.web_environment=false + spring.main.show_banner=false ---- and then the Spring Boot banner will not be printed on startup, and the application will @@ -167,9 +167,9 @@ Some people like to use (for example) `--port=9000` instead of `--server.port=90 set configuration properties on the command line. You can easily enable this by using placeholders in `application.properties`, e.g. -[indent=0,subs="verbatim,quotes,attributes"] +[source,properties,indent=0,subs="verbatim,quotes,attributes"] ---- - server.port: ${port:8080} + server.port=${port:8080} ---- NOTE: In this specific case the port binding will work in a PaaS environment like Heroku @@ -204,12 +204,12 @@ is 1-level deep and has period-separated keys, a lot like people are used to wit The example YAML above corresponds to an `application.properties` file -[indent=0,subs="verbatim,quotes,attributes"] +[source,properties,indent=0,subs="verbatim,quotes,attributes"] ---- - spring.application.name: cruncher - spring.datasource.driverClassName: com.mysql.jdbc.Driver - spring.datasource.url: jdbc:mysql://localhost/test - server.port: 9000 + spring.application.name=cruncher + spring.datasource.driverClassName=com.mysql.jdbc.Driver + spring.datasource.url=jdbc:mysql://localhost/test + server.port=9000 ---- See ``<>'' in @@ -230,7 +230,7 @@ or jar archive): In Spring Boot you can also set the active profile in `application.properties`, e.g. -[indent=0,subs="verbatim,quotes,attributes"] +[source,properties,indent=0,subs="verbatim,quotes,attributes"] ---- spring.profiles.active=production ---- @@ -1085,10 +1085,10 @@ standard behavior is determined by the presence or absence of certain request he work with most front end proxies. You switch on the valve by adding some entries to `application.properties`, e.g. -[indent=0] +[source,properties,indent=0] ---- - server.tomcat.remote_ip_header: x-forwarded-for - server.tomcat.protocol_header: x-forwarded-proto + server.tomcat.remote_ip_header=x-forwarded-for + server.tomcat.protocol_header=x-forwarded-proto ---- (The presence of either of those properties will switch on the valve. Or you can add the diff --git a/spring-boot-docs/src/main/asciidoc/production-ready-features.adoc b/spring-boot-docs/src/main/asciidoc/production-ready-features.adoc index 546e970c767..e2bd1c0e57a 100644 --- a/spring-boot-docs/src/main/asciidoc/production-ready-features.adoc +++ b/spring-boot-docs/src/main/asciidoc/production-ready-features.adoc @@ -124,7 +124,7 @@ Endpoints can be customized using Spring properties. You can change if an endpoi For example, here is an `application.properties` that changes the sensitivity and id of the `beans` endpoint and also enables `shutdown`. -[indent=0] +[source,properties,indent=0] ---- endpoints.beans.id=springbeans endpoints.beans.sensitive=false @@ -174,11 +174,11 @@ You can customize the data exposed by the `info` endpoint by settings `info.*` S properties. All `Environment` properties under the info key will be automatically exposed. For example, you could add the following to your `application.properties`: -[indent=0] +[source,properties,indent=0] ---- - info.app.name: MyService - info.app.description: My awesome service - info.app.version: 1.0.0 + info.app.name=MyService + info.app.description=My awesome service + info.app.version=1.0.0 ---- If you are using Maven, you can automatically expand info properties from the Maven @@ -197,16 +197,16 @@ element): You can then refer to your Maven ``project properties'' via placeholders, e.g. -[indent=0] +[source,properties,indent=0] ---- - project.artifactId: myproject - project.name: Demo - project.version: X.X.X.X - project.description: Demo project for info endpoint - info.build.artifact: ${project.artifactId} - info.build.name: ${project.name} - info.build.description: ${project.description} - info.build.version: ${project.version} + project.artifactId=myproject + project.name=Demo + project.version=X.X.X.X + project.description=Demo project for info endpoint + info.build.artifact=${project.artifactId} + info.build.name=${project.name} + info.build.description=${project.description} + info.build.version=${project.version} ---- NOTE: In the above example we used `project.*` to set some values to be used as @@ -262,7 +262,7 @@ You can use Spring properties to change the username and passsword and to change security role required to access the endpoints. For example, you might set the following in your `application.properties`: -[indent=0] +[source,properties,indent=0] ---- security.user.name=admin security.user.password=secret @@ -277,7 +277,7 @@ Sometimes it is useful to group all management endpoints under a single path. Fo your application might already use `/info` for another purpose. You can use the `management.contextPath` property to set a prefix for your manangement endpoint: -[indent=0] +[source,properties,indent=0] ---- management.contextpath=/manage ---- @@ -297,7 +297,7 @@ The `management.port` property can be used to change the HTTP port. Since your m port is often protected by a firewall, and not exposed to the public, you might also want to disable management security: -[indent=0] +[source,properties,indent=0] ---- management.port=8081 management.security.enabled=false @@ -318,7 +318,7 @@ main server port. Here is an example `application.properties` that will not allow remote management connections: -[indent=0] +[source,properties,indent=0] ---- management.port=8081 management.address=127.0.0.1 @@ -330,7 +330,7 @@ connections: === Disabling HTTP endpoints If you don't want to expose endpoints over HTTP you can set the management port to `-1`: -[indent=0] +[source,properties,indent=0] ---- management.port=-1 ---- @@ -357,7 +357,7 @@ to `true` so that MBean names are always unique. You can also customize the JMX domain under which endpoints are exposed. Here is an example `application.properties`: -[indent=0] +[source,properties,indent=0] ---- endpoints.jmx.domain=myapp endpoints.jmx.uniqueNames=true @@ -370,7 +370,7 @@ example `application.properties`: If you don't want to expose endpoints over JMX you can set the `spring.jmx.enabled` property to `false`: -[indent=0] +[source,properties,indent=0] ---- spring.jmx.enabled=false ---- @@ -401,7 +401,7 @@ Jolokia has a number of settings that you would traditionally configure using se parameters. With Spring Boot you can use your `application.properties`, simply prefix the parameter with `jolokia.config.`: -[indent=0] +[source,properties,indent=0] ---- jolokia.config.debug=true ---- @@ -413,7 +413,7 @@ parameter with `jolokia.config.`: If you are using Jolokia but you don't want Spring Boot to configure it, simply set the `endpoints.jolokia.enabled` property to `false`: -[indent=0] +[source,properties,indent=0] ---- jolokia.config.enabled=false ---- diff --git a/spring-boot-docs/src/main/asciidoc/spring-boot-features.adoc b/spring-boot-docs/src/main/asciidoc/spring-boot-features.adoc index dc3955f3fd0..d0823c56913 100644 --- a/spring-boot-docs/src/main/asciidoc/spring-boot-features.adoc +++ b/spring-boot-docs/src/main/asciidoc/spring-boot-features.adoc @@ -284,10 +284,10 @@ The values in `application.properties` are filtered through the existing `Enviro when they are used so you can refer back to previously defined values (e.g. from System properties). -[indent=0] +[source,properties,indent=0] ---- - app.name: MyApp - app.description: ${app.name} is a Spring Boot application + app.name=MyApp + app.description=${app.name} is a Spring Boot application ---- TIP: You can also use this technique to create ``short'' variants of existing Spring Boot @@ -328,7 +328,7 @@ For example, the following YAML document: Would be transformed into these properties: -[indent=0] +[source,properties,indent=0] ---- environments.dev.url=http://dev.bar.com environments.dev.name=Developer Setup @@ -348,7 +348,7 @@ and also as property keys with `[index]` dereferencers, for example this YAML: Would be transformed into these properties: -[indent=0] +[source,properties,indent=0] ---- servers=dev.bar.com,foo.bar.com servers[0]=dev.bar.com @@ -532,7 +532,7 @@ Spring Boot takes this a stage further, in that you can use a `spring.profiles.a in any of the usual ways, for example you could include it in your `application.properties`: -[indent=0] +[source,properties,indent=0] ---- spring.profiles.active=dev,hsqldb ---- @@ -1036,12 +1036,12 @@ DataSource configuration is controlled by external configuration properties in `spring.datasource.*`. For example, you might declare the following section in `application.properties`: -[indent=0] +[source,properties,indent=0] ---- - spring.datasource.url: jdbc:mysql://localhost/test - spring.datasource.username: dbuser - spring.datasource.password: dbpass - spring.datasource.driverClassName: com.mysql.jdbc.Driver + spring.datasource.url=jdbc:mysql://localhost/test + spring.datasource.username=dbuser + spring.datasource.password=dbpass + spring.datasource.driverClassName=com.mysql.jdbc.Driver ---- See {sc-spring-boot-autoconfigure}/jdbc/AbstractDataSourceConfiguration.{sc-ext}[`AbstractDataSourceConfiguration`] @@ -1268,10 +1268,10 @@ You can set `spring.data.mongodb.url` property to change the `url`, or alternati specify a `host`/`port`. For example, you might declare the following in your `application.properties`: -[indent=0] +[source,properties,indent=0] ---- - spring.data.mongodb.host = mongoserver - spring.data.mongodb.port = 27017 + spring.data.mongodb.host=mongoserver + spring.data.mongodb.port=27017 ---- TIP: If `spring.data.mongodb.port` is not specified the default of `27017` is used. You diff --git a/spring-boot-docs/src/main/docbook/xsl/xslthl-config.xml b/spring-boot-docs/src/main/docbook/xsl/xslthl-config.xml index 011a09e1bb5..d0fd16e684a 100644 --- a/spring-boot-docs/src/main/docbook/xsl/xslthl-config.xml +++ b/spring-boot-docs/src/main/docbook/xsl/xslthl-config.xml @@ -16,5 +16,6 @@ + diff --git a/spring-boot-docs/src/main/docbook/xsl/xslthl/properties-hl.xml b/spring-boot-docs/src/main/docbook/xsl/xslthl/properties-hl.xml new file mode 100644 index 00000000000..e53ac478e7e --- /dev/null +++ b/spring-boot-docs/src/main/docbook/xsl/xslthl/properties-hl.xml @@ -0,0 +1,38 @@ + + + + # + + ^(.+)(?==|:) + + MULTILINE + +