Skip to content

Commit 9b94c1c

Browse files
Improve antora and document
Signed-off-by: Tran Ngoc Nhan <[email protected]>
1 parent 85aa161 commit 9b94c1c

15 files changed

+63
-38
lines changed

gradle/docs.gradle

Lines changed: 35 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,21 +8,16 @@ antora {
88
stacktrace: true
99
]
1010
dependencies = [
11-
'@antora/atlas-extension' : '1.0.0-alpha.1',
12-
'@antora/collector-extension' : '1.0.0-alpha.3',
13-
'@asciidoctor/tabs' : '1.0.0-beta.3',
14-
'@springio/antora-extensions' : '1.4.2',
15-
'@springio/asciidoctor-extensions': '1.0.0-alpha.8',
11+
'@antora/atlas-extension' : '1.0.0-alpha.2',
12+
'@antora/collector-extension' : '1.0.1',
13+
'@asciidoctor/tabs' : '1.0.0-beta.6',
14+
'@springio/antora-extensions' : '1.14.4',
15+
'@springio/asciidoctor-extensions': '1.0.0-alpha.16',
1616
]
1717
}
1818

1919
tasks.named('generateAntoraYml') {
20-
asciidocAttributes = project.provider({
21-
return ['project-version': project.version,
22-
'revnumber' : project.version,
23-
'spring-version' : project.version,
24-
]
25-
})
20+
asciidocAttributes = project.provider( { generateAttributes() } )
2621
baseAntoraYmlFile = file('src/main/antora/antora.yml')
2722
}
2823

@@ -35,3 +30,32 @@ tasks.register('generateAntoraResources') {
3530
dependsOn 'createAntoraPartials'
3631
dependsOn 'generateAntoraYml'
3732
}
33+
34+
def generateAttributes() {
35+
def springDoc = "https://docs.spring.io"
36+
def springFrameworkReferenceUrl = "$springDoc/spring-framework/reference/${generateVersionWithoutPatch(springVersion)}"
37+
def springBootUrl = "$springDoc/spring-boot/${generateVersionWithoutPatch(springBootVersion)}"
38+
def springIntegrationUrl = "$springDoc/spring-integration/reference"
39+
def kafkaPage = "https://kafka.apache.org"
40+
def kafkaUrl = "$kafkaPage/${kafkaVersion.split('\\.')[0,1].join('')}"
41+
def micrometerTracingReferenceUrl = "https://docs.micrometer.io/tracing/reference/${generateVersionWithoutPatch(micrometerTracingVersion)}"
42+
43+
return [
44+
'project-version': project.version,
45+
'revnumber' : project.version,
46+
'spring-version' : project.version,
47+
'spring-framework-reference-url' : springFrameworkReferenceUrl.toString(),
48+
'spring-boot-url' : springBootUrl.toString(),
49+
'spring-integration-url' : springIntegrationUrl.toString(),
50+
'kafka-page' : kafkaPage,
51+
'kafka-url' : kafkaUrl.toString(),
52+
'micrometer-tracing-reference-url': micrometerTracingReferenceUrl.toString(),
53+
'javadoc-location-org-springframework-kafka': "$springDoc/spring-kafka/docs/$project.version/api".toString(),
54+
'javadoc-location-org-apache-kafka': "$kafkaUrl/javadoc".toString()
55+
]
56+
}
57+
58+
static String generateVersionWithoutPatch(String version) {
59+
60+
return version.split('\\.')[0,1].join('.') + (version.endsWith('-SNAPSHOT') ? '-SNAPSHOT' : '')
61+
}

spring-kafka-docs/src/main/antora/antora-playbook.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ asciidoc:
3333
extensions:
3434
- '@asciidoctor/tabs'
3535
- '@springio/asciidoctor-extensions'
36+
- '@springio/asciidoctor-extensions/javadoc-extension'
3637
sourcemap: true
3738
urls:
3839
latest_version_segment: ''

spring-kafka-docs/src/main/antora/modules/ROOT/pages/appendix/change-history.adoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -891,7 +891,7 @@ See xref:streams.adoc#streams-header-enricher[Header Enricher] for more informat
891891

892892
The `MessagingTransformer` has been provided.
893893
This allows a Kafka streams topology to interact with a spring-messaging component, such as a Spring Integration flow.
894-
See xref:streams.adoc#streams-messaging[`MessagingProcessor`] and See https://docs.spring.io/spring-integration/docs/current/reference/html/kafka.html#streams-integration[[Calling a Spring Integration Flow from a `KStream`]] for more information.
894+
See xref:streams.adoc#streams-messaging[`MessagingProcessor`] and See {spring-integration-url}/kafka.html#streams-integration[Calling a Spring Integration Flow from a `KStream`] for more information.
895895

