contrib: Fix check-doc script regexes
This commit is contained in:
parent
624bee9659
commit
136084470c
1 changed files with 19 additions and 17 deletions
|
@ -16,20 +16,21 @@ import sys
|
||||||
|
|
||||||
FOLDER_GREP = 'src'
|
FOLDER_GREP = 'src'
|
||||||
FOLDER_TEST = 'src/test/'
|
FOLDER_TEST = 'src/test/'
|
||||||
|
REGEX_ARG = '(?:ForceSet|SoftSet|Get|Is)(?:Bool)?Args?(?:Set)?\("(-[^"]+)"'
|
||||||
|
REGEX_DOC = 'HelpMessageOpt\("(-[^"=]+?)(?:=|")'
|
||||||
CMD_ROOT_DIR = '`git rev-parse --show-toplevel`/{}'.format(FOLDER_GREP)
|
CMD_ROOT_DIR = '`git rev-parse --show-toplevel`/{}'.format(FOLDER_GREP)
|
||||||
CMD_GREP_ARGS = r"egrep -r -I '(map(Multi)?Args(\.count\(|\[)|Get(Bool)?Arg\()\"\-[^\"]+?\"' {} | grep -v '{}'".format(CMD_ROOT_DIR, FOLDER_TEST)
|
CMD_GREP_ARGS = r"git grep --perl-regexp '{}' -- {} ':(exclude){}'".format(REGEX_ARG, CMD_ROOT_DIR, FOLDER_TEST)
|
||||||
CMD_GREP_DOCS = r"egrep -r -I 'HelpMessageOpt\(\"\-[^\"=]+?(=|\")' {}".format(CMD_ROOT_DIR)
|
CMD_GREP_DOCS = r"git grep --perl-regexp '{}' {}".format(REGEX_DOC, CMD_ROOT_DIR)
|
||||||
REGEX_ARG = re.compile(r'(?:map(?:Multi)?Args(?:\.count\(|\[)|Get(?:Bool)?Arg\()\"(\-[^\"]+?)\"')
|
|
||||||
REGEX_DOC = re.compile(r'HelpMessageOpt\(\"(\-[^\"=]+?)(?:=|\")')
|
|
||||||
# list unsupported, deprecated and duplicate args as they need no documentation
|
# list unsupported, deprecated and duplicate args as they need no documentation
|
||||||
SET_DOC_OPTIONAL = set(['-rpcssl', '-benchmark', '-h', '-help', '-socks', '-tor', '-debugnet', '-whitelistalwaysrelay', '-prematurewitness', '-walletprematurewitness', '-promiscuousmempoolflags', '-blockminsize', '-dbcrashratio', '-forcecompactdb', '-usehd'])
|
SET_DOC_OPTIONAL = set(['-rpcssl', '-benchmark', '-h', '-help', '-socks', '-tor', '-debugnet', '-whitelistalwaysrelay', '-prematurewitness', '-walletprematurewitness', '-promiscuousmempoolflags', '-blockminsize', '-dbcrashratio', '-forcecompactdb', '-usehd'])
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
used = check_output(CMD_GREP_ARGS, shell=True, universal_newlines=True)
|
used = check_output(CMD_GREP_ARGS, shell=True, universal_newlines=True)
|
||||||
docd = check_output(CMD_GREP_DOCS, shell=True, universal_newlines=True)
|
docd = check_output(CMD_GREP_DOCS, shell=True, universal_newlines=True)
|
||||||
|
|
||||||
args_used = set(re.findall(REGEX_ARG,used))
|
args_used = set(re.findall(re.compile(REGEX_ARG), used))
|
||||||
args_docd = set(re.findall(REGEX_DOC,docd)).union(SET_DOC_OPTIONAL)
|
args_docd = set(re.findall(re.compile(REGEX_DOC), docd)).union(SET_DOC_OPTIONAL)
|
||||||
args_need_doc = args_used.difference(args_docd)
|
args_need_doc = args_used.difference(args_docd)
|
||||||
args_unknown = args_docd.difference(args_used)
|
args_unknown = args_docd.difference(args_used)
|
||||||
|
|
||||||
|
@ -42,5 +43,6 @@ def main():
|
||||||
|
|
||||||
sys.exit(len(args_need_doc))
|
sys.exit(len(args_need_doc))
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
main()
|
main()
|
||||||
|
|
Loading…
Reference in a new issue