Skip to content

Commit 5e53b80

Browse files
author
MarcoFalke
committed
Merge #12820: contrib: Fix check-doc script regexes
0c17e27 init: Remove help text for non-existent -fuzzmessagestest arg (MarcoFalke) 1360844 contrib: Fix check-doc script regexes (MarcoFalke) Pull request description: Fixup the regexes to properly find all used args. The regex should now match all of the getter and setter methods of the `ArgsManager`. See https://dev.visucore.com/bitcoin/doxygen/class_args_manager.html#pub-methods Before: ``` Args used : 159 Args documented : 188 Args undocumented: 0 Args unknown : 29 ``` After: ``` Args used : 183 Args documented : 188 Args undocumented: 0 Args unknown : 5 ``` Tree-SHA512: 1a7fb7ea55b2f6030358a1055d8f2c19b31f69d0603be0b009e6e603564014b4e2bb824357c9d43d0fba3ce7159b7c4e7eaa60b3f962053d94f73d0e626294fc
2 parents de7e586 + 0c17e27 commit 5e53b80

File tree

2 files changed

+23
-23
lines changed

2 files changed

+23
-23
lines changed

contrib/devtools/check-doc.py

Lines changed: 22 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -16,31 +16,33 @@
1616

1717
FOLDER_GREP = 'src'
1818
FOLDER_TEST = 'src/test/'
19+
REGEX_ARG = '(?:ForceSet|SoftSet|Get|Is)(?:Bool)?Args?(?:Set)?\("(-[^"]+)"'
20+
REGEX_DOC = 'HelpMessageOpt\("(-[^"=]+?)(?:=|")'
1921
CMD_ROOT_DIR = '`git rev-parse --show-toplevel`/{}'.format(FOLDER_GREP)
20-
CMD_GREP_ARGS = r"egrep -r -I '(map(Multi)?Args(\.count\(|\[)|Get(Bool)?Arg\()\"\-[^\"]+?\"' {} | grep -v '{}'".format(CMD_ROOT_DIR, FOLDER_TEST)
21-
CMD_GREP_DOCS = r"egrep -r -I 'HelpMessageOpt\(\"\-[^\"=]+?(=|\")' {}".format(CMD_ROOT_DIR)
22-
REGEX_ARG = re.compile(r'(?:map(?:Multi)?Args(?:\.count\(|\[)|Get(?:Bool)?Arg\()\"(\-[^\"]+?)\"')
23-
REGEX_DOC = re.compile(r'HelpMessageOpt\(\"(\-[^\"=]+?)(?:=|\")')
22+
CMD_GREP_ARGS = r"git grep --perl-regexp '{}' -- {} ':(exclude){}'".format(REGEX_ARG, CMD_ROOT_DIR, FOLDER_TEST)
23+
CMD_GREP_DOCS = r"git grep --perl-regexp '{}' {}".format(REGEX_DOC, CMD_ROOT_DIR)
2424
# list unsupported, deprecated and duplicate args as they need no documentation
2525
SET_DOC_OPTIONAL = set(['-rpcssl', '-benchmark', '-h', '-help', '-socks', '-tor', '-debugnet', '-whitelistalwaysrelay', '-prematurewitness', '-walletprematurewitness', '-promiscuousmempoolflags', '-blockminsize', '-dbcrashratio', '-forcecompactdb', '-usehd'])
2626

27+
2728
def main():
28-
used = check_output(CMD_GREP_ARGS, shell=True, universal_newlines=True)
29-
docd = check_output(CMD_GREP_DOCS, shell=True, universal_newlines=True)
30-
31-
args_used = set(re.findall(REGEX_ARG,used))
32-
args_docd = set(re.findall(REGEX_DOC,docd)).union(SET_DOC_OPTIONAL)
33-
args_need_doc = args_used.difference(args_docd)
34-
args_unknown = args_docd.difference(args_used)
35-
36-
print("Args used : {}".format(len(args_used)))
37-
print("Args documented : {}".format(len(args_docd)))
38-
print("Args undocumented: {}".format(len(args_need_doc)))
39-
print(args_need_doc)
40-
print("Args unknown : {}".format(len(args_unknown)))
41-
print(args_unknown)
42-
43-
sys.exit(len(args_need_doc))
29+
used = check_output(CMD_GREP_ARGS, shell=True, universal_newlines=True)
30+
docd = check_output(CMD_GREP_DOCS, shell=True, universal_newlines=True)
31+
32+
args_used = set(re.findall(re.compile(REGEX_ARG), used))
33+
args_docd = set(re.findall(re.compile(REGEX_DOC), docd)).union(SET_DOC_OPTIONAL)
34+
args_need_doc = args_used.difference(args_docd)
35+
args_unknown = args_docd.difference(args_used)
36+
37+
print("Args used : {}".format(len(args_used)))
38+
print("Args documented : {}".format(len(args_docd)))
39+
print("Args undocumented: {}".format(len(args_need_doc)))
40+
print(args_need_doc)
41+
print("Args unknown : {}".format(len(args_unknown)))
42+
print(args_unknown)
43+
44+
sys.exit(len(args_need_doc))
45+
4446

4547
if __name__ == "__main__":
4648
main()

src/init.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -420,8 +420,7 @@ std::string HelpMessage(HelpMessageMode mode)
420420
#endif
421421

422422
strUsage += HelpMessageGroup(_("Debugging/Testing options:"));
423-
if (showDebug)
424-
{
423+
if (showDebug) {
425424
strUsage += HelpMessageOpt("-checkblocks=<n>", strprintf(_("How many blocks to check at startup (default: %u, 0 = all)"), DEFAULT_CHECKBLOCKS));
426425
strUsage += HelpMessageOpt("-checklevel=<n>", strprintf(_("How thorough the block verification of -checkblocks is (0-4, default: %u)"), DEFAULT_CHECKLEVEL));
427426
strUsage += HelpMessageOpt("-checkblockindex", strprintf("Do a full consistency check for mapBlockIndex, setBlockIndexCandidates, chainActive and mapBlocksUnlinked occasionally. (default: %u)", defaultChainParams->DefaultConsistencyChecks()));
@@ -431,7 +430,6 @@ std::string HelpMessage(HelpMessageMode mode)
431430
strUsage += HelpMessageOpt("-deprecatedrpc=<method>", "Allows deprecated RPC method(s) to be used");
432431
strUsage += HelpMessageOpt("-testsafemode", strprintf("Force safe mode (default: %u)", DEFAULT_TESTSAFEMODE));
433432
strUsage += HelpMessageOpt("-dropmessagestest=<n>", "Randomly drop 1 of every <n> network messages");
434-
strUsage += HelpMessageOpt("-fuzzmessagestest=<n>", "Randomly fuzz 1 of every <n> network messages");
435433
strUsage += HelpMessageOpt("-stopafterblockimport", strprintf("Stop running after importing blocks from disk (default: %u)", DEFAULT_STOPAFTERBLOCKIMPORT));
436434
strUsage += HelpMessageOpt("-stopatheight", strprintf("Stop running after reaching the given height in the main chain (default: %u)", DEFAULT_STOPATHEIGHT));
437435

0 commit comments

Comments
 (0)