PLearn 0.1
Static Public Member Functions | Static Private Member Functions | Static Private Attributes
PLearn::HelpSystem Struct Reference

#include <HelpSystem.h>

Collaboration diagram for PLearn::HelpSystem:
Collaboration graph
[legend]

List of all members.

Static Public Member Functions

static vector< string > listCommands ()
 Help on Commands.
static string helpCommands ()
 Returns a text list of all plearn command names.
static string helpOnCommand (const string &commandname)
 Will return full help on the given command.
static string helpCommandsHTML ()
 Returns a list of all plearn commands as an HTML page.
static string helpOnCommandHTML (const string &commandname)
 Will return full HTML help on the given command.
static vector< pair< string,
int > > 
listFunctions ()
 Help on Global Functions.
static vector< string > listFunctionPrototypes ()
 Returns a list of the prototypes of all registered global functions.
static string helpFunctions ()
 Returns a list of all registered global functions in plain text.
static string helpOnFunction (const string &functionname, int arity)
 Will return full help on all registered global functions with the given name.
static string helpFunctionsHTML ()
 Returns a list of all registered global functions as an HTML page.
static string helpOnFunctionHTML (const string &functionname, int arity)
 Will return full help on all registered global functions with the given name, as an HTML string.
static vector< string > listClasses ()
 Help on Registered Classes.
static map< string, string > getClassTree ()
 Returns a map, mapping all registered Object classnames to their parentclassname.
static string helpClasses ()
 Returns a list of all registered Object classes as plain text.
static string helpOnClass (const string &classname)
 Will returns detailed help on registered class with the given name listing its parent class, and detailed help on all options including inherited ones, as well as listing all its registered methods.
static string helpClassesHTML ()
 Returns a list of all registered Object classes as an HTML page.
static string helpOnClassHTML (const string &classname)
 same as helpOnClass, but in HTML
static vector< string > listClassParents (const string &classname)
 Returns a list of all parent classes of this class list goes from classname::inherited up to Object.
static string helpClassParents (const string &classname)
 Returns a text list of all parent classes of this class list goes from Object down to classname.
static string helpClassParentsHTML (const string &classname)
 Returns an HTML list of all parent classes of this class list goes from Object down to classname.
static vector< string > listDerivedClasses (const string &classname)
 Returns a list of all instantiable classes derived from 'classname'.
static string helpDerivedClasses (const string &classname)
 Returns a text list of all instantiable classes derived from 'classname'.
static string helpDerivedClassesHTML (const string &classname)
 Returns an HTML list of all instantiable classes derived from 'classname'.
static pair< string, vector
< string > > 
precisOnClass (const string &classname)
 Returns a pair of class descr. and list of build options.
static vector< string > listClassOptions (const string &classname)
 Help on Class Options.
static vector< string > listBuildOptions (const string &classname)
 Returns the list of build options for the class with the given name.
static vector< pair
< OptionBase::OptionLevel,
string > > 
listClassOptionsWithLevels (const string &classname, const OptionBase::flag_t &flags=OptionBase::getCurrentFlags())
 Returns the list of all options for the class with the given name.
static vector< pair
< OptionBase::OptionLevel,
string > > 
listBuildOptionsWithLevels (const string &classname)
 Returns the list of build options for the class with the given name.
static string helpClassOptions (const string &classname)
 Returns the list of options for the class with the given name, as text.
static string helpOnOption (const string &classname, const string &optionname)
 Will return full help on the declared option of the class with the given name.
static string helpClassOptionsHTML (const string &classname)
 Returns the list of options for the class with the given name, in HTML.
static string helpOnOptionHTML (const string &classname, const string &optionname)
 Will return full help on the declared option of the class with the given name, as an HTML string.
static string getOptionDefaultVal (const string &classname, const string &optionname)
 Returns the default value for this option, or "?" if it is from an abstract class.
static string getOptionDefiningClass (const string &classname, const string &optionname)
 Returns the class that defines this option, or "" if not known.
static vector< pair< string,
int > > 
listMethods (const string &classname)
 Help on Class Methods.
static vector< string > listMethodPrototypes (const string &classname)
 Returns a list of the prototypes of all registered methods for the given class.
static string helpMethods (const string &classname)
 Returns a list of all registered methods for the given class as text.
static string helpOnMethod (const string &classname, const string &methodname, int arity=-1)
 Will return full help on the registered method of the class with the given name and arity.
static string helpMethodsHTML (const string &classname)
 Returns a list of all registered methods for the given class as an HTML page.
static string helpOnMethodHTML (const string &classname, const string &methodname, int arity=-1)
 Will return full help on the registered method of the class with the given name and arity, as an HTML string.
static void setResourcesPathHTML (const string &path)
 Sets the path for resources for HTML help.
static string getResourcesPathHTML ()
 Returns the path for resources for HTML help.
static string helpIndexHTML ()
 Returns the global help index as an HTML page.
static string helpPrologueHTML (const string &title="PLearn User-Level Documentation")
 Returns the standard heading for HTML help.
static string helpEpilogueHTML ()
 Returns the standard ending for HTML help.

Static Private Member Functions

static PP< OptionBasegetOptionByName (const string &classname, const string &optionname)

Static Private Attributes

static string html_resources_path
 HTML Help.

Detailed Description

Definition at line 53 of file HelpSystem.h.


Member Function Documentation

map< string, string > PLearn::HelpSystem::getClassTree ( ) [static]

Returns a map, mapping all registered Object classnames to their parentclassname.

Definition at line 291 of file HelpSystem.cc.

References PLearn::TypeFactory::getTypeMap(), and PLearn::TypeFactory::instance().

{
    const TypeMap& type_map = TypeFactory::instance().getTypeMap();
    map<string, string> class_tree;
    TypeMap::const_iterator it = type_map.begin();
    TypeMap::const_iterator itend = type_map.end();
    for(; it!=itend; ++it)
        class_tree[it->first] = it->second.parent_class;
    return class_tree;
}

