Roxen.git / server / base_server / rxmlhelp.pike

version» Context lines:

Roxen.git/server/base_server/rxmlhelp.pike:35:    if(!has_value(roxen->list_languages(),pl)) pl="en";    else    pl="en";    mapping languages=roxen->language_low(pl)->list_languages();    return mktable( map(sort(indices(languages) & roxen->list_languages()),    lambda(string code) { return ({ code, languages[code] }); } ));   }      // --------------------- Help layout functions --------------------    - static string desc_cont(Parser.HTML parser, mapping m, string c, string rt) + class TagdocParser   { -  +  inherit Parser.HTML; +  mapping misc = ([]); + } +  + static string desc_cont(TagdocParser parser, mapping m, string c, string rt) + {    string type;    if(m->tag) type = "tag";    if(m->cont) type = "cont";    if(m->cont &&    m->tag) type = "both";    if(m->plugin) type = "plugin";    if(m->ent) type = "entity";    if(m->scope) type = "scope";    if(m->pi) type = "pi";    if(m->type) type = m->type;
Roxen.git/server/base_server/rxmlhelp.pike:62:    "&lt;%s&gt;&lt;/%s&gt;",    rt, rt, rt); break;    case "plugin": rt = replace(rt, "#", " plugin "); break;    //case "entity": rt = rt; break;    case "scope": rt = rt[..sizeof(rt)-2] + " ... ;";    case "pi": rt = "&lt;" + rt + " ... ?&gt;";    }    return sprintf("<h2>%s</h2><p>%s</p>", rt, c);   }    - static string attr_cont(Parser.HTML parser, mapping m, string c) + static string attr_cont(TagdocParser parser, mapping m, string c)   {    string p="";    if(!m->name) m->name="(Not entered)";    if(m->value) p=sprintf("<i>%s=%s</i>%s<br />",    m->name,    attr_vals(m->value),    m->default?" ("+m->default+")":""    );    if(m->required) p+="<i>This attribute is required.</i><br />"; -  return sprintf("<p><dl><dt><b>%s</b></dt><dd>%s%s</p></dl>",m->name,p,c); +  p = sprintf("<p><dl><dt><b>%s</b></dt><dd>%s%s</p></dl>",m->name,p,c); +  +  if (!parser->misc->got_attrs) { +  parser->misc->got_attrs = 1; +  p = "<h3>Attributes</h3>\n" + p;    }    -  +  return p; + } +    static string attr_vals(string v)   {    if(has_value(v,"|")) return "{"+(v/"|")*", "+"}";    // FIXME Use real config url    // if(v=="langcodes") return "<a href=\"/help/langcodes.pike\">language code</a>";    return v;   }    - static string noex_cont(Parser.HTML parser, mapping m, string c) { + static string noex_cont(TagdocParser parser, mapping m, string c) {    return Parser.HTML()->add_container("ex","")->    add_quote_tag("!--","","--")->feed(c)->read();   }      static string ex_quote(string in) {    return "<pre>"+replace(in, ({"<",">","&"}), ({"&lt;","&gt;","&amp;"}) )+"</pre>";   }    - static string ex_cont(Parser.HTML parser, mapping m, string c, string rt, void|object id) + static string ex_cont(TagdocParser parser, mapping m, string c, string rt, void|object id)   {    c=Parser.HTML()->add_container("ent", lambda(Parser.HTML parser, mapping m, string c) {    return "&amp;"+c+";";    } )->    add_quote_tag("!--","","--")->feed(c)->read();    string quoted = ex_quote(c);    if(m->type=="box")    return "<br />"+mktable( ({ ({ quoted }) }) );       if(!id) return "";
Roxen.git/server/base_server/rxmlhelp.pike:124:    case "shor":    return "<br />" + mktable( ({ ({ quoted, ex_quote(parsed) }) }) );    case "vert":    default:    return "<br />"+mktable( ({ ({ quoted }), ({ parsed }) }) );    case "hor":    return "<br />"+mktable( ({ ({ quoted, parsed }) }) );    }   }    - static string ex_box_cont(Parser.HTML parser, mapping m, string c, string rt) { + static string ex_box_cont(TagdocParser parser, mapping m, string c, string rt) {    return "<br />"+mktable( ({ ({ ex_quote(c) }) }) );   }    - static string ex_html_cont(Parser.HTML parser, mapping m, string c, string rt) { + static string ex_html_cont(TagdocParser parser, mapping m, string c, string rt) {    return "<br />" + mktable( ({ ({ c }) }) );   }    - static string ex_src_cont(Parser.HTML parser, mapping m, string c, string rt, void|object id) { + static string ex_src_cont(TagdocParser parser, mapping m, string c, string rt, void|object id) {    string quoted = ex_quote(c);    string parsed = parse_rxml("<colorscope bgcolor="+TDBG+">"+c+"</colorscope>", id);    return "<br />" + mktable( ({ ({ quoted }), ({ ex_quote(parsed) }) }) );   }    - static string list_cont( Parser.HTML parser, mapping m, string c ) + static string list_cont( TagdocParser parser, mapping m, string c )   {    string type = m->type || "ul";    return "<"+type+">"+    Parser.HTML()->    add_containers( ([ "item":lambda(Parser.HTML p, mapping m, string c) {    return ({    "<li>"+    (m->name ? "<b>"+m->name+"</b><br />" : "")+    c+"</li>" });    } ]) )->finish(c)->read()+
Roxen.git/server/base_server/rxmlhelp.pike:211:    }    }    }    }    else    doc=doc->standard;    }       name=replace(name, ({ "<", ">", "&" }), ({ "&lt;", "&gt;", "&amp;" }) );    -  return Parser.HTML()-> +  return TagdocParser()->    add_tag( "lang",lambda() { return available_languages(id); } )->    add_tag( "help", help_tag )->    add_containers( ([    "list":list_cont,    "xtable":xtable_cont,    "row":xtable_row_cont,    "c":xtable_c_cont,    "h":xtable_h_cont,    "module":module_cont,    "desc":desc_cont,    "attr":attr_cont,    "ex":ex_cont,    "ex-box":ex_box_cont,    "ex-src":ex_src_cont,    "ex-html":ex_html_cont,    "noex":noex_cont, -  "tag":lambda(Parser.HTML p, mapping m, string c) { +  "tag":lambda(TagdocParser p, mapping m, string c) {    return ({ "&lt;"+c+"&gt;" });    }, -  "ent":lambda(Parser.HTML p, mapping m, string c) { +  "ent":lambda(TagdocParser p, mapping m, string c) {    return ({ "&amp;" + c + ";" });    }, -  "xref":lambda(Parser.HTML p, mapping m, string c) { +  "xref":lambda(TagdocParser p, mapping m, string c) {    if( (!c || !sizeof(c)) && m->href ) {    c = m->href;    sscanf(c, "%s.tag", c);    return replace((c/"/")[-1], "_", " ");    }    return c; }, -  "short":lambda(Parser.HTML p, mapping m, string c) { +  "short":lambda(TagdocParser p, mapping m, string c) {    return m->hide?"":c;    }, -  "note":lambda(Parser.HTML p, mapping m, string c) { +  "note":lambda(TagdocParser p, mapping m, string c) {    return c;    },    ]) )->    add_quote_tag("!--","","--")->    set_extra(name, id)->finish(doc)->read();   }         // ------------------ Parse docs in mappings --------------