Api docs: use project.version as defined in release-notes 07/7807/1
authorMarek Gradzki <[email protected]>
Thu, 27 Jul 2017 06:41:17 +0000 (08:41 +0200)
committerMarek Gradzki <[email protected]>
Thu, 27 Jul 2017 06:41:17 +0000 (08:41 +0200)
Change-Id: I404d5d73580cc98dfed920f2ba781d0fe7fbd793
Signed-off-by: Marek Gradzki <[email protected]>
vpp-integration/api-docs/core/src/main/java/io/fd/hc2vpp/docs/core/ClassPathTypeIndex.java
vpp-integration/api-docs/core/src/main/java/io/fd/hc2vpp/docs/core/LinkGenerator.java
vpp-integration/api-docs/core/src/main/java/io/fd/hc2vpp/docs/core/ModelLinkIndex.java
vpp-integration/api-docs/core/src/main/java/io/fd/hc2vpp/docs/core/YangTypeLinkIndex.java
vpp-integration/api-docs/scripts/src/main/groovy/io/fd/hc2vpp/docs/scripts/ApiDocsIndexGenerator.groovy

index e204d63..4eeac59 100644 (file)
@@ -40,8 +40,8 @@ public class ClassPathTypeIndex implements LinkGenerator {
      */
     private final Map<String, String> index;
 
-    public ClassPathTypeIndex(final String projectRoot, final String version) {
-        index = buildIndex(projectRoot, version);
+    public ClassPathTypeIndex(final String projectRoot) {
+        index = buildIndex(projectRoot);
     }
 
     /**
@@ -58,7 +58,7 @@ public class ClassPathTypeIndex implements LinkGenerator {
         return index.get(clazz.replace("/", "."));
     }
 
-    private Map<String, String> buildIndex(final String projectRoot, final String version) {
+    private Map<String, String> buildIndex(final String projectRoot) {
         try {
             return Files.walk(Paths.get(projectRoot))
                     .filter(path -> path.toString().contains("src/main/java"))
@@ -66,7 +66,7 @@ public class ClassPathTypeIndex implements LinkGenerator {
                     .map(Path::toString)
                     .map(s -> s.replace(projectRoot, ""))
                     .distinct()
-                    .collect(Collectors.toMap(ClassPathTypeIndex::key, o -> generateLink(o, version)));
+                    .collect(Collectors.toMap(ClassPathTypeIndex::key, o -> generateLink(o)));
         } catch (IOException e) {
             throw new IllegalStateException(format("%s not found", projectRoot), e);
         }
index 3226639..2fd96dd 100644 (file)
@@ -18,16 +18,8 @@ package io.fd.hc2vpp.docs.core;
 
 public interface LinkGenerator {
 
-    static String resolveBranch(final String version) {
-        if (version.contains("SNAPSHOT")) {
-            return "master";
-        } else {
-            return "stable%2F" + version.replace(".", "");
-        }
-    }
-
-    default String generateLink(final String raw, final String version) {
+    default String generateLink(final String raw) {
         //https://git.fd.io/hc2vpp/tree/interface-role/api/src/main/yang/[email protected]?h=stable%2F1707
-        return "https://git.fd.io/hc2vpp/tree" + raw + "?h=" + resolveBranch(version);
+        return "https://git.fd.io/hc2vpp/tree" + raw + "?h={project-branch}";
     }
 }
index c1b2998..3a6268f 100644 (file)
@@ -35,10 +35,9 @@ class ModelLinkIndex implements LinkGenerator {
 
     /**
      * @param projectRoot for ex.: /home/jsrnicek/Projects/hc2vpp
-     * @param version     for ex.: 17.07 to get generateLink for correct branch
      */
-    ModelLinkIndex(final String projectRoot, final String version) {
-        modelLinkIndex = buildIndex(projectRoot, version);
+    ModelLinkIndex(final String projectRoot) {
+        modelLinkIndex = buildIndex(projectRoot);
     }
 
     private static String key(String raw) {
@@ -55,7 +54,7 @@ class ModelLinkIndex implements LinkGenerator {
                         .orElse("https://datatracker.ietf.org/"));
     }
 
-    private Map<String, String> buildIndex(final String projectRoot, final String version) {
+    private Map<String, String> buildIndex(final String projectRoot) {
         try {
             return Files.walk(Paths.get(projectRoot))
                     .filter(path -> path.toString().contains("src/main/yang"))
@@ -63,7 +62,7 @@ class ModelLinkIndex implements LinkGenerator {
                     .map(Path::toString)
                     .map(s -> s.replace(projectRoot, ""))
                     .distinct()
-                    .collect(Collectors.toMap(ModelLinkIndex::key, o -> generateLink(o, version)));
+                    .collect(Collectors.toMap(ModelLinkIndex::key, o -> generateLink(o)));
         } catch (IOException e) {
             throw new IllegalStateException(format("%s not found", projectRoot), e);
         }
index 8220d7f..e0c2b50 100644 (file)
@@ -27,8 +27,8 @@ public class YangTypeLinkIndex {
     private final ModelLinkIndex modelLinkIndex;
     private final ModelTypeIndex modelTypeIndex;
 
-    public YangTypeLinkIndex(final String projectRoot, final String version) {
-        modelLinkIndex = new ModelLinkIndex(projectRoot, version);
+    public YangTypeLinkIndex(final String projectRoot) {
+        modelLinkIndex = new ModelLinkIndex(projectRoot);
         try {
             modelTypeIndex = new ModelTypeIndex();
         } catch (IOException e) {
index 437def6..99e41ce 100644 (file)
@@ -77,9 +77,9 @@ class ApiDocsIndexGenerator {
         String outPath = project.build.outputDirectory
 
         log.info "Generating yang type generateLink index"
-        YangTypeLinkIndex yangTypeIndex = new YangTypeLinkIndex(projectRoot, project.version)
+        YangTypeLinkIndex yangTypeIndex = new YangTypeLinkIndex(projectRoot)
         log.info "Classpath type generateLink index"
-        ClassPathTypeIndex classPathIndex = new ClassPathTypeIndex(projectRoot, project.version)
+        ClassPathTypeIndex classPathIndex = new ClassPathTypeIndex(projectRoot)
 
         log.info "Generating VPP API to YANG mapping"
         PLUGIN_CLASSES.stream()