Merge "DO NOT MERGE - Add a -knowntags option to droiddoc" into gingerbread

This commit is contained in:
Joe Onorato 2010-09-16 09:02:54 -07:00 committed by Android (Google) Code Review
commit 25ab3dcce4
2 changed files with 65 additions and 2 deletions

View File

@ -55,8 +55,6 @@ public class Comment
"@sample",
"@include",
"@serial",
"@com.intel.drl.spec_ref",
"@ar.org.fitc.spec_ref",
};
public Comment(String text, ContainerInfo base, SourcePositionInfo sp)
@ -184,6 +182,9 @@ public class Comment
break;
}
}
if (!known) {
known = DroidDoc.knownTags.contains(name);
}
if (!known) {
Errors.error(Errors.UNKNOWN_TAG, pos == null ? null : new SourcePositionInfo(pos),
"Unknown tag: " + name);

View File

@ -58,6 +58,7 @@ public class DroidDoc
public static Map<Character,String> escapeChars = new HashMap<Character,String>();
public static String title = "";
public static SinceTagger sinceTagger = new SinceTagger();
public static HashSet<String> knownTags = new HashSet<String>();
private static boolean parseComments = false;
private static boolean generateDocs = true;
@ -111,6 +112,7 @@ public class DroidDoc
String apiFile = null;
String debugStubsFile = "";
HashSet<String> stubPackages = null;
ArrayList<String> knownTagsFiles = new ArrayList<String>();
root = r;
@ -125,6 +127,9 @@ public class DroidDoc
else if (a[0].equals("-hdf")) {
mHDFData.add(new String[] {a[1], a[2]});
}
else if (a[0].equals("-knowntags")) {
knownTagsFiles.add(a[1]);
}
else if (a[0].equals("-toroot")) {
ClearPage.toroot = a[1];
}
@ -214,6 +219,10 @@ public class DroidDoc
}
}
if (!readKnownTagsFiles(knownTags, knownTagsFiles)) {
return false;
}
// read some prefs from the template
if (!readTemplateSettings()) {
return false;
@ -316,6 +325,56 @@ public class DroidDoc
return true;
}
private static boolean readKnownTagsFiles(HashSet<String> knownTags,
ArrayList<String> knownTagsFiles) {
for (String fn: knownTagsFiles) {
BufferedReader in = null;
try {
in = new BufferedReader(new FileReader(fn));
int lineno = 0;
boolean fail = false;
while (true) {
lineno++;
String line = in.readLine();
if (line == null) {
break;
}
line = line.trim();
if (line.length() == 0) {
continue;
} else if (line.charAt(0) == '#') {
continue;
}
String[] words = line.split("\\s+", 2);
if (words.length == 2) {
if (words[1].charAt(0) != '#') {
System.err.println(fn + ":" + lineno
+ ": Only one tag allowed per line: " + line);
fail = true;
continue;
}
}
knownTags.add(words[0]);
System.out.println("Known tag: " + words[0]);
}
if (fail) {
return false;
}
} catch (IOException ex) {
System.err.println("Error reading file: " + fn + " (" + ex.getMessage() + ")");
return false;
} finally {
if (in != null) {
try {
in.close();
} catch (IOException e) {
}
}
}
}
return true;
}
public static String escape(String s) {
if (escapeChars.size() == 0) {
return s;
@ -371,6 +430,9 @@ public class DroidDoc
if (option.equals("-hdf")) {
return 3;
}
if (option.equals("-knowntags")) {
return 2;
}
if (option.equals("-toroot")) {
return 2;
}