You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by dj...@apache.org on 2021/12/20 17:26:48 UTC

[camel-quarkus] 02/05: base component tables on yml rather than attributes

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

djencks pushed a commit to branch 2.5.x
in repository https://gitbox.apache.org/repos/asf/camel-quarkus.git

commit bc3e671e930104024c4d6f493093c7ec750e870d
Author: David Jencks <dj...@apache.org>
AuthorDate: Wed Dec 15 18:51:32 2021 -0800

    base component tables on yml rather than attributes
---
 docs/antora.yml                                    |  4 ++-
 docs/modules/ROOT/examples/js/quarkus.js           | 35 ++++++++++++++++++++++
 docs/modules/ROOT/pages/reference/components.adoc  |  2 +-
 docs/modules/ROOT/pages/reference/dataformats.adoc |  4 +--
 docs/modules/ROOT/pages/reference/languages.adoc   |  4 +--
 docs/modules/ROOT/pages/reference/others.adoc      |  4 +--
 .../ROOT/partials/reference/summary-table.adoc     |  4 +--
 .../quarkus/maven/CheckExtensionPagesMojo.java     | 32 +++-----------------
 .../quarkus/maven/UpdateExtensionDocPageMojo.java  | 15 ++++++----
 .../doc-templates/extensions-camel-bits.adoc       | 11 -------
 .../doc-templates/extensions-camel-bits.yml        | 11 +++++++
 11 files changed, 71 insertions(+), 55 deletions(-)

diff --git a/docs/antora.yml b/docs/antora.yml
index 4276472..08f7bb1 100644
--- a/docs/antora.yml
+++ b/docs/antora.yml
@@ -22,6 +22,8 @@ nav:
 - modules/ROOT/nav.adoc
 asciidoc:
   attributes:
+    requires: "'util=camel-website-util,quarkus=xref:js/quarkus.js'"
+
     min-maven-version: 3.6.2 # replace ${min-maven-version}
     target-maven-version: 3.8.1 # replace ${target-maven-version}
     camel-version: 3.13.0 # replace ${camel.version}
@@ -31,4 +33,4 @@ asciidoc:
     quarkus-examples-version: latest
     # indexTable common
     indexer-version: 3.13.x # replace ${camel.docs.components.version}
-    indexer-component: components
+    indexer-component: camel-quarkus
diff --git a/docs/modules/ROOT/examples/js/quarkus.js b/docs/modules/ROOT/examples/js/quarkus.js
new file mode 100644
index 0000000..b79af1c
--- /dev/null
+++ b/docs/modules/ROOT/examples/js/quarkus.js
@@ -0,0 +1,35 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+module.exports = {
+  v: function (name, $) {
+    return $[name]
+  },
+
+  extensionRef: function ($) {
+    return `xref:reference/extensions/${$.cqArtifactIdBase}.adoc[${$.cqCamelPartTitle}]`
+  },
+
+  deprecatedFilter: function (items) {
+    return items.filter((item) => item.$.cqDeprecated === true)
+  },
+
+  jvmOnlyFilter: function (items) {
+    return items.filter((item) => item.$.cqNativeSupported === false)
+  }
+
+}
diff --git a/docs/modules/ROOT/pages/reference/components.adoc b/docs/modules/ROOT/pages/reference/components.adoc
index 7acc4c6..385e809 100644
--- a/docs/modules/ROOT/pages/reference/components.adoc
+++ b/docs/modules/ROOT/pages/reference/components.adoc
@@ -1,6 +1,6 @@
 = Camel components supported on Quarkus
 :indexer-module: ROOT
