From 283915ef6f657a8b1fe7a72a6d39465f823033a0 Mon Sep 17 00:00:00 2001 From: Marek Gradzki Date: Fri, 2 Mar 2018 14:12:01 +0100 Subject: Revert "Fix generating of docs" The actual issue occurs only locally if yang model was moved from one module to other and generated java files were not removed from the first location (see HC2VPP-286). Having doc generator failing in such cases might be annoying, but will also prevent duplicating yang models. This reverts commit 6abf9e092424f484e3f16b72d05f8fad0aa0f16e. Change-Id: I2e76ccc80f5a2f08a1b61df1d27ab41752b629b8 Signed-off-by: Marek Gradzki --- .../io/fd/hc2vpp/docs/core/ClassPathTypeIndex.java | 27 +++------------------- 1 file changed, 3 insertions(+), 24 deletions(-) (limited to 'vpp-integration/api-docs/core/src') 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 bc068034a..4eeac5953 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,13 +22,9 @@ 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 @@ -36,8 +32,6 @@ import org.slf4j.LoggerFactory; */ 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; @@ -66,28 +60,13 @@ public class ClassPathTypeIndex implements LinkGenerator { private Map buildIndex(final String projectRoot) { try { - Set names = - Files.walk(Paths.get(projectRoot)) + return 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, "")) - .collect(Collectors.toSet()); - - Map 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; + .distinct() + .collect(Collectors.toMap(ClassPathTypeIndex::key, o -> generateLink(o))); } catch (IOException e) { throw new IllegalStateException(format("%s not found", projectRoot), e); } -- cgit 1.2.3-korg