doxygen_xml2qbk moddified.

Paragraphs and precondition are no longer stored in qbk_markups - stored in separate members.
Added support for bold, verbatim, emphasis, computeroutput.

[SVN r82443]
This commit is contained in:
Adam Wulkiewicz
2013-01-11 01:07:38 +00:00
parent 42c7931bc7
commit 979eb9f53d
3 changed files with 86 additions and 34 deletions

View File

@@ -85,6 +85,12 @@ struct markup
}
};
struct paragraph
{
std::string title;
std::string text;
};
// Base of a class/struct, function, define
struct element : public base_element
{
@@ -103,6 +109,8 @@ struct element : public base_element
std::vector<parameter> template_parameters;
std::vector<parameter> parameters;
std::vector<paragraph> paragraphs;
element()
: line(0)
{}
@@ -114,6 +122,7 @@ struct function : public element
function_type type;
std::string definition, argsstring;
std::string return_type, return_description;
std::string precondition;
bool unique;

View File

@@ -77,28 +77,56 @@ static void parse_para(rapidxml::xml_node<>* node, std::string& contents, bool&
}
else if ( boost::equals(name, "itemizedlist") )
{
contents += "\n\n";
contents += "\n";
parse_para(node->first_node(), contents, skip);
contents += "\n[/]";
contents += "\n";
parse_para(node->next_sibling(), contents, skip);
return;
}
else if ( boost::equals(name, "listitem") )
{
contents += "* ";
rapidxml::xml_node<>* li = node->first_node("para");
contents += li ? li->value() : "";
parse_para(node->first_node(), contents, skip);
contents += "\n";
parse_para(node->next_sibling(), contents, skip);
parse_para(node->next_sibling(), contents, skip);
return;
}
else if ( boost::equals(name, "verbatim") )
{
contents += "\n``\n";
parse_para(node->first_node(), contents, skip, false);
contents += "``\n";
parse_para(node->next_sibling(), contents, skip, false);
return;
}
else if ( boost::equals(name, "bold") )
{
contents += "[*";
parse_para(node->first_node(), contents, skip, false);
contents += "]";
parse_para(node->next_sibling(), contents, skip, false);
return;
}
else if ( boost::equals(name, "emphasis") )
{
contents += "['";
parse_para(node->first_node(), contents, skip, false);
contents += "]";
parse_para(node->next_sibling(), contents, skip, false);
return;
}
else if ( boost::equals(name, "computeroutput") )
{
contents += "[^";
parse_para(node->first_node(), contents, skip, false);
contents += "]";
parse_para(node->next_sibling(), contents, skip, false);
return;
}
else if (! (
(boost::equals(name, "para") && first)
|| boost::equals(name, "ref")
|| boost::equals(name, "defval")
|| boost::equals(name, "verbatim")
|| boost::equals(name, "bold")
|| boost::equals(name, "emphasis")
|| boost::equals(name, "linebreak")
))
{
@@ -364,26 +392,15 @@ static void parse_element(rapidxml::xml_node<>* node, configuration const& confi
std::string kind = get_attribute(node, "kind");
if (kind == "par")
{
rapidxml::xml_node<> * title_node = node->first_node("title");
std::string title = title_node ? title_node->value() : "";
std::string m;
if ( title_node )
m = std::string("[heading ") + title + "]\n";
else
m = "\n\n";
paragraph p;
parse_para(node->first_node("para"), m, el.skip);
m += "\n";
el.qbk_markup.push_back(markup(m));
}
else if (kind == "pre")
{
std::string para;
parse_para(node->first_node("para"), para, el.skip);
rapidxml::xml_node<> * title_node = node->first_node("title");
if ( title_node )
p.title = title_node->value();
parse_para(node->first_node("para"), p.text, el.skip);
el.qbk_markup.push_back(markup(std::string("[heading Precondition]\n") + para));
el.paragraphs.push_back(p);
}
}
else if (full == ".param")
@@ -432,12 +449,16 @@ static void parse_function(rapidxml::xml_node<>* node, configuration const& conf
std::string kind = get_attribute(node, "kind");
if (kind == "return")
{
get_contents(node->first_node(), f.return_description);
parse_para(node->first_node(), f.return_description, f.skip);
}
/*else if (kind == "param")
{
get_contents(node->first_node(), f.paragraphs);
}*/
else if (kind == "pre")
{
parse_para(node->first_node(), f.precondition, f.skip);
}
}
else if (full == ".detaileddescription.para.image")
{

View File

@@ -741,7 +741,7 @@ void quickbook_output_function(std::vector<function> const& functions,
out << "`";
if ( !config.index_id_path.empty() )
out << "]";
out << "][" << replace_brackets(f.brief_description) << "]]" << std::endl;
out << "][" << f.brief_description << "]]" << std::endl;
}
}
out << "]" << std::endl
@@ -763,7 +763,7 @@ void quickbook_output_detail_function(std::vector<function> const& functions,
// Section
std::stringstream ss;
quickbook_synopsis_short(f, ss);
out << "[section:" << qbk_id_prefix << i << " " << replace_brackets(ss.str()) << "]" << std::endl;
out << "[section:" << qbk_id_prefix << i << " " << replace_brackets(ss.str()) << "]" << std::endl;
// Brief description
out << f.brief_description << std::endl;
@@ -785,18 +785,26 @@ void quickbook_output_detail_function(std::vector<function> const& functions,
// Parameters
if ( !f.parameters.empty() )
{
out << "[heading Parameters]" << std::endl;
out << "[heading Parameter(s)]" << std::endl;
out << "[table " << std::endl;
out << "[[Type][Name][Description]]" << std::endl;
BOOST_FOREACH(parameter const& p, f.parameters)
{
if (!p.skip)
{
out << "[[ `" << p.fulltype << "` ][ `" << p.name << "` ][" << replace_brackets(p.brief_description) << "]]"<< std::endl;
out << "[[ `" << p.fulltype << "` ][ `" << p.name << "` ][" << p.brief_description << "]]"<< std::endl;
}
}
out << "]" << std::endl;
}
}
// Precondition
if ( !f.precondition.empty() )
{
out << "[heading Precondition(s)]" << std::endl;
out << f.precondition << std::endl;
out << std::endl;
}
// Return
if ( !f.return_description.empty() )
@@ -804,6 +812,20 @@ void quickbook_output_detail_function(std::vector<function> const& functions,
out << "[heading Returns]" << std::endl;
out << f.return_description << std::endl;
}
// Additional paragraphs
if ( !f.paragraphs.empty() )
{
BOOST_FOREACH(paragraph const& p, f.paragraphs)
{
if ( !p.title.empty() )
out << "[heading " << p.title << "]" << std::endl;
else
out << "\n\n" << std::endl;
out << p.text << std::endl;
out << std::endl;
}
}
// QBK markup
quickbook_markup(f.qbk_markup, markup_any, markup_default, out);
@@ -942,7 +964,7 @@ void quickbook_output_alt(class_or_struct const& cos, configuration const& confi
out << p.fulltype.substr(6);
else
out << p.fulltype;
out << "`][" << replace_brackets(p.brief_description) << "]]" << std::endl;
out << "`][" << p.brief_description << "]]" << std::endl;
}
out << "]" << std::endl
<< std::endl;
@@ -966,7 +988,7 @@ void quickbook_output_alt(class_or_struct const& cos, configuration const& confi
continue;
out << "[[`" << e.name;
out << "`][" << replace_brackets(e.brief_description) << "]]" << std::endl;
out << "`][" << e.brief_description << "]]" << std::endl;
}
out << "]" << std::endl
<< std::endl;