camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject [4/4] camel git commit: Component docs - Adjust tables as the previous attempt did not look so good.
Date Fri, 17 Mar 2017 12:17:04 GMT
Component docs - Adjust tables as the previous attempt did not look so good.


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

Branch: refs/heads/master
Commit: 1f50c7291f73a0738b8f5e13481cd550ed639f57
Parents: 0b074a7
Author: Claus Ibsen <davsclaus@apache.org>
Authored: Fri Mar 17 12:10:22 2017 +0100
Committer: Claus Ibsen <davsclaus@apache.org>
Committed: Fri Mar 17 13:16:54 2017 +0100

----------------------------------------------------------------------
 .../tools/apt/EndpointAnnotationProcessor.java  |  3 +-
 .../maven/camel-package-maven-plugin/pom.xml    |  7 ++
 .../camel/maven/packaging/StringHelper.java     | 74 ++++++++++++++++++++
 .../packaging/model/ComponentOptionModel.java   | 28 ++++++++
 .../packaging/model/EndpointOptionModel.java    | 26 +++++++
 .../src/main/resources/component-options.mvel   |  3 +-
 .../src/main/resources/endpoint-options.mvel    |  5 +-
 7 files changed, 140 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/1f50c729/tooling/apt/src/main/java/org/apache/camel/tools/apt/EndpointAnnotationProcessor.java
----------------------------------------------------------------------
diff --git a/tooling/apt/src/main/java/org/apache/camel/tools/apt/EndpointAnnotationProcessor.java
b/tooling/apt/src/main/java/org/apache/camel/tools/apt/EndpointAnnotationProcessor.java
index 561dce8..3c7a381 100644
--- a/tooling/apt/src/main/java/org/apache/camel/tools/apt/EndpointAnnotationProcessor.java
+++ b/tooling/apt/src/main/java/org/apache/camel/tools/apt/EndpointAnnotationProcessor.java
@@ -452,7 +452,8 @@ public class EndpointAnnotationProcessor extends AbstractProcessor {
                 }
 
                 // skip unwanted methods as they are inherited from default component and
