[patch] Add \prototype command
"Johann Hanne" <[email protected]>
| Newsgroups | gmane.text.doxygen.devel |
|---|---|
| Message-ID | <[email protected]> |
Hi, the attached patch adds a command named \prototype which simply creates a paragraph showing the prototype of the member. This sometimes looks nicer compared to having the complete prototype output in the header. Comments, please? Cheers, Johann ------------------------------------------------------------------------- This SF.net email is sponsored by the 2008 JavaOne(SM) Conference Register now and save $200. Hurry, offer ends at 11:59 p.m., Monday, April 7! Use priority code J8TLD2. http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone _______________________________________________ Doxygen-develop mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/doxygen-develop
doxygen-prototype.diff
(text/x-diff, 14.2 KB)
diff -uNr doxygen-1.5.5/src/cmdmapper.cpp doxygen-1.5.5.jh2/src/cmdmapper.cpp
--- doxygen-1.5.5/src/cmdmapper.cpp 2008-01-26 15:56:47.000000000 +0100
+++ doxygen-1.5.5.jh2/src/cmdmapper.cpp 2008-04-08 10:55:17.000000000 +0200
@@ -109,6 +109,7 @@
{ "endmanonly", CMD_ENDMANONLY },
{ "includelineno", CMD_INCWITHLINES },
{ "inheritdoc", CMD_INHERITDOC },
+ { "prototype", CMD_PROTOTYPE },
{ 0, 0 }
};
diff -uNr doxygen-1.5.5/src/cmdmapper.h doxygen-1.5.5.jh2/src/cmdmapper.h
--- doxygen-1.5.5/src/cmdmapper.h 2008-01-26 15:57:33.000000000 +0100
+++ doxygen-1.5.5.jh2/src/cmdmapper.h 2008-04-08 10:55:17.000000000 +0200
@@ -110,7 +110,8 @@
CMD_ENDMANONLY = 76,
CMD_INCWITHLINES = 77,
CMD_INHERITDOC = 78,
- CMD_TPARAM = 79 | SIMPLESECT_BIT
+ CMD_TPARAM = 79 | SIMPLESECT_BIT,
+ CMD_PROTOTYPE = 80 | SIMPLESECT_BIT
};
enum HtmlTagType
diff -uNr doxygen-1.5.5/src/docparser.cpp doxygen-1.5.5.jh2/src/docparser.cpp
--- doxygen-1.5.5/src/docparser.cpp 2008-01-28 20:40:45.000000000 +0100
+++ doxygen-1.5.5.jh2/src/docparser.cpp 2008-04-08 11:04:59.000000000 +0200
@@ -3855,6 +3855,33 @@
return retval;
}
+int DocSimpleSect::genPrototype()
+{
+ DBG(("DocSimpleSect::genPrototype() start\n"));
+ g_nodeStack.push(this);
+
+ // add new paragraph as child
+ DocPara *par = new DocPara(this);
+ if (m_children.isEmpty())
+ {
+ par->markFirst();
+ }
+ else
+ {
+ ASSERT(m_children.last()->kind()==DocNode::Kind_Para);
+ ((DocPara *)m_children.last())->markLast(FALSE);
+ }
+ par->markLast();
+ m_children.append(par);
+
+ int retval = par->genPrototype();
+
+ DBG(("DocSimpleSect::genPrototype() end retval=%d\n",retval));
+ DocNode *n=g_nodeStack.pop();
+ ASSERT(n==this);
+ return retval; // 0==EOF, TK_NEWPARA, TK_LISTITEM, TK_ENDLIST, RetVal_SimpleSec
+}
+
void DocSimpleSect::appendLinkWord(const QString &word)
{
DocPara *p;
@@ -3898,6 +3925,7 @@
case Attention: return "attention";
case User: return "user";
case Rcs: return "rcs";
+ case Prototype: return "prototype";
}
return "unknown";
}
@@ -4114,6 +4142,17 @@
return (rv!=TK_NEWPARA) ? rv : RetVal_OK;
}
+int DocPara::handlePrototypeSection()
+{
+ DocSimpleSect *ss=0;
+ ss=new DocSimpleSect(this,DocSimpleSect::Prototype);
+ m_children.append(ss);
+
+ int rv = RetVal_OK;
+ rv = ss->genPrototype();
+ return (rv!=TK_NEWPARA) ? rv : RetVal_OK;
+}
+
int DocPara::handleXRefItem()
{
int retval=doctokenizerYYlex();
@@ -4799,6 +4838,11 @@
case CMD_INHERITDOC:
handleInheritDoc();
break;
+ case CMD_PROTOTYPE:
+ if (g_memberDef != NULL && g_memberDef->isFunction()) {
+ retval = handlePrototypeSection();
+ }
+ break;
default:
// we should not get here!
ASSERT(0);
@@ -5688,6 +5732,47 @@
return retval;
}
+int DocPara::genPrototype()
+{
+ DBG(("DocPara::genPrototype() start\n"));
+ g_nodeStack.push(this);
+ // handle style commands "inherited" from the previous paragraph
+ handleInitialStyleCommands(this,m_children);
+
+ ASSERT(g_memberDef != NULL);
+
+ LockingPtr<ArgumentList> defArgList=(g_memberDef->isDocsForDefinition()) ?
+ g_memberDef->argumentList() :
+ g_memberDef->declArgumentList();
+
+ m_children.append(new DocWord(this,g_memberDef->definition()));
+ m_children.append(new DocWord(this,"("));
+
+ Argument *a=defArgList->first();
+ bool first=TRUE;
+ while (a)
+ {
+ if (!a->name.isEmpty() || (a->name.isEmpty() && a->type=="...")) // argument has a name
+ {
+ m_children.append(new DocWord(this,a->type + " " + a->name));
+ }
+ a=defArgList->next();
+ if (a)
+ {
+ if (!g_memberDef->isObjCMethod()) m_children.append(new DocWord(this,", ")); // there are more arguments
+ }
+ first=FALSE;
+ }
+
+ m_children.append(new DocWord(this,")"));
+
+ handlePendingStyleCommands(this,m_children);
+ DocNode *n = g_nodeStack.pop();
+ ASSERT(n==this);
+
+ return TK_NEWPARA;
+}
+
//--------------------------------------------------------------------------
int DocSection::parse()
diff -uNr doxygen-1.5.5/src/docparser.h doxygen-1.5.5.jh2/src/docparser.h
--- doxygen-1.5.5/src/docparser.h 2008-01-26 15:02:09.000000000 +0100
+++ doxygen-1.5.5.jh2/src/docparser.h 2008-04-08 10:55:17.000000000 +0200
@@ -913,7 +913,8 @@
enum Type
{
Unknown, See, Return, Author, Authors, Version, Since, Date,
- Note, Warning, Pre, Post, Invar, Remark, Attention, User, Rcs
+ Note, Warning, Pre, Post, Invar, Remark, Attention, User, Rcs,
+ Prototype
};
DocSimpleSect(DocNode *parent,Type t);
virtual ~DocSimpleSect();
@@ -925,6 +926,7 @@
int parse(bool userTitle);
int parseRcs();
int parseXml();
+ int genPrototype();
void appendLinkWord(const QString &word);
private:
@@ -985,6 +987,7 @@
int handleParamSection(const QString &cmdName,DocParamSect::Type t,
bool xmlContext,
int direction);
+ int handlePrototypeSection();
void handleIncludeOperator(const QString &cmdName,DocIncOperator::Type t);
void handleImage(const QString &cmdName);
void handleDotFile(const QString &cmdName);
@@ -996,6 +999,7 @@
int handleStartCode();
int handleHtmlHeader(const HtmlAttribList &tagHtmlAttribs,int level);
bool injectToken(int tok,const QString &tokText);
+ int genPrototype();
private:
DocNode *m_parent;
diff -uNr doxygen-1.5.5/src/htmldocvisitor.cpp doxygen-1.5.5.jh2/src/htmldocvisitor.cpp
--- doxygen-1.5.5/src/htmldocvisitor.cpp 2008-01-26 15:05:40.000000000 +0100
+++ doxygen-1.5.5.jh2/src/htmldocvisitor.cpp 2008-04-08 10:55:17.000000000 +0200
@@ -514,6 +514,8 @@
m_t << theTranslator->trRemarks(); break;
case DocSimpleSect::Attention:
m_t << theTranslator->trAttention(); break;
+ case DocSimpleSect::Prototype:
+ m_t << theTranslator->trPrototype(); break;
case DocSimpleSect::User: break;
case DocSimpleSect::Rcs: break;
case DocSimpleSect::Unknown: break;
diff -uNr doxygen-1.5.5/src/latexdocvisitor.cpp doxygen-1.5.5.jh2/src/latexdocvisitor.cpp
--- doxygen-1.5.5/src/latexdocvisitor.cpp 2008-01-26 15:06:24.000000000 +0100
+++ doxygen-1.5.5.jh2/src/latexdocvisitor.cpp 2008-04-08 10:55:17.000000000 +0200
@@ -525,6 +525,8 @@
filter(theTranslator->trRemarks()); break;
case DocSimpleSect::Attention:
filter(theTranslator->trAttention()); break;
+ case DocSimpleSect::Prototype:
+ filter(theTranslator->trPrototype()); break;
case DocSimpleSect::User: break;
case DocSimpleSect::Rcs: break;
case DocSimpleSect::Unknown: break;
diff -uNr doxygen-1.5.5/src/mandocvisitor.cpp doxygen-1.5.5.jh2/src/mandocvisitor.cpp
--- doxygen-1.5.5/src/mandocvisitor.cpp 2008-01-26 15:07:07.000000000 +0100
+++ doxygen-1.5.5.jh2/src/mandocvisitor.cpp 2008-04-08 10:55:17.000000000 +0200
@@ -446,6 +446,8 @@
m_t << theTranslator->trRemarks(); break;
case DocSimpleSect::Attention:
m_t << theTranslator->trAttention(); break;
+ case DocSimpleSect::Prototype:
+ m_t << theTranslator->trPrototype(); break;
case DocSimpleSect::User: break;
case DocSimpleSect::Rcs: break;
case DocSimpleSect::Unknown: break;
diff -uNr doxygen-1.5.5/src/printdocvisitor.h doxygen-1.5.5.jh2/src/printdocvisitor.h
--- doxygen-1.5.5/src/printdocvisitor.h 2008-01-26 15:04:02.000000000 +0100
+++ doxygen-1.5.5.jh2/src/printdocvisitor.h 2008-04-08 10:55:17.000000000 +0200
@@ -287,6 +287,7 @@
case DocSimpleSect::Attention: printf("attention"); break;
case DocSimpleSect::User: printf("user"); break;
case DocSimpleSect::Rcs: printf("rcs"); break;
+ case DocSimpleSect::Prototype: printf("prototype"); break;
case DocSimpleSect::Unknown: printf("unknown"); break;
}
printf(">\n");
diff -uNr doxygen-1.5.5/src/rtfdocvisitor.cpp doxygen-1.5.5.jh2/src/rtfdocvisitor.cpp
--- doxygen-1.5.5/src/rtfdocvisitor.cpp 2008-01-26 15:07:07.000000000 +0100
+++ doxygen-1.5.5.jh2/src/rtfdocvisitor.cpp 2008-04-08 10:55:17.000000000 +0200
@@ -661,6 +661,8 @@
m_t << theTranslator->trRemarks(); break;
case DocSimpleSect::Attention:
m_t << theTranslator->trAttention(); break;
+ case DocSimpleSect::Prototype:
+ m_t << theTranslator->trPrototype(); break;
case DocSimpleSect::User: break;
case DocSimpleSect::Rcs: break;
case DocSimpleSect::Unknown: break;
diff -uNr doxygen-1.5.5/src/translator_adapter.h doxygen-1.5.5.jh2/src/translator_adapter.h
--- doxygen-1.5.5/src/translator_adapter.h 2008-01-01 11:41:02.000000000 +0100
+++ doxygen-1.5.5.jh2/src/translator_adapter.h 2008-04-08 10:55:17.000000000 +0200
@@ -115,6 +115,9 @@
virtual QCString trTypeConstraints()
{ return english.trTypeConstraints(); }
+
+ virtual QCString trPrototype()
+ { return english.trPrototype(); }
};
class TranslatorAdapter_1_4_6 : public TranslatorAdapter_1_5_4
diff -uNr doxygen-1.5.5/src/translator_br.h doxygen-1.5.5.jh2/src/translator_br.h
--- doxygen-1.5.5/src/translator_br.h 2008-02-07 23:31:50.000000000 +0100
+++ doxygen-1.5.5.jh2/src/translator_br.h 2008-04-08 10:55:17.000000000 +0200
@@ -1774,5 +1774,10 @@
{
return "Restrições do Tipo";
}
+
+ virtual QCString trPrototype()
+ {
+ return "Prototype";
+ }
};
#endif
diff -uNr doxygen-1.5.5/src/translator_cn.h doxygen-1.5.5.jh2/src/translator_cn.h
--- doxygen-1.5.5/src/translator_cn.h 2008-02-04 20:15:17.000000000 +0100
+++ doxygen-1.5.5.jh2/src/translator_cn.h 2008-04-08 10:55:17.000000000 +0200
@@ -1787,6 +1787,11 @@
{
return "ÀàÐÍÏÞÖÆ";
}
+
+ virtual QCString trPrototype()
+ {
+ return "Prototype";
+ }
};
#endif
diff -uNr doxygen-1.5.5/src/translator_cz.h doxygen-1.5.5.jh2/src/translator_cz.h
--- doxygen-1.5.5/src/translator_cz.h 2008-01-01 11:41:03.000000000 +0100
+++ doxygen-1.5.5.jh2/src/translator_cz.h 2008-04-08 10:55:17.000000000 +0200
@@ -1816,6 +1816,10 @@
return "Omezenà typů (Type Constraints)";
}
+ virtual QCString trPrototype()
+ {
+ return "Prototype";
+ }
};
#endif // TRANSLATOR_CZ_H
diff -uNr doxygen-1.5.5/src/translatordecoder.h doxygen-1.5.5.jh2/src/translatordecoder.h
--- doxygen-1.5.5/src/translatordecoder.h 2008-02-09 20:06:15.000000000 +0100
+++ doxygen-1.5.5.jh2/src/translatordecoder.h 2008-04-08 10:55:17.000000000 +0200
@@ -706,6 +706,8 @@
{ return toUtf8(m_translator->trSubprogram(first_capital,singular)); }
QCString trTypeConstraints()
{ return toUtf8(m_translator->trTypeConstraints()); }
+ QCString trPrototype()
+ { return toUtf8(m_translator->trPrototype()); }
//////////////////////////////////////////////////////////////////////////
diff -uNr doxygen-1.5.5/src/translator_de.h doxygen-1.5.5.jh2/src/translator_de.h
--- doxygen-1.5.5/src/translator_de.h 2008-02-04 20:05:49.000000000 +0100
+++ doxygen-1.5.5.jh2/src/translator_de.h 2008-04-08 10:55:17.000000000 +0200
@@ -1867,6 +1867,10 @@
return "Type Constraints";
}
+ virtual QCString trPrototype()
+ {
+ return "Prototype";
+ }
};
#endif
diff -uNr doxygen-1.5.5/src/translator_en.h doxygen-1.5.5.jh2/src/translator_en.h
--- doxygen-1.5.5/src/translator_en.h 2008-01-01 11:41:03.000000000 +0100
+++ doxygen-1.5.5.jh2/src/translator_en.h 2008-04-08 10:55:17.000000000 +0200
@@ -1776,6 +1776,10 @@
return "Type Constraints";
}
+ virtual QCString trPrototype()
+ {
+ return "Prototype";
+ }
};
#endif
diff -uNr doxygen-1.5.5/src/translator_fa.h doxygen-1.5.5.jh2/src/translator_fa.h
--- doxygen-1.5.5/src/translator_fa.h 2008-02-07 23:35:31.000000000 +0100
+++ doxygen-1.5.5.jh2/src/translator_fa.h 2008-04-08 10:55:17.000000000 +0200
@@ -1714,6 +1714,11 @@
{
return "Type Constraints";
}
+
+ virtual QCString trPrototype()
+ {
+ return "Prototype";
+ }
};
#endif
diff -uNr doxygen-1.5.5/src/translator.h doxygen-1.5.5.jh2/src/translator.h
--- doxygen-1.5.5/src/translator.h 2008-01-01 11:41:02.000000000 +0100
+++ doxygen-1.5.5.jh2/src/translator.h 2008-04-08 10:55:17.000000000 +0200
@@ -476,6 +476,8 @@
virtual QCString trSubprogram(bool first_capital, bool singular) = 0;
virtual QCString trTypeConstraints() = 0;
+ virtual QCString trPrototype() = 0;
+
};
#endif
diff -uNr doxygen-1.5.5/src/translator_hr.h doxygen-1.5.5.jh2/src/translator_hr.h
--- doxygen-1.5.5/src/translator_hr.h 2008-01-01 11:41:04.000000000 +0100
+++ doxygen-1.5.5.jh2/src/translator_hr.h 2008-04-08 10:55:17.000000000 +0200
@@ -1470,6 +1470,11 @@
{
return "Ogranièenja za tip podataka";
}
+
+ virtual QCString trPrototype()
+ {
+ return "Prototype";
+ }
};
#endif
diff -uNr doxygen-1.5.5/src/translator_it.h doxygen-1.5.5.jh2/src/translator_it.h
--- doxygen-1.5.5/src/translator_it.h 2008-01-01 11:41:04.000000000 +0100
+++ doxygen-1.5.5.jh2/src/translator_it.h 2008-04-08 10:55:17.000000000 +0200
@@ -1750,6 +1750,10 @@
return "Vincoli dei tipi";
}
+ virtual QCString trPrototype()
+ {
+ return "Prototype";
+ }
};
#endif
diff -uNr doxygen-1.5.5/src/translator_kr.h doxygen-1.5.5.jh2/src/translator_kr.h
--- doxygen-1.5.5/src/translator_kr.h 2008-01-26 12:21:23.000000000 +0100
+++ doxygen-1.5.5.jh2/src/translator_kr.h 2008-04-08 10:55:17.000000000 +0200
@@ -1795,6 +1795,10 @@
return "ÅžÀÔ ÇÑÁ€ÀÚµé";
}
+ virtual QCString trPrototype()
+ {
+ return "Prototype";
+ }
};
#endif
diff -uNr doxygen-1.5.5/src/translator_nl.h doxygen-1.5.5.jh2/src/translator_nl.h
--- doxygen-1.5.5/src/translator_nl.h 2008-01-01 11:41:04.000000000 +0100
+++ doxygen-1.5.5.jh2/src/translator_nl.h 2008-04-08 10:55:17.000000000 +0200
@@ -1373,6 +1373,11 @@
{
return "Type Beperkingen";
}
+
+ virtual QCString trPrototype()
+ {
+ return "Prototype";
+ }
};
#endif
diff -uNr doxygen-1.5.5/src/translator_tw.h doxygen-1.5.5.jh2/src/translator_tw.h
--- doxygen-1.5.5/src/translator_tw.h 2008-02-07 23:29:40.000000000 +0100
+++ doxygen-1.5.5.jh2/src/translator_tw.h 2008-04-08 10:55:17.000000000 +0200
@@ -1798,6 +1798,10 @@
return "«¬§Ošî±ø¥ó";
}
+ virtual QCString trPrototype()
+ {
+ return "Prototype";
+ }
};
#endif