Polish contribution and rework to use default attribute rather than macro
Rather than introducing a custom macro, this commit opts to implicitly configure the snippets attribute instead. The attribute is configured will the path into which snippets are generated, relative to the directory that contains the Asciidoctor document that is being rendered. The samples and documentation have been updated to use the new spring-restdocs-asciidoctor module and the implicitly configured snippets attribute. Closes gh-297
This commit is contained in:
@@ -37,6 +37,7 @@ dependencies {
|
||||
compile 'org.springframework.boot:spring-boot-starter-web'
|
||||
testCompile 'org.springframework.boot:spring-boot-starter-test'
|
||||
testCompile "org.springframework.restdocs:spring-restdocs-restassured:${project.ext['spring-restdocs.version']}"
|
||||
asciidoctor "org.springframework.restdocs:spring-restdocs-asciidoctor:${project.ext['spring-restdocs.version']}"
|
||||
}
|
||||
|
||||
test {
|
||||
@@ -44,7 +45,6 @@ test {
|
||||
}
|
||||
|
||||
asciidoctor {
|
||||
attributes 'snippets': snippetsDir
|
||||
inputs.dir snippetsDir
|
||||
dependsOn test
|
||||
}
|
||||
|
||||
5
samples/rest-notes-grails/.gitignore
vendored
5
samples/rest-notes-grails/.gitignore
vendored
@@ -11,7 +11,4 @@ classes/
|
||||
.settings
|
||||
.classpath
|
||||
gradlew*
|
||||
gradle/wrapper
|
||||
|
||||
|
||||
src/docs/generated-snippets
|
||||
gradle/wrapper
|
||||
@@ -44,6 +44,7 @@ repositories {
|
||||
dependencyManagement {
|
||||
dependencies {
|
||||
dependency "org.springframework.restdocs:spring-restdocs-restassured:$restDocsVersion"
|
||||
dependency "org.springframework.restdocs:spring-restdocs-asciidoctor:$restDocsVersion"
|
||||
}
|
||||
imports {
|
||||
mavenBom "org.grails:grails-bom:$grailsVersion"
|
||||
@@ -53,6 +54,8 @@ dependencyManagement {
|
||||
}
|
||||
|
||||
dependencies {
|
||||
asciidoctor "org.springframework.restdocs:spring-restdocs-asciidoctor"
|
||||
|
||||
compile "org.springframework.boot:spring-boot-starter-logging"
|
||||
compile "org.springframework.boot:spring-boot-starter-actuator"
|
||||
compile "org.springframework.boot:spring-boot-autoconfigure"
|
||||
@@ -85,24 +88,16 @@ task wrapper(type: Wrapper) {
|
||||
}
|
||||
|
||||
ext {
|
||||
snippetsDir = file('src/docs/generated-snippets')
|
||||
}
|
||||
|
||||
task cleanTempDirs(type: Delete) {
|
||||
delete fileTree(dir: 'src/docs/generated-snippets')
|
||||
snippetsDir = file('build/generated-snippets')
|
||||
}
|
||||
|
||||
test {
|
||||
dependsOn cleanTempDirs
|
||||
outputs.dir snippetsDir
|
||||
}
|
||||
|
||||
asciidoctor {
|
||||
dependsOn integrationTest
|
||||
inputs.dir snippetsDir
|
||||
sourceDir = file('src/docs')
|
||||
separateOutputDirs = false
|
||||
attributes 'snippets': snippetsDir
|
||||
}
|
||||
|
||||
build.dependsOn asciidoctor
|
||||
|
||||
@@ -45,7 +45,7 @@ import spock.lang.Specification
|
||||
class ApiDocumentationSpec extends Specification {
|
||||
|
||||
@Rule
|
||||
JUnitRestDocumentation restDocumentation = new JUnitRestDocumentation('src/docs/generated-snippets')
|
||||
JUnitRestDocumentation restDocumentation = new JUnitRestDocumentation()
|
||||
|
||||
@Value('${local.server.port}')
|
||||
Integer serverPort
|
||||
|
||||
@@ -84,12 +84,16 @@
|
||||
<configuration>
|
||||
<backend>html</backend>
|
||||
<doctype>book</doctype>
|
||||
<attributes>
|
||||
<snippets>${project.build.directory}/generated-snippets</snippets>
|
||||
</attributes>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework.restdocs</groupId>
|
||||
<artifactId>spring-restdocs-asciidoctor</artifactId>
|
||||
<version>${spring-restdocs.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<artifactId>maven-resources-plugin</artifactId>
|
||||
|
||||
@@ -34,6 +34,8 @@ ext['spring.version']='4.3.1.RELEASE'
|
||||
ext['spring-restdocs.version'] = '1.2.0.BUILD-SNAPSHOT'
|
||||
|
||||
dependencies {
|
||||
asciidoctor "org.springframework.restdocs:spring-restdocs-asciidoctor:${project.ext['spring-restdocs.version']}"
|
||||
|
||||
compile 'org.springframework.boot:spring-boot-starter-data-jpa'
|
||||
compile 'org.springframework.boot:spring-boot-starter-hateoas'
|
||||
|
||||
@@ -50,7 +52,6 @@ test {
|
||||
}
|
||||
|
||||
asciidoctor {
|
||||
attributes 'snippets': snippetsDir
|
||||
inputs.dir snippetsDir
|
||||
dependsOn test
|
||||
}
|
||||
|
||||
@@ -34,7 +34,10 @@ ext['spring.version']='4.3.1.RELEASE'
|
||||
ext['spring-restdocs.version'] = '1.2.0.BUILD-SNAPSHOT'
|
||||
|
||||
dependencies {
|
||||
asciidoctor "org.springframework.restdocs:spring-restdocs-asciidoctor:${project.ext['spring-restdocs.version']}"
|
||||
|
||||
compile 'org.springframework.boot:spring-boot-starter-web'
|
||||
|
||||
testCompile('org.springframework:spring-test') {
|
||||
exclude group: 'junit', module: 'junit;'
|
||||
}
|
||||
@@ -48,7 +51,6 @@ test {
|
||||
}
|
||||
|
||||
asciidoctor {
|
||||
attributes 'snippets': snippetsDir
|
||||
inputs.dir snippetsDir
|
||||
dependsOn test
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user