pike.git / lib / modules / Tools.pmod / Standalone.pmod / autodoc_to_html.pike

version» Context lines:

pike.git/lib/modules/Tools.pmod/Standalone.pmod/autodoc_to_html.pike:149:    ret += layout_matrix( map(c->get_elements("r")->get_elements("c"), map, parse_text) );    break;       case "section":    if(section)    error("Section inside section.\n");    if(subsection)    error("Section inside subsection.\n");    section = (int)c->get_attributes()->number;    ret += "</dd>\n<dt><a name='" + section + "'></a>\n" -  "<table width='100%' cellpadding='3' cellspacing='0' border='0'><tr>" -  "<td bgcolor='#EEEEEE'><font size='+3'>&nbsp; " + chapter + "." + section + +  "<h2 class='header'>" + chapter + "." + section +    ". " + quote(c->get_attributes()->title ||    // The following for bug compat.    c->get_attributes()->name) + -  "</font></td></tr></table><br />\n" -  "</dt>\n<dd>"; +  "</h2></dt>\n<dd>";    ret += low_parse_chapter(c, chapter);    section = 0;    break;       case "subsection":    if(!section)    error("Subsection outside section.\n");    if(subsection)    error("Subsection inside subsection.\n");    subsection = (int)c->get_attributes()->number;    ret += "</dd><dt>" -  "<table width='100%' cellpadding='3' cellspacing='0' border='0'><tr>" -  "<td bgcolor='#EEEEEE'><font size='+3'>&nbsp; " + chapter + "." + section + "." + subsection + +  "<h3 class='header'>" + chapter + "." + section + "." + subsection +    ". " + quote(c->get_attributes()->title) + -  "</font></td></tr></table><br />\n" -  "</dt><dd>"; +  "</h3></dt><dd>";    ret += low_parse_chapter(c, chapter);    subsection = 0;    break;       case "docgroup":    ret += parse_docgroup(c);    break;       case "autodoc":    ret += parse_autodoc(c);
pike.git/lib/modules/Tools.pmod/Standalone.pmod/autodoc_to_html.pike:213:    }    break;    }    return ret;   }      string parse_chapter(Node n, void|int noheader) {    string ret = "";    if(!noheader) {    ret += "<dl><dt>" -  "<table width='100%' cellpadding='3' cellspacing='0' border='0'><tr>" -  "<td bgcolor='#EEEEEE'><font size='+3'>&nbsp; "; +  "<h1 class='header'>";    if(n->get_attributes()->number)    ret += n->get_attributes()->number + ". ";    ret += quote(n->get_attributes()->title) + -  "</font></td></tr></table><br />\n" +  "</h1>"    "</dt><dd>";    }       ret += low_parse_chapter(n, (int)n->get_attributes()->number);       if(!noheader)    ret = ret + "</dd></dl>";       return ret;   }      string parse_appendix(Node n, void|int noheader) {    string ret ="";    if(!noheader)    ret += "<dl><dt>" -  "<table width='100%' cellpadding='3' cellspacing='0' border='0'><tr>" -  "<td bgcolor='#EEEEEE'><font size='+3'>&nbsp; Appendix " + +  "<h2 class='header'>Appendix " +    (string)({ 64+(int)n->get_attributes()->number }) + ". " + -  n->get_attributes()->name + "</font></td></tr></table><br />\n" +  n->get_attributes()->name + "</h2>\n"    "</dt><dd>";       Node c = n->get_first_element("doc");    if(c)    ret += parse_text(c);    else    error( "No doc element in appendix.\n" );      #ifdef DEBUG    if(sizeof(n->get_elements("doc"))>1)
pike.git/lib/modules/Tools.pmod/Standalone.pmod/autodoc_to_html.pike:287:   }      string parse_namespace(Node n, void|int noheader)   {    string ret = "";       mapping m = n->get_attributes();    int(0..1) header = !noheader && !(m->hidden) && m->name!=default_ns;    if(header)    ret += "<dl><dt>" -  "<table width='100%' cellpadding='3' cellspacing='0' border='0'><tr>" -  "<td bgcolor='#EEEEEE'><font size='+3'>&nbsp; Namespace <b>" + -  m->name + "::</b></font></td></tr></table><br />\n" +  "<h2 class='header'>Namespace <b class='ms datatype'>" + +  m->name + "::</b></h2>\n"    "</dt><dd>";       Node c = n->get_first_element("doc");    if(c) -  ret += "<dl>" + parse_doc(c) + "</dl>"; +  ret += "<dl class='group--doc'>" + parse_doc(c) + "</dl>";       if((sizeof(n->get_elements("doc"))>1) &&    ((flags & (Tools.AutoDoc.FLAG_KEEP_GOING|Tools.AutoDoc.FLAG_DEBUG)) ==    Tools.AutoDoc.FLAG_DEBUG)) {    error( "More than one doc element in namespace node.\n" );    }       ret += parse_children(n, "docgroup", parse_docgroup, noheader);    ret += parse_children(n, "enum", parse_enum, noheader);    ret += parse_children(n, "class", parse_class, noheader);
pike.git/lib/modules/Tools.pmod/Standalone.pmod/autodoc_to_html.pike:320:    return ret;   }      string parse_module(Node n, void|int noheader) {    string ret ="";       mapping m = n->get_attributes();    int(0..1) header = !noheader && !(m->hidden);    if(header)    ret += "<dl><dt>" -  "<table width='100%' cellpadding='3' cellspacing='0' border='0'><tr>" -  "<td bgcolor='#EEEEEE'><font size='+3'>&nbsp; Module <b>" + -  m->class_path + m->name + "</b></font></td></tr></table><br />\n" +  "<h2 class='header'>Module <b class='ms datatype'>" + +  m->class_path + m->name + "</b></h2>\n"    "</dt><dd>";       Node c = n->get_first_element("doc");    if(c) -  ret += "<dl>" + parse_doc(c) + "</dl>"; +  ret += "<dl class='group--doc'>" + parse_doc(c) + "</dl>";       if((sizeof(n->get_elements("doc"))>1) &&    ((flags & (Tools.AutoDoc.FLAG_KEEP_GOING|Tools.AutoDoc.FLAG_DEBUG)) ==    Tools.AutoDoc.FLAG_DEBUG)) {    error( "More than one doc element in module node.\n" );    }       ret += parse_children(n, "docgroup", parse_docgroup, noheader);    ret += parse_children(n, "enum", parse_enum, noheader);    ret += parse_children(n, "class", parse_class, noheader);
pike.git/lib/modules/Tools.pmod/Standalone.pmod/autodoc_to_html.pike:351:    ret += "</dd></dl>";       return ret;   }      ADT.Stack old_class_name = ADT.Stack();   string parse_class(Node n, void|int noheader) {    string ret ="";    if(!noheader)    ret += "<dl><dt>" -  "<table width='100%' cellpadding='3' cellspacing='0' border='0'><tr>" -  "<td bgcolor='#EEEEEE'><font size='+3'>&nbsp; CLASS <b><font color='#005080'>" + +  "<h2 class='header'>Class <b class='ms datatype'>" +    n->get_attributes()->class_path + n->get_attributes()->name + -  "</font></b></font></td></tr></table><br />\n" +  "</b></h2>\n"    "</dt><dd>";       Node c = n->get_first_element("doc");    old_class_name->push(class_name);    class_name = n->get_attributes()->class_path+n->get_attributes()->name;    if(c) -  ret += "<dl>" + parse_doc(c) + "</dl>"; +  ret += "<dl class='group--doc'>" + parse_doc(c) + "</dl>";       if((sizeof(n->get_elements("doc"))>1) &&    ((flags & (Tools.AutoDoc.FLAG_KEEP_GOING|Tools.AutoDoc.FLAG_DEBUG)) ==    Tools.AutoDoc.FLAG_DEBUG)) {    error( "More than one doc element in class node.\n" );    }       ret += parse_children(n, "docgroup", parse_docgroup);    ret += parse_children(n, "enum", parse_enum, noheader);    ret += parse_children(n, "class", parse_class, noheader);
pike.git/lib/modules/Tools.pmod/Standalone.pmod/autodoc_to_html.pike:384:    if(!noheader)    ret += "</dd></dl>";    class_name = old_class_name->pop();    return ret;   }      string parse_enum(Node n, void|int noheader) {    string ret ="";    if(!noheader) {    ret += "<dl><dt>" -  "<table width='100%' cellpadding='3' cellspacing='0' border='0'><tr>" -  "<td bgcolor='#EEEEEE'><font size='+3'>&nbsp; ENUM <b><font color='#005080'>" + +  "<h2 class='header'>Enum <b class='ms datatype'>" +    n->get_attributes()->class_path + n->get_attributes()->name + -  "</font></b></font></td></tr></table><br />\n" +  "</b></h2>\n"    "</dt><dd>";    }       Node c = n->get_first_element("doc");       if(c) -  ret += "<dl>" + parse_doc(c) + "</dl>"; +  ret += "<dl class='group--doc'>" + parse_doc(c) + "</dl>";       if((sizeof(n->get_elements("doc"))>1) &&    ((flags & (Tools.AutoDoc.FLAG_KEEP_GOING|Tools.AutoDoc.FLAG_DEBUG)) ==    Tools.AutoDoc.FLAG_DEBUG)) {    error( "More than one doc element in enum node.\n" );    }       ret += parse_children(n, "docgroup", parse_docgroup);       if(!noheader)    ret += "</dd></dl>";    return ret;   }      string layout_matrix( array(array(string)) rows ) {    -  string ret = "<table bgcolor='black' border='0' cellspacing='0' cellpadding='0'><tr><td>\n" -  "<table cellspacing='1' cellpadding='3' border='0' bgcolor='black'>\n"; +  string ret = +  "<table class='box'>\n";          int dim;    foreach(rows, array row)    dim = max(dim, sizeof(row));       foreach(rows, array row) { -  ret += "<tr valign='top'>"; +  ret += "<tr>";    if(sizeof(row)<dim) -  ret += "<td bgcolor='white'>" + row[..sizeof(row)-2]*"</td><td bgcolor='white'>" + -  "</td><td bgcolor='white' colspan='"+ (dim-sizeof(row)) + "'>" + row[-1] + "</td>"; +  ret += "<td>" + row[..sizeof(row)-2]*"</td><td>" + +  "</td><td colspan='"+ (dim-sizeof(row)) + "'>" + row[-1] + "</td>";    else -  ret += "<td bgcolor='white'>" + row*"</td><td bgcolor='white'>" + "</td>"; +  ret += "<td>" + row*"</td><td>" + "</td>";    ret += "</tr>\n";    }    -  return ret + "</table></td></tr></table><br>\n"; +  return ret + "</table>\n";   }      // ({ ({ array(string)+, void|string })* })   void nicebox(array rows, String.Buffer ret) { -  /* -  ret->add( "NICEBOX<table bgcolor='black' border='0' cellspacing='0' cellpadding='0'><tr><td>\n" -  "<table cellspacing='1' cellpadding='3' border='0' bgcolor='black'>\n" ); -  -  int dim; -  foreach(rows, array row) -  dim = max(dim, sizeof(row)); -  -  foreach(rows, array row) { -  if(sizeof(row)==1) { -  if(stringp(row[0])) -  ret->add( "<tr valign='top'><td bgcolor='white' colspan='", (string)dim, "'>", -  row[0], "</td></tr>\n" ); -  else -  foreach(row[0], string elem) -  ret->add( "<tr valign='top'><td bgcolor='white'><tt>", elem, "</tt></td>", -  (dim==2?"<td bgcolor='white'>&nbsp;</td>":""), "</tr>\n" ); -  } -  else if(sizeof(row[0])==1) -  ret->add( "<tr valign='top'><td bgcolor='white'><tt>", row[0][0], -  "</tt></td><td bgcolor='white'>", row[1], "</td></tr>\n" ); -  else { -  ret->add( "<tr valign='top'><td bgcolor='white'><tt>", row[0][0], -  "</tt></td><td bgcolor='white' rowspan='", (string)sizeof(row[0]), "'>", -  row[1], "</td></tr>\n" ); -  foreach(row[0][1..], string elem) -  ret->add( "<tr valign='top'><td bgcolor='white'><tt>", elem, "</tt></td></tr>\n" ); -  } -  } -  -  ret->add( "</table></td></tr></table><br />\n" ); -  */ -  +     ret->add("<table class='box'>");       int dim;    foreach (rows, array row) {    dim = max(dim, sizeof(row));    }       foreach (rows, array row) {    if (sizeof(row) == 1) {    if (stringp(row[0])) {
pike.git/lib/modules/Tools.pmod/Standalone.pmod/autodoc_to_html.pike:685:    break;       case "ref":    if(resolve_reference) {    ret->add(resolve_reference(parse_text(c), c->get_attributes()));    break;    }    string ref;    //ref = c->get_attributes()->resolved;    if(!ref) ref = parse_text(c); -  ret->add("<span class='ms'>", ref, "</span>"); +  ret->add("<tt>", ref, "</tt>");    break;       case "rfc":    {    string rfc = upper_case(parse_text(c));    string section;    sscanf(rfc, "%[0-9]:%[.A-Z0-9]", rfc, section);    if (sizeof(rfc) < 4) rfc = ("0000" + rfc)[<3..];    ret->add("<b><a href='http://pike.lysator.liu.se/rfc", rfc, ".xml");    if( section && sizeof(section) )
pike.git/lib/modules/Tools.pmod/Standalone.pmod/autodoc_to_html.pike:713:    ret->add(" appendix ");    else    ret->add(" section ");    ret->add(section);    }    ret->add("</a></b>");    }    break;       case "dl": -  ret->add("<dl>", map(c->get_elements("group"), parse_text)*"", "</dl>"); +  ret->add("<dl class='group--doc'>", map(c->get_elements("group"), parse_text)*"", "</dl>");    break;       case "item":    if(c->get_attributes()->name) {    ret->add("<dt>", c->get_attributes()->name, "</dt>\n");    if(c->count_children() &&    ((flags & (Tools.AutoDoc.FLAG_KEEP_GOING|Tools.AutoDoc.FLAG_DEBUG)) ==    Tools.AutoDoc.FLAG_DEBUG)) {    error( "dl item has a child.\n" );    }
pike.git/lib/modules/Tools.pmod/Standalone.pmod/autodoc_to_html.pike:738:    }    break;       case "mapping":    build_box(c, ret, "group", "member",    lambda(Node n) {    string res = "";    Node nn = n->get_first_element("index");    if (nn) {    res += -  "<font color='green'>" + parse_text(nn) + "</font> : "; +  "<tt class='key'>" + parse_text(nn) + "</tt> : ";    }    nn = n->get_first_element("type");    if (nn) {    res += parse_type(get_first_element(nn));    }    return res;    });    break;       case "array":
pike.git/lib/modules/Tools.pmod/Standalone.pmod/autodoc_to_html.pike:768:    if(n->get_first_element("maxindex"))    index += parse_text(n->get_first_element("maxindex"));    }    return parse_type(get_first_element(n->get_first_element("type"))) +    " <font color='green'>" + index + "</font>"; }, "Array" );    break;       case "int":    build_box(c, ret, "group", "value",    lambda(Node n) { -  return "<font color='green'>" + +  return "<tt class='key'>" +    range_type( parse_text(n),    n->get_first_element("minvalue"),    n->get_first_element("maxvalue"))+ -  "</font>"; +  "</tt>";    } );    break;       case "mixed":    if(c->get_attributes()->name)    ret->add("<tt>", c->get_attributes()->name, "</tt> can have any of the following types:<br />");    rows = ({});    foreach(c->get_elements("group"), Node d)    rows += ({ ({    ({ parse_type(get_first_element(d->get_first_element("type"))) }),    parse_text(d->get_first_element("text"))    }) });    nicebox(rows, ret);    break;       case "string": // Not in XSLT    build_box(c, ret, "group", "value",    lambda(Node n) { -  return "<font color='green'>" + +  return "<tt class='key'>" +    range_type( parse_text(n),    n->get_first_element("min"),    n->get_first_element("max")) + -  "</font>"; +  "</tt>";    } );    break;       case "multiset": // Not in XSLT    build_box(c, ret, "group", "index",    lambda(Node n) { -  return "<font color='green'>" + -  parse_text(n->get_first_element("value")) + "</font>"; +  return "<tt class='key'>" + +  parse_text(n->get_first_element("value")) + "</tt>";    } );    break;       case "image": // Not in XSLT    mapping m = c->get_attributes();    m->src = image_prefix() + m_delete(m, "file");    ret->add( render_tag("img", m, 1) );    break;       case "url": // Not in XSLT
pike.git/lib/modules/Tools.pmod/Standalone.pmod/autodoc_to_html.pike:1000:    if(!n || (n->get_node_type()!=XML_ELEMENT))    return "";       string ret = "";    Node c, d;    switch(n->get_any_name()) {       case "object":    if(n->count_children()) {    if (resolve_reference) { -  ret += "<span class='ms object resolved'>" + +  ret += "<tt class='object resolved'>" +    resolve_reference(n->value_of_node(), n->get_attributes()) + -  "</span>"; +  "</tt>";    } else { -  ret += "<span class='ms object unresolved'>" + -  n->value_of_node() + "</span>"; +  ret += "<tt class='object unresolved'>" + +  n->value_of_node() + "</tt>";    }    } else -  ret += "<span class='ms datatype'>object</span>"; +  ret += "<tt class='datatype'>object</tt>";    break;       case "type": -  ret += "<span class='ms type'>type</span>"; +  ret += "<tt class='type'>type</tt>";    if (n->count_children() && (c = get_first_element(n)) &&    (c->get_any_name() != "mixed")) {    ret += "(" + parse_type(c) + ")";    }    break;       case "multiset": -  ret += "<span class='ms datatype'>multiset</span>"; +  ret += "<tt class='datatype'>multiset</tt>";    c = n->get_first_element("indextype");    if(c) ret += "(" + parse_type( get_first_element(c) ) + ")";    break;       case "array": -  ret += "<span class='ms datatype'>array</span>"; +  ret += "<tt class='datatype'>array</tt>";    c = n->get_first_element("valuetype");    if(c) ret += "(" + parse_type( get_first_element(c) ) + ")";    break;       case "mapping": -  ret += "<span class='ms datatype'>mapping</span>"; +  ret += "<tt class='datatype'>mapping</tt>";    c = n->get_first_element("indextype");    d = n->get_first_element("valuetype");    if(c && d)    ret += "(" + parse_type( get_first_element(c) ) + ":" +    parse_type( get_first_element(d) ) + ")";   #ifdef DEBUG    if( !c != !d )    error( "Indextype/valuetype defined while the other is not in mapping.\n" );   #endif    break;       case "function": -  ret += "<span class='ms datatype'>function</span>"; +  ret += "<tt class='datatype'>function</tt>";    array(Node) args = n->get_elements("argtype");    d = n->get_first_element("returntype");    // Doing different than the XSL here. Must both    // argtype and returntype be defined?    if(args || d) {    ret += "(";    if(args) ret += map(args->get_children() * ({}), parse_type)*", ";    ret += ":";    if(d) ret += parse_type( get_first_element(d) ); -  else ret += "<span class='ms datatype void'>void</span>"; +  else ret += "<tt class='datatype void'>void</tt>";    ret += ")";    }    break;       case "varargs":   #ifdef DEBUG    if(!n->count_children())    error( "varargs node must have child node.\n" );   #endif    ret += parse_type(get_first_element(n)) + " ... ";
pike.git/lib/modules/Tools.pmod/Standalone.pmod/autodoc_to_html.pike:1077:       case "or":    ret += map(filter(n->get_children(),    lambda(Node n){    return n->get_node_type()==XML_ELEMENT;    }), parse_type)*"|";    break;       case "void": case "program": case "mixed": case "float":    case "zero": -  ret += "<span class='ms datatype'>" + n->get_any_name() + "</span>"; +  ret += "<tt class='datatype'>" + n->get_any_name() + "</tt>";    break;       case "string":    case "int": -  ret += ("<span class='ms datatype'>" + +  ret += ("<tt class='datatype'>" +    range_type( n->get_any_name(),    n->get_first_element("min"),    n->get_first_element("max")) + -  "</span>"); +  "</tt>");    break;       case "attribute":    string attr = n->get_first_element("attribute")->value_of_node();    string subtype =    parse_type(n->get_first_element("subtype")->get_first_element());    if (n->get_first_element("prefix")) {    if (attr == "\"deprecated\"") { -  ret += "<span class='ms deprecated'>__deprecated__</span> " + +  ret += "<tt class='deprecated'>__deprecated__</tt> " +    subtype;    } else {    ret += sprintf("__attribute__(%s) %s", attr, subtype);    }    } else if (attr == "\"deprecated\"") { -  ret += "<span class='ms deprecated'>__deprecated__</span>(" + +  ret += "<tt class='deprecated'>__deprecated__</tt>(" +    subtype + ")";    } else {    ret += sprintf("__attribute__(%s, %s)", attr, subtype);    }    break;       // Modifiers:    case "extern": // Not in XSLT -  ret += "<span class='ms modifier'>extern</span> "; +  ret += "<tt class='modifier'>extern</tt> ";    break;    case "final": // Not in XSLT    case "nomask": // Not in XSLT -  ret += "<span class='ms modifier'>final</span> "; +  ret += "<tt class='modifier'>final</tt> ";    break;    case "inline": // Not in XSLT    case "local": // Not in XSLT -  ret += "<span class='ms modifier'>local</span> "; +  ret += "<tt class='modifier'>local</tt> ";    break;    case "optional": // Not in XSLT -  ret += "<span class='ms modifier'>optional</span> "; +  ret += "<tt class='modifier'>optional</tt> ";    break;    case "private": // Not in XSLT -  ret += "<span class='ms modifier'>private</span> "; +  ret += "<tt class='modifier'>private</tt> ";    break;    case "protected": // Not in XSLT    case "static": // Not in XSLT -  ret += "<span class='ms modifier'>protected</span> "; +  ret += "<tt class='modifier'>protected</tt> ";    break;    case "public": // Not in XSLT    // Ignored.    break;    case "variant": // Not in XSLT -  ret += "<span class='ms modifier'>variant</span> "; +  ret += "<tt class='modifier'>variant</tt> ";    break;       default:    error( "Illegal element " + n->get_any_name() + " in mode type.\n" );    break;    }    return ret;   }      void resolve_class_paths(Node n, string|void path, Node|void parent)
pike.git/lib/modules/Tools.pmod/Standalone.pmod/autodoc_to_html.pike:1294: Inside #if 0 and #if defined(DEBUG)
   return " (could not resolve) ";   #ifdef DEBUG    error( "Parent module is " + n->get_parent()->get_any_name() + ".\n" );   #else    return "";   #endif   }   #endif /* 0 */   string class_name = "";    + #define HTML_ENC(S) (Parser.encode_html_entities(S))      string parse_not_doc(Node n) {    string ret = "";    int method, argument, variable, num_const, typedf, cppdir;       if (!n) return "";       foreach(n->get_children(), Node c) {       if(c->get_node_type()!=XML_ELEMENT)
pike.git/lib/modules/Tools.pmod/Standalone.pmod/autodoc_to_html.pike:1331:   #endif       void emit_default_func()    {    ret += "<tt>";    cc = c->get_first_element("modifiers");    if(cc) ret += map(cc->get_children(), parse_type)*" " + " ";    ret += parse_type(get_first_element(c->get_first_element("returntype")));    ret += " ";    ret += c->get_attributes()->class_path; -  ret += "<b><span class='method'>" + c->get_attributes()->name + "</span>(</b>"; +  ret += "<b><span class='method'>" + HTML_ENC(c->get_attributes()->name) + "</span>(</b>";    ret += parse_not_doc( c->get_first_element("arguments") );    ret += "<b>)</b>";    ret += "</tt>";    };    if( class_name == "" )    {    emit_default_func();    }    else switch( string method = c->get_attributes()->name )    {
pike.git/lib/modules/Tools.pmod/Standalone.pmod/autodoc_to_html.pike:1436:    case "_encode":    ret += "<tt>";    ret += "<span class='datatype'>string(8bit)</span> ";    ret += ("<b><span class='method'>encode_value</span>("    "</b><span class='class'>"+class_name+"</span> "    "<span class='argument'>data</span>)</b></tt>");    break;       case "cast":    { -  //ret += "<tt>"; +  ret += "<tt>";       string base = -  "<b>(</b><span class='ms datatype'>_@_TYPE_@_</span>" -  "<b>)</b><span class='ms class'>"+class_name+"</span>()"; +  "<b>(</b><span class='datatype'>_@_TYPE_@_</span>" +  "<b>)</b><span class='class'>"+class_name+"</span>()";       multiset seen = (<>);    void add_typed( string type )    {    if( type == "mixed" )    {    add_typed("int"); ret +="<br>";    add_typed("float"); ret +="<br>";    add_typed("string"); ret +="<br>";    add_typed("array"); ret +="<br>";
pike.git/lib/modules/Tools.pmod/Standalone.pmod/autodoc_to_html.pike:1489:    break;    case "or":    if( toplevel )    map( x->get_children(), output_from_type, false );    }    };    output_from_type(get_first_element(c->get_first_element("returntype")),    true);    if( !sizeof(seen) )    add_typed("mixed"); +  +  ret += "</tt>";    };    break;       default:    if( string pat = Tools.AutoDoc.PikeObjects.lfuns[method] )    {    Node a = c->get_first_element("arguments") ;    array(Node) args = a->get_elements("argument"); -  mapping repl = (["OBJ":"<span class='ms class'>"+ -  class_name+"()</span>"]); +  mapping repl = (["OBJ":"<tt class='class'>"+ +  class_name+"()</tt>"]);    /* there are a few cases: obj OP arg - we do not want types    RET func(op,ARG) - we do want types.       This code should only be triggered for the first case.    Hence, no types wanted.    */    if( sizeof(args) > 0 )    { -  repl->x = "<span class='ms class'>"+ -  args[0]->get_attributes()->name+"</span>"; +  repl->x = "<tt class='class'>"+ +  args[0]->get_attributes()->name+"</tt>";    }    if( sizeof(args) > 1 )    { -  repl->y = "<span class='ms class'>"+ -  args[1]->get_attributes()->name+"</span>"; +  repl->y = "<tt class='class'>"+ +  args[1]->get_attributes()->name+"</tt>";    }    -  //ret += "<tt>"; +  ret += "<tt>";    if( method != "`+=" && method != "`[]=" && method != "`->=")    {    ret += parse_type(get_first_element(c->get_first_element("returntype")));    ret += " res = ";    } -  ret += replace( pat, repl ); -  //ret += "</tt>"; +  +  ret += replace(HTML_ENC(pat), repl ); +  ret += "</tt>";    break;    }    emit_default_func( );    break;    }    break;       case "argument":    if(argument++) ret += ", ";    cc = c->get_first_element("value"); -  if(cc) ret += "<span class='ms argument'>" + cc->value_of_node() + "</span>"; +  if(cc) ret += "<tt class='argument'>" + cc->value_of_node() + "</tt>";    else if( !c->count_children() );    else if( get_first_element(c)->get_any_name()=="type") {    ret += parse_type(get_first_element(get_first_element(c)));    if(c->get_attributes()->name) -  ret += " <span class='ms argument'>" + -  c->get_attributes()->name + "</span>"; +  ret += " <tt class='argument'>" + +  c->get_attributes()->name + "</tt>";    }    else    error( "Malformed argument element.\n" + c->html_of_node() + "\n" );    break;       case "variable":    if(variable++) ret += "<br>\n";    ret += "<tt>";    cc = c->get_first_element("modifiers");    if(cc) ret += map(cc->get_children(), parse_type)*" " + " ";    if (c->get_first_element("type")) {    ret += parse_type(get_first_element(c->get_first_element("type")),    "variable") + " " +    c->get_attributes()->class_path + "<b><span class='variable'>" +    c->get_attributes()->name + "</span></b></tt>";    } else    error("Malformed variable element.\n" + c->html_of_node() + "\n");    break;       case "constant": -  if(num_const++) ret += "<br />\n"; -  ret += "<span class='ms datatype'>"; +  if(num_const++) ret += "<br>\n"; +  ret += "<tt><tt class='datatype'>";    cc = c->get_first_element("modifiers");    if(cc) ret += map(cc->get_children(), parse_type)*" " + " "; -  ret += "constant</span> "; +  ret += "constant</tt> ";    if (Node type = c->get_first_element ("type"))    ret += parse_type (get_first_element (type), "constant") + " ";    ret += c->get_attributes()->class_path; -  ret += "<span class='ms constant'>" + c->get_attributes()->name + "</span>"; +  ret += "<tt class='constant'>" + c->get_attributes()->name + "</tt>";    cc = c->get_first_element("typevalue"); -  if(cc) ret += " <tt>=</tt> <tt class='value'>" + parse_type(get_first_element(cc)) + "</tt>"; -  //ret += "</tt>"; +  if(cc) { +  ret += " = <tt class='value'>" + +  parse_type(get_first_element(cc)) + "</tt>"; +  } +  ret += "</tt>";    break;       case "typedef": -  if(typedf++) ret += "<br />\n"; -  ret += "<span class='ms datatype'>"; +  if(typedf++) ret += "<br>\n"; +  ret += "<tt><tt class='datatype'>";    cc = c->get_first_element("modifiers");    if(cc) ret += map(cc->get_children(), parse_type)*" " + " "; -  ret += "typedef</span> "; +  ret += "typedef</tt> ";    ret += parse_type(get_first_element(c->get_first_element("type")), "typedef") + " " + -  c->get_attributes()->class_path + "<span class='ms typedef'>" + c->get_attributes()->name + -  "</span>"; +  c->get_attributes()->class_path + +  "<tt class='typedef'>" + c->get_attributes()->name + "</tt></tt>";    break;       case "inherit": -  ret += "<span class='ms datatype'>"; +  ret += "<tt><span class='datatype'>";    cc = c->get_first_element("modifiers");    if(cc) ret += map(cc->get_children(), parse_type)*" " + " ";    ret += "inherit ";    Node n = c->get_first_element("classname");    if (resolve_reference) {    ret += "</span>" +    resolve_reference(n->value_of_node(), n->get_attributes());    } else {    ret += Parser.encode_html_entities(n->value_of_node()) + "</span>";    }    if (c->get_attributes()->name) { -  ret += "<span class='ms'> : " + "<span class='ms inherit'>" + +  ret += " : " + "<span class='inherit'>" +    Parser.encode_html_entities(c->get_attributes()->name) + -  "</span></span>"; +  "</span>";    } -  +  ret += "</tt>";    break;       // We don't need import information.    case "import":    break;       case "directive": -  if(cppdir++) ret += "<br />\n"; -  ret += "<span class='ms directive'>" + quote(c->get_attributes()->name) + -  "</span>"; +  if(cppdir++) ret += "<br>\n"; +  ret += "<tt class='directive'>" + quote(c->get_attributes()->name) + +  "</tt>";    break;       default:    error( "Illegal element " + c->get_any_name() + " in !doc.\n" );    break;    }    }       return ret;   }
pike.git/lib/modules/Tools.pmod/Standalone.pmod/autodoc_to_html.pike:1682:   }      string parse_children(Node n, string tag, function cb, mixed ... args) {    string ret = "";    foreach(n->get_elements(tag), Node c)    ret += cb(c, @args);       return ret;   }    + // This can be overridden by passing --template=template.html to main + string html_template = +  "<!doctype html><html><head><title>$title$</title>\n" +  "<meta charset='utf-8'></head>\n" +  "<body>$contents$</body></html>";   string manual_title = "Pike Reference Manual";   string frame_html(string res, void|string title) {    title = title || manual_title; -  return "<!doctype html><html><head><title>" + quote(title) + "</title>\n" -  "<meta charset='utf-8' /></head>\n" -  "<body>\n" + res + -  "</body></html>"; +  return replace(html_template, ([ "$title$" : quote(title), +  "$contents$" : res ]));   }      string layout_toploop(Node n, Git.Export|void exporter) {    string res = "";    foreach(n->get_elements(), Node c)    switch(c->get_any_name()) {       case "dir":    if (exporter) {    layout_toploop(c, exporter);
pike.git/lib/modules/Tools.pmod/Standalone.pmod/autodoc_to_html.pike:1820:       if (verbosity >= Tools.AutoDoc.FLAG_VERBOSE) {    werror("Took %d seconds.\n\n", time()-t);    }       return 0;   }      int main(int num, array args) {    -  string title; +  string title, template;       foreach(Getopt.find_all_options(args, ({ -  ({ "img", Getopt.HAS_ARG, "--img" }), -  ({ "dest", Getopt.HAS_ARG, "--dest" }), -  ({ "title", Getopt.HAS_ARG, "--title" }), -  ({ "defns", Getopt.HAS_ARG, "--default-ns" }), -  ({ "verbose", Getopt.NO_ARG, "-v,--verbose"/"," }), -  ({ "quiet", Getopt.NO_ARG, "-q,--quiet"/"," }), -  ({ "help", Getopt.NO_ARG, "--help" }), +  ({ "img", Getopt.HAS_ARG, "--img" }), +  ({ "dest", Getopt.HAS_ARG, "--dest" }), +  ({ "title", Getopt.HAS_ARG, "--title" }), +  ({ "template", Getopt.HAS_ARG, "--template" }), +  ({ "defns", Getopt.HAS_ARG, "--default-ns" }), +  ({ "verbose", Getopt.NO_ARG, "-v,--verbose"/"," }), +  ({ "quiet", Getopt.NO_ARG, "-q,--quiet"/"," }), +  ({ "help", Getopt.NO_ARG, "--help" }),    })), array opt)    switch(opt[0]) {    case "img":    image_path = opt[1];    break;    case "dest":    dest_path = opt[1];    break;    case "title":    title = opt[1];    break; -  +  case "template": +  template = opt[1]; +  break;    case "defns":    default_ns = opt[1];    break;    case "verbose":    if (verbosity < Tools.AutoDoc.FLAG_DEBUG) {    verbosity += 1;    flags = (flags & ~Tools.AutoDoc.FLAG_VERB_MASK) | verbosity;    }    break;    case "quiet":    flags &= ~Tools.AutoDoc.FLAG_VERB_MASK;    verbosity = Tools.AutoDoc.FLAG_QUIET;    break;    case "help":    write(#"pike -x autodoc_to_html [args] <input file> [<output file>]   --img=<image path>   --dest=<destination path>      --title=<document title> -  +  + --template=<template.html path>   ");    break;    }    args = Getopt.get_args(args)[1..];       if(!sizeof(args))    error( "No input file given.\n" );    -  +  if (template && Stdio.exist(template)) { +  string dir = dirname(template); +  html_template = Stdio.read_file(template); +  Parser.HTML p = Parser.HTML(); +  p->add_tag("link", lambda (Parser.HTML pp, mapping attr) { +  if (attr->href && attr["data-inline"]) { +  return "<style>" + (Stdio.read_file(combine_path(dir, attr->href))) + +  "</style>"; +  } +  }); +  +  html_template = p->feed(html_template)->finish()->read(); +  } +     return low_main(title, @args);   }