Merge "remove hard-coded behavior for Android libraries, replacing them with support for a new doclava option, "dac_libraryroot", which specifies the path to this API's root URL (after accounting for DAC's reference/ path). For example, the wearable doclava build must specify libraryroot as "android/support/constraint/". Also required is a unique name for array created inside lists.js, specified with the "dac_dataname" option. For wearable, it is "SUPPORT_WEARABLE_DATA"" into oc-dev
am: d001ea7777

Change-Id: I815d720b2abd0a7ff04be569cadc645db827234b
diff --git a/res/assets/templates-sdk/head_tag.cs b/res/assets/templates-sdk/head_tag.cs
index 0665391..0d85b8c 100644
--- a/res/assets/templates-sdk/head_tag.cs
+++ b/res/assets/templates-sdk/head_tag.cs
@@ -82,12 +82,9 @@
             elif:samples ?>/samples<?cs
             elif:reference ?>/reference<?cs
             elif:downloads ?>/downloads<?cs /if ?><?cs
+          elif:library.root ?><?cs var:library.root ?><?cs
           else ?><?cs
-            if:reference.testSupport ?>/reference/android/support/test<?cs
-            elif:reference.wearableSupport ?>/reference/android/support/wearable<?cs
-            elif:reference.androidSupport ?>/reference/android/support<?cs
-            elif:reference.constraintSupport ?>/reference/android/support/constraint<?cs
-            elif:(guide||develop||training||reference||tools||sdk||samples) ?><?cs
+            if:(guide||develop||training||reference||tools||sdk||samples) ?><?cs
               if:guide ?>/guide<?cs
               elif:training ?>/training<?cs
               elif:reference ?>/reference<?cs
diff --git a/res/assets/templates-sdk/lists.cs b/res/assets/templates-sdk/lists.cs
index f08abba..9d86dfa 100644
--- a/res/assets/templates-sdk/lists.cs
+++ b/res/assets/templates-sdk/lists.cs
@@ -1,8 +1,7 @@
 var <?cs
