Add doclava flag 'referenceonly' to skip generating the HTML files.
Also add an override function in the template to allow a custom "docroot"
string in the override templates. (So we can set it to always be a web site.)

Change-Id: I9edd6eab9ecb7e3b41c444e7e545702e855a5928
diff --git a/res/assets/templates/macros.cs b/res/assets/templates/macros.cs
index ff6e3be..a462e0d 100644
--- a/res/assets/templates/macros.cs
+++ b/res/assets/templates/macros.cs
@@ -84,6 +84,10 @@
   /each ?><?cs
 /def ?>
 
+<?cs def:doc_root_override()
+  ?><?cs var:toroot ?><?cs
+/def ?>
+
 <?cs # Print a list of tags (e.g. description text ?><?cs
 def:tag_list(tags) ?><?cs
   each:tag = tags ?><?cs
@@ -107,7 +111,7 @@
       elif:tag.kind == "@samplecode" ?><pre><?cs var:tag.text ?></pre><?cs
       elif:tag.name == "@sample" ?><pre><?cs var:tag.text ?></pre><?cs
       elif:tag.name == "@include" ?><?cs var:tag.text ?><?cs
-      elif:tag.kind == "@docRoot" ?><?cs var:toroot ?><?cs
+      elif:tag.kind == "@docRoot" ?><?cs call:doc_root_override() ?><?cs
       elif:tag.kind == "@sdkCurrent" ?><?cs var:sdk.current ?><?cs
       elif:tag.kind == "@sdkCurrentVersion" ?><?cs var:sdk.version ?><?cs
       elif:tag.kind == "@sdkCurrentRelId" ?><?cs var:sdk.rel.id ?><?cs
diff --git a/src/com/google/doclava/Doclava.java b/src/com/google/doclava/Doclava.java
index b397835..634e26d 100644
--- a/src/com/google/doclava/Doclava.java
+++ b/src/com/google/doclava/Doclava.java
@@ -101,6 +101,7 @@
   public static boolean documentAnnotations = false;
   public static String documentAnnotationsPath = null;
   public static Map<String, String> annotationDocumentationMap = null;
+  public static boolean referenceOnly = false;
 
   public static JSilver jSilver = null;
 
@@ -291,6 +292,8 @@
       } else if (a[0].equals("-documentannotations")) {
         documentAnnotations = true;
         documentAnnotationsPath = a[1];
+      } else if (a[0].equals("-referenceonly")) {
+        referenceOnly = true;
       }
     }
 
@@ -341,26 +344,28 @@
         TodoFile.writeTodoFile(todoFile);
       }
 
-  if (samplesRef) {
+      if (samplesRef) {
         // always write samples without offlineMode behaviors
-  writeSamples(false, sampleCodes, SORT_BY_NAV_GROUPS);
-  }
-
-      // HTML2 Pages -- Generate Pages from optional secondary dir
-      if (!inputPathHtmlDir2.isEmpty()) {
-        if (!outputPathHtmlDir2.isEmpty()) {
-          ClearPage.outputDir = outputPathBase + "/" + outputPathHtmlDir2;
-        }
-        ClearPage.htmlDirs = inputPathHtmlDir2;
-        writeHTMLPages();
-        ClearPage.htmlDirs = inputPathHtmlDirs;
+        writeSamples(false, sampleCodes, SORT_BY_NAV_GROUPS);
       }
 
-      // HTML Pages
-      if (!ClearPage.htmlDirs.isEmpty()) {
-        ClearPage.htmlDirs = inputPathHtmlDirs;
-        ClearPage.outputDir = outputPathHtmlDirs;
-        writeHTMLPages();
+      if (!referenceOnly) {
+        // HTML2 Pages -- Generate Pages from optional secondary dir
+        if (!inputPathHtmlDir2.isEmpty()) {
+          if (!outputPathHtmlDir2.isEmpty()) {
+            ClearPage.outputDir = outputPathBase + "/" + outputPathHtmlDir2;
+          }
+          ClearPage.htmlDirs = inputPathHtmlDir2;
+          writeHTMLPages();
+          ClearPage.htmlDirs = inputPathHtmlDirs;
+        }
+
+        // HTML Pages
+        if (!ClearPage.htmlDirs.isEmpty()) {
+          ClearPage.htmlDirs = inputPathHtmlDirs;
+          ClearPage.outputDir = outputPathHtmlDirs;
+          writeHTMLPages();
+        }
       }
 
       writeAssets();
@@ -694,6 +699,9 @@
     if (option.equals("-documentannotations")) {
       return 2;
     }
+    if (option.equals("-referenceonly")) {
+      return 1;
+    }
     return 0;
   }
   public static boolean validOptions(String[][] options, DocErrorReporter r) {