-:indexer-rel-filter: *-component.adoc
+:indexer-rel-filter: components/*.yml
 :indexer-human-readable-kind: Component
 :indexer-human-readable-kind-plural: components
 
diff --git a/docs/modules/ROOT/pages/reference/dataformats.adoc b/docs/modules/ROOT/pages/reference/dataformats.adoc
index 7b48979..ebe51a0 100644
--- a/docs/modules/ROOT/pages/reference/dataformats.adoc
+++ b/docs/modules/ROOT/pages/reference/dataformats.adoc
@@ -1,6 +1,6 @@
 = Camel data formats supported on Quarkus
-:indexer-module: dataformats
-:indexer-rel-filter: *-dataformat.adoc
+:indexer-module: ROOT
+:indexer-rel-filter: dataformats/*.yml
 :indexer-human-readable-kind: Data format
 :indexer-human-readable-kind-plural: data formats
 
diff --git a/docs/modules/ROOT/pages/reference/languages.adoc b/docs/modules/ROOT/pages/reference/languages.adoc
index 3fd908a..5e2ec89 100644
--- a/docs/modules/ROOT/pages/reference/languages.adoc
+++ b/docs/modules/ROOT/pages/reference/languages.adoc
@@ -1,6 +1,6 @@
 = Camel languages supported on Quarkus
-:indexer-module: languages
-:indexer-rel-filter: *-language.adoc
+:indexer-module: ROOT
+:indexer-rel-filter: languages/*.yml
 :indexer-human-readable-kind: Language
 :indexer-human-readable-kind-plural: languages
 
diff --git a/docs/modules/ROOT/pages/reference/others.adoc b/docs/modules/ROOT/pages/reference/others.adoc
index 523f982..128d0d7 100644
--- a/docs/modules/ROOT/pages/reference/others.adoc
+++ b/docs/modules/ROOT/pages/reference/others.adoc
@@ -1,6 +1,6 @@
 = Camel misc. components supported on Quarkus
-:indexer-module: others
-:indexer-rel-filter: *.adoc
+:indexer-module: ROOT
+:indexer-rel-filter: others/*.yml
 :indexer-human-readable-kind: Misc. component
 :indexer-human-readable-kind-plural: misc. components
 
diff --git a/docs/modules/ROOT/partials/reference/summary-table.adoc b/docs/modules/ROOT/partials/reference/summary-table.adoc
index 3154608..f4e5156 100644
--- a/docs/modules/ROOT/partials/reference/summary-table.adoc
+++ b/docs/modules/ROOT/partials/reference/summary-table.adoc
@@ -1,4 +1,4 @@
-There are indexCount:[version="{indexer-version}",component="{indexer-component}",module="{indexer-module}",relative="{indexer-rel-filter}",attributes=cq-artifact-id] {indexer-human-readable-kind-plural} (indexCount:[version="{indexer-version}",component="{indexer-component}",module="{indexer-module}",relative="{indexer-rel-filter}",attributes='cq-artifact-id,cq-deprecated=true'] deprecated, indexCount:[version="{indexer-version}",component="{indexer-component}",module="{indexer-module}" [...]
+There are indexCount:[relative="{indexer-rel-filter}",family="example"] {indexer-human-readable-kind-plural} (indexCount:[relative="{indexer-rel-filter}",family="example",transform=quarkus.deprecatedFilter,contentAs=json,requires={requires}] deprecated, indexCount:[relative="{indexer-rel-filter}",family="example",transform=quarkus.jvmOnlyFilter,contentAs=json,requires={requires}] JVM only)
 
 [.counted-table,width="100%",cols="4,1,1,1,1,5",options="header"]
 |===
@@ -13,4 +13,4 @@ level
 | Description
 |===
 
-indexTable::[version="{indexer-version}",component="{indexer-component}",module="{indexer-module}",relative="{indexer-rel-filter}",attributes=cq-artifact-id,cellformats="`xref:reference/extensions/$\{cqArtifactIdBase}.adoc[$\{cqCamelPartTitle}]`|cqArtifactId|cqJvmSince|cqNativeSince|cqStatus|cqCamelPartDescription"]
+indexTable::[relative="{indexer-rel-filter}",family="example",cellformats="quarkus.extensionRef($)|quarkus.v('cqArtifactId', $)|quarkus.v('cqJvmSince', $)|quarkus.v('cqNativeSince', $)|quarkus.v('cqStatus', $)|quarkus.v('cqCamelPartDescription', $)",contentAs=json,requires={requires}]
diff --git a/tooling/maven-plugin/src/main/java/org/apache/camel/quarkus/maven/CheckExtensionPagesMojo.java b/tooling/maven-plugin/src/main/java/org/apache/camel/quarkus/maven/CheckExtensionPagesMojo.java
index 8cb2377..9e342bd 100644
--- a/tooling/maven-plugin/src/main/java/org/apache/camel/quarkus/maven/CheckExtensionPagesMojo.java
+++ b/tooling/maven-plugin/src/main/java/org/apache/camel/quarkus/maven/CheckExtensionPagesMojo.java
@@ -18,11 +18,9 @@ package org.apache.camel.quarkus.maven;
 
 import java.io.File;
 import java.io.IOException;
-import java.nio.charset.StandardCharsets;
 import java.nio.file.Files;
 import java.nio.file.Path;
 import java.nio.file.Paths;
-import java.util.Arrays;
 import java.util.Comparator;
 import java.util.HashSet;
 import java.util.Set;
@@ -44,9 +42,7 @@ import org.apache.maven.plugins.annotations.Parameter;
  * Performs the following tasks:
  * <ul>
  * <li>Deletes extension pages whose extensions do not exist anymore
- * <li>Creates dummy partials for Camel bits that Camel Quarkus does not support, so that there are no warnings when
- * they are included from the Camel component pages
- * <li>Deletes Camel bit partials that do not exist anymore.
+ * <li>Deletes yml descriptors for extensions that do not exist anymore.
  * <li>Synchronizes nav.adoc with the reality
  * <ul>
  */