-  if:reference.testSupport ?>SUPPORT_TEST_<?cs
-  elif: reference.wearableSupport ?>SUPPORT_WEARABLE_<?cs
-  elif: reference.constraintSupport ?>CONSTRAINT_<?cs
-  /if ?>DATA = [
+  if:dac_dataname ?><?cs var:dac_dataname ?><?cs
+  else ?>DATA<?cs
+  /if ?> = [
 <?cs each:page = docs.pages
 ?>      { id:<?cs var: page.id ?>, label:"<?cs var:page.label ?>", link:"<?cs var:page.link ?>", type:"<?cs var:page.type ?>", deprecated:"<?cs var:page.deprecated ?>" }<?cs if:!last(page) ?>,<?cs /if ?>
 <?cs /each ?>
diff --git a/src/com/google/doclava/AtLinksNavTree.java b/src/com/google/doclava/AtLinksNavTree.java
index 532e8b6..f311c12 100644
--- a/src/com/google/doclava/AtLinksNavTree.java
+++ b/src/com/google/doclava/AtLinksNavTree.java
@@ -47,7 +47,7 @@
   * }</pre>
   *
   * @param dir The directory path to prepend to the output path if the generated navtree is for
-  *        the /support/test or /support/wearable reference docs.
+  *        one the a supplemental library references (such as the wearable support library)
   */
   public static void writeAtLinksNavTree(String dir) {
     StringBuilder buf = new StringBuilder();
@@ -60,10 +60,8 @@
     data.setValue("navtree", buf.toString());
 
     String output_path;
-    if (Doclava.USE_DEVSITE_LOCALE_OUTPUT_PATHS && Doclava.testSupportRef) {
-      output_path = dir + Doclava.testSupportPath + "at_links_navtree.json";
-    } else if (Doclava.USE_DEVSITE_LOCALE_OUTPUT_PATHS && Doclava.wearableSupportRef) {
-      output_path = dir + Doclava.wearableSupportPath + "at_links_navtree.json";
+    if (Doclava.USE_DEVSITE_LOCALE_OUTPUT_PATHS && (Doclava.libraryRoot != null)) {
+      output_path = dir + Doclava.libraryRoot + "at_links_navtree.json";
     } else {
       output_path = "at_links_navtree.json";
     }
diff --git a/src/com/google/doclava/Doclava.java b/src/com/google/doclava/Doclava.java
index 84b187f..8cf17e8 100644
--- a/src/com/google/doclava/Doclava.java
+++ b/src/com/google/doclava/Doclava.java
@@ -124,14 +124,7 @@
   //API reference extensions
   private static boolean gmsRef = false;
   private static boolean gcmRef = false;
-  public static boolean testSupportRef = false;
-  public static String testSupportPath = "android/support/test/";
-  public static boolean wearableSupportRef = false;
-  public static String wearableSupportPath = "android/support/wearable/";
-  public static boolean androidSupportRef = false;
-  public static String androidSupportPath = "android/support/";
-  public static boolean constraintSupportRef = false;
-  public static String constraintSupportPath = "android/support/constraint/";
+  public static String libraryRoot = null;
   private static boolean samplesRef = false;
   private static boolean sac = false;
 
@@ -323,6 +316,10 @@
         federationTagger.addSiteApi(name, file);
       } else if (a[0].equals("-yaml")) {
         yamlNavFile = a[1];
+      } else if (a[0].equals("-dac_libraryroot")) {
+        libraryRoot = a[1];
+      } else if (a[0].equals("-dac_dataname")) {
+        mHDFData.add(new String[] {"dac_dataname", a[1]});
       } else if (a[0].equals("-documentannotations")) {
         documentAnnotations = true;
         documentAnnotationsPath = a[1];
@@ -666,6 +663,12 @@
     if (option.equals("-devsite")) {
       return 1;
     }
+    if (option.equals("-dac_libraryroot")) {
+      return 2;
+    }
+    if (option.equals("-dac_dataname")) {
+      return 2;
+    }
     if (option.equals("-ignoreJdLinks")) {
       return 1;
     }
@@ -779,22 +782,6 @@
       gcmRef = true;
       return 1;
     }
-    if (option.equals("-testSupportRef")) {
-      testSupportRef = true;
-      return 1;
-    }
-    if (option.equals("-wearableSupportRef")) {
-      wearableSupportRef = true;
-      return 1;
-    }
-    if (option.equals("-androidSupportRef")) {
-      androidSupportRef = true;
-      return 1;
-    }
-    if (option.equals("-constraintSupportRef")) {
-      constraintSupportRef = true;
-      return 1;
-    }
     if (option.equals("-metadataDebug")) {
       return 1;
     }
@@ -915,14 +902,6 @@
           data.setValue("reference.gms", "true");
       } else if(gcmRef){
           data.setValue("reference.gcm", "true");
-      } else if(testSupportRef){
-          data.setValue("reference.testSupport", "true");
-      } else if(wearableSupportRef){
-          data.setValue("reference.wearableSupport", "true");
-      } else if(androidSupportRef){
-          data.setValue("reference.androidSupport", "true");
-      } else if(constraintSupportRef){
-          data.setValue("reference.constraintSupport", "true");
       }
       data.setValue("reference", "1");
       data.setValue("reference.apilevels", sinceTagger.hasVersions() ? "1" : "0");
@@ -1058,18 +1037,9 @@
     int i = 0;
     String listDir = javadocDir;
     if (USE_DEVSITE_LOCALE_OUTPUT_PATHS) {
-      if (testSupportRef) {
-        listDir = listDir + testSupportPath;
-        data.setValue("reference.testSupport", "true");
-      } else if (wearableSupportRef) {
-        listDir = listDir + wearableSupportPath;
-        data.setValue("reference.wearableSupport", "true");
-      } else if (androidSupportRef) {
-        listDir = listDir + androidSupportPath;
-        data.setValue("reference.androidSupport", "true");
-      } else if (constraintSupportRef) {
-        listDir = listDir + constraintSupportPath;
-        data.setValue("reference.constraintSupport", "true");
+      if (libraryRoot != null) {
+        listDir = listDir + libraryRoot;
+        data.setValue("library.root", libraryRoot);
       }
     }
     for (String s : sorted.keySet()) {
@@ -1358,14 +1328,8 @@
 
     String packageDir = javadocDir;
     if (USE_DEVSITE_LOCALE_OUTPUT_PATHS) {
-      if (testSupportRef) {
-        packageDir = packageDir + testSupportPath;
-      } else if (wearableSupportRef) {
-        packageDir = packageDir + wearableSupportPath;
-      } else if (androidSupportRef) {
-        packageDir = packageDir + androidSupportPath;
-      } else if (constraintSupportRef) {
-        packageDir = packageDir + constraintSupportPath;
+      if (libraryRoot != null) {
+        packageDir = packageDir + libraryRoot;
       }
     }
     data.setValue("page.not-api", "true");
@@ -1454,14 +1418,8 @@
 
     String packageDir = javadocDir;
     if (USE_DEVSITE_LOCALE_OUTPUT_PATHS) {
-      if (testSupportRef) {
-        packageDir = packageDir + testSupportPath;
-      } else if (wearableSupportRef) {
-        packageDir = packageDir + wearableSupportPath;
-      } else if (androidSupportRef) {
-        packageDir = packageDir + androidSupportPath;
-      } else if (constraintSupportRef) {
-        packageDir = packageDir + constraintSupportPath;
+      if (libraryRoot != null) {
+        packageDir = packageDir + libraryRoot;
       }
     }
 
diff --git a/src/com/google/doclava/NavTree.java b/src/com/google/doclava/NavTree.java
index 0f79917..03926b2 100644
--- a/src/com/google/doclava/NavTree.java
+++ b/src/com/google/doclava/NavTree.java
@@ -49,21 +49,8 @@
       ClearPage.write(data, "gms_navtree_data.cs", "gms_navtree_data.js");
     } else if (refPrefix == "gcm-"){
       ClearPage.write(data, "gcm_navtree_data.cs", "gcm_navtree_data.js");
-    } else if ((Doclava.USE_DEVSITE_LOCALE_OUTPUT_PATHS)
-          && (Doclava.testSupportRef)){
-        ClearPage.write(data, "navtree_data.cs", dir + Doclava.testSupportPath
-          + "navtree_data.js");
-    } else if ((Doclava.USE_DEVSITE_LOCALE_OUTPUT_PATHS)
-          && (Doclava.wearableSupportRef)){
-        ClearPage.write(data, "navtree_data.cs", dir + Doclava.wearableSupportPath
-          + "navtree_data.js");
-    } else if ((Doclava.USE_DEVSITE_LOCALE_OUTPUT_PATHS)
-          && (Doclava.androidSupportRef)){
-        ClearPage.write(data, "navtree_data.cs", dir + Doclava.androidSupportPath
-          + "navtree_data.js");
-    } else if ((Doclava.USE_DEVSITE_LOCALE_OUTPUT_PATHS)
-          && (Doclava.constraintSupportRef)){
-        ClearPage.write(data, "navtree_data.cs", dir + Doclava.constraintSupportPath
+    } else if (Doclava.USE_DEVSITE_LOCALE_OUTPUT_PATHS && (Doclava.libraryRoot != null)) {
+        ClearPage.write(data, "navtree_data.cs", dir + Doclava.libraryRoot
           + "navtree_data.js");
     } else {
       ClearPage.write(data, "navtree_data.cs", "navtree_data.js");
@@ -97,14 +84,8 @@
 
     data = makeYamlHDF(sorted, "docs.pages", data);
 
-    if ((Doclava.USE_DEVSITE_LOCALE_OUTPUT_PATHS) && (Doclava.testSupportRef)) {
-      dir = Doclava.ensureSlash(dir) + Doclava.testSupportPath;
-    } else if ((Doclava.USE_DEVSITE_LOCALE_OUTPUT_PATHS) && (Doclava.wearableSupportRef)) {
-      dir = Doclava.ensureSlash(dir) + Doclava.wearableSupportPath;
-    } else if ((Doclava.USE_DEVSITE_LOCALE_OUTPUT_PATHS) && (Doclava.androidSupportRef)) {
-      dir = Doclava.ensureSlash(dir) + Doclava.androidSupportPath;
-    } else if ((Doclava.USE_DEVSITE_LOCALE_OUTPUT_PATHS) && (Doclava.constraintSupportRef)) {
-      dir = Doclava.ensureSlash(dir) + Doclava.constraintSupportPath;
+    if (Doclava.USE_DEVSITE_LOCALE_OUTPUT_PATHS && (Doclava.libraryRoot != null)) {
+      dir = Doclava.ensureSlash(dir) + Doclava.libraryRoot;
     }
 
     data.setValue("docs.classes.link", Doclava.ensureSlash(dir) + "classes.html");