Here is the call graph for this function:

END_DECLARE_REMOTE_FUNCTIONS PP< OptionBase > PLearn::HelpSystem::getOptionByName ( const string &  classname,
const string &  optionname 
) [static, private]

Definition at line 1166 of file HelpSystem.cc.

References PLearn::TypeMapEntry::getoptionlist_method, PLearn::TypeFactory::getTypeMapEntry(), and PLearn::TypeFactory::instance().

{
    const TypeMapEntry& e= TypeFactory::instance().getTypeMapEntry(classname);
    OptionList& optlist= (*e.getoptionlist_method)();
    for(OptionList::iterator it= optlist.begin();
        it != optlist.end(); ++it)
        if((*it)->optionname() == optionname)
            return *it;
    return 0;//not found...
}

Here is the call graph for this function:

string PLearn::HelpSystem::getOptionDefaultVal ( const string &  classname,
const string &  optionname 
) [static]

Returns the default value for this option, or "?" if it is from an abstract class.

Definition at line 711 of file HelpSystem.cc.

References PLearn::TypeMapEntry::constructor, PLearn::TypeFactory::getTypeMapEntry(), and PLearn::TypeFactory::instance().

{
    PP<OptionBase> opt= getOptionByName(classname, optionname);
    const TypeMapEntry& entry= TypeFactory::instance().getTypeMapEntry(classname);
    Object* obj= 0;
    if(entry.constructor) obj= (*entry.constructor)();

    string defaultval= "?";
    if(obj) // it's an instantiable class
    {
        defaultval= opt->defaultval(); 
        if(defaultval=="") defaultval= opt->writeIntoString(obj);
        delete obj;
    }
    return defaultval;
}

Here is the call graph for this function:

string PLearn::HelpSystem::getOptionDefiningClass ( const string &  classname,
const string &  optionname 
) [static]

Returns the class that defines this option, or "" if not known.

Definition at line 729 of file HelpSystem.cc.

References PLearn::TypeMapEntry::constructor, PLearn::TypeFactory::getTypeMapEntry(), and PLearn::TypeFactory::instance().

{
    PP<OptionBase> opt= getOptionByName(classname, optionname);
    const TypeMapEntry& entry= TypeFactory::instance().getTypeMapEntry(classname);
    string defclass= "";
    if(entry.constructor)
    {
        Object* obj= (*entry.constructor)();
        defclass= opt->optionHolderClassName(obj);
        delete obj;
    }
    return defclass;
}

Here is the call graph for this function:

static string PLearn::HelpSystem::getResourcesPathHTML ( ) [inline, static]

Returns the path for resources for HTML help.

Definition at line 242 of file HelpSystem.h.

References html_resources_path.

    { return html_resources_path; }
string PLearn::HelpSystem::helpClasses ( ) [static]

Returns a list of all registered Object classes as plain text.

Definition at line 302 of file HelpSystem.cc.

References PLearn::TypeFactory::getTypeMapEntry(), PLearn::TypeFactory::instance(), PLearn::TypeMapEntry::one_line_descr, and PLearn::TypeMapEntry::parent_class.

{
    vector<string> classes= listClasses();
    string s= "";
    for(vector<string>::iterator it= classes.begin();
        it != classes.end(); ++it)
    {
        const TypeMapEntry& e= 
            TypeFactory::instance().getTypeMapEntry(*it);
        s+= "- " + *it + "\t("+ e.parent_class +")\t:  " 
            + e.one_line_descr + '\n';
    }
    return s+'\n';
}

Here is the call graph for this function:

string PLearn::HelpSystem::helpClassesHTML ( ) [static]

Returns a list of all registered Object classes as an HTML page.

Definition at line 380 of file HelpSystem.cc.

References PLearn::TypeFactory::getTypeMapEntry(), i, PLearn::TypeFactory::instance(), PLearn::TypeMapEntry::one_line_descr, PLearn::TypeMapEntry::parent_class, and PLearn::HTMLUtils::quote_format_and_highlight().

Referenced by PLearn::HTMLHelpGenerator::helpClasses().

{
    string s= "<div class=\"generaltable\">\n"
        "<h2>Index of Available Classes</h2>\n"
        "<table cellspacing=\"0\" cellpadding=\"0\">\n";
    s.reserve(131072);
    int i=0;
    vector<string> classes= listClasses();
    for(vector<string>::iterator it= classes.begin();
        it != classes.end(); ++it)
    {
        const TypeMapEntry& e= TypeFactory::instance().getTypeMapEntry(*it);
        s+= string("  <tr class=\"") + (i++%2 == 0? "even" : "odd") + "\">\n"
            "    <td>" 
            + HTMLUtils::quote_format_and_highlight(*it)
            + "</td>\n"
            "    <td>" 
            + HTMLUtils::quote_format_and_highlight(e.one_line_descr)
            + '(' + HTMLUtils::quote_format_and_highlight(e.parent_class) + ')'
            + "</td></tr>\n";
    }
    s+= "</table></div>\n";
    return helpPrologueHTML("Class Index") + s + helpEpilogueHTML();
}

Here is the call graph for this function:

Here is the caller graph for this function:

string PLearn::HelpSystem::helpClassOptions ( const string &  classname) [static]

Returns the list of options for the class with the given name, as text.

Definition at line 595 of file HelpSystem.cc.

References PLearn::OptionBase::getCurrentOptionLevel(), PLearn::OptionBase::optionLevelToString(), and PLearn::tostring().

