summaryrefslogtreecommitdiffstats
path: root/src/com/google/doclava/Doclava.java
diff options
context:
space:
mode:
authorDirk Dougherty <ddougherty@google.com>2013-11-21 18:08:58 -0800
committerDirk Dougherty <ddougherty@google.com>2013-11-22 09:59:00 -0800
commit5ce827a43e16b415ad8554c97cee01bf549067d6 (patch)
treecc90097af63d05bec8283c95bcde937a9f36789d /src/com/google/doclava/Doclava.java
parentf9d9cb045339e902b36391d19be3c665b1585ab8 (diff)
downloadandroid_external_doclava-5ce827a43e16b415ad8554c97cee01bf549067d6.tar.gz
android_external_doclava-5ce827a43e16b415ad8554c97cee01bf549067d6.tar.bz2
android_external_doclava-5ce827a43e16b415ad8554c97cee01bf549067d6.zip
Initiate samples browser processing from a single root directory, rather than from a list of project paths defined in Android.mk.
Change-Id: I680cfeb5d2690d64064859f40cec6014e392bfe5
Diffstat (limited to 'src/com/google/doclava/Doclava.java')
-rw-r--r--src/com/google/doclava/Doclava.java47
1 files changed, 43 insertions, 4 deletions
diff --git a/src/com/google/doclava/Doclava.java b/src/com/google/doclava/Doclava.java
index 3aca5c9..a571ab4 100644
--- a/src/com/google/doclava/Doclava.java
+++ b/src/com/google/doclava/Doclava.java
@@ -79,6 +79,7 @@ public class Doclava {
public static RootDoc root;
public static ArrayList<String[]> mHDFData = new ArrayList<String[]>();
public static List<PageMetadata.Node> sTaglist = new ArrayList<PageMetadata.Node>();
+ public static ArrayList<SampleCode> sampleCodes = new ArrayList<SampleCode>();
public static ArrayList<SampleCode> sampleCodeGroups = new ArrayList<SampleCode>();
public static Map<Character, String> escapeChars = new HashMap<Character, String>();
public static String title = "";
@@ -142,7 +143,6 @@ public class Doclava {
String proofreadFile = null;
String todoFile = null;
String sdkValuePath = null;
- ArrayList<SampleCode> sampleCodes = new ArrayList<SampleCode>();
String stubsDir = null;
// Create the dependency graph for the stubs directory
boolean offlineMode = false;
@@ -169,6 +169,8 @@ public class Doclava {
sampleCodes.add(new SampleCode(a[1], a[2], a[3]));
} else if (a[0].equals("-samplegroup")) {
sampleCodeGroups.add(new SampleCode(null, null, a[1]));
+ } else if (a[0].equals("-samplesdir")) {
+ getSampleProjects(new File(a[1]));
//the destination output path for main htmldir
} else if (a[0].equals("-htmldir")) {
inputPathHtmlDirs.add(a[1]);
@@ -537,6 +539,10 @@ public class Doclava {
if (option.equals("-samplegroup")) {
return 2;
}
+ if (option.equals("-samplesdir")) {
+ samplesRef = true;
+ return 2;
+ }
if (option.equals("-devsite")) {
return 1;
}
@@ -1687,8 +1693,8 @@ public class Doclava {
}
/**
- * Process samples dirs that are specified in Android.mk. Generate html
- * wrapped pages, copy files to output dir, and generate a SampleCode NavTree.
+ * Process sample projects. Generate html wrapped pages, copy files to
+ * output dir, and generate a SampleCode NavTree.
*/
public static void writeSamples(boolean offlineMode, ArrayList<SampleCode> sampleCodes,
boolean sortNavByGroups) {
@@ -1712,4 +1718,37 @@ public class Doclava {
}
}
-}
+ /**
+ * Given an initial samples directory root, walk through the directory collecting
+ * sample code project roots and adding them to an array of SampleCodes.
+ * @param rootDir Root directory holding all browseable sample code projects,
+ * defined in frameworks/base/Android.mk as "-sampleDir path".
+ */
+ public static void getSampleProjects(File rootDir) {
+ for (File f : rootDir.listFiles()) {
+ String name = f.getName();
+ if (f.isDirectory()) {
+ if (isValidSampleProjectRoot(f)) {
+ sampleCodes.add(new SampleCode(f.getAbsolutePath(), "samples/" + name, name));
+ } else {
+ getSampleProjects(f);
+ }
+ }
+ }
+ }
+
+ /**
+ * Test whether a given directory is the root directory for a sample code project.
+ * Root directories must include both a src/ directory and a valid _index.jd file.
+ */
+ public static boolean isValidSampleProjectRoot(File dir) {
+ File srcDir = new File(dir.getAbsolutePath(), "src");
+ File indexJd = new File(dir.getAbsolutePath(), "_index.jd");
+ if (srcDir.exists() && indexJd.exists()) {
+ return true;
+ } else {
+ return false;
+ }
+ }
+
+} \ No newline at end of file