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 2022/09/21 05:53:14 UTC

[camel] branch main updated (245938dd1d5 -> 3d86bb9aa55)

This is an automated email from the ASF dual-hosted git repository.

davsclaus pushed a change to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git


    from 245938dd1d5 Regen for commit f31bd55d491d3bc943c4d8647ff22301294684e4
     new 7606d2f2817 camel-jbang - doc with url
     new 3d86bb9aa55 camel-jbang - doc with url

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../jbang/core/commands/catalog/CatalogDoc.java    | 142 +++++++++++++++++++--
 1 file changed, 133 insertions(+), 9 deletions(-)


[camel] 01/02: camel-jbang - doc with url

Posted by da...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

davsclaus pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git

commit 7606d2f28175369406146a55846a0ed1ef877c5a
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Wed Sep 21 07:47:39 2022 +0200

    camel-jbang - doc with url
---
 .../jbang/core/commands/catalog/CatalogDoc.java    | 92 +++++++++++++++++++++-
 1 file changed, 91 insertions(+), 1 deletion(-)

diff --git a/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/catalog/CatalogDoc.java b/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/catalog/CatalogDoc.java
index e761bdbcd31..8c62e24f3df 100644
--- a/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/catalog/CatalogDoc.java
+++ b/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/catalog/CatalogDoc.java
@@ -48,6 +48,11 @@ public class CatalogDoc extends CamelCommand {
                             arity = "1")
     String name;
 
+    @CommandLine.Option(names = { "--url" },
+                        description = "Prints the link to the online documentation on the Camel website",
+                        defaultValue = "false")
+    boolean url;
+
     @CommandLine.Option(names = { "--filter" },
                         description = "Filter option listed in tables by name, description, or group")
     String filter;
@@ -61,7 +66,6 @@ public class CatalogDoc extends CamelCommand {
     String kameletsVersion;
 
     // TODO: endpoint uri to document the uri only
-    // TODO: --url to output url to website doc
     // TODO: --open-url to open the url in a browser
 
     final CamelCatalog catalog = new DefaultCamelCatalog(true);
@@ -153,6 +157,14 @@ public class CatalogDoc extends CamelCommand {
     }
 
     private void docKamelet(KameletModel km) {
+        String link = websiteLink("kamelet", name, kameletsVersion);
+        if (url) {
+            if (link != null) {
+                System.out.println(link);
+            }
+            return;
+        }
+
         System.out.printf("Kamelet Name: %s%n", km.name);
         System.out.printf("Kamelet Type: %s%n", km.type);
         System.out.println("Support Level: " + km.supportLevel);
@@ -206,9 +218,21 @@ public class CatalogDoc extends CamelCommand {
             System.out.println("");
         }
 
+        if (link != null) {
+            System.out.println(link);
+            System.out.println("");
+        }
     }
 
     private void docComponent(ComponentModel cm) {
+        String link = websiteLink("component", name, catalog.getCatalogVersion());
+        if (url) {
+            if (link != null) {
+                System.out.println(link);
+            }
+            return;
+        }
+
         if (cm.isDeprecated()) {
             System.out.printf("Component Name: %s (deprecated)%n", cm.getName());
         } else {
@@ -284,9 +308,22 @@ public class CatalogDoc extends CamelCommand {
                             .with(BaseOptionModel::getShortJavaType))));
             System.out.println("");
         }
+
+        if (link != null) {
+            System.out.println(link);
+            System.out.println("");
+        }
     }
 
     private void docDataFormat(DataFormatModel dm) {
+        String link = websiteLink("dataformat", name, catalog.getCatalogVersion());
+        if (url) {
+            if (link != null) {
+                System.out.println(link);
+            }
+            return;
+        }
+
         if (dm.isDeprecated()) {
             System.out.printf("Dataformat Name: %s (deprecated)%n", dm.getName());
         } else {
@@ -322,9 +359,22 @@ public class CatalogDoc extends CamelCommand {
                 new Column().header("TYPE").dataAlign(HorizontalAlign.LEFT).maxWidth(25, OverflowBehaviour.NEWLINE)
                         .with(BaseOptionModel::getShortJavaType))));
         System.out.println("");
+
+        if (link != null) {
+            System.out.println(link);
+            System.out.println("");
+        }
     }
 
     private void docLanguage(LanguageModel lm) {
+        String link = websiteLink("language", name, catalog.getCatalogVersion());
+        if (url) {
+            if (link != null) {
+                System.out.println(link);
+            }
+            return;
+        }
+
         if (lm.isDeprecated()) {
             System.out.printf("Language Name: %s (deprecated)%n", lm.getName());
         } else {
@@ -360,9 +410,22 @@ public class CatalogDoc extends CamelCommand {
                 new Column().header("TYPE").dataAlign(HorizontalAlign.LEFT).maxWidth(25, OverflowBehaviour.NEWLINE)
                         .with(BaseOptionModel::getShortJavaType))));
         System.out.println("");
