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  from textwrap import wrap 
 28   
 29   
 30  from status import Status; status = Status() 
 31   
 32   
 33   
 34   
 35   
 36  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)'." 
 37   
 38   
 39   
 40   
 41   
 43      text = """\ 
 44  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()'. 
 45      """ 
 46   
 48          """String representation of the object. 
 49   
 50          @return:    The help description. 
 51          @rtype:     str 
 52          """ 
 53   
 54           
 55          string = '' 
 56          for line in wrap(self.text, status.text_width): 
 57              string += line + '\n' 
 58   
 59           
 60          return string 
  61   
 62   
 64          """Make the object executable.""" 
 65   
 66           
 67          if len(args) != 1 or isinstance(args[0], str): 
 68              print(self.text) 
 69              return 
 70   
 71           
 72          obj = args[0] 
 73   
 74           
 75          if not hasattr(obj, '__relax_help__') and hasattr(obj, '_build_doc'): 
 76              obj.__relax_help__ = obj._build_doc() 
 77   
 78           
 79          if hasattr(obj, '__relax_help__'): 
 80              pydoc.pager(obj.__relax_help__) 
 81              return 
 82   
 83           
 84          return pydoc.help(*args, **kwds) 
   85   
 86   
 88      text = """\ 
 89  For the interactive python help system, type 'help_python()'.  The help_python function is identical 
 90  to the help function built into the normal python interpreter. 
 91      """ 
 92   
 93   
 96   
 97   
 99          return pydoc.help(*args, **kwds) 
  100