Skip to content
This repository was archived by the owner on Mar 11, 2022. It is now read-only.

Commit 138b286

Browse files
authored
Merge pull request #16 from pvlugter/antora
Convert docs to asciidoc/antora
2 parents 86bb2d5 + 6c54549 commit 138b286

21 files changed

+263
-203
lines changed

.travis.yml

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,16 @@ jobs:
1313
tags: true
1414
repo: cloudstateio/springboot-support
1515

16+
- stage: validate_docs
17+
script: make -C docs
18+
1619
- stage: deploy_docs
17-
name: deploy docs to cloudstate.io
18-
if: repo = cloudstateio/springboot-support AND ((branch = master AND type = push) OR tag =~ ^v)
19-
language: scala
20-
install: true
21-
script: cd docs && sbt deploy
20+
if: repo = cloudstateio/springboot-support AND tag =~ ^v
21+
script: make -C docs deploy
2222

2323
stages:
2424
- build
25+
- validate_docs
2526
- deploy_docs
2627

2728
env:

docs/.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
/.cache/
2+
/.deploy/
3+
/build/

docs/Makefile

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
# Make Cloudstate Spring Boot documentation
2+
3+
module := springboot
4+
upstream := cloudstateio/springboot-support
5+
branch := docs/current
6+
sources := src build/src/managed
7+
8+
cloudstate_antora_download := https://github.com/cloudstateio/cloudstate-antora/raw/master/cloudstate-antora
9+
cloudstate_antora := .cache/bin/cloudstate-antora
10+
descriptor := build/site.yml
11+
src_managed := build/src/managed
12+
managed_partials := ${src_managed}/modules/springboot/partials
13+
14+
.SILENT:
15+
16+
build: clean managed validate html
17+
18+
${cloudstate_antora}:
19+
mkdir -p $$(dirname ${cloudstate_antora})
20+
curl -Lo ${cloudstate_antora} ${cloudstate_antora_download}
21+
chmod +x ${cloudstate_antora}
22+
23+
clean-cache:
24+
rm -rf .cache
25+
26+
update: clean-cache ${cloudstate_antora}
27+
28+
clean: ${cloudstate_antora}
29+
${cloudstate_antora} clean
30+
31+
managed: attributes
32+
mkdir -p "${src_managed}"
33+
cp src/antora.yml "${src_managed}/antora.yml"
34+
35+
attributes: ${cloudstate_antora}
36+
mkdir -p "${managed_partials}"
37+
${cloudstate_antora} version | xargs -0 printf ":cloudstate-springboot-lib-version: %s" \
38+
> "${managed_partials}/attributes.adoc"
39+
40+
${descriptor}: ${cloudstate_antora}
41+
mkdir -p $$(dirname ${descriptor})
42+
${cloudstate_antora} source --preview --upstream ${upstream} ${sources} > build/source.yml
43+
${cloudstate_antora} site --preview --exclude ${module} build/source.yml > ${descriptor}
44+
45+
validate: ${descriptor}
46+
${cloudstate_antora} validate ${descriptor}
47+
48+
html: ${descriptor}
49+
${cloudstate_antora} build ${descriptor}
50+
51+
validate-links: ${cloudstate_antora}
52+
${cloudstate_antora} validate --no-xrefs --links --links-config config/validate-links.json
53+
54+
deploy: clean managed
55+
${cloudstate_antora} deploy --module ${module} --upstream ${upstream} --branch ${branch} ${sources}

docs/README.md

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,19 @@
11
# Cloudstate Spring Boot documentation
22

3-
Documentation source for Cloudstate Spring Boot Support, published to https://cloudstate.io/docs/springboot/current/
3+
The Cloudstate documentation is built using [Antora](https://antora.org) with Asciidoc sources.
44

5-
To build the docs with [sbt](https://www.scala-sbt.org):
5+
The build is defined in the [Makefile](Makefile) and requires `make`, `bash`, and `docker`.
6+
7+
To build the documentation run:
68

79
```
8-
sbt paradox
10+
make
911
```
1012

11-
Can also first start the sbt interactive shell with `sbt`, then run commands.
12-
13-
The documentation can be viewed locally by opening the generated pages:
13+
The generated documentation site will be available in the `build/site` directory:
1414

1515
```
16-
open target/paradox/site/main/index.html
16+
open build/site/index.html
1717
```
1818

19-
To watch files for changes and rebuild docs automatically:
20-
21-
```
22-
sbt ~paradox
23-
```
19+
Documentation will be automatically deployed on tagged versions, in the Travis CI builds.

docs/build.sbt

Lines changed: 0 additions & 13 deletions
This file was deleted.

docs/config/validate-links.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"ignorePatterns": [
3+
{ "pattern": "^http://maven\\.apache\\.org/POM" }
4+
]
5+
}

docs/project/build.properties

Lines changed: 0 additions & 1 deletion
This file was deleted.

docs/project/plugins.sbt

Lines changed: 0 additions & 2 deletions
This file was deleted.

docs/src/antora.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
name: ""
2+
version: master

docs/src/main/paradox/conventions.md

Lines changed: 0 additions & 35 deletions
This file was deleted.

docs/src/main/paradox/examples.md

Lines changed: 0 additions & 5 deletions
This file was deleted.

docs/src/main/paradox/index.md

Lines changed: 0 additions & 17 deletions
This file was deleted.

docs/src/tests/paradox/ShoppingCartEntity.java renamed to docs/src/modules/springboot/examples/ShoppingCartEntity.java

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//#shopping-cart-entity
1+
// tag::shopping-cart-entity[]
22
/**
33
* An event sourced entity.
44
*/
@@ -84,9 +84,9 @@ public Empty removeItem(Shoppingcart.RemoveLineItem item, CommandContext ctx) {
8484
return Empty.getDefaultInstance();
8585
}
8686
}
87-
//#shopping-cart-entity
87+
// end::shopping-cart-entity[]
8888

