GROOVY-7775: JavadocAssertionTestBuilder should handle escapes needed for HTML 
within javadoc, e.g. @ for @ and {@code ...}


Project: http://git-wip-us.apache.org/repos/asf/groovy/repo
Commit: http://git-wip-us.apache.org/repos/asf/groovy/commit/bf1a2386
Tree: http://git-wip-us.apache.org/repos/asf/groovy/tree/bf1a2386
Diff: http://git-wip-us.apache.org/repos/asf/groovy/diff/bf1a2386

Branch: refs/heads/GROOVY_2_4_X
Commit: bf1a2386c587c2ade7f56fe325b928bd767f56ad
Parents: f4c49d1
Author: paulk <pa...@asert.com.au>
Authored: Thu Mar 3 22:23:32 2016 +1000
Committer: paulk <pa...@asert.com.au>
Committed: Thu Mar 3 22:24:23 2016 +1000

----------------------------------------------------------------------
 src/main/groovy/transform/AnnotationCollector.java    | 14 ++++++++------
 .../groovy/util/JavadocAssertionTestBuilder.groovy    |  7 ++++---
 2 files changed, 12 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/groovy/blob/bf1a2386/src/main/groovy/transform/AnnotationCollector.java
----------------------------------------------------------------------
diff --git a/src/main/groovy/transform/AnnotationCollector.java 
b/src/main/groovy/transform/AnnotationCollector.java
index 89b3014..f6be712 100644
--- a/src/main/groovy/transform/AnnotationCollector.java
+++ b/src/main/groovy/transform/AnnotationCollector.java
@@ -34,7 +34,7 @@ import java.lang.annotation.Target;
  * arguments and error will be given. Is this not wished or if you want a 
  * different mapping a custom processor has to be used. There are two ways of 
  * using the alias. The first way is by providing the annotations as 
list/array:
- * <pre>
+ * <pre class="groovyTestCase">
  *          import groovy.transform.*
  *          &#64;AnnotationCollector([ToString, EqualsAndHashCode, Immutable])
  *          &#64;interface Alias {}
@@ -50,7 +50,7 @@ import java.lang.annotation.Target;
  * excludes which will be mapped to ToString and EqualsAndHashCode. Immutable 
  * doesn't have excludes, thus nothing will be done there.<br>
  * The other way is to add annotations to the alias:
- * <pre>
+ * <pre class="groovyTestCase">
  * import groovy.transform.*
  * &#64;ToString(excludes=["a"])
  * &#64;EqualsAndHashCode
@@ -74,8 +74,9 @@ import java.lang.annotation.Target;
  * If both ways are combined, then the list overwrites annotation usage.
  * NOTE: The aliasing does not support aliasing of aliased annotations. 
  * <p>More examples:</p>
- * <pre>
+ * <pre class="groovyTestCase">
  * //--------------------------------------------------------------------------
+ * import groovy.transform.*
  * &#64;AnnotationCollector([EqualsAndHashCode, ToString])
  * &#64;interface Simple {}
  *
@@ -95,7 +96,7 @@ import java.lang.annotation.Target;
  *
  * // We can use the attributes from the 
  * // grouped annotations.
- * &#64;Simple(excludes = 'street') 
+ * &#64;Simple(excludes = 'street')
  * class Address {
  *     String street, town
  * }
@@ -103,7 +104,7 @@ import java.lang.annotation.Target;
  * def address = new Address(street: 'Evergreen Terrace', town: 'Springfield') 
  * assert address.toString() == 'Address(Springfield)'
  * </pre>
- * <pre>
+ * <pre class="groovyTestCase">
  * //--------------------------------------------------------------------------
  * // Use a custom processor to handle attributes.
  * import org.codehaus.groovy.transform.*
@@ -149,10 +150,11 @@ import java.lang.annotation.Target;
  * assert user.toString() == 'User(mrhaki)'
  * '''
  * </pre>
- * <pre>
+ * <pre class="groovyTestCase">
  * //--------------------------------------------------------------------------
  * // Use AnnotationCollector as last annotation to group the
  * // previous annotations.
+ * import groovy.transform.*
  * &#64;EqualsAndHashCode
  * &#64;ToString
  * &#64;AnnotationCollector

http://git-wip-us.apache.org/repos/asf/groovy/blob/bf1a2386/subprojects/groovy-test/src/main/groovy/groovy/util/JavadocAssertionTestBuilder.groovy
----------------------------------------------------------------------
diff --git 
a/subprojects/groovy-test/src/main/groovy/groovy/util/JavadocAssertionTestBuilder.groovy
 
b/subprojects/groovy-test/src/main/groovy/groovy/util/JavadocAssertionTestBuilder.groovy
index c77f1cf..176afcc 100644
--- 
a/subprojects/groovy-test/src/main/groovy/groovy/util/JavadocAssertionTestBuilder.groovy
+++ 
b/subprojects/groovy-test/src/main/groovy/groovy/util/JavadocAssertionTestBuilder.groovy
@@ -28,8 +28,8 @@ import java.util.regex.Pattern
  *
  * @author Merlyn Albery-Speyer
  */
-
 class JavadocAssertionTestBuilder {
+    // TODO write tests for this classes functionality
     private static final Pattern javadocPattern =
         Pattern.compile( /(?ims)\/\*\*.*?\*\// )
     private static final Pattern assertionPattern =
@@ -92,10 +92,11 @@ class JavadocAssertionTestBuilder {
         String htmlAssertion = tagInner.replaceAll("(?m)^\\s*\\*", "")
         String assertion = htmlAssertion
         // TODO improve on this
-        [nbsp:' ', gt:'>', lt:'<', quot:'"', apos:"'", at:'@', ndash:'-', 
amp:'&'].each { key, value ->
+        [nbsp:' ', gt:'>', lt:'<', quot:'"', apos:"'", at:'@', '#64':'@', 
ndash:'-', amp:'&'].each { key, value ->
             assertion = assertion.replaceAll("(?i)&$key;", value)
         }
-        
+        assertion = assertion.replaceAll(/(?i)\{@code ([^}]*)\}/, '$1')
+
         return assertion
     }
     

Reply via email to