summaryrefslogtreecommitdiffstats
path: root/vpp-integration/api-docs
diff options
context:
space:
mode:
authorMichal Cmarada <michal.cmarada@pantheon.tech>2018-03-02 13:03:09 +0100
committerMichal Cmarada <michal.cmarada@pantheon.tech>2018-03-02 13:04:05 +0100
commit6abf9e092424f484e3f16b72d05f8fad0aa0f16e (patch)
tree0843ca06581ea75f96cd2e3a6e9e0096c8b1ee86 /vpp-integration/api-docs
parent3cb345044738b742be165a49398779fcd96d5fe4 (diff)
Fix generating of docs
- when multiple ClassPaths pointed to the same class, ClassPathTypeIndex failed on duplicate key. Issue is resolved by ignoring other keys that refer to the same class and for every class key is genereated only once. Change-Id: I67fc783a335400c936cd52a0ba9118ab53402800 Signed-off-by: Michal Cmarada <michal.cmarada@pantheon.tech>
Diffstat (limited to 'vpp-integration/api-docs')
-rw-r--r--vpp-integration/api-docs/core/src/main/java/io/fd/hc2vpp/docs/core/ClassPathTypeIndex.java27
1 files changed, 24 insertions, 3 deletions
diff --git a/vpp-integration/api-docs/core/src/main/java/io/fd/hc2vpp/docs/core/ClassPathTypeIndex.java b/vpp-integration/api-docs/core/src/main/java/io/fd/hc2vpp/docs/core/ClassPathTypeIndex.java
index 4eeac5953..bc068034a 100644
--- a/vpp-integration/api-docs/core/src/main/java/io/fd/hc2vpp/docs/core/ClassPathTypeIndex.java
+++ b/vpp-integration/api-docs/core/src/main/java/io/fd/hc2vpp/docs/core/ClassPathTypeIndex.java
@@ -22,9 +22,13 @@ import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
+import java.util.HashMap;
import java.util.Map;
+import java.util.Set;
import java.util.stream.Collectors;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* Index of java classes to relative absolute paths within repository. Used to generate Git links for binding classes of
@@ -32,6 +36,8 @@ import java.util.stream.Collectors;
*/
public class ClassPathTypeIndex implements LinkGenerator {
+ private static final Logger LOG = LoggerFactory.getLogger(ClassPathTypeIndex.class);
+
private static final String JAVA_SOURCE_FOLDER = "src/main/java";
private static final int JAVA_SOURCE_FOLDER_NAME_LENGTH = JAVA_SOURCE_FOLDER.length() + 1;
@@ -60,13 +66,28 @@ public class ClassPathTypeIndex implements LinkGenerator {
private Map<String, String> buildIndex(final String projectRoot) {
try {
- return Files.walk(Paths.get(projectRoot))
+ Set<String> names =
+ Files.walk(Paths.get(projectRoot))
.filter(path -> path.toString().contains("src/main/java"))
.filter(path -> path.toString().endsWith(".java"))
.map(Path::toString)
.map(s -> s.replace(projectRoot, ""))
- .distinct()
- .collect(Collectors.toMap(ClassPathTypeIndex::key, o -> generateLink(o)));
+ .collect(Collectors.toSet());
+
+ Map<String, String> register = new HashMap<>();
+ for (String name : names) {
+ String key = key(name);
+ if (register.containsKey(key)) {
+ /* expected duplicates e.g. In MPLS and SRV6 modules several same types are used
+ (like ipv6-multicast-source-address). We don`t need to create another link for the same class
+ so we can skip these duplicates */
+
+ LOG.trace("Duplicate key found for name: {}. Skip generating new link for the same class", name);
+ } else {
+ register.put(key, generateLink(name));
+ }
+ }
+ return register;
} catch (IOException e) {
throw new IllegalStateException(format("%s not found", projectRoot), e);
}