gh-67248: cmd: Sort miscellaneous help topics (#92254)

Closes #67248
This commit is contained in:
Sam Denton 2022-05-03 22:36:52 -05:00 committed by GitHub
parent 9badc86fb7
commit 465fdc02a3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 34 additions and 9 deletions

View file

@ -310,10 +310,10 @@ class Cmd:
names = self.get_names()
cmds_doc = []
cmds_undoc = []
help = {}
topics = set()
for name in names:
if name[:5] == 'help_':
help[name[5:]]=1
topics.add(name[5:])
names.sort()
# There can be duplicates if routines overridden
prevname = ''
@ -323,16 +323,16 @@ class Cmd:
continue
prevname = name
cmd=name[3:]
if cmd in help:
if cmd in topics:
cmds_doc.append(cmd)
del help[cmd]
topics.remove(cmd)
elif getattr(self, name).__doc__:
cmds_doc.append(cmd)
else:
cmds_undoc.append(cmd)
self.stdout.write("%s\n"%str(self.doc_leader))
self.print_topics(self.doc_header, cmds_doc, 15,80)
self.print_topics(self.misc_header, list(help.keys()),15,80)
self.print_topics(self.misc_header, sorted(topics),15,80)
self.print_topics(self.undoc_header, cmds_undoc, 15,80)
def print_topics(self, header, cmds, cmdlen, maxcol):