+
+        if (link != null) {
+            System.out.println(link);
+            System.out.println("");
+        }
     }
 
     private void docOther(OtherModel om) {
+        String link = websiteLink("other", name, catalog.getCatalogVersion());
+        if (url) {
+            if (link != null) {
+                System.out.println(link);
+            }
+            return;
+        }
+
         if (om.isDeprecated()) {
             System.out.printf("Miscellaneous Name: %s (deprecated)%n", om.getName());
         } else {
@@ -378,6 +441,11 @@ public class CatalogDoc extends CamelCommand {
         System.out.println("        <version>" + om.getVersion() + "</version>");
         System.out.println("    </dependency>");
         System.out.println("");
+
+        if (link != null) {
+            System.out.println(link);
+            System.out.println("");
+        }
     }
 
     String getName(BaseOptionModel o) {
@@ -436,4 +504,26 @@ public class CatalogDoc extends CamelCommand {
                 .collect(Collectors.toList());
     }
 
+    String websiteLink(String prefix, String name, String version) {
+        String v = "next";
+        if (version != null && !version.endsWith("-SNAPSHOT")) {
+            // 3.18.2 -> 3.18.x
+            int pos = version.lastIndexOf('.');
+            v = version.substring(0, pos) + ".x";
+        }
+        if ("component".equals(prefix)) {
+            return String.format("https://camel.apache.org/components/%s/%s-component.html", v, name);
+        } else if ("dataformat".equals(prefix)) {
+            return String.format("https://camel.apache.org/components/%s/dataformats/%s-dataformat.html", v, name);
+        } else if ("language".equals(prefix)) {
+            return String.format("https://camel.apache.org/components/%s/languages/%s-language.html", v, name);
+        } else if ("other".equals(prefix)) {
+            return String.format("https://camel.apache.org/components/%s/others/%s.html", v, name);
+        } else if ("kamelet".equals(prefix)) {
+            return String.format("https://camel.apache.org/camel-kamelets/%s/%s.html", v, name);
+        }
+
+        return null;
+    }
+
 }


[camel] 02/02: camel-jbang - doc with url

Posted by da...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

davsclaus pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git

commit 3d86bb9aa550c9eddd836972ddcefd669e4547fb
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Wed Sep 21 07:53:01 2022 +0200

    camel-jbang - doc with url
---
 .../jbang/core/commands/catalog/CatalogDoc.java    | 50 ++++++++++++++++++----
 1 file changed, 42 insertions(+), 8 deletions(-)

diff --git a/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/catalog/CatalogDoc.java b/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/catalog/CatalogDoc.java
index 8c62e24f3df..7e0538e3786 100644
--- a/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/catalog/CatalogDoc.java
+++ b/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/catalog/CatalogDoc.java
@@ -16,6 +16,8 @@
  */
 package org.apache.camel.dsl.jbang.core.commands.catalog;
 
+import java.awt.*;
+import java.net.URI;
 import java.util.Arrays;
 import java.util.Collection;
 import java.util.List;
@@ -53,6 +55,11 @@ public class CatalogDoc extends CamelCommand {
                         defaultValue = "false")
     boolean url;
 
+    @CommandLine.Option(names = { "--open-url" },
+                        description = "Opens the online documentation form the Camel website in the web browser",
+                        defaultValue = "false")
+    boolean openUrl;
+
     @CommandLine.Option(names = { "--filter" },
                         description = "Filter option listed in tables by name, description, or group")
     String filter;
@@ -65,9 +72,6 @@ public class CatalogDoc extends CamelCommand {
             "--kamelets-version" }, description = "Apache Camel Kamelets version", defaultValue = "0.9.0")
     String kameletsVersion;
 
-    // TODO: endpoint uri to document the uri only
-    // TODO: --open-url to open the url in a browser
-
     final CamelCatalog catalog = new DefaultCamelCatalog(true);
 
     public CatalogDoc(CamelJBangMain main) {
@@ -156,8 +160,14 @@ public class CatalogDoc extends CamelCommand {
         return 1;
     }
 
-    private void docKamelet(KameletModel km) {
+    private void docKamelet(KameletModel km) throws Exception {
         String link = websiteLink("kamelet", name, kameletsVersion);
+        if (openUrl) {
+            if (link != null) {
+                Desktop.getDesktop().browse(new URI(link));
+            }
+            return;
+        }
         if (url) {
             if (link != null) {
                 System.out.println(link);
@@ -224,8 +234,14 @@ public class CatalogDoc extends CamelCommand {
         }
     }
 
-    private void docComponent(ComponentModel cm) {
+    private void docComponent(ComponentModel cm) throws Exception {
         String link = websiteLink("component", name, catalog.getCatalogVersion());
+        if (openUrl) {
+            if (link != null) {
+                Desktop.getDesktop().browse(new URI(link));
+            }
+            return;
+        }
         if (url) {
             if (link != null) {
                 System.out.println(link);
@@ -315,8 +331,14 @@ public class CatalogDoc extends CamelCommand {
         }
     }
 
-    private void docDataFormat(DataFormatModel dm) {
+    private void docDataFormat(DataFormatModel dm) throws Exception {
         String link = websiteLink("dataformat", name, catalog.getCatalogVersion());
+        if (openUrl) {
+            if (link != null) {
+                Desktop.getDesktop().browse(new URI(link));
+            }
+            return;
+        }
         if (url) {
             if (link != null) {
                 System.out.println(link);
@@ -366,8 +388,14 @@ public class CatalogDoc extends CamelCommand {
         }
     }
 
-    private void docLanguage(LanguageModel lm) {
+    private void docLanguage(LanguageModel lm) throws Exception {
         String link = websiteLink("language", name, catalog.getCatalogVersion());
+        if (openUrl) {
+            if (link != null) {
+                Desktop.getDesktop().browse(new URI(link));
+            }
+            return;
+        }
         if (url) {
             if (link != null) {
                 System.out.println(link);
@@ -417,8 +445,14 @@ public class CatalogDoc extends CamelCommand {
         }
     }
 
-    private void docOther(OtherModel om) {
+    private void docOther(OtherModel om) throws Exception {
         String link = websiteLink("other", name, catalog.getCatalogVersion());
+        if (openUrl) {
+            if (link != null) {
+                Desktop.getDesktop().browse(new URI(link));
+            }
+            return;
+        }
         if (url) {
             if (link != null) {
                 System.out.println(link);