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:1: + #pike __REAL_VERSION__ +    //! AutoDoc XML to HTML converter.   //!   //! @seealso   //! @[tree_split]      constant description = "AutoDoc XML to HTML converter.";      #define Node Parser.XML.Tree.SimpleNode   #define XML_COMMENT Parser.XML.Tree.XML_COMMENT   #define XML_ELEMENT Parser.XML.Tree.XML_ELEMENT
pike.git/lib/modules/Tools.pmod/Standalone.pmod/autodoc_to_html.pike:115:    Node dummy = Node(XML_ELEMENT, "dummy", ([]), "");    foreach(n->get_elements(), Node c)    switch(c->get_any_name()) {       case "p":    dummy->replace_children( ({ c }) );    ret += parse_text(dummy);    break;       case "example": -  ret += "<p><pre>" + c->value_of_node() + "</pre></p>\n"; +  ret += "<p><pre>" + quote(c->value_of_node()) + "</pre></p>\n";    break;       case "ul":    case "ol":    ret += (string)c;    break;       case "dl":    ret += "<dl>\n";    foreach(c->get_elements(), Node cc) {
pike.git/lib/modules/Tools.pmod/Standalone.pmod/autodoc_to_html.pike:470:    foreach(d->get_elements(second), Node e)    elems += ({ layout(e) });    if(d->get_first_element("text"))    rows += ({ ({ elems, parse_text(d->get_first_element("text")) }) });    else    rows += ({ ({ elems }) });    }    nicebox(rows, ret);   }    + // type(min..max) + string range_type( string type, Node min, Node max ) + { +  if( !min && !max ) +  return type; +  if( !min ) +  return type+"(.."+parse_text(max)+")"; +  if( !max ) +  return type+"("+parse_text(min)+"..)"; +  +  int low = (int)parse_text(min); +  int high = (int)parse_text(max); +  +  if( low == 0 && (high+1)->popcount() == 1 ) +  { +  return type+"("+strlen((high+1)->digits(2))+"bit)"; +  } +  return type+"("+low+".."+high+")"; + } +    //! Typically called with a <group/> node or a sub-node that is a container.   string parse_text(Node n, void|String.Buffer ret) {    if(n->get_node_type()==XML_TEXT && n->get_text()) {    if(ret) -  ret->add(quote(n->get_test())); +  ret->add(quote(n->get_text()));    else    return quote(n->get_text());    }       int cast;    if(!ret) {    ret = String.Buffer();    cast = 1;    }   
pike.git/lib/modules/Tools.pmod/Standalone.pmod/autodoc_to_html.pike:600:    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) { -  string tmp = "<font color='green'>"; -  Node min = n->get_first_element("minvalue"); -  Node max = n->get_first_element("maxvalue"); -  if(min || max) { -  if(min) tmp += parse_text(min); -  tmp += ".."; -  if(max) tmp += parse_text(max); -  } -  else -  tmp += parse_text(n); -  return tmp + "</font>"; +  return "<font color='green'>" + +  range_type( parse_text(n), +  n->get_first_element("minvalue"), +  n->get_first_element("maxvalue"))+ +  "</font>";    } );    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'>" + parse_text(n) + "</font>"; +  return "<font color='green'>" + +  range_type( parse_text(n), +  n->get_first_element("min"), +  n->get_first_element("max")) + +  "</font>";    } );    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>";    } );    break;
pike.git/lib/modules/Tools.pmod/Standalone.pmod/autodoc_to_html.pike:908:    ret += parse_type(get_first_element(n)) + " ... ";    break;       case "or":    ret += map(filter(n->get_children(),    lambda(Node n){    return n->get_node_type()==XML_ELEMENT;    }), parse_type)*"|";    break;    -  case "string": case "void": case "program": case "mixed": case "float": +  case "void": case "program": case "mixed": case "float":    case "zero":    ret += "<font color='#202020'>" + n->get_any_name() + "</font>";    break;    -  +  case "string":    case "int": -  ret += "<font color='#202020'>int</font>"; -  c = n->get_first_element("min"); -  d = n->get_first_element("max"); -  if(c && d) -  ret += "(" + c->value_of_node() + ".." + d->value_of_node() + ")"; -  else if(c) -  ret += "(" + c->value_of_node() + "..)"; -  else if(d) -  ret += "(.." + d->value_of_node() + ")"; +  ret += ("<font color='#202020'>" + +  range_type( n->get_any_name(), +  n->get_first_element("min"), +  n->get_first_element("max")) + +  "</font>");    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 += "<font color='#600000'>__deprecated__</font> " + subtype;    } else {