PATCH: Add tags for tabular lists, take 2
mwoehlke <[email protected]>
| Newsgroups | gmane.text.doxygen.devel |
|---|---|
| Message-ID | <[email protected]> |
This is an improved version of my previous patch to add '\li2' and '\li3' tags to Doxygen. This adds \li2 and \li3 tags to Doxygen (diff'd against 1.4.7). \li2 is identical to \param except that it does not cause a section to be created, and so can be used with custom sections (\par) or in the detailed description. \li3 uses the first (typically unused, except for \param with [in], [out], [in,out]) column to make three-column lists (\li2 does 2-column lists, obviously); it treats '-' as an empty cell. This second version attempts to support the other formats (man, rtf, latex) as well, although the latex support is a WAG (because I don't know latex and don't have latex to play around with it); man however I do know and should be OK. This also contains a file with suggested doc, although I didn't patch it because my cursory glance at the existing doc did not reveal any obvious logic for where in the existing doc this should be placed (the order is not simply alphabetical). This could still benefit from allowing \li2 and \li3 to be mixed, although that would either violate some coding principles (assign both the same internal type, but parse differently) or make the code a good deal more complicated than the existing hack of treating '-' as an empty word. -- Matthew "Try to bring it back in one piece this time." -- Q (MI6) ------------------------------------------------------------------------- Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys -- and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV _______________________________________________ Doxygen-develop mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/doxygen-develop
doxygen_li.doc
(application/vnd.ms-word, 2.2 KB) - not displayed
doxygen_li.patch
(text/x-patch, 13 KB)
diff -ur doxygen-1.4.7_old/src/cmdmapper.cpp doxygen-1.4.7/src/cmdmapper.cpp
--- doxygen-1.4.7_old/src/cmdmapper.cpp 2006-05-07 13:02:30.000000000 -0500
+++ doxygen-1.4.7/src/cmdmapper.cpp 2006-09-19 13:46:12.000000000 -0500
@@ -107,6 +107,8 @@
{ "endmanonly", CMD_ENDMANONLY },
{ "includelineno", CMD_INCWITHLINES },
{ "inheritdoc", CMD_INHERITDOC },
+ { "li2", CMD_LI2 },
+ { "li3", CMD_LI3 },
{ 0, 0 }
};
diff -ur doxygen-1.4.7_old/src/cmdmapper.h doxygen-1.4.7/src/cmdmapper.h
--- doxygen-1.4.7_old/src/cmdmapper.h 2006-05-07 13:02:30.000000000 -0500
+++ doxygen-1.4.7/src/cmdmapper.h 2006-09-19 14:43:02.000000000 -0500
@@ -107,7 +107,9 @@
CMD_MANONLY = 73,
CMD_ENDMANONLY = 74,
CMD_INCWITHLINES = 75,
- CMD_INHERITDOC = 76
+ CMD_INHERITDOC = 76,
+ CMD_LI2 = 77 | SIMPLESECT_BIT,
+ CMD_LI3 = 78 | SIMPLESECT_BIT
};
enum HtmlTagType
diff -ur doxygen-1.4.7_old/src/compound_xsd.h doxygen-1.4.7/src/compound_xsd.h
--- doxygen-1.4.7_old/src/compound_xsd.h 2006-05-07 13:02:30.000000000 -0500
+++ doxygen-1.4.7/src/compound_xsd.h 2006-09-19 11:24:21.000000000 -0500
@@ -760,6 +760,8 @@
" <xsd:restriction base=\"xsd:string\">\n"
" <xsd:enumeration value=\"param\" />\n"
" <xsd:enumeration value=\"retval\" />\n"
+" <xsd:enumeration value=\"li2\" />\n"
+" <xsd:enumeration value=\"li3\" />\n"
" <xsd:enumeration value=\"exception\" />\n"
" </xsd:restriction>\n"
" </xsd:simpleType>\n"
diff -ur doxygen-1.4.7_old/src/docparser.cpp doxygen-1.4.7/src/docparser.cpp
--- doxygen-1.4.7_old/src/docparser.cpp 2006-05-07 13:02:30.000000000 -0500
+++ doxygen-1.4.7/src/docparser.cpp 2006-09-19 15:13:03.000000000 -0500
@@ -3597,6 +3597,25 @@
cmdName.data());
}
doctokenizerYYsetStateParam();
+
+ if (cmdName=="li3") {
+ tok=doctokenizerYYlex();
+ while (tok==TK_WORD) /* there is a parameter name */
+ {
+ if (g_token->name!="-")
+ handleLinkedWord(this,m_iparams);
+ tok=doctokenizerYYlex();
+ }
+ if (tok==0) /* premature end of comment block */
+ {
+ warn_doc_error(g_fileName,doctokenizerYYlineno,"Warning: unexpected end of comment block while parsing the "
+ "argument of command %s",cmdName.data());
+ retval=0;
+ goto endparamlist;
+ }
+ ASSERT(tok==TK_WORD || tok==TK_WHITESPACE);
+ }
+
tok=doctokenizerYYlex();
while (tok==TK_WORD) /* there is a parameter name */
{
@@ -4316,6 +4336,12 @@
case CMD_RETVAL:
retval = handleParamSection(cmdName,DocParamSect::RetVal);
break;
+ case CMD_LI2:
+ retval = handleParamSection(cmdName,DocParamSect::List2Item);
+ break;
+ case CMD_LI3:
+ retval = handleParamSection(cmdName,DocParamSect::List3Item);
+ break;
case CMD_EXCEPTION:
retval = handleParamSection(cmdName,DocParamSect::Exception);
break;
diff -ur doxygen-1.4.7_old/src/docparser.h doxygen-1.4.7/src/docparser.h
--- doxygen-1.4.7_old/src/docparser.h 2006-05-07 13:02:30.000000000 -0500
+++ doxygen-1.4.7/src/docparser.h 2006-09-19 13:57:30.000000000 -0500
@@ -934,7 +934,7 @@
public:
enum Type
{
- Unknown, Param, RetVal, Exception
+ Unknown, Param, RetVal, List2Item, List3Item, Exception
};
enum Direction
{
@@ -945,6 +945,7 @@
int parse(const QString &cmdName,bool xmlContext,Direction d);
Kind kind() const { return Kind_ParamSect; }
Type type() const { return m_type; }
+ bool isInline() const { return m_type == List2Item || m_type == List3Item; }
DocNode *parent() const { return m_parent; }
void accept(DocVisitor *v) { CompAccept<DocParamSect>::accept(this,v); }
@@ -1009,6 +1010,7 @@
Kind kind() const { return Kind_ParamList; }
DocNode *parent() const { return m_parent; }
const QList<DocNode> ¶meters() { return m_params; }
+ const QList<DocNode> &iparameters() { return m_iparams; }
DocParamSect::Type type() const { return m_type; }
DocParamSect::Direction direction() const { return m_dir; }
void markFirst(bool b=TRUE) { m_isFirst=b; }
@@ -1030,6 +1032,7 @@
DocNode * m_parent;
QList<DocPara> m_paragraphs;
QList<DocNode> m_params;
+ QList<DocNode> m_iparams;
DocParamSect::Type m_type;
DocParamSect::Direction m_dir;
bool m_isFirst;
diff -ur doxygen-1.4.7_old/src/htmldocvisitor.cpp doxygen-1.4.7/src/htmldocvisitor.cpp
--- doxygen-1.4.7_old/src/htmldocvisitor.cpp 2006-05-07 13:02:31.000000000 -0500
+++ doxygen-1.4.7/src/htmldocvisitor.cpp 2006-09-19 14:38:39.000000000 -0500
@@ -879,28 +879,31 @@
void HtmlDocVisitor::visitPre(DocParamSect *s)
{
if (m_hide) return;
- m_t << "<dl compact><dt><b>";
- switch(s->type())
- {
- case DocParamSect::Param:
- m_t << theTranslator->trParameters(); break;
- case DocParamSect::RetVal:
- m_t << theTranslator->trReturnValues(); break;
- case DocParamSect::Exception:
- m_t << theTranslator->trExceptions(); break;
- default:
- ASSERT(0);
+ if (!s->isInline()) {
+ m_t << "<dl compact><dt><b>";
+ switch(s->type())
+ {
+ case DocParamSect::Param:
+ m_t << theTranslator->trParameters(); break;
+ case DocParamSect::RetVal:
+ m_t << theTranslator->trReturnValues(); break;
+ case DocParamSect::Exception:
+ m_t << theTranslator->trExceptions(); break;
+ default:
+ ASSERT(0);
+ }
+ m_t << ":";
+ m_t << "</b></dt><dd>" << endl;
}
- m_t << ":";
- m_t << "</b></dt><dd>" << endl;
m_t << " <table border=\"0\" cellspacing=\"2\" cellpadding=\"0\">" << endl;
}
-void HtmlDocVisitor::visitPost(DocParamSect *)
+void HtmlDocVisitor::visitPost(DocParamSect *s)
{
if (m_hide) return;
m_t << " </table>" << endl;
- m_t << "</dl>" << endl;
+ if (!s->isInline())
+ m_t << "</dl>" << endl;
}
void HtmlDocVisitor::visitPre(DocParamList *pl)
@@ -924,6 +927,23 @@
}
m_t << "]</tt> ";
}
+ QListIterator<DocNode> lii(pl->iparameters());
+ if (lii.count()>0) {
+ DocNode *iparam;
+ bool ifirst=TRUE;
+ for (lii.toFirst();(iparam=lii.current());++lii)
+ {
+ if (!ifirst) m_t << ","; else ifirst=FALSE;
+ if (iparam->kind()==DocNode::Kind_Word)
+ {
+ visit((DocWord*)iparam);
+ }
+ else if (iparam->kind()==DocNode::Kind_LinkedWord)
+ {
+ visit((DocLinkedWord*)iparam);
+ }
+ }
+ }
m_t << "</td><td valign=\"top\"><em>";
//QStrListIterator li(pl->parameters());
//const char *s;
diff -ur doxygen-1.4.7_old/src/latexdocvisitor.cpp doxygen-1.4.7/src/latexdocvisitor.cpp
--- doxygen-1.4.7_old/src/latexdocvisitor.cpp 2006-05-07 13:02:31.000000000 -0500
+++ doxygen-1.4.7/src/latexdocvisitor.cpp 2006-10-09 15:48:28.000000000 -0500
@@ -888,28 +888,31 @@
void LatexDocVisitor::visitPre(DocParamSect *s)
{
if (m_hide) return;
- m_t << "\\begin{Desc}" << endl;
- m_t << "\\item[";
- switch(s->type())
+ if (!s->isInline())
{
- case DocParamSect::Param:
- filter(theTranslator->trParameters()); break;
- case DocParamSect::RetVal:
- filter(theTranslator->trReturnValues()); break;
- case DocParamSect::Exception:
- filter(theTranslator->trExceptions()); break;
- default:
- ASSERT(0);
+ m_t << "\\begin{Desc}" << endl;
+ m_t << "\\item[";
+ switch(s->type())
+ {
+ case DocParamSect::Param:
+ filter(theTranslator->trParameters()); break;
+ case DocParamSect::RetVal:
+ filter(theTranslator->trReturnValues()); break;
+ case DocParamSect::Exception:
+ filter(theTranslator->trExceptions()); break;
+ default:
+ ASSERT(0);
+ }
+ m_t << ":]" << endl;
}
- m_t << ":]" << endl;
m_t << "\\begin{description}" << endl;
}
-void LatexDocVisitor::visitPost(DocParamSect *)
+void LatexDocVisitor::visitPost(DocParamSect *s)
{
if (m_hide) return;
m_t << "\\end{description}" << endl;
- m_t << "\\end{Desc}" << endl;
+ if (!s->isInline()) m_t << "\\end{Desc}" << endl;
}
void LatexDocVisitor::visitPre(DocParamList *pl)
diff -Bbur doxygen-1.4.7_old/src/mandocvisitor.cpp doxygen-1.4.7/src/mandocvisitor.cpp
--- doxygen-1.4.7_old/src/mandocvisitor.cpp 2006-05-07 13:02:31.000000000 -0500
+++ doxygen-1.4.7/src/mandocvisitor.cpp 2006-10-09 15:40:02.000000000 -0500
@@ -797,6 +797,7 @@
m_t << endl;
m_t << ".PP" << endl;
}
+ if (s->isInline()) return;
m_t << "\\fB";
switch(s->type())
{
@@ -813,11 +814,11 @@
m_t << ".RS 4" << endl;
}
-void ManDocVisitor::visitPost(DocParamSect *)
+void ManDocVisitor::visitPost(DocParamSect *s)
{
if (m_hide) return;
if (!m_firstCol) m_t << endl;
- m_t << ".RE" << endl;
+ if (!s->isInline()) m_t << ".RE" << endl;
m_t << ".PP" << endl;
m_firstCol=TRUE;
}
diff -ur doxygen-1.4.7_old/src/outputgen.h doxygen-1.4.7/src/outputgen.h
--- doxygen-1.4.7_old/src/outputgen.h 2006-05-07 13:02:31.000000000 -0500
+++ doxygen-1.4.7/src/outputgen.h 2006-09-19 11:31:54.000000000 -0500
@@ -83,7 +83,7 @@
{
public:
virtual ~BaseOutputDocInterface() {}
- enum ParamListTypes { Param, RetVal, Exception };
+ enum ParamListTypes { Param, RetVal, List2Item, List3Item, Exception };
enum SectionTypes { /*See, Return, Author, Version,
Since, Date, Bug, Note,
Warning, Par, Deprecated, Pre,
diff -ur doxygen-1.4.7_old/src/perlmodgen.cpp doxygen-1.4.7/src/perlmodgen.cpp
--- doxygen-1.4.7_old/src/perlmodgen.cpp 2006-05-07 13:02:31.000000000 -0500
+++ doxygen-1.4.7/src/perlmodgen.cpp 2006-09-19 11:39:57.000000000 -0500
@@ -1151,6 +1151,8 @@
{
case DocParamSect::Param: type = "params"; break;
case DocParamSect::RetVal: type = "retvals"; break;
+ case DocParamSect::List2Item: type = "list2items"; break;
+ case DocParamSect::List3Item: type = "list3items"; break;
case DocParamSect::Exception: type = "exceptions"; break;
case DocParamSect::Unknown:
err("Error: unknown parameter section found\n");
diff -ur doxygen-1.4.7_old/src/printdocvisitor.h doxygen-1.4.7/src/printdocvisitor.h
--- doxygen-1.4.7_old/src/printdocvisitor.h 2006-05-07 13:02:31.000000000 -0500
+++ doxygen-1.4.7/src/printdocvisitor.h 2006-09-19 13:47:02.000000000 -0500
@@ -586,6 +586,8 @@
{
case DocParamSect::Param: printf("param"); break;
case DocParamSect::RetVal: printf("retval"); break;
+ case DocParamSect::List2Item: printf("li2"); break;
+ case DocParamSect::List3Item: printf("li3"); break;
case DocParamSect::Exception: printf("exception"); break;
case DocParamSect::Unknown: printf("unknown"); break;
}
diff -ur doxygen-1.4.7_old/src/rtfdocvisitor.cpp doxygen-1.4.7/src/rtfdocvisitor.cpp
--- doxygen-1.4.7_old/src/rtfdocvisitor.cpp 2006-05-07 13:02:31.000000000 -0500
+++ doxygen-1.4.7/src/rtfdocvisitor.cpp 2006-10-09 16:04:44.000000000 -0500
@@ -1135,34 +1135,37 @@
if (m_hide) return;
DBG_RTF("{\\comment RTFDocVisitor::visitPre(DocParamSect)}\n");
m_t << "{"; // start param list
- if (!m_lastIsPara) m_t << "\\par" << endl;
- //m_t << "{\\b "; // start bold
- m_t << "{" << rtf_Style["Heading5"]->reference << endl;
- switch(s->type())
+ if (!s->isInline())
{
- case DocParamSect::Param:
- m_t << theTranslator->trParameters(); break;
- case DocParamSect::RetVal:
- m_t << theTranslator->trReturnValues(); break;
- case DocParamSect::Exception:
- m_t << theTranslator->trExceptions(); break;
- default:
- ASSERT(0);
+ if (!m_lastIsPara) m_t << "\\par" << endl;
+ //m_t << "{\\b "; // start bold
+ m_t << "{" << rtf_Style["Heading5"]->reference << endl;
+ switch(s->type())
+ {
+ case DocParamSect::Param:
+ m_t << theTranslator->trParameters(); break;
+ case DocParamSect::RetVal:
+ m_t << theTranslator->trReturnValues(); break;
+ case DocParamSect::Exception:
+ m_t << theTranslator->trExceptions(); break;
+ default:
+ ASSERT(0);
+ }
+ m_t << ":";
+ m_t << "\\par" << endl;
+ m_t << "}" << endl;
+ incIndentLevel();
}
- m_t << ":";
- m_t << "\\par" << endl;
- m_t << "}" << endl;
- incIndentLevel();
m_t << rtf_Style_Reset << getStyle("DescContinue");
m_lastIsPara=TRUE;
}
-void RTFDocVisitor::visitPost(DocParamSect *)
+void RTFDocVisitor::visitPost(DocParamSect *s)
{
if (m_hide) return;
DBG_RTF("{\\comment RTFDocVisitor::visitPost(DocParamSect)}\n");
//m_t << "\\par" << endl;
- decIndentLevel();
+ if (!s->isInline()) decIndentLevel();
m_t << "}" << endl;
}
diff -ur doxygen-1.4.7_old/src/xmldocvisitor.cpp doxygen-1.4.7/src/xmldocvisitor.cpp
--- doxygen-1.4.7_old/src/xmldocvisitor.cpp 2006-05-07 13:02:32.000000000 -0500
+++ doxygen-1.4.7/src/xmldocvisitor.cpp 2006-09-19 11:25:12.000000000 -0500
@@ -770,6 +770,10 @@
m_t << "param"; break;
case DocParamSect::RetVal:
m_t << "retval"; break;
+ case DocParamSect::List2Item:
+ m_t << "li2"; break;
+ case DocParamSect::List3Item:
+ m_t << "li3"; break;
case DocParamSect::Exception:
m_t << "exception"; break;
default: