1   
  2   
  3   
  4   
  5   
  6   
  7   
  8   
  9   
 10   
 11   
 12   
 13   
 14   
 15   
 16   
 17   
 18   
 19   
 20   
 21   
 22   
 23  """The prompt UI help system.""" 
 24   
 25   
 26  import pydoc 
 27  import sys 
 28  from textwrap import wrap 
 29   
 30   
 31  from status import Status; status = Status() 
 32   
 33   
 34   
 35   
 36   
 37  relax_class_help = "This is a python class which contains user functions.  To list these functions, either place a period at the end of class name and hit the tab key, or type 'dir(class_name)'." 
 38   
 39   
 40   
 41   
 42   
 44      text = """\ 
 45  For assistance in using a function, simply type 'help(function)'.  All functions can be viewed by hitting the [TAB] key.  In addition to functions, if 'help(object)' is typed, the help for the python object is returned.  This system is similar to the help function built into the python interpreter, which has been renamed to help_python, with the interactive component removed.  For the interactive python help system, type 'help_python()'. 
 46      """ 
 47   
 49          """String representation of the object. 
 50   
 51          @return:    The help description. 
 52          @rtype:     str 
 53          """ 
 54   
 55           
 56          string = '' 
 57          for line in wrap(self.text, status.text_width): 
 58              string += line + '\n' 
 59   
 60           
 61          return string 
  62   
 63   
 65          """Make the object executable.""" 
 66   
 67           
 68          if len(args) != 1 or isinstance(args[0], str): 
 69              print(self.text) 
 70              return 
 71   
 72           
 73          obj = args[0] 
 74   
 75           
 76          if not hasattr(obj, '__relax_help__') and hasattr(obj, '_build_doc'): 
 77              obj.__relax_help__ = obj._build_doc() 
 78   
 79           
 80          if hasattr(obj, '__relax_help__'): 
 81              pydoc.pager(obj.__relax_help__) 
 82              return 
 83   
 84           
 85          return pydoc.help(*args, **kwds) 
   86   
 87   
 89      text = """\ 
 90  For the interactive python help system, type 'help_python()'.  The help_python function is identical 
 91  to the help function built into the normal python interpreter. 
 92      """ 
 93   
 94   
 97   
 98   
100          return pydoc.help(*args, **kwds) 
  101