89-
//#shopping-cart-configuration
89+
// tag::shopping-cart-configuration[]
9090
import com.example.shoppingcart.Shoppingcart;
9191
import com.google.protobuf.Descriptors;
9292
import org.springframework.context.annotation.Bean;
@@ -105,9 +105,9 @@ public Descriptors.FileDescriptor[] shoppingCartEntityFileDescriptors() {
105105
return new Descriptors.FileDescriptor[]{com.example.shoppingcart.persistence.Domain.getDescriptor()};
106106
}
107107
}
108-
//#shopping-cart-configuration
108+
// end::shopping-cart-configuration[]
109109

110-
//#shopping-cart-main
110+
// tag::shopping-cart-main[]
111111
import org.springframework.boot.SpringApplication;
112112
import org.springframework.boot.autoconfigure.SpringBootApplication;
113113
import io.cloudstate.springboot.starter.autoconfigure.EnableCloudstate;
@@ -117,9 +117,9 @@ public Descriptors.FileDescriptor[] shoppingCartEntityFileDescriptors() {
117117
public class Main {
118118
public static void main(String[] args) { SpringApplication.run(Main.class, args); }
119119
}
120-
//#shopping-cart-main
120+
// end::shopping-cart-main[]
121121

122-
//#shopping-cart-descriptors
122+
// tag::shopping-cart-descriptors[]
123123
@Bean(name = "shoppingCartEntityServiceDescriptor")
124124
public Descriptors.ServiceDescriptor serviceDescriptor() {
125125
return Shoppingcart.getDescriptor().findServiceByName("ShoppingCart");
@@ -129,9 +129,9 @@ public Descriptors.ServiceDescriptor serviceDescriptor() {
129129
public Descriptors.FileDescriptor[] fileDescriptors() {
130130
return new Descriptors.FileDescriptor[] {com.example.shoppingcart.persistence.Domain.getDescriptor()};
131131
}
132-
//#shopping-cart-descriptors
132+
// end::shopping-cart-descriptors[]
133133

134-
//#shopping-cart-descriptors-alternative
134+
// tag::shopping-cart-descriptors-alternative[]
135135
@Bean
136136
public Descriptors.ServiceDescriptor shoppingCartEntityServiceDescriptor() {
137137
return Shoppingcart.getDescriptor().findServiceByName("ShoppingCart");
@@ -141,9 +141,9 @@ public Descriptors.ServiceDescriptor shoppingCartEntityServiceDescriptor() {
141141
public Descriptors.FileDescriptor[] shoppingCartEntityFileDescriptors() {
142142
return new Descriptors.FileDescriptor[] {com.example.shoppingcart.persistence.Domain.getDescriptor()};
143143
}
144-
//#shopping-cart-descriptors-alternative
144+
// end::shopping-cart-descriptors-alternative[]
145145

146-
//#shopping-cart-descriptors-static
146+
// tag::shopping-cart-descriptors-static[]
147147
@EntityServiceDescriptor
148148
public static Descriptors.ServiceDescriptor getDescriptor() {
149149
return Shoppingcart.getDescriptor().findServiceByName("ShoppingCart");
@@ -153,4 +153,4 @@ public static Descriptors.ServiceDescriptor getDescriptor() {
153153
public static Descriptors.FileDescriptor[] getAdditionalDescriptors() {
154154
return new Descriptors.FileDescriptor[]{com.example.shoppingcart.persistence.Domain.getDescriptor()};
155155
}
156-
//#shopping-cart-descriptors-static
156+
// end::shopping-cart-descriptors-static[]

docs/src/modules/springboot/nav.adoc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
* xref:index.adoc[Implementing in Spring Boot]
2+
** xref:gettingstarted.adoc[Getting started]
3+
** xref:configuration.adoc[Configuration]
4+
** xref:cdi.adoc[Context Injection]
5+
** xref:conventions.adoc[Conventions and Restrictions]
6+
** xref:examples.adoc[Examples]
Lines changed: 26 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,46 @@
1-
# Context Injection
1+
= Context Injection
22

3-
As we saw in the Getting Started example, it is perfectly possible to inject any Bean available in Spring into a
4-
Cloudstate entity class.
5-
It is also possible to use the annotations present in the javax.inject package
6-
([JSR330](https://jcp.org/en/jsr/detail?id=330)).
3+
As we saw in the Getting Started example, it is perfectly possible to inject any Bean available in Spring into a Cloudstate entity class.
4+
It is also possible to use the annotations present in the javax.inject package (https://jcp.org/en/jsr/detail?id=330[JSR330]).
75
The Cloudstate Springboot Support library already includes the necessary dependencies so you don't have to worry about it.
86

9-
You can annotate your entity classes with Spring `@Component` or `@Service` annotations but we have created a convenient
10-
annotation that we call `@CloudstateEntityBean` that can be used for that too.
7+
You can annotate your entity classes with Spring `@Component` or `@Service` annotations but we have created a convenient annotation that we call `@CloudstateEntityBean` that can be used for that too.
118

12-
## JSR330
9+
== JSR330
1310

14-
The Cloudstate Spring Boot Support library supports JSR330 within the scope of the support provided by Spring itself to
15-
this specification.
16-
Note that the Cloudstate Java Support library on which we depend allows you to bind Cloudstate and any other DI container
17-
you want. However, no specific module for any of these other containers has yet been made.
11+
The Cloudstate Spring Boot Support library supports JSR330 within the scope of the support provided by Spring itself to this specification.
12+
Note that the Cloudstate Java Support library on which we depend allows you to bind Cloudstate and any other DI container you want.
13+
However, no specific module for any of these other containers has yet been made.
1814

1915
Feel free to contribute or suggest support for more runtimes.
2016

21-
## Injecting EntityId and Cloudstate Context Objects
17+
== Injecting EntityId and Cloudstate Context Objects
2218

2319
You can use the `@EntityId` annotation to access the managed entity's id.
24-
It is also possible to have access to the EventSourcedEntityCreationContext created during the activation of the object
25-
by Cloudstate. However for this you will need to annotate the Context property with the annotation @CloudstateContext
26-
as in the example below:
20+
It is also possible to have access to the EventSourcedEntityCreationContext created during the activation of the object by Cloudstate.
21+
However for this you will need to annotate the Context property with the annotation @CloudstateContext as in the example below:
2722

28-
```java
23+
[source,java]
24+
----
2925
@EntityId
3026
private String entityId;
3127
3228
@CloudstateContext
3329
private EventSourcedContext context;
34-
```
30+
----
3531

36-
### Using properties instead constructors
32+
=== Using properties instead constructors
3733

38-
It is currently not possible to inject Cloudstate's EntityId and Context properties via constructor.
34+
It is currently not possible to inject Cloudstate's EntityId and Context properties via constructor.
3935
This is because the life cycles of these properties differ from the life cycle of objects managed directly by Spring.
4036

4137
This is obviously only an issue if you want to inject EntityId or EventSourcedEntityCreationContext.
4238
Otherwise, if you want to inject only other Spring Context Beans, you can use injection via builders as normal.
4339

4440
The builders below would be perfectly acceptable:
4541

46-
```java
42+
[source,java]
43+
----
4744
@EventSourcedEntity
4845
@CloudstateEntityBean
4946
public final class ShoppingCartEntity {
@@ -58,19 +55,19 @@ public final class ShoppingCartEntity {
5855
private final RuleService ruleService;
5956
6057
private final ShoppingCartTypeConverter typeConverter;
61-
58+
6259
@Autowired
6360
public ShoppingCartEntity(RuleService ruleService, ShoppingCartTypeConverter typeConverter){
6461
this.ruleService = ruleService;
6562
this.typeConverter = typeConverter;
6663
}
67-
64+
6865
//......
6966
}
70-
```
71-
@@@ note { title=Important }
72-
73-
As you can see, the constructor injection constraint applies only to EntityId and CreationContext.
74-
So, as in the example above, you can mix the approaches and get the best of both worlds together
67+
----
7568

76-
@@@
69+
[IMPORTANT]
70+
====
71+
As you can see, the constructor injection constraint applies only to EntityId and CreationContext.
72+
So, as in the example above, you can mix the approaches and get the best of both worlds together
73+
====

0 commit comments

Comments
 (0)