{
    string s= "";
    vector<pair<OptionBase::OptionLevel, string> > options= 
        listClassOptionsWithLevels(classname);
    sort(options.begin(), options.end());
    OptionBase::OptionLevel lvl= 0;
    OptionBase::OptionLevel curlvl= OptionBase::getCurrentOptionLevel();
    int nbeyond= 0;
    for(vector<pair<OptionBase::OptionLevel, string> >::iterator 
            it= options.begin(); it != options.end(); ++it)
    {
        if(lvl != it->first)
        {
            lvl= it->first;
            if(lvl <= curlvl)
                s+= "##############################\n"
                    "# Options for level " 
                    + OptionBase::optionLevelToString(lvl) 
                    + "\n\n";
        }
        if(lvl <= curlvl)
            s+= helpOnOption(classname, it->second) + '\n';
        else
            ++nbeyond;
    }
    if(nbeyond > 0)
        s+= "##############################\n"
            "# " + tostring(nbeyond)
            + " hidden options beyond level "
            + OptionBase::optionLevelToString(curlvl)
            + "\n\n";
    return s;
}

Here is the call graph for this function:

string PLearn::HelpSystem::helpClassOptionsHTML ( const string &  classname) [static]

Returns the list of options for the class with the given name, in HTML.

Definition at line 645 of file HelpSystem.cc.

References PLearn::OptionBase::buildoption, PLearn::OptionBase::getCurrentOptionLevel(), and i.

{
    string s= "<div class=\"generaltable\">\n" 
        "<h2>List of All Options</h2>\n" 
        "<table cellspacing=\"0\" cellpadding=\"0\">\n";
    s.reserve(32768);

    vector<string> options= listClassOptions(classname);
    int i= 0;
    for(vector<string>::iterator it= options.begin();
        it != options.end(); ++it)
    {
        PP<OptionBase> opt= getOptionByName(classname, *it);
        if(opt->flags() & OptionBase::buildoption 
           && opt->level() <= OptionBase::getCurrentOptionLevel())
        {
            s+= string("  <tr class=\"") + (i % 2 == 0? "even" : "odd") + "\">\n"
                + helpOnOptionHTML(classname, *it) + "</tr>\n";
            ++i;
        }
    }
    
    if (i==0)
        s+= "<tr><td>This class does not specify any build options.</td></tr>\n";
    
    s+= "</table></div>\n";
    return s;
}

Here is the call graph for this function:

string PLearn::HelpSystem::helpClassParents ( const string &  classname) [static]

Returns a text list of all parent classes of this class list goes from Object down to classname.

Definition at line 467 of file HelpSystem.cc.

{
    vector<string> parents= listClassParents(classname);
    string s= "";
    for(vector<string>::reverse_iterator it= parents.rbegin();
        it != parents.rend(); ++it)
        s+= *it + " > ";
    return s + classname;
}
string PLearn::HelpSystem::helpClassParentsHTML ( const string &  classname) [static]

Returns an HTML list of all parent classes of this class list goes from Object down to classname.

Definition at line 477 of file HelpSystem.cc.

References PLearn::HTMLUtils::quote_format_and_highlight().

{
    return string("<div class=\"crumbtrail\">")
        + HTMLUtils::quote_format_and_highlight(helpClassParents(classname))
        + "</div>";
}

Here is the call graph for this function:

string PLearn::HelpSystem::helpCommands ( ) [static]

Returns a text list of all plearn command names.

Definition at line 75 of file HelpSystem.cc.

References PLearn::PLearnCommand::description, and PLearn::PLearnCommandRegistry::getCommand().

Referenced by PLearn::PLearnCommandRegistry::badcommand(), and PLearn::HelpCommand::helpCommands().

{
    vector<string> commands= listCommands();
    string s= "";
    for(vector<string>::iterator it= commands.begin();
        it != commands.end(); ++it)
    {
        PLearnCommand* cmd= PLearnCommandRegistry::getCommand(*it);
        s+= *it + "\t:  " + cmd->description + '\n';
    }
    return s+'\n';
}

Here is the call graph for this function:

Here is the caller graph for this function:

string PLearn::HelpSystem::helpCommandsHTML ( ) [static]

Returns a list of all plearn commands as an HTML page.

Definition at line 97 of file HelpSystem.cc.

References PLearn::PLearnCommand::description, PLearn::PLearnCommandRegistry::getCommand(), and i.

Referenced by PLearn::HTMLHelpGenerator::helpCommands().

{
    string s;
    s.reserve(16384);
    s+= "<div class=\"generaltable\">\n"
        "<h2>Index of Available Commands</h2>\n"
        "<table cellspacing=\"0\" cellpadding=\"0\">\n";
   
    int i=0;
    vector<string> commands= listCommands();
    for(vector<string>::iterator it= commands.begin();
        it != commands.end(); ++it, ++i)
    {
        PLearnCommand* cmd= PLearnCommandRegistry::getCommand(*it);
        string helpurl= "command_" + *it + ".html";
        string helphtml= "<a href=\"" + helpurl + "\">" + *it + "</a>";
        s+= string("  <tr class=\"") + (i%2 == 0? "even" : "odd") + "\">\n"
            "    <td>" + helphtml + "</td>"
            "<td>" + cmd->description + "</td></tr>\n";
    }
    s+="</table>\n</div>\n";
    return helpPrologueHTML("Command Index") + s + helpEpilogueHTML();
}

Here is the call graph for this function:

Here is the caller graph for this function:

string PLearn::HelpSystem::helpDerivedClasses ( const string &  classname) [static]

Returns a text list of all instantiable classes derived from 'classname'.

Definition at line 505 of file HelpSystem.cc.

References PLearn::TypeFactory::getTypeMapEntry(), PLearn::TypeFactory::instance(), PLearn::TypeMapEntry::one_line_descr, and PLearn::right().

{
    vector<string> classes= listDerivedClasses(classname);
    string s= "";
    for(vector<string>::iterator it= classes.begin();
        it != classes.end(); ++it)
        s+= right(*it, 30) + " - " 
            + TypeFactory::instance().getTypeMapEntry(*it).one_line_descr 
            + '\n';
    return s;
}

Here is the call graph for this function:

string PLearn::HelpSystem::helpDerivedClassesHTML ( const string &  classname) [static]

Returns an HTML list of all instantiable classes derived from 'classname'.

Definition at line 517 of file HelpSystem.cc.