896896
[[cb-2-2-and-2-3-json-component-changes]]
897897
=== JSON Component Changes

spring-kafka-docs/src/main/antora/modules/ROOT/pages/appendix/native-images.adoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[[native-images]]
22
= Native Images
33

4-
https://docs.spring.io/spring-framework/docs/current/reference/html/core.html#aot[Spring AOT] native hints are provided to assist in developing native images for Spring applications that use Spring for Apache Kafka, including hints for AVRO generated classes used in `@KafkaListener`+++s+++.
4+
{spring-framework-reference-url}/core/aot.html[Spring AOT] native hints are provided to assist in developing native images for Spring applications that use Spring for Apache Kafka, including hints for AVRO generated classes used in `@KafkaListener`+++s+++.
55

66
IMPORTANT: `spring-kafka-test` (and, specifically, its `EmbeddedKafkaBroker`) is not supported in native images.
77

spring-kafka-docs/src/main/antora/modules/ROOT/pages/kafka/micrometer.adoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ Set `observationEnabled` to `true` on the `KafkaTemplate` and `ContainerProperti
102102

103103
IMPORTANT: Micrometer Observation does not support batch listener; this will enable Micrometer Timers
104104

105-
Refer to https://micrometer.io/docs/tracing[Micrometer Tracing] for more information.
105+
Refer to {micrometer-tracing-reference-url}[Micrometer Tracing] for more information.
106106

107107
To add tags to timers/traces, configure a custom `KafkaTemplateObservationConvention` or `KafkaListenerObservationConvention` to the template or listener container, respectively.
108108

spring-kafka-docs/src/main/antora/modules/ROOT/pages/kafka/receiving-messages/filtering.adoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
In certain scenarios, such as rebalancing, a message that has already been processed may be redelivered.
55
The framework cannot know whether such a message has been processed or not.
66
That is an application-level function.
7-
This is known as the https://www.enterpriseintegrationpatterns.com/patterns/messaging/IdempotentReceiver.html[Idempotent Receiver] pattern and Spring Integration provides an https://docs.spring.io/spring-integration/reference/handler-advice/idempotent-receiver.html[implementation] of it.
7+
This is known as the https://www.enterpriseintegrationpatterns.com/patterns/messaging/IdempotentReceiver.html[Idempotent Receiver] pattern and Spring Integration provides an {spring-integration-url}/handler-advice/idempotent-receiver.html[implementation] of it.
88

99
The Spring for Apache Kafka project also provides some assistance by means of the `FilteringMessageListenerAdapter` class, which can wrap your `MessageListener`.
1010
This class takes an implementation of `RecordFilterStrategy` in which you implement the `filter` method to signal that a message is a duplicate and should be discarded.

spring-kafka-docs/src/main/antora/modules/ROOT/pages/kafka/receiving-messages/listener-annotation.adoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ The `@KafkaListener` annotation is used to designate a bean method as a listener
55
The bean is wrapped in a `MessagingMessageListenerAdapter` configured with various features, such as converters to convert the data, if necessary, to match the method parameters.
66

77
You can configure most attributes on the annotation with SpEL by using `#{...}` or property placeholders (`${...}`).
8-
See the https://docs.spring.io/spring-kafka/api/org/springframework/kafka/annotation/KafkaListener.html[Javadoc] for more information.
8+
See the javadoc:org.springframework.kafka.annotation.KafkaListener[Javadoc] for more information.
99

1010
[[record-listener]]
1111
== Record Listeners

spring-kafka-docs/src/main/antora/modules/ROOT/pages/kafka/receiving-messages/message-listener-container.adoc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ You can set the listener container's `interceptBeforeTx` property to `false` to
2727
Starting with version 2.9, this will apply to any transaction manager, not just `KafkaAwareTransactionManager`+++s+++.
2828
This allows, for example, the interceptor to participate in a JDBC transaction started by the container.
2929

30-
Starting with versions 2.3.8, 2.4.6, the `ConcurrentMessageListenerContainer` now supports https://kafka.apache.org/documentation/#static_membership[Static Membership] when the concurrency is greater than one.
30+
Starting with versions 2.3.8, 2.4.6, the `ConcurrentMessageListenerContainer` now supports {kafka-url}/documentation/#static_membership[Static Membership] when the concurrency is greater than one.
3131
The `group.instance.id` is suffixed with `-n` with `n` starting at `1`.
3232
This, together with an increased `session.timeout.ms`, can be used to reduce rebalance events, for example, when application instances are restarted.
3333

@@ -94,7 +94,7 @@ KafkaMessageListenerContainer<Integer, String> container =
9494
return container;
9595
----
9696

