Previously, a | character in a cell of an Asciidoctor table would break that table's formatting as it would be interpretted as a delimiter for the cell. The problem also affects Markdown tables where the | character is not within backticks. This commit addresses the problem with Asciidoctor tables by introducing a JMustache Lambda that escapes | characters by prefixing them with a backslash. Unfortunately, a complete solution to the problem when using Markdown is not as straightforward. Markdown only requires a | character to be espaced when it is not within backticks. Determing this isn't straightforward as the text would have to be parsed, taking into account the possibility of backticks themselves being escaped. Instead, this commit attempts to avoid the problem in a different way. The most likely source of a | character is when documenting a `@Pattern` constraint that uses a | character in its regular expression. To improve the readability of the regular expression this commit wraps it in backticks, thereby formatting it in a monospaced font in both Asciidoctor and Markdown and also avoiding any escaping problems with the latter. Closes gh-232 See gh-230
63 lines
1.8 KiB
Groovy
63 lines
1.8 KiB
Groovy
description = 'Spring REST Docs Core'
|
|
|
|
configurations {
|
|
jarjar
|
|
jmustache
|
|
testArtifacts.extendsFrom testRuntime
|
|
}
|
|
|
|
task jmustacheRepackJar(type: Jar) { repackJar ->
|
|
repackJar.baseName = "restdocs-jmustache-repack"
|
|
repackJar.version = dependencyManagement.managedVersions['com.samskivert:jmustache']
|
|
|
|
doLast() {
|
|
project.ant {
|
|
taskdef name: "jarjar", classname: "com.tonicsystems.jarjar.JarJarTask",
|
|
classpath: configurations.jarjar.asPath
|
|
jarjar(destfile: repackJar.archivePath) {
|
|
configurations.jmustache.each { originalJar ->
|
|
zipfileset(src: originalJar, includes: '**/*.class')
|
|
}
|
|
rule(pattern: 'com.samskivert.**', result: 'org.springframework.restdocs.@1')
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
dependencies {
|
|
compile 'com.fasterxml.jackson.core:jackson-databind'
|
|
compile 'org.springframework:spring-webmvc'
|
|
compile 'javax.servlet:javax.servlet-api'
|
|
compile files(jmustacheRepackJar)
|
|
jarjar 'com.googlecode.jarjar:jarjar:1.3'
|
|
jmustache 'com.samskivert:jmustache@jar'
|
|
optional 'commons-codec:commons-codec'
|
|
optional 'javax.validation:validation-api'
|
|
optional 'junit:junit'
|
|
testCompile 'org.mockito:mockito-core'
|
|
testCompile 'org.hamcrest:hamcrest-core'
|
|
testCompile 'org.hamcrest:hamcrest-library'
|
|
testCompile 'org.hibernate:hibernate-validator'
|
|
testCompile 'org.springframework:spring-test'
|
|
testRuntime 'org.glassfish:javax.el:3.0.0'
|
|
}
|
|
|
|
jar {
|
|
dependsOn jmustacheRepackJar
|
|
from(zipTree(jmustacheRepackJar.archivePath)) {
|
|
include "org/springframework/restdocs/**"
|
|
}
|
|
}
|
|
|
|
task testJar(type: Jar) {
|
|
classifier "test"
|
|
from sourceSets.test.output
|
|
}
|
|
|
|
artifacts {
|
|
testArtifacts testJar
|
|
}
|
|
|
|
test {
|
|
jvmArgs "-javaagent:${configurations.jacoco.asPath}=destfile=${buildDir}/jacoco.exec,includes=org.springframework.restdocs.*,excludes=org.springframework.restdocs.mustache.*"
|
|
} |