References i, PLearn::TypeFactory::instance(), and PLearn::HTMLUtils::quote_format_and_highlight().

{
    // Output instantiable derived classes
    vector<string> classes= listDerivedClasses(classname);

    string s= "<div class=\"generaltable\">\n"
        "<h2>List of Instantiable Derived Classes</h2>\n"
        "<table cellspacing=\"0\" cellpadding=\"0\">\n";

    int i= 0;
    for(vector<string>::iterator it= classes.begin();
        it != classes.end(); ++it)
        s+= string("  <tr class=\"") + (i++%2 == 0? "even" : "odd") + "\">\n"
            "    <td>"
            + HTMLUtils::quote_format_and_highlight(*it) + "</td><td>" 
            + HTMLUtils::quote_format_and_highlight(
                TypeFactory::instance().getTypeMapEntry(*it).one_line_descr)
            + "    </td>  </tr>\n";

    if(i==0)
        s+= "<tr><td>This class does not have instantiable "
            "derived classes.</td></tr>\n";

    return s+"</table></div>\n";
}

Here is the call graph for this function:

string PLearn::HelpSystem::helpEpilogueHTML ( ) [static]

Returns the standard ending for HTML help.

Definition at line 887 of file HelpSystem.cc.

References PLearn::HTMLUtils::generated_by(), PLearn::openFile(), PLearn::PStream::raw_ascii, and PLearn::PStream::readAll().

{
    static PPath from_dir= "";
    static string the_epilogue= "</body></html>";

    if(from_dir != html_resources_path)
    {
        from_dir= html_resources_path;
        PStream f= openFile(from_dir/"help_epilog.html",
                            PStream::raw_ascii);
        the_epilogue= f.readAll();
    }

    return HTMLUtils::generated_by() + the_epilogue;
}

Here is the call graph for this function:

string PLearn::HelpSystem::helpFunctions ( ) [static]

Returns a list of all registered global functions in plain text.

Definition at line 149 of file HelpSystem.cc.

References PLearn::tostring().

{
    vector<pair<string, int> > funcs= listFunctions();
    string s;
    for(vector<pair<string, int> >::iterator it= funcs.begin();
        it != funcs.end(); ++it)
        s+= it->first +'('+tostring(it->second)+")\t:"
            + helpOnFunction(it->first, it->second) +'\n';
    return s;
}

Here is the call graph for this function:

string PLearn::HelpSystem::helpFunctionsHTML ( ) [static]

Returns a list of all registered global functions as an HTML page.

Definition at line 165 of file HelpSystem.cc.

References i, and PLERROR.

Referenced by PLearn::HTMLHelpGenerator::helpFunctions().

{
    string s= "<div class=\"rmitable\">\n" 
        "<h2>List of Functions</h2>\n"
        "<table cellspacing=\"0\" cellpadding=\"0\">\n";
    s.reserve(32768);

    vector<pair<string, int> > functions= listFunctions();

    int i= 0;
    for(vector<pair<string, int> >::iterator it= functions.begin(); 
        it != functions.end(); ++it)
        s+= string("<tr class=\"") + (i++ == 0? "first" : "others") + "\">\n"
            + helpOnFunctionHTML(it->first, it->second)
            + "</tr>\n";

        PLERROR("In HelpSystem::helpFunctionsHTML - Error thrown because of "
            "commented code (see code for details)");
    /* TODO The code below was commented because the 'index' variable was not
     * defined. It should probably be fixed and uncommented.
     if(index == 0)
        s+= "<tr><td>No Remote-Callable Functions.</td></tr>\n";
     */
           
    s+= "</table></div>\n";

    return helpPrologueHTML("Function Index") + s + helpEpilogueHTML();
}

Here is the caller graph for this function:

string PLearn::HelpSystem::helpIndexHTML ( ) [static]

Returns the global help index as an HTML page.

Definition at line 839 of file HelpSystem.cc.

References PLearn::openFile(), PLearn::pathexists(), PLearn::PStream::raw_ascii, and PLearn::PStream::readAll().

Referenced by PLearn::HTMLHelpGenerator::run().

{
    static PPath from_dir= "";
    static string the_index= string("<div class=\"cmdname\">\n")
        + "Welcome to PLearn User-Level Class and Commands Help\n" 
        "</div>"
        "<div class=\"cmdhelp\">\n"
        "<ul>\n"
        "  <li> <a href=\"classes_index.html\">Class Index</a>\n"
        "  <li> <a href=\"commands_index.html\">Command Index</a>\n"
        "  <li> <a href=\"functions_index.html\">Function Index</a>\n"
        "</ul></div>\n";

    if(from_dir != html_resources_path)
    {
        from_dir= html_resources_path;
        PPath indexfile= from_dir/"index.html";
        if(pathexists(indexfile))
        {
            PStream f= openFile(indexfile,
                                PStream::raw_ascii);
            the_index= f.readAll();
        }
    }

    return helpPrologueHTML() + the_index + helpEpilogueHTML();
}

Here is the call graph for this function:

Here is the caller graph for this function:

string PLearn::HelpSystem::helpMethods ( const string &  classname) [static]

Returns a list of all registered methods for the given class as text.

Definition at line 760 of file HelpSystem.cc.

{
    vector<pair<string, int> > methods= listMethods(classname);
    string s= "";
    for(vector<pair<string, int> >::iterator it= methods.begin();
        it != methods.end(); ++it)
        s+= string("\n##########\n") 
            + helpOnMethod(classname, it->first, it->second) + '\n';
    return s;
}
string PLearn::HelpSystem::helpMethodsHTML ( const string &  classname) [static]

Returns a list of all registered methods for the given class as an HTML page.

Definition at line 778 of file HelpSystem.cc.

References i, and PLERROR.

