Changeset View
Changeset View
Standalone View
Standalone View
test/lint/check-doc.py
Show All 18 Lines | |||||
TOP_LEVEL = 'git rev-parse --show-toplevel' | TOP_LEVEL = 'git rev-parse --show-toplevel' | ||||
FOLDER_SRC = '/src/**/' | FOLDER_SRC = '/src/**/' | ||||
FOLDER_TEST = '/src/**/test/' | FOLDER_TEST = '/src/**/test/' | ||||
EXTENSIONS = ["*.c", "*.h", "*.cpp", "*.cc", "*.hpp"] | EXTENSIONS = ["*.c", "*.h", "*.cpp", "*.cc", "*.hpp"] | ||||
REGEX_ARG = r'(?:ForceSet|SoftSet|Get|Is)(?:Bool)?Args?(?:Set)?\(\s*"(-[^"]+)"' | REGEX_ARG = r'(?:ForceSet|SoftSet|Get|Is)(?:Bool)?Args?(?:Set)?\(\s*"(-[^"]+)"' | ||||
REGEX_DOC = r'AddArg\(\s*"(-[^"=]+?)(?:=|")' | REGEX_DOC = r'AddArg\(\s*"(-[^"=]+?)(?:=|")' | ||||
# list unsupported, deprecated and duplicate args as they need no documentation | |||||
SET_DOC_OPTIONAL = set(['-benchmark', | |||||
'-blockminsize', | |||||
'-dbcrashratio', | |||||
'-debugnet', | |||||
'-forcecompactdb', | |||||
# TODO remove after the Nov 2019 upgrade | |||||
'-gravitonactivationtime', | |||||
'-h', | |||||
'-help', | |||||
'-parkdeepreorg', | |||||
'-replayprotectionactivationtime', | |||||
'-rpcssl', | |||||
'-socks', | |||||
'-tor', | |||||
'-usehd', | |||||
'-whitelistalwaysrelay']) | |||||
# list false positive unknows arguments | # list false positive unknows arguments | ||||
SET_FALSE_POSITIVE_UNKNOWNS = set(['-zmqpubhashblock', | SET_FALSE_POSITIVE_UNKNOWNS = set(['-zmqpubhashblock', | ||||
'-zmqpubhashtx', | '-zmqpubhashtx', | ||||
'-zmqpubrawblock', | '-zmqpubrawblock', | ||||
'-zmqpubrawtx']) | '-zmqpubrawtx']) | ||||
def main(): | def main(): | ||||
Show All 14 Lines | def main(): | ||||
args_docd = set() | args_docd = set() | ||||
for file in files: | for file in files: | ||||
with open(file, 'r') as f: | with open(file, 'r') as f: | ||||
content = f.read() | content = f.read() | ||||
args_used |= set(re.findall(re.compile(REGEX_ARG), content)) | args_used |= set(re.findall(re.compile(REGEX_ARG), content)) | ||||
args_docd |= set(re.findall(re.compile(REGEX_DOC), content)) | args_docd |= set(re.findall(re.compile(REGEX_DOC), content)) | ||||
args_used |= SET_FALSE_POSITIVE_UNKNOWNS | args_used |= SET_FALSE_POSITIVE_UNKNOWNS | ||||
args_need_doc = args_used - args_docd - SET_DOC_OPTIONAL | args_need_doc = args_used - args_docd | ||||
args_unknown = args_docd - args_used | args_unknown = args_docd - args_used | ||||
pp = PrettyPrinter() | pp = PrettyPrinter() | ||||
print("Args used : {}".format(len(args_used))) | print("Args used : {}".format(len(args_used))) | ||||
print("Args documented : {}".format(len(args_docd))) | print("Args documented : {}".format(len(args_docd))) | ||||
print("Args undocumented: {} ({} don't need documentation)".format( | print("Args undocumented: {}".format(len(args_need_doc))) | ||||
len(args_need_doc), len(SET_DOC_OPTIONAL))) | |||||
pp.pprint(args_need_doc) | pp.pprint(args_need_doc) | ||||
print("Args unknown : {}".format(len(args_unknown))) | print("Args unknown : {}".format(len(args_unknown))) | ||||
pp.pprint(args_unknown) | pp.pprint(args_unknown) | ||||
if __name__ == "__main__": | if __name__ == "__main__": | ||||
main() | main() |