Terry J. Reedy added the comment:

cmd.Cmd has a documented do_help(self, arg) method (written in 2000).  If arg 
is '', it prints
1. Documented commands (do_x with help_x or do_x.__doc__ != ''), sorted
2. Other help topics (help_y with no do_y), unsorted
3. Undocumented commands (do_ without no help_x and no do_x.__doc__), sorted

The dict called 'help' (which should be a set, and might better be called 
'topics') ends up with a member for each help_y topic without a do_y command.  
Not sorting the keys is at least a design bug.  Leaving users aside, it makes 
do_help unpredictable and hard to test.  Our test.test_cmd omits misc help 
topics.  In verbose mode, it prints

Trying:
    mycmd.do_help("")
Expecting:
    <BLANKLINE>
    Documented commands (type help <topic>):
    ========================================
    add  help
    <BLANKLINE>
    Undocumented commands:
    ======================
    exit  shell
    <BLANKLINE>
ok

As near as I can tell, text_cmd would still pass if Misc topics were removed 
and never printed.  Topics can only be added to the test above is they are 
dependably ordered (ie, sorted).

---
This '?' or 'help' case is also not properly documented, but should be.  3.4 
cmd.__doc__ has this mishmash:

"With no arguments, it lists all topics with defined help_ functions, broken 
into up to three topics; documented commands, miscellaneous help topics, and 
undocumented commands."

3.4 doc says "With no argument, do_help() lists all available help topics (that 
is, all commands with corresponding help_*() methods or commands that have 
docstrings), and also lists any undocumented commands."

----------
nosy: +terry.reedy
stage:  -> test needed
type:  -> enhancement

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue23059>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to