{
    string s= "<div class=\"rmitable\">\n" 
        "<h2>List of Remote-Callable Methods</h2>\n"
        "<table cellspacing=\"0\" cellpadding=\"0\">\n";
    
    vector<string> parents= listClassParents(classname);
    parents.insert(parents.begin(), classname);
    vector<pair<string, int> > methods;
    map<pair<string, int>, string> definingclass;
    for(vector<string>::iterator it= parents.begin();
        it != parents.end(); ++it)
    {
        vector<pair<string, int> > ms= listMethods(*it);
        for(vector<pair<string, int> >::iterator jt= ms.begin();
            jt != ms.end(); ++jt)
        {
            if(definingclass.find(*jt) == definingclass.end())
                methods.push_back(*jt);
            definingclass[*jt]= *it;
        }
    }

    int i= 0;
    for(vector<pair<string, int> >::iterator it= methods.begin(); 
        it != methods.end(); ++it)
        s+= string("<tr class=\"") + (i++ == 0? "first" : "others") + "\">\n"
            + helpOnMethodHTML(definingclass[*it], it->first, it->second)
            + "</tr>\n";

    PLERROR("In HelpSystem::helpMethodsHTML - Error thrown because of "
            "commented code (see code for details)");
    /* TODO The code below was commented because the 'index' variable was not
     * defined. It should probably be fixed and uncommented.
    if(index == 0)
        s+= "<tr><td>This class does not define any remote-callable methods.</td></tr>\n";
           
        */
    s+= "</table></div>\n";

    return s;
}
string PLearn::HelpSystem::helpOnClass ( const string &  classname) [static]

Will returns detailed help on registered class with the given name listing its parent class, and detailed help on all options including inherited ones, as well as listing all its registered methods.

Definition at line 317 of file HelpSystem.cc.

References PLearn::addprefix(), PLearn::TypeFactory::getTypeMap(), PLearn::TypeFactory::instance(), and PLERROR.

Referenced by PLearn::injectPLearnClasses(), and PLearn::HelpCommand::run().

{

    const TypeMap& type_map = TypeFactory::instance().getTypeMap();
    TypeMap::const_iterator it = type_map.find(classname);
    TypeMap::const_iterator itend = type_map.end();

    if(it==itend)
        PLERROR("Object type %s unknown.\n"
                "Did you #include it, does it call the IMPLEMENT_NAME_AND_DEEPCOPY macro?\n"
                "and has it indeed been linked with your program?", classname.c_str());

    const TypeMapEntry& entry = it->second;
    Object* obj = 0;

    string s= "################################################################## \n";
    s+= "## " + classname + "\n";
    s+= "## " + helpClassParents(classname) + '\n';
    s+= "## declared in file '" + entry.declaring_file.canonical() + "'\n";
    s+= "################################################################## \n\n";

    // Display basic help
    s+= addprefix("# ", entry.one_line_descr) + "\n\n";
    s+= addprefix("# ", entry.multi_line_help) + "\n\n";

    if(entry.constructor) // it's an instantiable class
        obj = (*entry.constructor)();
    else {
        string virtual_help =
            "Note: " + classname 
            + " is a base-class with pure virtual methods that\n"
            "cannot be instantiated directly (default values for build options\n"
            "can only be displayed for instantiable classes, so you will only\n"
            "see question marks here).\n\n";
        s += addprefix("# ", virtual_help);
    }
      
    s+= "################################################################## \n"
        "##                         Build Options                        ## \n"
        "## (including those inherited from parent and ancestor classes) ## \n"
        "################################################################## \n\n";
    s+= classname + "( \n";
    s+= helpClassOptions(classname);
    s+= ");\n\n";

    if(obj) delete obj;

    s+= "################################################################## \n";
    s+= "## Subclasses of " + classname + " \n"
        "# (only those that can be instantiated) \n"
        "################################################################## \n\n";
    s+= addprefix("# ", helpDerivedClasses(classname));
/*
    s+= "\n\n################################################################## \n";
    s+= "## Remote-callable methods of " + classname + " \n"
        "################################################################## \n\n";
    s+= addprefix("# ", helpMethods(classname));
*/
    s+= "\n\n################################################################## \n\n";

    return s;
}

Here is the call graph for this function:

Here is the caller graph for this function:

string PLearn::HelpSystem::helpOnClassHTML ( const string &  classname) [static]

same as helpOnClass, but in HTML

Definition at line 405 of file HelpSystem.cc.

References PLearn::PPath::canonical(), PLearn::TypeMapEntry::constructor, PLearn::TypeMapEntry::declaring_file, PLearn::TypeFactory::getTypeMapEntry(), PLearn::TypeFactory::instance(), PLearn::TypeMapEntry::multi_line_help, PLearn::TypeMapEntry::one_line_descr, PLearn::HTMLUtils::quote(), and PLearn::HTMLUtils::quote_format_and_highlight().

Referenced by PLearn::HTMLHelpGenerator::helpClasses().

{
    string s= "";
    s.reserve(65536);

    // Output parents heading
    s+= helpClassParentsHTML(classname);

    // Output general information
    const TypeMapEntry& entry= TypeFactory::instance().getTypeMapEntry(classname);
    s+= "<div class=\"classname\">" + HTMLUtils::quote(classname) + "</div>\n"
        "<div class=\"classdescr\">" 
        + HTMLUtils::quote(entry.one_line_descr) 
        + " (declared in '" + HTMLUtils::quote(entry.declaring_file.canonical()) 
        + "')</div>\n"
        "<div class=\"classhelp\">" 
        + HTMLUtils::quote_format_and_highlight(entry.multi_line_help) 
        + "</div>\n";
  
    if(!entry.constructor) // it's not an instantiable class
        s+= "<div class=\"classhelp\"><b>Note:</b>" + HTMLUtils::quote(classname)
            + " is a base-class with pure virtual methods "
            "that cannot be instantiated directly.\n" 
            "(default values for build options can only be "
            "displayed for instantiable classes, \n"
            " so you'll only see question marks here.)</div>\n";

    // Output list of options
    s+= helpClassOptionsHTML(classname);

    // Output instantiable derived classes
    s+= helpDerivedClassesHTML(classname);

    // Output remote-callable methods
    s+= helpMethodsHTML(classname);

    return helpPrologueHTML(classname) + s + helpEpilogueHTML();
}

