gendynapi.py: always check comment formatting of the public api
This commit is contained in:
@@ -335,12 +335,19 @@ def full_API_json():
|
|||||||
json.dump(full_API, f, indent=4, sort_keys=True)
|
json.dump(full_API, f, indent=4, sort_keys=True)
|
||||||
print("dump API to '%s'" % filename);
|
print("dump API to '%s'" % filename);
|
||||||
|
|
||||||
# Dump API into a json file
|
# Check public function comments are correct
|
||||||
def check_comment():
|
def check_comment_header():
|
||||||
if args.check_comment:
|
if not check_comment_header.done:
|
||||||
print("check comment formatting");
|
check_comment_header.done = True
|
||||||
|
print("")
|
||||||
|
print("Please fix following warning(s):")
|
||||||
|
print("-------------------------------")
|
||||||
|
|
||||||
|
|
||||||
|
def check_comment():
|
||||||
|
|
||||||
|
check_comment_header.done = False
|
||||||
|
|
||||||
# Check \param
|
# Check \param
|
||||||
for i in full_API:
|
for i in full_API:
|
||||||
comment = i['comment']
|
comment = i['comment']
|
||||||
@@ -357,7 +364,17 @@ def check_comment():
|
|||||||
# skip SDL_stdinc.h
|
# skip SDL_stdinc.h
|
||||||
if header != 'SDL_stdinc.h':
|
if header != 'SDL_stdinc.h':
|
||||||
# Warning mismatch \param and function prototype
|
# Warning mismatch \param and function prototype
|
||||||
print("%s: %s() %d '\\param'' but expected %d" % (header, name, count, expected));
|
check_comment_header()
|
||||||
|
print(" In file %s: function %s() has %d '\\param' but expected %d" % (header, name, count, expected));
|
||||||
|
|
||||||
|
# Warning check \param uses the correct parameter name
|
||||||
|
# skip SDL_stdinc.h
|
||||||
|
if header != 'SDL_stdinc.h':
|
||||||
|
parameter_name = i['parameter_name']
|
||||||
|
for n in parameter_name:
|
||||||
|
if n != "" and "\\param " + n not in comment:
|
||||||
|
check_comment_header()
|
||||||
|
print(" In file %s: function %s() missing '\\param %s'" % (header, name, n));
|
||||||
|
|
||||||
|
|
||||||
# Check \returns
|
# Check \returns
|
||||||
@@ -376,7 +393,8 @@ def check_comment():
|
|||||||
# skip SDL_stdinc.h
|
# skip SDL_stdinc.h
|
||||||
if header != 'SDL_stdinc.h':
|
if header != 'SDL_stdinc.h':
|
||||||
# Warning mismatch \param and function prototype
|
# Warning mismatch \param and function prototype
|
||||||
print("%s: %s() %d '\\returns'' but expected %d" % (header, name, count, expected));
|
check_comment_header()
|
||||||
|
print(" In file %s: function %s() has %d '\\returns' but expected %d" % (header, name, count, expected));
|
||||||
|
|
||||||
# Check \since
|
# Check \since
|
||||||
for i in full_API:
|
for i in full_API:
|
||||||
@@ -391,10 +409,8 @@ def check_comment():
|
|||||||
# skip SDL_stdinc.h
|
# skip SDL_stdinc.h
|
||||||
if header != 'SDL_stdinc.h':
|
if header != 'SDL_stdinc.h':
|
||||||
# Warning mismatch \param and function prototype
|
# Warning mismatch \param and function prototype
|
||||||
print("%s: %s() %d '\\since'' but expected %d" % (header, name, count, expected));
|
check_comment_header()
|
||||||
|
print(" In file %s: function %s() has %d '\\since' but expected %d" % (header, name, count, expected));
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -529,7 +545,6 @@ if __name__ == '__main__':
|
|||||||
|
|
||||||
parser = argparse.ArgumentParser()
|
parser = argparse.ArgumentParser()
|
||||||
parser.add_argument('--dump', help='output all SDL API into a .json file', action='store_true')
|
parser.add_argument('--dump', help='output all SDL API into a .json file', action='store_true')
|
||||||
parser.add_argument('--check-comment', help='check comment formatting', action='store_true')
|
|
||||||
parser.add_argument('--debug', help='add debug traces', action='store_true')
|
parser.add_argument('--debug', help='add debug traces', action='store_true')
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user