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:483:    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 ) + // min..max + string low_range_type( Node min, Node max )   {    // Work with plain text; if there's no node, that's the same as an empty node.    string min_text = min ? parse_text(min) : "";    string max_text = max ? parse_text(max) : "";    if( min_text == "" && max_text == "" ) -  return type; +  return "";    if( min_text == "" ) -  return type+"(.."+max_text+")"; +  return ".." + max_text;    if( max_text == "" ) -  return type+"("+min_text+"..)"; +  return min_text + "..";       int low = (int)min_text;    int high = (int)max_text;       if( low == 0 && high && (high+1)->popcount() == 1 )    { -  if( high == 1 && type == "int" ) +  return strlen((high)->digits(2)) + "bit"; +  } +  if (low == high) { +  return low + ""; +  } +  return low + ".." + high; + } +  + // type(min..max) + string range_type( string type, Node min, Node max ) + { +  // Work with plain text; if there's no node, that's the same as an empty node. +  string ret = low_range_type(min, max); +  +  if ((ret == "1bit") && (type == "int")) {    return "bool"; -  return type+"("+strlen((high)->digits(2))+"bit)"; +     } -  return type+"("+low+".."+high+")"; +  +  if (ret == "") return type; +  +  return type + "(" + ret + ")";   }      Tools.Standalone.pike_to_html code_highlighter;      // Normalizes indentation of @code ... @endcode blocks.   // Also tries to syntax highlight code that looks like Pike.   string parse_code(Node n, void|String.Buffer ret)   {    string text;    if (n->get_tag_name() != "code") {
pike.git/lib/modules/Tools.pmod/Standalone.pmod/autodoc_to_html.pike:1021:    if(c) ret += "(" + parse_type( get_first_element(c) ) + ")";    break;       case "array":    ret += "<code class='datatype'>array</code>";    c = n->get_first_element("length");    d = n->get_first_element("valuetype");    if(c||d) {    ret += "(";    if(c) { -  ret += c->value_of_node(); -  if(d) ret += ":"; +  Node l = get_first_element(c); +  if (l->get_tag_name() == "int") { +  // Trivial case. +  ret += ("<code class='datatype'>" + +  low_range_type(l->get_first_element("min"), +  l->get_first_element("max")) + +  "</code>"); +  } else { +  ret += parse_type(l);    } -  +  ret += ":"; +  }    if(d) ret += parse_type( get_first_element(d) );    ret += ")";    }    break;       case "mapping":    ret += "<code class='datatype'>mapping</code>";    c = n->get_first_element("indextype");    d = n->get_first_element("valuetype");    if(c && d)