Here is the call graph for this function:

Here is the caller graph for this function:

string PLearn::HelpSystem::helpOnCommand ( const string &  commandname) [static]

Will return full help on the given command.

Definition at line 88 of file HelpSystem.cc.

References PLearn::PLearnCommand::description, PLearn::PLearnCommandRegistry::getCommand(), and PLearn::PLearnCommand::helpmsg.

Referenced by PLearn::HelpCommand::run(), and PLearn::vmatmain().

{
    PLearnCommand* cmd= PLearnCommandRegistry::getCommand(commandname);
    string help= "*** Help for command '" + commandname + "' ***\n";
    help+= cmd->description + '\n';
    help+= cmd->helpmsg + '\n';        
    return help;
}

Here is the call graph for this function:

Here is the caller graph for this function:

string PLearn::HelpSystem::helpOnCommandHTML ( const string &  commandname) [static]

Will return full HTML help on the given command.

Definition at line 121 of file HelpSystem.cc.

References PLearn::PLearnCommand::description, PLearn::PLearnCommandRegistry::getCommand(), PLearn::PLearnCommand::helpmsg, PLearn::HTMLUtils::quote(), and PLearn::HTMLUtils::quote_format_and_highlight().

Referenced by PLearn::HTMLHelpGenerator::helpCommands().

{
    PLearnCommand* cmd= PLearnCommandRegistry::getCommand(commandname);
    string s= string("<div class=\"cmdname\">")
        + HTMLUtils::quote(commandname) + "</div>\n"
        "<div class=\"cmddescr\">"
        + HTMLUtils::quote_format_and_highlight(cmd->description) + "</div>\n"
        "<div class=\"cmdhelp\">"
        + HTMLUtils::quote_format_and_highlight(cmd->helpmsg) 
        + "</div>\n";
    return helpPrologueHTML(commandname) + s + helpEpilogueHTML();
}

Here is the call graph for this function:

Here is the caller graph for this function:

string PLearn::HelpSystem::helpOnFunction ( const string &  functionname,
int  arity 
) [static]

Will return full help on all registered global functions with the given name.

Definition at line 160 of file HelpSystem.cc.

References PLearn::getGlobalFunctionMap(), and PLearn::RemoteMethodMap::getMethodHelpText().

Referenced by PLearn::injectPLearnGlobalFunctions().

{
    return getGlobalFunctionMap().getMethodHelpText(functionname, arity);
}

Here is the call graph for this function:

Here is the caller graph for this function:

string PLearn::HelpSystem::helpOnFunctionHTML ( const string &  functionname,
int  arity 
) [static]

Will return full help on all registered global functions with the given name, as an HTML string.

Definition at line 266 of file HelpSystem.cc.

References PLearn::RemoteTrampoline::documentation(), PLearn::getGlobalFunctionMap(), PLearn::RemoteMethodMap::lookup(), and PLASSERT.

{
    // the result is a list of table fields (<td>...</td>)
    // should be enclosed in a table row (<table><tr>...</tr></table>)
    const RemoteTrampoline* t= 
        getGlobalFunctionMap().lookup(functionname, arity);
    PLASSERT(t);
    return formatMethodDocHTML(t->documentation());
}

Here is the call graph for this function:

string PLearn::HelpSystem::helpOnMethod ( const string &  classname,
const string &  methodname,
int  arity = -1 
) [static]

Will return full help on the registered method of the class with the given name and arity.

Definition at line 771 of file HelpSystem.cc.

References PLearn::TypeMapEntry::get_remote_methods, PLearn::TypeFactory::getTypeMapEntry(), and PLearn::TypeFactory::instance().

Referenced by PLearn::injectPLearnClasses().

{
    return TypeFactory::instance().getTypeMapEntry(classname)
        .get_remote_methods().getMethodHelpText(methodname, arity);
}

Here is the call graph for this function:

Here is the caller graph for this function:

string PLearn::HelpSystem::helpOnMethodHTML ( const string &  classname,
const string &  methodname,
int  arity = -1 
) [static]

Will return full help on the registered method of the class with the given name and arity, as an HTML string.

Definition at line 821 of file HelpSystem.cc.

References PLearn::RemoteTrampoline::documentation(), PLearn::TypeMapEntry::get_remote_methods, PLearn::TypeFactory::getTypeMapEntry(), PLearn::TypeFactory::instance(), and PLASSERT.

{
    // the result is a list of table fields (<td>...</td>)
    // should be enclosed in a table row (<table><tr>...</tr></table>)
    const RemoteTrampoline* t= TypeFactory::instance().getTypeMapEntry(classname)
        .get_remote_methods().lookup(methodname, arity);
    PLASSERT(t);
    return formatMethodDocHTML(t->documentation(), classname);
}

Here is the call graph for this function:

string PLearn::HelpSystem::helpOnOption ( const string &  classname,
const string &  optionname 
) [static]

Will return full help on the declared option of the class with the given name.

Definition at line 630 of file HelpSystem.cc.

References PLearn::addprefix(), PLearn::OptionBase::buildoption, and PLearn::OptionBase::getCurrentOptionLevel().

{
    string s= "";
    PP<OptionBase> opt= getOptionByName(classname, optionname);
    OptionBase::flag_t flags = opt->flags();
    if(flags & OptionBase::buildoption 
       && opt->level() <= OptionBase::getCurrentOptionLevel())
        s+= addprefix("# ", opt->optiontype() + ": " + opt->description())
            //+ addprefix("# ", "*OptionLevel: " + opt->levelString())
            + "\n" + opt->optionname() + " = " 
            + getOptionDefaultVal(classname, optionname) + " ;\n\n";

    return s;
}

Here is the call graph for this function:

