PATCH: Add tags for tabular lists (ala \param, \retval, etc)

mwoehlke <[email protected]>
Newsgroups gmane.text.doxygen.devel
Message-ID <[email protected]>
The attached patch 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) 
column to make three-column lists (\li2 does 2-column lists, obviously); 
it treats '-' as an empty cell.

Needed improvements:
- Support the new tags in other output formats (shouldn't be difficult, 
but I don't feel familiar enough with the code - or LaTeX for that 
matter - to want to mess with it).

Suggested improvements:
- Allow mixing \li2 and \li3 in the same table/list (and then remove 
treating '-' as empty).
- Add \li1?

I'm also open to suggestions on how to make the new code less ugly (for 
instance, not needing the second params list would be nice).

-- 
Matthew
Will your shell have salvation? Only if it's Bourne Again.

-------------------------------------------------------------------------
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.patch (text/x-patch, 9 KB)
diff -Bbur 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 -Bbur 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 -Bbur 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 -Bbur 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 -Bbur 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> &parameters()    { 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 -Bbur 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>&nbsp;";
   }
+  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 -Bbur 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 -Bbur 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 -Bbur 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 -Bbur 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:
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.