are not intended for end users to configure
-                if ("setEndpointClass".equals(methodName) || "setCamelContext".equals(methodName)
|| "setEndpointHeaderFilterStrategy".equals(methodName)) {
+                if ("setEndpointClass".equals(methodName) || "setCamelContext".equals(methodName)
+                    || "setEndpointHeaderFilterStrategy".equals(methodName) || "setApplicationContext".equals(methodName))
{
                     continue;
                 }
 

http://git-wip-us.apache.org/repos/asf/camel/blob/1f50c729/tooling/maven/camel-package-maven-plugin/pom.xml
----------------------------------------------------------------------
diff --git a/tooling/maven/camel-package-maven-plugin/pom.xml b/tooling/maven/camel-package-maven-plugin/pom.xml
index c702518..24bbc02 100644
--- a/tooling/maven/camel-package-maven-plugin/pom.xml
+++ b/tooling/maven/camel-package-maven-plugin/pom.xml
@@ -105,6 +105,13 @@
       <version>${asciidoctorj-version}</version>
     </dependency>
 
+    <!-- guava for some word wrap helper -->
+    <dependency>
+      <groupId>com.google.guava</groupId>
+      <artifactId>guava</artifactId>
+      <version>${google-guava-version}</version>
+    </dependency>
+
     <!-- roaster to create java source for Spring Boot auto configuration support -->
     <dependency>
       <groupId>org.jboss.forge.roaster</groupId>

http://git-wip-us.apache.org/repos/asf/camel/blob/1f50c729/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/StringHelper.java
----------------------------------------------------------------------
diff --git a/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/StringHelper.java
b/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/StringHelper.java
index d7829ae..2f0dfcd 100644
--- a/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/StringHelper.java
+++ b/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/StringHelper.java
@@ -18,6 +18,8 @@ package org.apache.camel.maven.packaging;
 
 import java.util.Collection;
 
+import com.google.common.base.CaseFormat;
+
 public final class StringHelper {
 
     private StringHelper() {
@@ -97,4 +99,76 @@ public final class StringHelper {
         return answer;
     }
 
+    /**
+     * To wrap long camel cased texts by words.
+     *
+     * @param option  the option which is camel cased.
+     * @param watermark a watermark to denote the size to cut after
+     * @param newLine the new line to use when breaking into a new line
+     */
+    public static String wrapCamelCaseWords(String option, int watermark, String newLine)
{
+        String text = CaseFormat.UPPER_CAMEL.to(CaseFormat.LOWER_HYPHEN, option);
+        text = text.replace('-', ' ');
+        text = wrapWords(text, "\n", watermark, false);
+        text = text.replace(' ', '-');
+        text = CaseFormat.LOWER_HYPHEN.to(CaseFormat.UPPER_CAMEL, text);
+        text = text.replaceAll("\\n", newLine);
+        return text;
+    }
+
+    /**
+     * To wrap a big line by words.
+     *
+     * @param line the big line
+     * @param newLine the new line to use when breaking into a new line
+     * @param watermark a watermark to denote the size to cut after
+     * @param wrapLongWords whether to wrap long words
+     */
+    private static String wrapWords(String line, String newLine, int watermark, boolean wrapLongWords)
{
+        if (line == null) {
+            return null;
+        } else {
+            if (newLine == null) {
+                newLine = System.lineSeparator();
+            }
+
+            if (watermark < 1) {
+                watermark = 1;
+            }
+
+            int inputLineLength = line.length();
+            int offset = 0;
+            StringBuilder sb = new StringBuilder(inputLineLength + 32);
+
+            while (inputLineLength - offset > watermark) {
+                if (line.charAt(offset) == 32) {
+                    ++offset;
+                } else {
+                    int spaceToWrapAt = line.lastIndexOf(32, watermark + offset);
+                    if (spaceToWrapAt >= offset) {
+                        sb.append(line.substring(offset, spaceToWrapAt));
+                        sb.append(newLine);
+                        offset = spaceToWrapAt + 1;
+                    } else if (wrapLongWords) {
+                        sb.append(line.substring(offset, watermark + offset));
+                        sb.append(newLine);
+                        offset += watermark;
+                    } else {
+                        spaceToWrapAt = line.indexOf(32, watermark + offset);
+                        if (spaceToWrapAt >= 0) {
+                            sb.append(line.substring(offset, spaceToWrapAt));
+                            sb.append(newLine);
+                            offset = spaceToWrapAt + 1;
+                        } else {
+                            sb.append(line.substring(offset));
+                            offset = inputLineLength;
+                        }
+                    }
+                }
+            }
+
+            sb.append(line.substring(offset));
+            return sb.toString();
+        }
+    }
 }

http://git-wip-us.apache.org/repos/asf/camel/blob/1f50c729/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/model/ComponentOptionModel.java
----------------------------------------------------------------------
diff --git a/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/model/ComponentOptionModel.java
b/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/model/ComponentOptionModel.java
index 5b79f61..ce9d9b9 100644
--- a/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/model/ComponentOptionModel.java
+++ b/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/model/ComponentOptionModel.java
@@ -16,6 +16,10 @@
  */
 package org.apache.camel.maven.packaging.model;
 
+import org.apache.camel.maven.packaging.StringHelper;
+
+import static org.apache.camel.maven.packaging.StringHelper.wrapCamelCaseWords;
+
 public class ComponentOptionModel {
 
     private String name;
@@ -154,4 +158,28 @@ public class ComponentOptionModel {
         }
     }
 
+    public String getShortGroup() {
+        if (group.endsWith(" (advanced)")) {
+            return group.substring(0, group.length() - 11);
+        }
+        return group;
+    }
+
+    public String getShortDefaultValue(int watermark) {
+        String text = defaultValue;
+        if (text.endsWith("<T>")) {
+            text = text.substring(0, text.length() - 3);
+        } else if (text.endsWith("<T>>")) {
+            text = text.substring(0, text.length() - 4);
+        }
+
+        return wrapCamelCaseWords(text, watermark, " ");
+    }
+
+    public String getShortName(int watermark) {
+        String text = wrapCamelCaseWords(name, watermark, " ");
+        // ensure the option name starts with lower-case
+        return Character.toLowerCase(text.charAt(0)) + text.substring(1);
+    }
+
 }

http://git-wip-us.apache.org/repos/asf/camel/blob/1f50c729/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/model/EndpointOptionModel.java
----------------------------------------------------------------------
diff --git a/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/model/EndpointOptionModel.java
b/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/model/EndpointOptionModel.java
index d71596d..ce76cf1 100644
--- a/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/model/EndpointOptionModel.java
+++ b/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/model/EndpointOptionModel.java
@@ -16,6 +16,8 @@
  */
 package org.apache.camel.maven.packaging.model;
 
+import static org.apache.camel.maven.packaging.StringHelper.wrapCamelCaseWords;
+
 public class EndpointOptionModel {
 
     private String name;
@@ -181,4 +183,28 @@ public class EndpointOptionModel {
         }
     }
 
+    public String getShortGroup() {
+        if (group.endsWith(" (advanced)")) {
+            return group.substring(0, group.length() - 11);
+        }
+        return group;
+    }
+
+    public String getShortDefaultValue(int watermark) {
+        String text = defaultValue;
+        if (text.endsWith("<T>")) {
+            text = text.substring(0, text.length() - 3);
+        } else if (text.endsWith("<T>>")) {
+            text = text.substring(0, text.length() - 4);
+        }
+
+        return wrapCamelCaseWords(text, watermark, " ");
+    }
+
+    public String getShortName(int watermark) {
+        String text = wrapCamelCaseWords(name, watermark, " ");
+        // ensure the option name starts with lower-case
+        return Character.toLowerCase(text.charAt(0)) + text.substring(1);
+    }
+
 }

