Tools.AutoDoc: Improved rendering of annotations.

Annotations are now resolved and get proper links.
parent 3fa28206
......@@ -584,9 +584,57 @@ class Annotation
array(string) tokens;
void format_xml(String.Buffer buf, array(string|array) tokens)
{
string end_tag;
foreach(tokens, string|array elem) {
if (arrayp(elem)) {
if (end_tag) {
buf->add(end_tag);
end_tag = UNDEFINED;
}
format_xml(buf, elem);
} else {
switch(elem) {
case ",": case "(": case "{": case "[": case ")": case "}": case "]":
// Separator.
if (end_tag) {
buf->add(end_tag);
end_tag = UNDEFINED;
}
buf->add(elem);
break;
default:
elem = String.trim_all_whites(elem);
if (elem == "") continue;
if ((elem[0] == '"') || (elem[0] == '\'')) {
// String or character literal.
if (end_tag) {
buf->add(end_tag);
end_tag = UNDEFINED;
}
} else if (!end_tag) {
buf->add("<ref>");
end_tag = "</ref>";
}
buf->add(xmlquote(elem));
break;
}
}
}
if (end_tag) {
buf->add(end_tag);
}
}
string xml(.Flags|void flags)
{
return xmltag("annotation", tokens * "");
String.Buffer res = String.Buffer();
res->add("<annotation>");
array(string|array) grouped = Parser.Pike.group(tokens);
format_xml(res, tokens);
res->add("</annotation>");
return res->get();
}
string `name()
......
......@@ -334,12 +334,12 @@ string parse_module(Node n, void|int noheader) {
return ret;
}
string parse_annotations(Node n)
string parse_annotations(Node n, void|int noheader)
{
string ret = "";
ret += lay->dochead + "Annotations" + lay->_dochead;
foreach(n->get_elements("annotation"), Node a) {
ret += lay->annotation + lay->code + quote(a->value_of_node()) +
ret += lay->annotation + lay->code + parse_text(a) +
lay->_code + lay->_annotation;
}
return ret;
......@@ -356,15 +356,15 @@ string parse_class(Node n, void|int noheader) {
"</dt><dd>";
Node a = n->get_first_element("annotations");
if (a) {
ret += "<dl class='group--annotations'>" + parse_annotations(a) + "</dl>\n";
}
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 class='group--doc'>" + parse_doc(c) + "</dl>";
if(a || c) {
ret += "<dl class='group--doc'>";
if (a) ret += parse_annotations(a);
if (c) ret += parse_doc(c);
ret += "</dl>";
}
if((sizeof(n->get_elements("doc"))>1) &&
((flags & (Tools.AutoDoc.FLAG_KEEP_GOING|Tools.AutoDoc.FLAG_DEBUG)) ==
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment