summaryrefslogtreecommitdiffstats
path: root/vpp-integration/api-docs
diff options
context:
space:
mode:
authorMarek Gradzki <mgradzki@cisco.com>2017-07-25 15:44:21 +0200
committerMarek Gradzki <mgradzki@cisco.com>2017-07-25 16:23:02 +0200
commit2f832ea2eda1727308adf82051afdf30bfdb247f (patch)
treee52b8bce4fdd63e4b14db98ddfcc352b3981b751 /vpp-integration/api-docs
parentd615f74168ffccf8be8eda4b39b1e9bf9ba06bda (diff)
Api docs: single row per VPP API message
Lists all of supported CUD operations in single cell. Change-Id: I5f23200d869221f797ed8b4b5ca0512baa92486b Signed-off-by: Marek Gradzki <mgradzki@cisco.com>
Diffstat (limited to 'vpp-integration/api-docs')
-rw-r--r--vpp-integration/api-docs/api/src/main/java/io/fd/hc2vpp/docs/api/CoverageUnit.java12
-rw-r--r--vpp-integration/api-docs/api/src/main/java/io/fd/hc2vpp/docs/api/JavaApiMessage.java14
-rw-r--r--vpp-integration/api-docs/core/src/main/java/io/fd/hc2vpp/docs/core/CoverageGenerator.java71
-rw-r--r--vpp-integration/api-docs/core/src/main/java/io/fd/hc2vpp/docs/core/PluginMethodReference.java5
-rw-r--r--vpp-integration/api-docs/scripts/src/main/groovy/io/fd/hc2vpp/docs/scripts/ApiDocsIndexGenerator.groovy4
5 files changed, 61 insertions, 45 deletions
diff --git a/vpp-integration/api-docs/api/src/main/java/io/fd/hc2vpp/docs/api/CoverageUnit.java b/vpp-integration/api-docs/api/src/main/java/io/fd/hc2vpp/docs/api/CoverageUnit.java
index 06cb59f69..e04d28304 100644
--- a/vpp-integration/api-docs/api/src/main/java/io/fd/hc2vpp/docs/api/CoverageUnit.java
+++ b/vpp-integration/api-docs/api/src/main/java/io/fd/hc2vpp/docs/api/CoverageUnit.java
@@ -16,8 +16,10 @@
package io.fd.hc2vpp.docs.api;
+import java.util.Collection;
import java.util.List;
import java.util.Objects;
+import java.util.Set;
/**
* Represents mapping between single supported VPP binary api and its binding
@@ -42,11 +44,11 @@ public class CoverageUnit {
/**
* Operations supported for this api
*/
- private final List<Operation> supportedOperations;
+ private final Collection<Operation> supportedOperations;
private CoverageUnit(final VppApiMessage vppApi, final JavaApiMessage javaApi,
final List<YangType> yangTypes,
- final List<Operation> supportedOperations) {
+ final Collection<Operation> supportedOperations) {
this.vppApi = vppApi;
this.javaApi = javaApi;
this.yangTypes = yangTypes;
@@ -65,7 +67,7 @@ public class CoverageUnit {
return yangTypes;
}
- public List<Operation> getSupportedOperations() {
+ public Collection<Operation> getSupportedOperations() {
return supportedOperations;
}
@@ -95,7 +97,7 @@ public class CoverageUnit {
private VppApiMessage vppApi;
private JavaApiMessage javaApi;
private List<YangType> yangTypes;
- private List<Operation> supportedOperations;
+ private Set<Operation> supportedOperations;
public CoverageUnitBuilder setVppApi(final VppApiMessage vppApi) {
this.vppApi = vppApi;
@@ -112,7 +114,7 @@ public class CoverageUnit {
return this;
}
- public CoverageUnitBuilder setSupportedOperations(final List<Operation> supportedOperations) {
+ public CoverageUnitBuilder setSupportedOperations(final Set<Operation> supportedOperations) {
this.supportedOperations = supportedOperations;
return this;
}
diff --git a/vpp-integration/api-docs/api/src/main/java/io/fd/hc2vpp/docs/api/JavaApiMessage.java b/vpp-integration/api-docs/api/src/main/java/io/fd/hc2vpp/docs/api/JavaApiMessage.java
index db4575c5a..a25fdc245 100644
--- a/vpp-integration/api-docs/api/src/main/java/io/fd/hc2vpp/docs/api/JavaApiMessage.java
+++ b/vpp-integration/api-docs/api/src/main/java/io/fd/hc2vpp/docs/api/JavaApiMessage.java
@@ -26,14 +26,14 @@ public class JavaApiMessage {
/**
* Name of the call
*/
- private final String api;
+ private final String name;
- public JavaApiMessage(final String api) {
- this.api = api;
+ public JavaApiMessage(final String name) {
+ this.name = name;
}
- public String getApi() {
- return api;
+ public String getName() {
+ return name;
}
@Override
@@ -46,11 +46,11 @@ public class JavaApiMessage {
}
final JavaApiMessage that = (JavaApiMessage) o;
- return Objects.equals(this.api, that.api);
+ return Objects.equals(this.name, that.name);
}
@Override
public int hashCode() {
- return Objects.hash(api);
+ return Objects.hash(name);
}
}
diff --git a/vpp-integration/api-docs/core/src/main/java/io/fd/hc2vpp/docs/core/CoverageGenerator.java b/vpp-integration/api-docs/core/src/main/java/io/fd/hc2vpp/docs/core/CoverageGenerator.java
index 4a8a77827..ff6c9b78b 100644
--- a/vpp-integration/api-docs/core/src/main/java/io/fd/hc2vpp/docs/core/CoverageGenerator.java
+++ b/vpp-integration/api-docs/core/src/main/java/io/fd/hc2vpp/docs/core/CoverageGenerator.java
@@ -34,7 +34,7 @@ import io.fd.hc2vpp.docs.api.PluginCoverage;
import io.fd.hc2vpp.docs.api.YangType;
import io.fd.honeycomb.translate.write.WriterFactory;
import java.lang.reflect.Field;
-import java.util.LinkedList;
+import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
@@ -63,53 +63,62 @@ public class CoverageGenerator implements VppApiUtils {
final Set<CoverageUnit> coverageUnits = writerBuilder.getWriteHandlers().stream()
.flatMap(handler -> {
+ LOG.debug("Processing writer handling nodes: {}", handler.getHandledNodes());
// extracts customizer class from handler
final Class<?> customizerClass = getCustomizerClass(handler.getWriter());
// scans within write method
final Set<PluginMethodReference> writeReferences =
new CoverageScanner(customizerClass, WRITE, pluginClass).scan();
+ LOG.debug("writeReferences: {}", writeReferences);
// scans within update method
final Set<PluginMethodReference> updateReferences =
new CoverageScanner(customizerClass, UPDATE, pluginClass).scan();
+ LOG.debug("updateReferences: {}", updateReferences);
// scans within delete method
final Set<PluginMethodReference> deleteReferences =
new CoverageScanner(customizerClass, DELETE, pluginClass).scan();
+ LOG.debug("deleteReferences: {}", deleteReferences);
return Stream.of(writeReferences.stream(), updateReferences.stream(), deleteReferences.stream())
- .flatMap(pluginMethodReferenceStream -> pluginMethodReferenceStream)
- .map(reference -> {
- final CoverageUnit.CoverageUnitBuilder builder = new CoverageUnit.CoverageUnitBuilder();
-
- // binds vpp api name and generateLink bind with version
- builder.setVppApi(fromJvppApi(version, reference.getName()));
-
- //binds java api reference
- builder.setJavaApi(new JavaApiMessage(reference.getName()));
-
- // binds Yang types with links from pre-build index
- // TODO - use deserialized yii e.g. /module:parent-node/child-node
- builder.setYangTypes(handler.getHandledNodes().stream()
- .map(type -> new YangType(type, yangTypeIndex.getLinkForType(type)))
- .collect(Collectors.toList()));
-
- final String callerClassLink = classPathIndex.linkForClass(reference.getCaller());
- final List<Operation> supportedOperations = new LinkedList<>();
- if (writeReferences.contains(reference)) {
- supportedOperations.add(new Operation(callerClassLink, WRITE));
+ .flatMap(pluginMethodReferenceStream -> pluginMethodReferenceStream)
+ .collect(Collectors.groupingBy(PluginMethodReference::getName)).entrySet().stream()
+ .map(vppMessageReferenceByName -> {
+ final String jvppMethodName = vppMessageReferenceByName.getKey();
+ final CoverageUnit.CoverageUnitBuilder builder = new CoverageUnit.CoverageUnitBuilder();
+
+ // binds vpp api name and generateLink bind with version
+ builder.setVppApi(fromJvppApi(version, jvppMethodName));
+
+ //binds java api reference
+ builder.setJavaApi(new JavaApiMessage(jvppMethodName));
+
+ // binds Yang types with links from pre-build index
+ // TODO - use deserialized yii e.g. /module:parent-node/child-node
+ builder.setYangTypes(handler.getHandledNodes().stream()
+ .map(type -> new YangType(type, yangTypeIndex.getLinkForType(type)))
+ .collect(Collectors.toList()));
+
+
+ final Set<Operation> supportedOperations = new HashSet<>();
+ vppMessageReferenceByName.getValue().stream().forEach(
+ reference -> {
+ final String callerClassLink = classPathIndex.linkForClass(reference.getCaller());
+ if (writeReferences.contains(reference)) {
+ supportedOperations.add(new Operation(callerClassLink, WRITE));
+ }
+ if (updateReferences.contains(reference)) {
+ supportedOperations.add(new Operation(callerClassLink, UPDATE));
+ }
+ if (deleteReferences.contains(reference)) {
+ supportedOperations.add(new Operation(callerClassLink, DELETE));
+ }
}
-
- if (updateReferences.contains(reference)) {
- supportedOperations.add(new Operation(callerClassLink, UPDATE));
- }
-
- if (deleteReferences.contains(reference)) {
- supportedOperations.add(new Operation(callerClassLink, DELETE));
- }
- return builder.setSupportedOperations(supportedOperations).build();
- });
+ );
+ return builder.setSupportedOperations(supportedOperations).build();
+ });
}).collect(Collectors.toSet());
return new PluginCoverage(pluginClass.getSimpleName(), coverageUnits, true);
diff --git a/vpp-integration/api-docs/core/src/main/java/io/fd/hc2vpp/docs/core/PluginMethodReference.java b/vpp-integration/api-docs/core/src/main/java/io/fd/hc2vpp/docs/core/PluginMethodReference.java
index 5a98639ae..4e03b4a73 100644
--- a/vpp-integration/api-docs/core/src/main/java/io/fd/hc2vpp/docs/core/PluginMethodReference.java
+++ b/vpp-integration/api-docs/core/src/main/java/io/fd/hc2vpp/docs/core/PluginMethodReference.java
@@ -53,4 +53,9 @@ public class PluginMethodReference {
public String getName() {
return name;
}
+
+ @Override
+ public String toString() {
+ return "PluginMethodReference{name=" + this.name + ", caller=" + this.caller + ", owner=" + this.owner + ", " + "}";
+ }
}
diff --git a/vpp-integration/api-docs/scripts/src/main/groovy/io/fd/hc2vpp/docs/scripts/ApiDocsIndexGenerator.groovy b/vpp-integration/api-docs/scripts/src/main/groovy/io/fd/hc2vpp/docs/scripts/ApiDocsIndexGenerator.groovy
index 238f4a25b..437def689 100644
--- a/vpp-integration/api-docs/scripts/src/main/groovy/io/fd/hc2vpp/docs/scripts/ApiDocsIndexGenerator.groovy
+++ b/vpp-integration/api-docs/scripts/src/main/groovy/io/fd/hc2vpp/docs/scripts/ApiDocsIndexGenerator.groovy
@@ -139,14 +139,14 @@ class ApiDocsIndexGenerator {
}
private static String javaApi(final JavaApiMessage javaApi) {
- "$TABLE_PART_MARK${javaApi.api}$NL"
+ "$TABLE_PART_MARK${javaApi.name}$NL"
}
private static String yangTypes(final List<YangType> yangTypes) {
"$NL$TABLE_PART_MARK$NL ${yangTypes.stream().map { yangType -> " ${yangType.link}[${yangType.type}]" }.collect(Collectors.joining(NL))}"
}
- private static String supportedOperations(final List<Operation> operations) {
+ private static String supportedOperations(final Collection<Operation> operations) {
"$NL$TABLE_PART_MARK${operations.stream().map { reference -> " ${reference.link}[${reference.operation}]" }.collect(Collectors.joining(NL))}"
}