97-
Refer to the https://docs.spring.io/spring-kafka/api/org/springframework/kafka/listener/ContainerProperties.html[Javadoc] for `ContainerProperties` for more information about the various properties that you can set.
97+
Refer to the javadoc:org.springframework.kafka.listener.ContainerProperties[Javadoc] for `ContainerProperties` for more information about the various properties that you can set.
9898

9999
Since version 2.1.1, a new property called `logContainerConfig` is available.
100100
When `true` and `INFO` logging is enabled each listener container writes a log message summarizing its configuration properties.

spring-kafka-docs/src/main/antora/modules/ROOT/pages/kafka/sending-messages.adoc

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ interface OperationsCallback<K, V, T> {
6060
}
6161
----
6262

63-
See the https://docs.spring.io/spring-kafka/api/org/springframework/kafka/core/KafkaTemplate.html[Javadoc] for more detail.
63+
See the javadoc:org.springframework.kafka.core.KafkaTemplate[Javadoc] for more detail.
6464

6565
The `sendDefault` API requires that a default topic has been provided to the template.
6666

@@ -69,13 +69,13 @@ How the user-provided timestamp is stored depends on the timestamp type configur
6969
If the topic is configured to use `CREATE_TIME`, the user-specified timestamp is recorded (or generated if not specified).
7070
If the topic is configured to use `LOG_APPEND_TIME`, the user-specified timestamp ignored and the broker adds in the local broker time.
7171

72-
The `metrics` and `partitionsFor` methods delegate to the same methods on the underlying https://kafka.apache.org/20/javadoc/org/apache/kafka/clients/producer/Producer.html[`Producer`].
73-
The `execute` method provides direct access to the underlying https://kafka.apache.org/20/javadoc/org/apache/kafka/clients/producer/Producer.html[`Producer`].
72+
The `metrics` and `partitionsFor` methods delegate to the same methods on the underlying javadoc:org.apache.kafka.clients.producer.Producer[].
73+
The `execute` method provides direct access to the underlying javadoc:org.apache.kafka.clients.producer.Producer[].
7474

7575
To use the template, you can configure a producer factory and provide it in the template's constructor.
7676
The following example shows how to do so:
7777

