Skip to content

Commit 6823546

Browse files
rwinchrstoyanchev
authored andcommitted
Use include-code Macro
1 parent 51ada4e commit 6823546

File tree

5 files changed

+14
-12
lines changed

5 files changed

+14
-12
lines changed

framework-docs/antora-playbook.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ asciidoc:
2424
extensions:
2525
- '@asciidoctor/tabs'
2626
- '@springio/asciidoctor-extensions'
27+
- '@springio/asciidoctor-extensions/include-code-extension'
2728
sourcemap: true
2829
urls:
2930
latest_version_segment: ''

framework-docs/antora.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ asciidoc:
1717
# FIXME: the copyright is not removed
1818
# FIXME: The package is not renamed
1919
chomp: 'all'
20-
import-java: 'example$docs-src/main/java/org/springframework/docs'
20+
include-java: 'example$docs-src/main/java/org/springframework/docs'
2121
spring-framework-main-code: 'https://github.com/spring-projects/spring-framework/tree/main'
2222
docs-site: 'https://docs.spring.io'
2323
docs-spring: "{docs-site}/spring-framework/docs/{spring-version}"
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../../src

framework-docs/modules/ROOT/pages/core/aot.adoc

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -54,13 +54,13 @@ An application context is created with any number of entry points, usually in th
5454

5555
Let's look at a basic example:
5656

57-
include::code:AotProcessingSample[tag=myapplication]
57+
include-code::AotProcessingSample[tag=myapplication]
5858

5959
Starting this application with the regular runtime involves a number of steps including classpath scanning, configuration class parsing, bean instantiation, and lifecycle callback handling.
6060
Refresh for AOT processing only applies a subset of what happens with a xref:core/beans/introduction.adoc[regular `refresh`].
6161
AOT processing can be triggered as follows:
6262

63-
include::code:AotProcessingSample[tag=aotcontext]
63+
include-code::AotProcessingSample[tag=aotcontext]
6464

6565
In this mode, xref:core/beans/factory-extension.adoc#beans-factory-extension-factory-postprocessors[`BeanFactoryPostProcessor` implementations] are invoked as usual.
6666
This includes configuration class parsing, import selectors, classpath scanning, etc.
@@ -217,7 +217,7 @@ A number of convenient annotations are also provided for common use cases.
217217
Implementations of this interface can be registered using `@ImportRuntimeHints` on any Spring bean or `@Bean` factory method.
218218
`RuntimeHintsRegistrar` implementations are detected and invoked at build time.
219219

220-
include::code:SpellCheckService[]
220+
include-code::SpellCheckService[]
221221

222222
If at all possible, `@ImportRuntimeHints` should be used as close as possible to the component that requires the hints.
223223
This way, if the component is not contributed to the `BeanFactory`, the hints won't be contributed either.
@@ -269,7 +269,7 @@ Spring Core also ships `RuntimeHintsPredicates`, a utility for checking that exi
269269
This can be used in your own tests to validate that a `RuntimeHintsRegistrar` contains the expected results.
270270
We can write a test for our `SpellCheckService` and ensure that we will be able to load a dictionary at runtime:
271271

272-
include::code:SpellCheckServiceTests[tag=hintspredicates]
272+
include-code::SpellCheckServiceTests[tag=hintspredicates]
273273

274274
With `RuntimeHintsPredicates`, we can check for reflection, resource, serialization, or proxy generation hints.
275275
This approach works well for unit tests but implies that the runtime behavior of a component is well known.
@@ -281,11 +281,11 @@ For more targeted discovery and testing, Spring Framework ships a dedicated modu
281281
This module contains the RuntimeHints Agent, a Java agent that records all method invocations that are related to runtime hints and helps you to assert that a given `RuntimeHints` instance covers all recorded invocations.
282282
Let's consider a piece of infrastructure for which we'd like to test the hints we're contributing during the AOT processing phase.
283283

284-
include::code:SampleReflection[]
284+
include-code::SampleReflection[]
285285

286286
We can then write a unit test (no native compilation required) that checks our contributed hints:
287287

288-
include::code:SampleReflectionRuntimeHintsTests[]
288+
include-code::SampleReflectionRuntimeHintsTests[]
289289

290290
If you forgot to contribute a hint, the test will fail and provide some details about the invocation:
291291

framework-docs/modules/ROOT/pages/integration/observability.adoc

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -66,16 +66,16 @@ Let's take the example of the Spring MVC "http.server.requests" metrics instrume
6666
This observation is using a `ServerRequestObservationConvention` with a `ServerRequestObservationContext`; custom conventions can be configured on the Servlet filter.
6767
If you would like to customize the metadata produced with the observation, you can extend the `DefaultServerRequestObservationConvention` for your requirements:
6868

69-
include::code:ExtendedServerRequestObservationConvention[]
69+
include-code::ExtendedServerRequestObservationConvention[]
7070

7171
If you want full control, you can then implement the entire convention contract for the observation you're interested in:
7272

73-
include::code:CustomServerRequestObservationConvention[]
73+
include-code::CustomServerRequestObservationConvention[]
7474

7575
You can also achieve similar goals using a custom `ObservationFilter` - adding or removing key values for an observation.
7676
Filters do not replace the default convention and are used as a post-processing component.
7777

78-
include::code:ServerRequestObservationFilter[]
78+
include-code::ServerRequestObservationFilter[]
7979

8080
You can configure `ObservationFilter` instances on the `ObservationRegistry`.
8181

@@ -95,7 +95,7 @@ This will only record an observation as an error if the `Exception` has not been
9595
Typically, all exceptions handled by Spring MVC's `@ExceptionHandler` and xref:web/webmvc/mvc-ann-rest-exceptions.adoc[`ProblemDetail` support] will not be recorded with the observation.
9696
You can, at any point during request processing, set the error field on the `ObservationContext` yourself:
9797

98-
include::code:UserController[]
98+
include-code::UserController[]
9999

100100
By default, the following `KeyValues` are created:
101101

@@ -128,7 +128,7 @@ This will only record an observation as an error if the `Exception` has not been
128128
Typically, all exceptions handled by Spring WebFlux's `@ExceptionHandler` and xref:web/webflux/ann-rest-exceptions.adoc[`ProblemDetail` support] will not be recorded with the observation.
129129
You can, at any point during request processing, set the error field on the `ObservationContext` yourself:
130130

131-
include::code:UserController[]
131+
include-code::UserController[]
132132

133133
By default, the following `KeyValues` are created:
134134

0 commit comments

Comments
 (0)