@@ -54,8 +50,7 @@ import org.apache.maven.plugins.annotations.Parameter;
 public class CheckExtensionPagesMojo extends AbstractDocGeneratorMojo {
 
     private static final Pattern ADOC_ENDING_PATTERN = Pattern.compile("\\.adoc$");
-    private static final byte[] DUMMY_COMPONENT_FILE_COMMENT = "// Empty partial for a Camel bit unsupported by Camel Quarkus to avoid warnings when this file is included from a Camel page\n"
-            .getBytes(StandardCharsets.UTF_8);
+    private static final Pattern YML_ENDING_PATTERN = Pattern.compile("\\.yml$");
 
     /**
      * The directory relative to which the catalog data is read.
@@ -103,7 +98,7 @@ public class CheckExtensionPagesMojo extends AbstractDocGeneratorMojo {
     void camelBits(Path docsBasePath) {
         final CqCatalog cqCatalog = new CqCatalog(catalogBaseDir.toPath(), Flavor.camelQuarkus);
 
-        final Path referenceDir = docsBasePath.resolve("modules/ROOT/partials/reference");
+        final Path referenceDir = docsBasePath.resolve("modules/ROOT/examples");
         try (GavCqCatalog camelCatalog = GavCqCatalog.open(Paths.get(localRepository), Flavor.camel, camelVersion)) {
 
             CqCatalog.kinds().forEach(kind -> {
@@ -126,18 +121,10 @@ public class CheckExtensionPagesMojo extends AbstractDocGeneratorMojo {
                 }
                 try (Stream<Path> kindFiles = Files.list(kindDir)) {
                     kindFiles.forEach(kindFile -> {
-                        final String artifactIdBase = ADOC_ENDING_PATTERN.matcher(kindFile.getFileName().toString())
+                        final String artifactIdBase = YML_ENDING_PATTERN.matcher(kindFile.getFileName().toString())
                                 .replaceAll("");
                         if (cqNames.contains(artifactIdBase)) {
                             /* Nothing to do, this should have been done by UpdateExtensionDocPageMojo */
-                        } else if (camelNames.contains(artifactIdBase)) {
-                            try {
-                                if (!Arrays.equals(DUMMY_COMPONENT_FILE_COMMENT, Files.readAllBytes(kindFile))) {
-                                    Files.write(kindFile, DUMMY_COMPONENT_FILE_COMMENT);
-                                }
-                            } catch (IOException e) {
-                                throw new RuntimeException("Could not read or write " + kindFile, e);
-                            }
                         } else {
                             try {
                                 Files.delete(kindFile);
@@ -149,17 +136,6 @@ public class CheckExtensionPagesMojo extends AbstractDocGeneratorMojo {
                 } catch (IOException e) {
                     throw new RuntimeException("Could not list " + kindDir, e);
                 }
-
-                for (String name : camelNames) {
-                    final Path kindFile = kindDir.resolve(name + ".adoc");
-                    if (!Files.isRegularFile(kindFile)) {
-                        try {
-                            Files.write(kindFile, DUMMY_COMPONENT_FILE_COMMENT);
-                        } catch (IOException e) {
-                            throw new RuntimeException("Could not write " + kindFile, e);
-                        }
-                    }
-                }
             });
         }
 
diff --git a/tooling/maven-plugin/src/main/java/org/apache/camel/quarkus/maven/UpdateExtensionDocPageMojo.java b/tooling/maven-plugin/src/main/java/org/apache/camel/quarkus/maven/UpdateExtensionDocPageMojo.java
index deba1bd..029d823 100644
--- a/tooling/maven-plugin/src/main/java/org/apache/camel/quarkus/maven/UpdateExtensionDocPageMojo.java
+++ b/tooling/maven-plugin/src/main/java/org/apache/camel/quarkus/maven/UpdateExtensionDocPageMojo.java
@@ -244,19 +244,22 @@ public class UpdateExtensionDocPageMojo extends AbstractDocGeneratorMojo {
         final Path docPagePath = multiModuleProjectDirectoryPath
                 .resolve("docs/modules/ROOT/pages/reference/extensions/" + ext.getRuntimeArtifactIdBase() + ".adoc");
 
-        evalTemplate(charset, docPagePath, cfg, model, "extension-doc-page.adoc");
+        evalTemplate(charset, docPagePath, cfg, model, "extension-doc-page.adoc", "//");
 
         camelBits(charset, cfg, models, multiModuleProjectDirectoryPath, ext, model);
     }
 
     static void evalTemplate(final Charset charset, final Path docPagePath, final Configuration cfg,
-            final Map<String, Object> model, String template) {
+            final Map<String, Object> model, String template, String commentMarker) {
         try {
             Files.createDirectories(docPagePath.getParent());
         } catch (IOException e) {
             throw new RuntimeException("Could not create directories " + docPagePath.getParent(), e);
         }
-        String pageText = "// Do not edit directly!\n// This file was generated by camel-quarkus-maven-plugin:update-extension-doc-page\n"
+        String pageText = commentMarker
+                + " Do not edit directly!\n"
+                + commentMarker
+                + " This file was generated by camel-quarkus-maven-plugin:update-extension-doc-page\n"
                 + evalTemplate(cfg, template, model, new StringWriter()).toString();
         try {
             Files.write(docPagePath, pageText.getBytes(charset));
@@ -278,10 +281,10 @@ public class UpdateExtensionDocPageMojo extends AbstractDocGeneratorMojo {
 
                     final ArtifactModel<?> camelDocModel = CqCatalog.toCamelDocsModel(m);
                     final Path docPagePath = multiModuleProjectDirectoryPath
-                            .resolve("docs/modules/ROOT/partials/reference/" + CqUtils.kindPlural(kind) + "/"
-                                    + camelDocModel.getName() + ".adoc");
+                            .resolve("docs/modules/ROOT/examples/" + CqUtils.kindPlural(kind) + "/"
+                                    + camelDocModel.getName() + ".yml");
 
-                    evalTemplate(charset, docPagePath, cfg, modelClone, "extensions-camel-bits.adoc");
+                    evalTemplate(charset, docPagePath, cfg, modelClone, "extensions-camel-bits.yml", "#");
 
                 });
 
diff --git a/tooling/maven-plugin/src/main/resources/doc-templates/extensions-camel-bits.adoc b/tooling/maven-plugin/src/main/resources/doc-templates/extensions-camel-bits.adoc
deleted file mode 100644
index 109fa96..0000000
--- a/tooling/maven-plugin/src/main/resources/doc-templates/extensions-camel-bits.adoc
+++ /dev/null
@@ -1,11 +0,0 @@
-:cq-artifact-id: camel-quarkus-[=artifactIdBase]
-:cq-artifact-id-base: [=artifactIdBase]
-:cq-native-supported: [=nativeSupported?then('true', 'false')]
-:cq-status: [=nativeSupported?then('Stable', 'Preview')]
-:cq-deprecated: [=deprecated?then('true', 'false')]
-:cq-jvm-since: [=jvmSince]
-:cq-native-since: [=nativeSince]
-:cq-camel-part-name: [=camelPartName]
-:cq-camel-part-title: [=camelPartTitle]
-:cq-camel-part-description: [=camelPartDescription]
-:cq-extension-page-title: [=name]
diff --git a/tooling/maven-plugin/src/main/resources/doc-templates/extensions-camel-bits.yml b/tooling/maven-plugin/src/main/resources/doc-templates/extensions-camel-bits.yml
new file mode 100644
index 0000000..652fc20
--- /dev/null
+++ b/tooling/maven-plugin/src/main/resources/doc-templates/extensions-camel-bits.yml
@@ -0,0 +1,11 @@
+cqArtifactId: camel-quarkus-[=artifactIdBase]
+cqArtifactIdBase: [=artifactIdBase]
+cqNativeSupported: [=nativeSupported?then('true', 'false')]
+cqStatus: [=nativeSupported?then('Stable', 'Preview')]
+cqDeprecated: [=deprecated?then('true', 'false')]
+cqJvmSince: [=jvmSince]
+cqNativeSince: [=nativeSince]
+cqCamelPartName: [=camelPartName]
+cqCamelPartTitle: [=camelPartTitle]
+cqCamelPartDescription: [=camelPartDescription]
+cqExtensionPageTitle: [=name]