Skip to content

Commit 466b57c

Browse files
hselliksnicoll
authored andcommitted
Add Spring-specific styling to Gradle Plugin's documentation
This commit replaces the default Asciidoctor styling with Spring specific styling. First, we need to unzip the contents of the Spring Asciidoctor documentation resources provided by the `io.spring.docsresources:spring-docs-resources` distribution zip. This is done in a `/target/refdocs` folder. We then copy all files from `src/main/asciidoc` to the same location, and then launch the generation process. See gh-16327
1 parent 8c8a088 commit 466b57c

File tree

3 files changed

+79
-14
lines changed

3 files changed

+79
-14
lines changed

spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/pom.xml

Lines changed: 57 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
<gradle.executable>./gradlew</gradle.executable>
1717
<gradle.task>build</gradle.task>
1818
<skip.gradle.build>false</skip.gradle.build>
19+
<refdocs.build.directory>${project.build.directory}/refdocs/</refdocs.build.directory>
1920
</properties>
2021
<dependencies>
2122
<dependency>
@@ -39,6 +40,24 @@
3940
</dependencies>
4041
<build>
4142
<plugins>
43+
<plugin>
44+
<groupId>com.googlecode.maven-download-plugin</groupId>
45+
<artifactId>download-maven-plugin</artifactId>
46+
<executions>
47+
<execution>
48+
<id>unpack-doc-resources</id>
49+
<phase>generate-resources</phase>
50+
<goals>
51+
<goal>wget</goal>
52+
</goals>
53+
<configuration>
54+
<url>https://repo.spring.io/release/io/spring/docresources/spring-doc-resources/${spring-doc-resources.version}/spring-doc-resources-${spring-doc-resources.version}.zip</url>
55+
<unpack>true</unpack>
56+
<outputDirectory>${refdocs.build.directory}</outputDirectory>
57+
</configuration>
58+
</execution>
59+
</executions>
60+
</plugin>
4261
<plugin>
4362
<groupId>org.apache.maven.plugins</groupId>
4463
<artifactId>maven-dependency-plugin</artifactId>
@@ -69,6 +88,28 @@
6988
</execution>
7089
</executions>
7190
</plugin>
91+
<plugin>
92+
<groupId>org.apache.maven.plugins</groupId>
93+
<artifactId>maven-resources-plugin</artifactId>
94+
<executions>
95+
<execution>
96+
<id>copy-asciidoc-resources</id>
97+
<phase>generate-resources</phase>
98+
<goals>
99+
<goal>copy-resources</goal>
100+
</goals>
101+
<configuration>
102+
<outputDirectory>${refdocs.build.directory}</outputDirectory>
103+
<resources>
104+
<resource>
105+
<directory>src/main/asciidoc</directory>
106+
<filtering>false</filtering>
107+
</resource>
108+
</resources>
109+
</configuration>
110+
</execution>
111+
</executions>
112+
</plugin>
72113
<plugin>
73114
<groupId>org.codehaus.mojo</groupId>
74115
<artifactId>exec-maven-plugin</artifactId>
@@ -233,17 +274,7 @@
233274
<target>
234275
<zip
235276
destfile="${project.build.directory}/${project.artifactId}-${project.version}-docs.zip">
236-
<zipfileset
237-
src="build/libs/${project.artifactId}-${project.version}-javadoc.jar"
238-
prefix="api" />
239-
<zipfileset dir="${project.build.directory}/generated-docs"
240-
includes="index.html" prefix="reference/html" />
241-
<mappedresources>
242-
<fileset dir="${project.build.directory}/generated-docs"
243-
includes="index.pdf" />
244-
<globmapper from="index.pdf"
245-
to="reference/pdf/spring-boot-gradle-plugin-reference.pdf" />
246-
</mappedresources>
277+
<fileset dir="${project.build.directory}/generated-docs" />
247278
</zip>
248279
</target>
249280
</configuration>
@@ -261,7 +292,19 @@
261292
<goal>process-asciidoc</goal>
262293
</goals>
263294
<configuration>
264-
<backend>html</backend>
295+
<backend>html5</backend>
296+
<outputDirectory>${project.build.directory}/generated-docs/reference/html</outputDirectory>
297+
<sourceHighlighter>highlight.js</sourceHighlighter>
298+
<doctype>book</doctype>
299+
<attributes>
300+
<highlightjsdir>js/highlight</highlightjsdir>
301+
<highlightjs-theme>atom-one-dark-reasonable</highlightjs-theme>
302+
<linkcss>true</linkcss>
303+
<imagesdir>./images</imagesdir>
304+
<icons>font</icons>
305+
<stylesdir>css/</stylesdir>
306+
<stylesheet>style.css</stylesheet>
307+
</attributes>
265308
</configuration>
266309
</execution>
267310
<execution>
@@ -272,11 +315,12 @@
272315
</goals>
273316
<configuration>
274317
<backend>pdf</backend>
318+
<outputDirectory>${project.build.directory}/generated-docs/reference/pdf</outputDirectory>
275319
</configuration>
276320
</execution>
277321
</executions>
278322
<configuration>
279-
<sourceDocumentName>index.adoc</sourceDocumentName>
323+
<sourceDirectory>${refdocs.build.directory}</sourceDirectory>
280324
<attributes>
281325
<github-tag>${github-tag}</github-tag>
282326
<version-type>${version-type}</version-type>
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
@import url("spring.css");
2+
3+
div .switch {
4+
margin-left: 8px;
5+
border-color: #406A2A;
6+
border-radius: 4px 4px 0 0;
7+
}
8+
9+
div .switch--item {
10+
color: #406A2A;
11+
background-color: transparent;
12+
}
13+
14+
div .switch--item.selected {
15+
background-color: #406A2A;
16+
}
17+
18+
div .switch--item:not(:first-child) {
19+
border-color: #406A2A;
20+
}

spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/main/asciidoc/index.adoc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ Andy Wilkinson
77
:numbered:
88
:icons: font
99
:hide-uri-scheme:
10+
:docinfo: shared,private
11+
1012
:dependency-management-plugin: https://github.com/spring-gradle-plugins/dependency-management-plugin
1113
:dependency-management-plugin-documentation: {dependency-management-plugin}/blob/master/README.md
1214
:gradle-userguide: https://docs.gradle.org/current/userguide
@@ -30,7 +32,6 @@ Andy Wilkinson
3032
:github-code: https://github.com/spring-projects/spring-boot/tree/{github-tag}
3133

3234

33-
3435
[[introduction]]
3536
== Introduction
3637

0 commit comments

Comments
 (0)