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 12:03:01 UTC
[camel] 03/03: 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 camel-2.25.x
in repository https://gitbox.apache.org/repos/asf/camel.git
commit b6aa6da46c99e745e189541e2b2586e97f31bed4
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).
---
.../apache/camel/maven/DocumentationEnricher.java | 7 +++---
.../java/org/apache/camel/maven/DomFinder.java | 6 +++++
.../camel/maven/EipDocumentationEnricherMojo.java | 29 +++++++++++++++-------
3 files changed, 29 insertions(+), 13 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 e601974..284609d 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
@@ -54,9 +54,9 @@ public class DocumentationEnricher {
}
}
- public void enrichTypeAttributesDocumentation(Log log, NodeList attributeElements, File jsonFile) throws IOException {
- for (int j = 0; j < attributeElements.getLength(); j++) {
- Element item = (Element) attributeElements.item(j);
+ public void enrichElementDocumentation(Log log, NodeList elements, File jsonFile) throws IOException {
+ for (int j = 0; j < elements.getLength(); j++) {
+ Element item = (Element) elements.item(j);
addAttributeDocumentation(log, item, jsonFile);
}
}
@@ -77,7 +77,6 @@ public class DocumentationEnricher {
}
private void addAttributeDocumentation(Log log, Element item, File jsonFile) throws IOException {
-
String name = item.getAttribute(Constants.NAME_ATTRIBUTE_NAME);
if (isNullOrEmpty(name)) {
return;
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 64b4a20..c7ddbb9 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 8364dcc..e82120a 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
@@ -166,7 +166,12 @@ public class EipDocumentationEnricherMojo extends AbstractMojo {
if (jsonFileExistsForElement(jsonFiles, elementName)) {
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) {
+ getLog().warn("Cannot find json metadata to use for enriching element " + elementName);
+ }
}
}
@@ -187,13 +192,15 @@ 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(DomFinder domFinder,
- DocumentationEnricher documentationEnricher,
- File jsonFile,
- String type,
- Set<String> injectedTypes) throws XPathExpressionException, IOException {
+ private void injectChildElementsDocumentation(
+ DomFinder domFinder,
+ DocumentationEnricher documentationEnricher,
+ File jsonFile,
+ String type,
+ Set<String> injectedTypes)
+ throws XPathExpressionException, IOException {
if (injectedTypes.contains(type)) {
return;
}
@@ -201,13 +208,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);
}
}