You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2020/09/17 13:01:06 UTC
[camel] 01/04: CAMEL-15478: Docs include alias methods
This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch api
in repository https://gitbox.apache.org/repos/asf/camel.git
commit 19e3eaeafb7c10a3a8b15dc495ad3135be2894ec
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Thu Sep 17 12:59:15 2020 +0200
CAMEL-15478: Docs include alias methods
---
.../org/apache/camel/maven/packaging/MvelHelper.java | 18 ++++++++++++++++++
.../src/main/resources/endpoint-options.mvel | 10 ++++++----
2 files changed, 24 insertions(+), 4 deletions(-)
diff --git a/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/MvelHelper.java b/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/MvelHelper.java
index 64a5e23..a7a76e1 100644
--- a/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/MvelHelper.java
+++ b/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/MvelHelper.java
@@ -18,6 +18,9 @@ package org.apache.camel.maven.packaging;
import java.util.regex.Pattern;
+import org.apache.camel.tooling.model.ApiMethodModel;
+import org.apache.camel.tooling.model.ApiModel;
+
public final class MvelHelper {
public static final MvelHelper INSTANCE = new MvelHelper();
@@ -48,4 +51,19 @@ public final class MvelHelper {
signature = signature.replace('$', '.');
return signature + ";";
}
+
+ public static String apiMethodNameWithAlias(ApiModel api, ApiMethodModel method) {
+ String name = method.getName();
+ for (String alias : api.getAliases()) {
+ int pos = alias.indexOf('=');
+ String pattern = alias.substring(0, pos);
+ String aliasMethod = alias.substring(pos + 1);
+ // match ignore case
+ if (Pattern.compile(pattern, Pattern.CASE_INSENSITIVE).matcher(name).matches()) {
+ name += " + \n " + aliasMethod;
+ break;
+ }
+ }
+ return name;
+ }
}
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 625e174..444200d 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
@@ -49,7 +49,7 @@ The following lists each API name and method and its additional parameters.
The @{api.name} has no API methods.
@else{}
-The @{api.name} has @{api.methods.size} API method(s) which is represented by the following method signatures
+The @{api.name} API has @{api.methods.size} method(s) which is represented by the following method signatures
(an API method may have multiple signatures due to overloading):
[source,java]
@@ -59,11 +59,13 @@ The @{api.name} has @{api.methods.size} API method(s) which is represented by th
@end{}@end{}
----
+API methods can have a shorthand alias name which can be used in the syntax instead of the name.
+
The API methods has the following set of options listed in the following table:
-[width="100%",cols="1,2,5,2",options="header"]
+[width="100%",cols="2,2,4,2",options="header"]
|===@comment{ Render table cells. If description contains newline, prefix cell with `a`, so the content is rendered with formatting. }
-| Method | Name | Description | Type
-@foreach{method : api.methods}@foreach{row : method.options}| @{method.name} | *@{row.getShortName(30)}* @{row.description.?contains("\n") ? "a" : ""}| @{util.escape(row.description)} | @{row.getShortJavaType()}
+| Method / Alias | Name | Description | Type
+@foreach{method : api.methods}@foreach{row : method.options}| @{util.apiMethodNameWithAlias(api, method)} | *@{row.getShortName(30)}* @{row.description.?contains("\n") ? "a" : ""}| @{util.escape(row.description)} | @{row.getShortJavaType()}
@end{}@end{}|===