string PLearn::HelpSystem::helpOnOptionHTML ( const string &  classname,
const string &  optionname 
) [static]

Will return full help on the declared option of the class with the given name, as an HTML string.

Definition at line 674 of file HelpSystem.cc.

References PLearn::HTMLUtils::highlight_known_classes(), PLearn::join(), PLearn::HTMLUtils::quote(), PLearn::HTMLUtils::quote_format_and_highlight(), and PLearn::removeblanks().

{
    // the result is a list of table fields (<td>...</td>)
    // should be enclosed in a table row (<table><tr>...</tr></table>)
    string s= "";
    PP<OptionBase> opt= getOptionByName(classname, optionname);
    s+= "    <td><div class=\"opttype\">" 
        + HTMLUtils::quote_format_and_highlight(opt->optiontype()) + "</div>\n"
        "    <div class=\"optname\">" 
        + HTMLUtils::quote(opt->optionname()) + "</div>\n";

    string defaultval= getOptionDefaultVal(classname, optionname);
    if (defaultval != "?")
        s+= "    <div class=\"optvalue\">= " 
            + HTMLUtils::quote(defaultval) + "</div>\n";

    string flag_string = join(opt->flagStrings(), " | ");
    s+= string("    <div class=\"opttype\"><i>(")
        + join(opt->flagStrings(), " | ") + ")</i></div>\n"
        + "    <div class=\"optlevel\"><i>(OptionLevel: " 
        + opt->levelString() + ")</i></div>\n"
        "    </td>\n";

    string descr= opt->description();
    if (removeblanks(descr) == "") descr = "(no description)";
    s+= string("    <td>")+HTMLUtils::quote_format_and_highlight(descr);

    string defclass= getOptionDefiningClass(classname, optionname);
    if (defclass != "") 
        s+= string("    <span class=\"fromclass\">")
            + "(defined&nbsp;by&nbsp;" 
            + HTMLUtils::highlight_known_classes(defclass) + ")"
            "</span>\n";
    s+= "    </td>\n";
    return s;
}

Here is the call graph for this function:

string PLearn::HelpSystem::helpPrologueHTML ( const string &  title = "PLearn User-Level Documentation") [static]

Returns the standard heading for HTML help.

Definition at line 867 of file HelpSystem.cc.

References PLearn::openFile(), PLearn::openString(), PLearn::PStream::raw_ascii, PLearn::PStream::readAll(), and PLearn::readAndMacroProcess().

{
    static PPath from_dir= "";
    static string the_prologue= "<html><body>";

    if(from_dir != html_resources_path)
    {
        from_dir= html_resources_path;
        PStream f= openFile(from_dir/"help_prolog.html",
                            PStream::raw_ascii);
        the_prologue= f.readAll();
    }

    map<string, string> dic;
    dic["PAGE_TITLE"]= title;
    PStream stm= openString(the_prologue, PStream::raw_ascii);
    time_t latest = 0;
    return readAndMacroProcess(stm, dic, latest, false);
}

Here is the call graph for this function:

vector< string > PLearn::HelpSystem::listBuildOptions ( const string &  classname) [static]

Returns the list of build options for the class with the given name.

Definition at line 565 of file HelpSystem.cc.

References i.

{
    vector<pair<OptionBase::OptionLevel, string> > optswl=
        listBuildOptionsWithLevels(classname);
    int nopts= optswl.size();
    vector<string> opts(nopts);
    for(int i= 0; i < nopts; ++i)
        opts[i]= optswl[i].second;
    return opts;
}
vector< pair< OptionBase::OptionLevel, string > > PLearn::HelpSystem::listBuildOptionsWithLevels ( const string &  classname) [static]

Returns the list of build options for the class with the given name.

Definition at line 592 of file HelpSystem.cc.

References PLearn::OptionBase::buildoption.

vector< string > PLearn::HelpSystem::listClasses ( ) [static]

Help on Registered Classes.

Returns a list of all registered Object classes

Definition at line 280 of file HelpSystem.cc.

References PLearn::TypeFactory::getTypeMap(), and PLearn::TypeFactory::instance().

Referenced by PLearn::HTMLHelpGenerator::helpClasses().

{
    const TypeMap& type_map = TypeFactory::instance().getTypeMap();
    int nclasses = type_map.size();
    vector<string> class_list(type_map.size());
    TypeMap::const_iterator it = type_map.begin();
    for(int k=0; k<nclasses; ++k, ++it)
        class_list[k] = it->first;
    return class_list;
}

Here is the call graph for this function:

Here is the caller graph for this function:

vector< string > PLearn::HelpSystem::listClassOptions ( const string &  classname) [static]

Help on Class Options.

Returns the list of all options for the class with the given name

Definition at line 554 of file HelpSystem.cc.

References i.

{
    vector<pair<OptionBase::OptionLevel, string> > optswl=
        listClassOptionsWithLevels(classname);
    int nopts= optswl.size();
    vector<string> opts(nopts);
    for(int i= 0; i < nopts; ++i)
        opts[i]= optswl[i].second;
    return opts;
}
vector< pair< OptionBase::OptionLevel, string > > PLearn::HelpSystem::listClassOptionsWithLevels ( const string &  classname,
const OptionBase::flag_t flags = OptionBase::getCurrentFlags() 
) [static]

Returns the list of all options for the class with the given name.

Definition at line 577 of file HelpSystem.cc.

References PLearn::TypeMapEntry::getoptionlist_method, PLearn::TypeFactory::getTypeMapEntry(), i, and PLearn::TypeFactory::instance().

{
    const TypeMapEntry& e= TypeFactory::instance().getTypeMapEntry(classname);
    OptionList& optlist= (*e.getoptionlist_method)();
    int nopts= optlist.size();
    vector<pair<OptionBase::OptionLevel, string> > options;
    for(int i= 0; i < nopts; ++i)
        if(optlist[i]->flags() & flags)
            options.push_back(make_pair(optlist[i]->level(), 
                                        optlist[i]->optionname()));
    return options;
}

