Package lyntin :: Module helpmanager :: Class HelpManager
[show private | hide private]
[frames | no frames]

Class HelpManager

Manager --+
          |
         HelpManager


The HelpManager exists on the engine scoping--there is only one per Lyntin instance. It holds a hierarchy of help texts which can be retrieved and perused through via the #help user command. In general, it's best to access the HelpManager instance through the exported module.

Help texts are indexed by an 'fqn' which is a fully-qualified-name. For example, the #alias command would be under 'commands.alias' where 'commands' is the category in the help hierarchy that it goes under and 'alias' is the help text topic name.

Help text can also handle options set in the text in itself. Currently the only option we support is "category". This will be used if the fqn you supply to the addHelp call is lacking a category--for example 'alias'.
Method Summary
  __init__(self, e)
string addHelp(self, fqn, helptext)
Adds a help text to the hierarchy.
tuple of (string, string, string) getHelp(self, fqn)
Retrieves the help topic requested.
(string, list of strings) getNode(self, fqn)
Retrieves the help topic requested.
  removeHelp(self, fqn)
Takes in a fully-qualified name and attempts to remove it from the structure.
  _printTree(self, tree, tab)
Prints out the hierarchy--for debugging purposes.
tuple of (list of strings, string) _split_name(self, fqn)
Takes an fqn and splits it into a series of categories and a help topic name.
  _trimTree(self, tree)
Takes a tree and trims off the branches that don't hold any elements.
    Inherited from Manager
  addSession(self, newsession, basesession)
Tells the manager to create a new session based on another session.
  clear(self, ses)
Removes everything the manager was managing--essentially reinitializes it.
string getInfo(self, ses, text)
Returns information managed by this class.
list of mappings getInfoMappings(self, item, ses)
Returns a list of maps of parameter name -> value that represents all the info this manager is managing for this session.
list of strings getItems(self)
Returns a list of the items that this manager manages.
list of tuples getParameters(self, item)
Returns a list of tuples of the parameters we're storing in this manager and the description of each parameter.
string getStatus(self, ses)
Returns a one-liner status of the state of this manager for a given session.
  removeSession(self, ses)
Tells the manager to remove information regarding the session.

Method Details

addHelp(self, fqn, helptext)

Adds a help text to the hierarchy. Use the 'exported.add_help' and not this directly.
Parameters:
fqn - the fully qualified name
           (type=string)
helptext - the help text
           (type=string)
Returns:
the fqn of the help topic we just added (this can change depending on whether there's a category directive)
           (type=string)
Raises:
ValueError - if the help name or help text are not valid

getHelp(self, fqn)

Retrieves the help topic requested. This is the hard-core attempt at finding help text. It will look for it outright, then try searching, then try black magic.
Parameters:
fqn - the fully qualified name or topic name
           (type=string)
Returns:
A tuple composed of three strings. The first string is error text (if any or empty string if none). The second string is the breadcrumbs trail. The third string is the help text found or a columnized text of what tree elements exist at that level.
           (type=tuple of (string, string, string))

getNode(self, fqn)

Retrieves the help topic requested.

The difference between this and getHelp is that getHelp will do searching and try to find the best topic for what you asked for. This will return the topic at the prescribed place or throw an exception if it doesn't exist. This is better for exporting help topics to a manual of some kind.
Parameters:
fqn - the fully qualified name of the topic being requested
           (type=string)
Returns:
a tuple consisting of the topic data string, and then a list of nodes under this fqn (if it's a category)
           (type=(string, list of strings))
Raises:
ValueError - if the fqn doesn't exist

removeHelp(self, fqn)

Takes in a fully-qualified name and attempts to remove it from the structure.
Parameters:
fqn - the fully qualified name of the help topic to remove
           (type=string)
Raises:
ValueError - if no topic by that fqn exists

_printTree(self, tree=None, tab='')

Prints out the hierarchy--for debugging purposes.

_split_name(self, fqn)

Takes an fqn and splits it into a series of categories and a help topic name. fqn's are delimited by a '.' (period).

It tries to fix up the fqn as well--doing things like removing lyntin command characters from the name (some users type "#help #alias" to view the help on the alias command) and also removing instances of "root" from the beginning of the fqn because it's not needed.
Parameters:
fqn - the fully qualified name to split
           (type=string)
Returns:
the category list and the help topic name
           (type=tuple of (list of strings, string))

_trimTree(self, tree)

Takes a tree and trims off the branches that don't hold any elements. This method is recursive and will call itself at the various branches. It modifies the tree in place.
Parameters:
tree - the map of topics to trim
           (type=dict)

Generated by Epydoc 2.1 on Mon Aug 9 09:17:41 2004 http://epydoc.sf.net