http://git-wip-us.apache.org/repos/asf/camel/blob/1f50c729/tooling/maven/camel-package-maven-plugin/src/main/resources/component-options.mvel
----------------------------------------------------------------------
diff --git a/tooling/maven/camel-package-maven-plugin/src/main/resources/component-options.mvel
b/tooling/maven/camel-package-maven-plugin/src/main/resources/component-options.mvel
index 70012fc..1e85c88 100644
--- a/tooling/maven/camel-package-maven-plugin/src/main/resources/component-options.mvel
+++ b/tooling/maven/camel-package-maven-plugin/src/main/resources/component-options.mvel
@@ -8,7 +8,6 @@ The @{title} component supports @{componentOptions.size()} options which are
lis
 [width="100%",cols="2,1m,1m,6",options="header"]
 |=======================================================================
 | Name | Default | Java Type | Description
-@foreach{row : componentOptions}@if{row.newGroup} 4+^s| @{row.group}@end{}
-| @{row.name} | @{row.defaultValue} | @{row.shortJavaType} | @{row.description}
+@foreach{row : componentOptions}| **@{row.getShortName(40)}** (@{row.shortGroup}) | @{row.getShortDefaultValue(40)}
| @{row.shortJavaType} | @{row.description}
 @end{}|=======================================================================
 @end{}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/camel/blob/1f50c729/tooling/maven/camel-package-maven-plugin/src/main/resources/endpoint-options.mvel
----------------------------------------------------------------------
diff --git a/tooling/maven/camel-package-maven-plugin/src/main/resources/endpoint-options.mvel
b/tooling/maven/camel-package-maven-plugin/src/main/resources/endpoint-options.mvel
index 69d3d37..a2d5b40 100644
--- a/tooling/maven/camel-package-maven-plugin/src/main/resources/endpoint-options.mvel
+++ b/tooling/maven/camel-package-maven-plugin/src/main/resources/endpoint-options.mvel
@@ -9,7 +9,7 @@ with the following path and query parameters:
 [width="100%",cols="2,1,1m,6",options="header"]
 |=======================================================================
 | Name | Default | Java Type | Description
-@foreach{row : endpointPathOptions}| @{row.name} | @{row.defaultValue} | @{row.shortJavaType}
| @{row.description}
+@foreach{row : endpointPathOptions}| **@{row.getShortName(40)}** | @{row.getShortDefaultValue(50)}
| @{row.shortJavaType} | @{row.description}
 @end{}|=======================================================================
 
 #### Query Parameters (@{endpointOptions.size()} parameters):
@@ -17,6 +17,5 @@ with the following path and query parameters:
 [width="100%",cols="2,1m,1m,6",options="header"]
 |=======================================================================
 | Name | Default | Java Type | Description
-@foreach{row : endpointOptions}@if{row.newGroup} 4+^s| @{row.group}@end{}
-| @{row.name} | @{row.defaultValue} | @{row.shortJavaType} | @{row.description}
+@foreach{row : endpointOptions}| **@{row.getShortName(40)}** (@{row.shortGroup}) | @{row.getShortDefaultValue(40)}
| @{row.shortJavaType} | @{row.description}
 @end{}|=======================================================================


Mime
View raw message