summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorRenato Mangini <mangini@google.com>2014-08-15 13:17:12 -0700
committerRenato Mangini <mangini@google.com>2014-08-15 20:27:03 +0000
commite11680d498d71b1503b77a5137bd67492dee0c58 (patch)
tree88ecb75a147cebc7982e9b36838eaa1944f3ca44 /src
parent80e276116a8c4183444b8c89297daa054d53bf9d (diff)
downloadandroid_external_doclava-e11680d498d71b1503b77a5137bd67492dee0c58.tar.gz
android_external_doclava-e11680d498d71b1503b77a5137bd67492dee0c58.tar.bz2
android_external_doclava-e11680d498d71b1503b77a5137bd67492dee0c58.zip
Change Doclava to support multimodule samples
Doclava only recognizes samples as browseable projects if they contain both an _index.jd file and a src/ directory on their root directories. This CL relaxes this rule by allowing the src/ to be inside a top level director as well, so samples with multiple modules, like Wear apps, can be browsed. Bug: 17042843 Change-Id: I2bcebb1dc3b2d317b43ff4af379c761067535bd9
Diffstat (limited to 'src')
-rw-r--r--src/com/google/doclava/Doclava.java26
1 files changed, 20 insertions, 6 deletions
diff --git a/src/com/google/doclava/Doclava.java b/src/com/google/doclava/Doclava.java
index 88222e7..b09fcf4 100644
--- a/src/com/google/doclava/Doclava.java
+++ b/src/com/google/doclava/Doclava.java
@@ -1783,16 +1783,30 @@ public class Doclava {
/**
* 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.
+ * Root directories must contain a valid _index.jd file and a src/ directory
+ * or a module directory that contains a src/ directory.
*/
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()) {
+ File indexJd = new File(dir, "_index.jd");
+ if (!indexJd.exists()) {
+ return false;
+ }
+ File srcDir = new File(dir, "src");
+ if (srcDir.exists()) {
return true;
} else {
+ // Look for a src/ directory one level below the root directory, so
+ // modules are supported.
+ for (File childDir : dir.listFiles()) {
+ if (childDir.isDirectory()) {
+ srcDir = new File(childDir, "src");
+ if (srcDir.exists()) {
+ return true;
+ }
+ }
+ }
return false;
}
}
-
-} \ No newline at end of file
+
+}