78-
[source, java]
78+
[source, java, subs="attributes"]
7979
----
8080
@Bean
8181
public ProducerFactory<Integer, String> producerFactory() {
@@ -88,7 +88,7 @@ public Map<String, Object> producerConfigs() {
8888
props.put(ProducerConfig.BOOTSTRAP_SERVERS_CONFIG, "localhost:9092");
8989
props.put(ProducerConfig.KEY_SERIALIZER_CLASS_CONFIG, IntegerSerializer.class);
9090
props.put(ProducerConfig.VALUE_SERIALIZER_CLASS_CONFIG, StringSerializer.class);
91-
// See https://kafka.apache.org/documentation/#producerconfigs for more properties
91+
// See {kafka-url}/documentation/#producerconfigs for more properties
9292
return props;
9393
}
9494

spring-kafka-docs/src/main/antora/modules/ROOT/pages/kafka/serdes.adoc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ Starting with version 2.3, all the JSON-aware components are configured by defau
9393
Also such an instance is supplied with well-known modules for custom data types, such a Java time and Kotlin support.
9494
See `JacksonUtils.enhancedObjectMapper()` JavaDocs for more information.
9595
This method also registers a `org.springframework.kafka.support.JacksonMimeTypeModule` for `org.springframework.util.MimeType` objects serialization into the plain string for inter-platform compatibility over the network.
96-
A `JacksonMimeTypeModule` can be registered as a bean in the application context and it will be auto-configured into the https://docs.spring.io/spring-boot/docs/current/reference/html/howto.html#howto.spring-mvc.customize-jackson-objectmapper[Spring Boot `ObjectMapper` instance].
96+
A `JacksonMimeTypeModule` can be registered as a bean in the application context and it will be auto-configured into the {spring-boot-url}/how-to/spring-mvc.html#howto.spring-mvc.customize-jackson-objectmapper[Spring Boot `ObjectMapper` instance].
9797

9898
Also starting with version 2.3, the `JsonDeserializer` provides `TypeReference`-based constructors for better handling of target generic container types.
9999

@@ -146,7 +146,7 @@ consumerProps.put(JsonDeserializer.TYPE_MAPPINGS, "cat:com.yourcat.Cat, hat:com.
146146

147147
IMPORTANT: The corresponding objects must be compatible.
148148

149-
If you use https://docs.spring.io/spring-boot/docs/current/reference/html/messaging.html#messaging.kafka[Spring Boot], you can provide these properties in the `application.properties` (or yaml) file.
149+
If you use {spring-boot-url}/reference/messaging/kafka.html[Spring Boot], you can provide these properties in the `application.properties` (or yaml) file.
150150
The following example shows how to do so:
151151

152152
[source]
@@ -408,7 +408,7 @@ Refer to the https://github.com/spring-projects/spring-retry[spring-retry] proje
408408
[[messaging-message-conversion]]
409409
== Spring Messaging Message Conversion
410410

411-
Although the `Serializer` and `Deserializer` API is quite simple and flexible from the low-level Kafka `Consumer` and `Producer` perspective, you might need more flexibility at the Spring Messaging level, when using either `@KafkaListener` or https://docs.spring.io/spring-integration/docs/current/reference/html/kafka.html#kafka[Spring Integration's Apache Kafka Support].
411+
Although the `Serializer` and `Deserializer` API is quite simple and flexible from the low-level Kafka `Consumer` and `Producer` perspective, you might need more flexibility at the Spring Messaging level, when using either `@KafkaListener` or {spring-integration-url}/kafka.html[Spring Integration's Apache Kafka Support].
412412
To let you easily convert to and from `org.springframework.messaging.Message`, Spring for Apache Kafka provides a `MessageConverter` abstraction with the `MessagingMessageConverter` implementation and its `JsonMessageConverter` (and subclasses) customization.
413413
You can inject the `MessageConverter` into a `KafkaTemplate` instance directly and by using `AbstractKafkaListenerContainerFactory` bean definition for the `@KafkaListener.containerFactory()` property.
414414
The following example shows how to do so:
@@ -532,7 +532,7 @@ Alternatively, you can configure the `ErrorHandlingDeserializer` to create a cus
532532
This function is invoked to create an instance of `T`, which is passed to the listener in the usual fashion.
533533
An object of type `FailedDeserializationInfo`, which contains all the contextual information is provided to the function.
534534
You can find the `DeserializationException` (as a serialized Java object) in headers.
535-
See the https://docs.spring.io/spring-kafka/api/org/springframework/kafka/support/serializer/ErrorHandlingDeserializer.html[Javadoc] for the `ErrorHandlingDeserializer` for more information.
535+
See the javadoc:org.springframework.kafka.support.serializer.ErrorHandlingDeserializer[Javadoc] for the `ErrorHandlingDeserializer` for more information.
536536

537537
You can use the `DefaultKafkaConsumerFactory` constructor that takes key and value `Deserializer` objects and wire in appropriate `ErrorHandlingDeserializer` instances that you have configured with the proper delegates.
538538
Alternatively, you can use consumer configuration properties (which are used by the `ErrorHandlingDeserializer`) to instantiate the delegates.

spring-kafka-docs/src/main/antora/modules/ROOT/pages/kafka/tombstones.adoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[[tombstones]]
22
= Null Payloads and Log Compaction of 'Tombstone' Records
33

4-
When you use https://kafka.apache.org/documentation/#compaction[Log Compaction], you can send and receive messages with `null` payloads to identify the deletion of a key.
4+
When you use {kafka-url}/documentation/#compaction[Log Compaction], you can send and receive messages with `null` payloads to identify the deletion of a key.
55

66
You can also receive `null` values for other reasons, such as a `Deserializer` that might return `null` when it cannot deserialize a value.
77

spring-kafka-docs/src/main/antora/modules/ROOT/pages/other-resources.adoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
In addition to this reference documentation, we recommend a number of other resources that may help you learn about Spring and Apache Kafka.
55

6-
- https://kafka.apache.org/[Apache Kafka Project Home Page]
6+
- {kafka-page}[Apache Kafka Project Home Page]
77
- https://projects.spring.io/spring-kafka/[Spring for Apache Kafka Home Page]
88
- https://github.com/spring-projects/spring-kafka[Spring for Apache Kafka GitHub Repository]
99
- https://github.com/spring-projects/spring-integration[Spring Integration GitHub Repository (Apache Kafka Module)]

spring-kafka-docs/src/main/antora/modules/ROOT/pages/quick-tour.adoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ This quick tour works with the following versions:
6666
== Getting Started
6767

6868
The simplest way to get started is to use https://start.spring.io[start.spring.io] (or the wizards in Spring Tool Suits and Intellij IDEA) and create a project, selecting 'Spring for Apache Kafka' as a dependency.
69-
Refer to the https://docs.spring.io/spring-boot/docs/current/reference/html/messaging.html#messaging.kafka[Spring Boot documentation] for more information about its opinionated auto configuration of the infrastructure beans.
69+
Refer to the {spring-boot-url}/reference/messaging/kafka.html[Spring Boot documentation] for more information about its opinionated auto configuration of the infrastructure beans.
7070

7171
Here is a minimal consumer application.
7272

0 commit comments

Comments
 (0)