add option to @hide classes generated from .logtags files
Generate a javadoc @hide comment on the class when "option javadoc_hide true" is specified in the input .logtags file.
This commit is contained in:
parent
3a59b2ceb9
commit
5ae770fc0e
|
@ -93,6 +93,18 @@ class TagFile(object):
|
||||||
self.AddError(str(e))
|
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):
|
def WriteOutput(output_file, data):
|
||||||
"""Write 'data' to the given output filename (which may be None to
|
"""Write 'data' to the given output filename (which may be None to
|
||||||
indicate stdout). Emit an error message and die on any failure.
|
indicate stdout). Emit an error message and die on any failure.
|
||||||
|
|
|
@ -60,6 +60,10 @@ tagfile = event_log_tags.TagFile(fn)
|
||||||
if "java_package" not in tagfile.options:
|
if "java_package" not in tagfile.options:
|
||||||
tagfile.AddError("java_package option not specified", linenum=0)
|
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:
|
if tagfile.errors:
|
||||||
for fn, ln, msg in tagfile.errors:
|
for fn, ln, msg in tagfile.errors:
|
||||||
print >> sys.stderr, "%s:%d: error: %s" % (fn, ln, msg)
|
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],))
|
buffer.write("package %s;\n\n" % (tagfile.options["java_package"][0],))
|
||||||
|
|
||||||
basename, _ = os.path.splitext(os.path.basename(fn))
|
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("public class %s {\n" % (basename,))
|
||||||
buffer.write(" private %s() { } // don't instantiate\n" % (basename,))
|
buffer.write(" private %s() { } // don't instantiate\n" % (basename,))
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue