OSDN Git Service

add option to @hide classes generated from .logtags files
authorDoug Zongker <dougz@android.com>
Tue, 8 Dec 2009 20:45:02 +0000 (12:45 -0800)
committerDoug Zongker <dougz@android.com>
Wed, 9 Dec 2009 20:31:00 +0000 (12:31 -0800)
Generate a javadoc @hide comment on the class when "option
javadoc_hide true" is specified in the input .logtags file.

tools/event_log_tags.py
tools/java-event-log-tags.py

index fc05aff..4e6d960 100644 (file)
@@ -93,6 +93,18 @@ class TagFile(object):
       self.AddError(str(e))
 
 
+def BooleanFromString(s):
+  """Interpret 's' as a boolean and return its value.  Raise
+  ValueError if it's not something we can interpret as true or
+  false."""
+  s = s.lower()
+  if s in ("true", "t", "1", "on", "yes", "y"):
+    return True
+  if s in ("false", "f", "0", "off", "no", "n"):
+    return False
+  raise ValueError("'%s' not a valid boolean" % (s,))
+
+
 def WriteOutput(output_file, data):
   """Write 'data' to the given output filename (which may be None to
   indicate stdout).  Emit an error message and die on any failure.
index f8374b0..20b8ca4 100755 (executable)
@@ -60,6 +60,10 @@ tagfile = event_log_tags.TagFile(fn)
 if "java_package" not in tagfile.options:
   tagfile.AddError("java_package option not specified", linenum=0)
 
+hide = True
+if "javadoc_hide" in tagfile.options:
+  hide = event_log_tags.BooleanFromString(tagfile.options["javadoc_hide"][0])
+
 if tagfile.errors:
   for fn, ln, msg in tagfile.errors:
     print >> sys.stderr, "%s:%d: error: %s" % (fn, ln, msg)
@@ -73,6 +77,11 @@ buffer.write("/* This file is auto-generated.  DO NOT MODIFY.\n"
 buffer.write("package %s;\n\n" % (tagfile.options["java_package"][0],))
 
 basename, _ = os.path.splitext(os.path.basename(fn))
+
+if hide:
+  buffer.write("/**\n"
+               " * @hide\n"
+               " */\n")
 buffer.write("public class %s {\n" % (basename,))
 buffer.write("  private %s() { }  // don't instantiate\n" % (basename,))