Here is the call graph for this function:

vector< string > PLearn::HelpSystem::listClassParents ( const string &  classname) [static]

Returns a list of all parent classes of this class list goes from classname::inherited up to Object.

Definition at line 445 of file HelpSystem.cc.

References PLearn::TypeFactory::getTypeMapEntry(), PLearn::TypeFactory::instance(), and PLearn::TypeMapEntry::parent_class.

{
    string cl= classname;
    vector<string> parents;
    const TypeMapEntry* e= 
        &TypeFactory::instance().getTypeMapEntry(cl);
    bool known_parent= true;
    while(known_parent && e->parent_class != cl)
    {
        cl= e->parent_class;
        parents.push_back(cl);
        if(TypeFactory::instance().isRegistered(cl))
            e= &TypeFactory::instance().getTypeMapEntry(cl);
        else
        {
            known_parent= false;
            parents.push_back("!?!UNKNOWN_PARENT_CLASS!?!");
        }
    }
    return parents;
}

Here is the call graph for this function:

vector< string > PLearn::HelpSystem::listCommands ( ) [static]

Help on Commands.

Returns a list of all plearn command names

Definition at line 65 of file HelpSystem.cc.

References PLearn::PLearnCommandRegistry::allCommands().

Referenced by PLearn::HTMLHelpGenerator::helpCommands().

{
    vector<string> commands;
    for(PLearnCommandRegistry::command_map::const_iterator
            it  = PLearnCommandRegistry::allCommands().begin();
        it != PLearnCommandRegistry::allCommands().end(); ++it)
        commands.push_back(it->first);
    return commands;
}

Here is the call graph for this function:

Here is the caller graph for this function:

vector< string > PLearn::HelpSystem::listDerivedClasses ( const string &  classname) [static]

Returns a list of all instantiable classes derived from 'classname'.

Definition at line 484 of file HelpSystem.cc.

References PLearn::TypeMapEntry::constructor, PLearn::TypeFactory::getTypeMap(), PLearn::TypeFactory::getTypeMapEntry(), PLearn::TypeFactory::instance(), and PLearn::TypeMapEntry::isa_method.

{
    const TypeMapEntry& entry= 
        TypeFactory::instance().getTypeMapEntry(classname);
    const TypeMap& the_map= TypeFactory::instance().getTypeMap();
    vector<string> classes;
    for(TypeMap::const_iterator it= the_map.begin();
        it != the_map.end(); ++it)
    {
        const TypeMapEntry& e= it->second;
        if(e.constructor && it->first!=classname)
        {
            Object* o= (*e.constructor)();
            if((*entry.isa_method)(o))
                classes.push_back(it->first);
            if(o) delete o;
        }
    }
    return classes;
}

Here is the call graph for this function:

vector< string > PLearn::HelpSystem::listFunctionPrototypes ( ) [static]

Returns a list of the prototypes of all registered global functions.

Definition at line 144 of file HelpSystem.cc.

References PLearn::getGlobalFunctionMap(), and PLearn::RemoteMethodMap::getMethodPrototypes().

{ 
    return getGlobalFunctionMap().getMethodPrototypes(); 
}

Here is the call graph for this function:

vector< pair< string, int > > PLearn::HelpSystem::listFunctions ( ) [static]

Help on Global Functions.

Returns a list of all registered global functions as pairs of (funtionname, nargs)

Definition at line 139 of file HelpSystem.cc.

References PLearn::getGlobalFunctionMap(), and PLearn::RemoteMethodMap::getMethodList().

{ 
    return getGlobalFunctionMap().getMethodList(); 
}

Here is the call graph for this function:

vector< string > PLearn::HelpSystem::listMethodPrototypes ( const string &  classname) [static]

Returns a list of the prototypes of all registered methods for the given class.

Definition at line 754 of file HelpSystem.cc.

References PLearn::TypeFactory::getTypeMapEntry(), and PLearn::TypeFactory::instance().

{
    return TypeFactory::instance().getTypeMapEntry(classname).
        get_remote_methods().getMethodPrototypes();
}

Here is the call graph for this function:

vector< pair< string, int > > PLearn::HelpSystem::listMethods ( const string &  classname) [static]

Help on Class Methods.

Returns a list of all registered methods for the given class as pairs of (methodname, nargs)

Definition at line 748 of file HelpSystem.cc.

References PLearn::TypeFactory::getTypeMapEntry(), and PLearn::TypeFactory::instance().

{
    return TypeFactory::instance().getTypeMapEntry(classname).
        get_remote_methods().getMethodList();
}

Here is the call graph for this function:

pair< string, vector< string > > PLearn::HelpSystem::precisOnClass ( const string &  classname) [static]

Returns a pair of class descr. and list of build options.

Definition at line 543 of file HelpSystem.cc.

References PLearn::TypeFactory::getTypeMapEntry(), PLearn::TypeFactory::instance(), and PLearn::TypeMapEntry::one_line_descr.

{
    const TypeMapEntry& tme = TypeFactory::instance().getTypeMapEntry(classname);
    return make_pair(tme.one_line_descr, listBuildOptions(classname));
}

Here is the call graph for this function:

static void PLearn::HelpSystem::setResourcesPathHTML ( const string &  path) [inline, static]

Sets the path for resources for HTML help.

Definition at line 238 of file HelpSystem.h.

References html_resources_path.

Referenced by PLearn::HTMLHelpGenerator::build_().

    { html_resources_path= path; }

Here is the caller graph for this function:


Member Data Documentation

string PLearn::HelpSystem::html_resources_path [static, private]

HTML Help.

Directory that holds HTML resources. These include:

  • index.html (optional)
  • help_prolog.html
  • help_epilog.html e.g. {PLEARNDIR}/python_modules/plearn/plide/resources

Definition at line 234 of file HelpSystem.h.

Referenced by getResourcesPathHTML(), and setResourcesPathHTML().


The documentation for this struct was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines