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 2021/04/20 11:35:08 UTC
[camel] branch master updated: CAMEL-16533: Spring and Blueprint
XML XSD now include completion documentation for EIP elements also (before
it was only attributes).
This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel.git
The following commit(s) were added to refs/heads/master by this push:
new 18ae110 CAMEL-16533: Spring and Blueprint XML XSD now include completion documentation for EIP elements also (before it was only attributes).
18ae110 is described below
commit 18ae11010e38c75036da08e097d4c53ff2fbef1b
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Tue Apr 20 13:00:19 2021 +0200
CAMEL-16533: Spring and Blueprint XML XSD now include completion documentation for EIP elements also (before it was only attributes).
---
.../java/org/apache/camel/maven/DocumentationEnricher.java | 11 +++++++----
.../src/main/java/org/apache/camel/maven/DomFinder.java | 6 ++++++
.../apache/camel/maven/EipDocumentationEnricherMojo.java | 14 +++++++++-----
3 files changed, 22 insertions(+), 9 deletions(-)
diff --git a/tooling/maven/camel-eip-documentation-enricher-maven-plugin/src/main/java/org/apache/camel/maven/DocumentationEnricher.java b/tooling/maven/camel-eip-documentation-enricher-maven-plugin/src/main/java/org/apache/camel/maven/DocumentationEnricher.java
index 32a69f2..3c971d4 100644
--- a/tooling/maven/camel-eip-documentation-enricher-maven-plugin/src/main/java/org/apache/camel/maven/DocumentationEnricher.java
+++ b/tooling/maven/camel-eip-documentation-enricher-maven-plugin/src/main/java/org/apache/camel/maven/DocumentationEnricher.java
@@ -55,9 +55,9 @@ public class DocumentationEnricher {
}
}
- public void enrichTypeAttributesDocumentation(Log log, NodeList attributeElements, File jsonFile) {
- for (int j = 0; j < attributeElements.getLength(); j++) {
- Element item = (Element) attributeElements.item(j);
+ public void enrichElementDocumentation(Log log, NodeList elements, File jsonFile) {
+ for (int j = 0; j < elements.getLength(); j++) {
+ Element item = (Element) elements.item(j);
addAttributeDocumentation(log, item, jsonFile);
}
}
@@ -72,7 +72,6 @@ public class DocumentationEnricher {
}
private void addAttributeDocumentation(Log log, Element item, File jsonFile) {
-
String name = item.getAttribute(Constants.NAME_ATTRIBUTE_NAME);
if (isNullOrEmpty(name)) {
return;
@@ -101,6 +100,10 @@ public class DocumentationEnricher {
= "Reference to existing endpoint to lookup by endpoint id in the Camel registry to be used as proxied service";
}
+ if (descriptionText == null || descriptionText.equals("null")) {
+ descriptionText = "";
+ }
+
if (option != null && option.isDeprecated()) {
descriptionText = "Deprecated: " + descriptionText;
}
diff --git a/tooling/maven/camel-eip-documentation-enricher-maven-plugin/src/main/java/org/apache/camel/maven/DomFinder.java b/tooling/maven/camel-eip-documentation-enricher-maven-plugin/src/main/java/org/apache/camel/maven/DomFinder.java
index 3f74573..5bff984 100644
--- a/tooling/maven/camel-eip-documentation-enricher-maven-plugin/src/main/java/org/apache/camel/maven/DomFinder.java
+++ b/tooling/maven/camel-eip-documentation-enricher-maven-plugin/src/main/java/org/apache/camel/maven/DomFinder.java
@@ -46,6 +46,12 @@ public class DomFinder {
.evaluate(document, XPathConstants.NODESET);
}
+ public NodeList findElementsElements(String name) throws XPathExpressionException {
+ return (NodeList) xPath.compile(
+ "/xs:schema/xs:complexType[@name='" + name + "']//xs:element")
+ .evaluate(document, XPathConstants.NODESET);
+ }
+
public String findBaseType(String name) throws XPathExpressionException {
return (String) xPath.compile(
"/xs:schema/xs:complexType[@name='" + name + "']//xs:extension/@base")
diff --git a/tooling/maven/camel-eip-documentation-enricher-maven-plugin/src/main/java/org/apache/camel/maven/EipDocumentationEnricherMojo.java b/tooling/maven/camel-eip-documentation-enricher-maven-plugin/src/main/java/org/apache/camel/maven/EipDocumentationEnricherMojo.java
index c95c075..31f2aca 100644
--- a/tooling/maven/camel-eip-documentation-enricher-maven-plugin/src/main/java/org/apache/camel/maven/EipDocumentationEnricherMojo.java
+++ b/tooling/maven/camel-eip-documentation-enricher-maven-plugin/src/main/java/org/apache/camel/maven/EipDocumentationEnricherMojo.java
@@ -189,7 +189,7 @@ public class EipDocumentationEnricherMojo extends AbstractMojo {
enriched++;
getLog().debug("Enriching " + elementName);
File file = jsonFiles.get(elementName);
- injectAttributesDocumentation(domFinder, documentationEnricher, file, elementType, injectedTypes);
+ injectChildElementsDocumentation(domFinder, documentationEnricher, file, elementType, injectedTypes);
} else {
boolean ignore = "ExpressionDefinition".equalsIgnoreCase(elementName);
if (!ignore) {
@@ -217,9 +217,9 @@ public class EipDocumentationEnricherMojo extends AbstractMojo {
}
/**
- * Recursively injects documentation to complex type attributes and it's parents.
+ * Recursively injects documentation to complex type attributes and elements and it's parents.
*/
- private void injectAttributesDocumentation(
+ private void injectChildElementsDocumentation(
DomFinder domFinder,
DocumentationEnricher documentationEnricher,
File jsonFile,
@@ -233,13 +233,17 @@ public class EipDocumentationEnricherMojo extends AbstractMojo {
injectedTypes.add(type);
NodeList attributeElements = domFinder.findAttributesElements(type);
if (attributeElements.getLength() > 0) {
- documentationEnricher.enrichTypeAttributesDocumentation(getLog(), attributeElements, jsonFile);
+ documentationEnricher.enrichElementDocumentation(getLog(), attributeElements, jsonFile);
+ }
+ NodeList elementElements = domFinder.findElementsElements(type);
+ if (elementElements.getLength() > 0) {
+ documentationEnricher.enrichElementDocumentation(getLog(), elementElements, jsonFile);
}
String baseType = domFinder.findBaseType(type);
if (baseType != null && !StringUtils.isEmpty(baseType)) {
baseType = truncateTypeNamespace(baseType);
- injectAttributesDocumentation(domFinder, documentationEnricher, jsonFile, baseType, injectedTypes);
+ injectChildElementsDocumentation(domFinder, documentationEnricher, jsonFile, baseType, injectedTypes);
}
}