@@ -586,7 +586,7 @@ def _complete_expression(self, text, line, begidx, endidx):
586586 # Return true to exit from the command loop
587587
588588 def do_commands (self , arg ):
589- """commands [bpnumber]
589+ """(Pdb) commands [bpnumber]
590590 (com) ...
591591 (com) end
592592 (Pdb)
@@ -672,6 +672,7 @@ def do_commands(self, arg):
672672
673673 def do_break (self , arg , temporary = 0 ):
674674 """b(reak) [ ([filename:]lineno | function) [, condition] ]
675+
675676 Without argument, list all breaks.
676677
677678 With a line number argument, set a break at this line in the
@@ -780,6 +781,7 @@ def defaultFile(self):
780781
781782 def do_tbreak (self , arg ):
782783 """tbreak [ ([filename:]lineno | function) [, condition] ]
784+
783785 Same arguments as break, but sets a temporary breakpoint: it
784786 is automatically deleted when first hit.
785787 """
@@ -844,6 +846,7 @@ def checkline(self, filename, lineno):
844846
845847 def do_enable (self , arg ):
846848 """enable bpnumber [bpnumber ...]
849+
847850 Enables the breakpoints given as a space separated list of
848851 breakpoint numbers.
849852 """
@@ -861,6 +864,7 @@ def do_enable(self, arg):
861864
862865 def do_disable (self , arg ):
863866 """disable bpnumber [bpnumber ...]
867+
864868 Disables the breakpoints given as a space separated list of
865869 breakpoint numbers. Disabling a breakpoint means it cannot
866870 cause the program to stop execution, but unlike clearing a
@@ -881,6 +885,7 @@ def do_disable(self, arg):
881885
882886 def do_condition (self , arg ):
883887 """condition bpnumber [condition]
888+
884889 Set a new condition for the breakpoint, an expression which
885890 must evaluate to true before the breakpoint is honored. If
886891 condition is absent, any existing condition is removed; i.e.,
@@ -911,6 +916,7 @@ def do_condition(self, arg):
911916
912917 def do_ignore (self , arg ):
913918 """ignore bpnumber [count]
919+
914920 Set the ignore count for the given breakpoint number. If
915921 count is omitted, the ignore count is set to 0. A breakpoint
916922 becomes active when the ignore count is zero. When non-zero,
@@ -945,7 +951,8 @@ def do_ignore(self, arg):
945951 complete_ignore = _complete_bpnumber
946952
947953 def do_clear (self , arg ):
948- """cl(ear) filename:lineno\n cl(ear) [bpnumber [bpnumber...]]
954+ """cl(ear) [filename:lineno | bpnumber ...]
955+
949956 With a space separated list of breakpoint numbers, clear
950957 those breakpoints. Without argument, clear all breaks (but
951958 first ask confirmation). With a filename:lineno argument,
@@ -997,6 +1004,7 @@ def do_clear(self, arg):
9971004
9981005 def do_where (self , arg ):
9991006 """w(here)
1007+
10001008 Print a stack trace, with the most recent frame at the bottom.
10011009 An arrow indicates the "current frame", which determines the
10021010 context of most commands. 'bt' is an alias for this command.
@@ -1015,6 +1023,7 @@ def _select_frame(self, number):
10151023
10161024 def do_up (self , arg ):
10171025 """u(p) [count]
1026+
10181027 Move the current frame count (default one) levels up in the
10191028 stack trace (to an older frame).
10201029 """
@@ -1035,6 +1044,7 @@ def do_up(self, arg):
10351044
10361045 def do_down (self , arg ):
10371046 """d(own) [count]
1047+
10381048 Move the current frame count (default one) levels down in the
10391049 stack trace (to a newer frame).
10401050 """
@@ -1055,6 +1065,7 @@ def do_down(self, arg):
10551065
10561066 def do_until (self , arg ):
10571067 """unt(il) [lineno]
1068+
10581069 Without argument, continue execution until the line with a
10591070 number greater than the current one is reached. With a line
10601071 number, continue execution until a line with a number greater
@@ -1079,6 +1090,7 @@ def do_until(self, arg):
10791090
10801091 def do_step (self , arg ):
10811092 """s(tep)
1093+
10821094 Execute the current line, stop at the first possible occasion
10831095 (either in a function that is called or in the current
10841096 function).
@@ -1089,6 +1101,7 @@ def do_step(self, arg):
10891101
10901102 def do_next (self , arg ):
10911103 """n(ext)
1104+
10921105 Continue execution until the next line in the current function
10931106 is reached or it returns.
10941107 """
@@ -1098,6 +1111,7 @@ def do_next(self, arg):
10981111
10991112 def do_run (self , arg ):
11001113 """run [args...]
1114+
11011115 Restart the debugged python program. If a string is supplied
11021116 it is split with "shlex", and the result is used as the new
11031117 sys.argv. History, breakpoints, actions and debugger options
@@ -1119,6 +1133,7 @@ def do_run(self, arg):
11191133
11201134 def do_return (self , arg ):
11211135 """r(eturn)
1136+
11221137 Continue execution until the current function returns.
11231138 """
11241139 self .set_return (self .curframe )
@@ -1127,6 +1142,7 @@ def do_return(self, arg):
11271142
11281143 def do_continue (self , arg ):
11291144 """c(ont(inue))
1145+
11301146 Continue execution, only stop when a breakpoint is encountered.
11311147 """
11321148 if not self .nosigint :
@@ -1145,6 +1161,7 @@ def do_continue(self, arg):
11451161
11461162 def do_jump (self , arg ):
11471163 """j(ump) lineno
1164+
11481165 Set the next line that will be executed. Only available in
11491166 the bottom-most frame. This lets you jump back and execute
11501167 code again, or jump forward to skip code that you don't want
@@ -1174,6 +1191,7 @@ def do_jump(self, arg):
11741191
11751192 def do_debug (self , arg ):
11761193 """debug code
1194+
11771195 Enter a recursive debugger that steps through the code
11781196 argument (which is an arbitrary expression or statement to be
11791197 executed in the current environment).
@@ -1195,7 +1213,8 @@ def do_debug(self, arg):
11951213 complete_debug = _complete_expression
11961214
11971215 def do_quit (self , arg ):
1198- """q(uit)\n exit
1216+ """q(uit) | exit
1217+
11991218 Quit from the debugger. The program being executed is aborted.
12001219 """
12011220 self ._user_requested_quit = True
@@ -1207,6 +1226,7 @@ def do_quit(self, arg):
12071226
12081227 def do_EOF (self , arg ):
12091228 """EOF
1229+
12101230 Handles the receipt of EOF as a command.
12111231 """
12121232 self .message ('' )
@@ -1216,6 +1236,7 @@ def do_EOF(self, arg):
12161236
12171237 def do_args (self , arg ):
12181238 """a(rgs)
1239+
12191240 Print the argument list of the current function.
12201241 """
12211242 co = self .curframe .f_code
@@ -1233,6 +1254,7 @@ def do_args(self, arg):
12331254
12341255 def do_retval (self , arg ):
12351256 """retval
1257+
12361258 Print the return value for the last return of a function.
12371259 """
12381260 if '__return__' in self .curframe_locals :
@@ -1273,12 +1295,14 @@ def _msg_val_func(self, arg, func):
12731295
12741296 def do_p (self , arg ):
12751297 """p expression
1298+
12761299 Print the value of the expression.
12771300 """
12781301 self ._msg_val_func (arg , repr )
12791302
12801303 def do_pp (self , arg ):
12811304 """pp expression
1305+
12821306 Pretty-print the value of the expression.
12831307 """
12841308 self ._msg_val_func (arg , pprint .pformat )
@@ -1288,7 +1312,7 @@ def do_pp(self, arg):
12881312 complete_pp = _complete_expression
12891313
12901314 def do_list (self , arg ):
1291- """l(ist) [first [, last] | .]
1315+ """l(ist) [first[, last] | .]
12921316
12931317 List source code for the current file. Without arguments,
12941318 list 11 lines around the current line or continue the previous
@@ -1345,7 +1369,8 @@ def do_list(self, arg):
13451369 do_l = do_list
13461370
13471371 def do_longlist (self , arg ):
1348- """longlist | ll
1372+ """ll | longlist
1373+
13491374 List the whole source code for the current function or frame.
13501375 """
13511376 filename = self .curframe .f_code .co_filename
@@ -1360,6 +1385,7 @@ def do_longlist(self, arg):
13601385
13611386 def do_source (self , arg ):
13621387 """source expression
1388+
13631389 Try to get source code for the given object and display it.
13641390 """
13651391 try :
@@ -1397,7 +1423,8 @@ def _print_lines(self, lines, start, breaks=(), frame=None):
13971423 self .message (s + '\t ' + line .rstrip ())
13981424
13991425 def do_whatis (self , arg ):
1400- """whatis arg
1426+ """whatis expression
1427+
14011428 Print the type of the argument.
14021429 """
14031430 try :
@@ -1485,7 +1512,8 @@ def do_interact(self, arg):
14851512 code .interact ("*interactive*" , local = ns )
14861513
14871514 def do_alias (self , arg ):
1488- """alias [name [command [parameter parameter ...] ]]
1515+ """alias [name [command]]
1516+
14891517 Create an alias called 'name' that executes 'command'. The
14901518 command must *not* be enclosed in quotes. Replaceable
14911519 parameters can be indicated by %1, %2, and so on, while %* is
@@ -1521,6 +1549,7 @@ def do_alias(self, arg):
15211549
15221550 def do_unalias (self , arg ):
15231551 """unalias name
1552+
15241553 Delete the specified alias.
15251554 """
15261555 args = arg .split ()
@@ -1563,6 +1592,7 @@ def print_stack_entry(self, frame_lineno, prompt_prefix=line_prefix):
15631592
15641593 def do_help (self , arg ):
15651594 """h(elp)
1595+
15661596 Without argument, print the list of available commands.
15671597 With a command name as argument, print help about that command.
15681598 "help pdb" shows the full pdb documentation.
@@ -1586,12 +1616,13 @@ def do_help(self, arg):
15861616 if command .__doc__ is None :
15871617 self .error ('No help for %r; __doc__ string missing' % arg )
15881618 return
1589- self .message (command .__doc__ . rstrip ( ))
1619+ self .message (self . _help_message_from_doc ( command .__doc__ ))
15901620
15911621 do_h = do_help
15921622
15931623 def help_exec (self ):
15941624 """(!) statement
1625+
15951626 Execute the (one-line) statement in the context of the current
15961627 stack frame. The exclamation point can be omitted unless the
15971628 first word of the statement resembles a debugger command. To
@@ -1672,6 +1703,26 @@ def _getsourcelines(self, obj):
16721703 lineno = max (1 , lineno )
16731704 return lines , lineno
16741705
1706+ def _help_message_from_doc (self , doc ):
1707+ lines = [line .strip () for line in doc .rstrip ().splitlines ()]
1708+ if not lines :
1709+ return "No help message found."
1710+ if "" in lines :
1711+ usage_end = lines .index ("" )
1712+ else :
1713+ usage_end = 1
1714+ formatted = []
1715+ indent = " " * len (self .prompt )
1716+ for i , line in enumerate (lines ):
1717+ if i == 0 :
1718+ prefix = "Usage: "
1719+ elif i < usage_end :
1720+ prefix = " "
1721+ else :
1722+ prefix = ""
1723+ formatted .append (indent + prefix + line )
1724+ return "\n " .join (formatted )
1725+
16751726# Collect all command help into docstring, if not run with -OO
16761727
16771728if __doc__ is not None :
0 commit comments