From 9c915b83bc06babe6f0127f6446143ea50d00b62 Mon Sep 17 00:00:00 2001 From: Dimitri van Heesch Date: Wed, 31 Aug 2016 11:47:12 +0200 Subject: Unified display of enum values across output formats and languages --- src/htmlgen.cpp | 48 +++++++++++++++++++++++-- src/htmlgen.h | 33 +++++++---------- src/latexgen.cpp | 86 +++++++++++++++++++++++++++++++++++++++++---- src/latexgen.h | 31 +++++++--------- src/mangen.cpp | 13 +++++-- src/mangen.h | 6 ++-- src/memberdef.cpp | 66 ++++++++++++++++++---------------- src/memberlist.cpp | 9 +++-- src/outputgen.h | 6 ++-- src/outputlist.h | 12 ++++--- src/rtfgen.cpp | 79 ++++++++++++++++++++++++++++------------- src/rtfgen.h | 6 ++-- templates/latex/doxygen.sty | 16 +++++++++ 13 files changed, 293 insertions(+), 118 deletions(-) diff --git a/src/htmlgen.cpp b/src/htmlgen.cpp index 53926cf..24af9fc 100644 --- a/src/htmlgen.cpp +++ b/src/htmlgen.cpp @@ -1863,6 +1863,46 @@ void HtmlGenerator::writeNonBreakableSpace(int n) } } +void HtmlGenerator::startDescTable(const char *title) +{ + t << "" << endl + << ""; +} +void HtmlGenerator::endDescTable() +{ + t << "
" << title << "
" << endl; +} + +void HtmlGenerator::startDescTableRow() +{ + t << ""; +} + +void HtmlGenerator::endDescTableRow() +{ + t << "" << endl; +} + +void HtmlGenerator::startDescTableTitle() +{ + t << ""; +} + +void HtmlGenerator::endDescTableTitle() +{ + t << " "; +} + +void HtmlGenerator::startDescTableData() +{ + t << ""; +} + +void HtmlGenerator::endDescTableData() +{ + t << ""; +} + void HtmlGenerator::startSimpleSect(SectionTypes, const char *filename,const char *anchor, const char *title) @@ -2488,14 +2528,16 @@ void HtmlGenerator::endInlineHeader() t << "" << endl; } -void HtmlGenerator::startMemberDocSimple() +void HtmlGenerator::startMemberDocSimple(bool isEnum) { DBG_HTML(t << "" << endl;) t << "" << endl; - t << "" << endl; + t << "" << endl; } -void HtmlGenerator::endMemberDocSimple() +void HtmlGenerator::endMemberDocSimple(bool) { DBG_HTML(t << "" << endl;) t << "
" << theTranslator->trCompoundMembers() << "
"; + t << (isEnum? theTranslator->trEnumerationValues() : + theTranslator->trCompoundMembers()) << "
" << endl; diff --git a/src/htmlgen.h b/src/htmlgen.h index cafb666..30f54f4 100644 --- a/src/htmlgen.h +++ b/src/htmlgen.h @@ -272,25 +272,16 @@ class HtmlGenerator : public OutputGenerator void startContents(); void endContents(); void writeNonBreakableSpace(int); - - void startDescTable(const char *title) - //{ t << "" << endl; } - { t << "
" << endl - << ""; - } - void endDescTable() - { t << "
" << title << "
" << endl; } - void startDescTableTitle() - //{ t << ""; } - { t << ""; } - void endDescTableTitle() - { t << " "; } - void startDescTableData() - //{ t << "" << endl; } - { t << "" << endl; } - void endDescTableData() - { t << "" << endl; } - + + void startDescTable(const char *title); + void endDescTable(); + void startDescTableRow(); + void endDescTableRow(); + void startDescTableTitle(); + void endDescTableTitle(); + void startDescTableData(); + void endDescTableData(); + void startDotGraph(); void endDotGraph(const DotClassGraph &g); void startInclDepGraph(); @@ -330,8 +321,8 @@ class HtmlGenerator : public OutputGenerator void endConstraintDocs(); void endConstraintList(); - void startMemberDocSimple(); - void endMemberDocSimple(); + void startMemberDocSimple(bool); + void endMemberDocSimple(bool); void startInlineMemberType(); void endInlineMemberType(); void startInlineMemberName(); diff --git a/src/latexgen.cpp b/src/latexgen.cpp index e56f91d..ca60b50 100644 --- a/src/latexgen.cpp +++ b/src/latexgen.cpp @@ -1579,7 +1579,7 @@ void LatexGenerator::startMemberDoc(const char *clname, t << "\\hspace{0.1cm}{\\footnotesize\\ttfamily [" << memCount << "/" << memTotal << "]}"; } t << "}"; - t << "\n{\\ttfamily "; + t << "\n{\\footnotesize\\ttfamily "; //disableLinks=TRUE; } @@ -1826,6 +1826,65 @@ void LatexGenerator::writeNonBreakableSpace(int) } } +// ---------------------------------------------- +// nesting of functions below: +// startDescTable() +// - startDescTableRow() +// - startDescTableTitle() +// - endDescTabelTitle() +// - startDescTableData() +// - endDescTableData() +// - endDescTableRow() +// - startDescTableRow() +// - ... +// - endDescTableRow() +// endDescTable() + +void LatexGenerator::startDescTable(const char *title) +{ + t << "\\begin{DoxyEnumFields}{" << title << "}" << endl; +} + +void LatexGenerator::endDescTable() +{ + t << "\\end{DoxyEnumFields}" << endl; +} + +void LatexGenerator::startDescTableRow() +{ + // this is needed to prevent the \hypertarget, \label, and \index commands from messing up + // the row height (based on http://tex.stackexchange.com/a/186102) + t << "\\raisebox{\\heightof{T}}[0pt][0pt]{"; +} + +void LatexGenerator::endDescTableRow() +{ +} + +void LatexGenerator::startDescTableTitle() +{ + t << "}"; +} + +void LatexGenerator::endDescTableTitle() +{ +} + +void LatexGenerator::startDescTableData() +{ + t << "&"; +} + +void LatexGenerator::endDescTableData() +{ + t << "\\\\\n\\hline\n" << endl; +} + +void LatexGenerator::lastIndexPage() +{ +} + + void LatexGenerator::startMemberList() { if (!insideTabbing) @@ -2128,16 +2187,31 @@ void LatexGenerator::lineBreak(const char *) } } -void LatexGenerator::startMemberDocSimple() +void LatexGenerator::startMemberDocSimple(bool isEnum) { - t << "\\begin{DoxyFields}{"; - docify(theTranslator->trCompoundMembers()); + if (isEnum) + { + t << "\\begin{DoxyEnumFields}{"; + docify(theTranslator->trEnumerationValues()); + } + else + { + t << "\\begin{DoxyFields}{"; + docify(theTranslator->trCompoundMembers()); + } t << "}" << endl; } -void LatexGenerator::endMemberDocSimple() +void LatexGenerator::endMemberDocSimple(bool isEnum) { - t << "\\end{DoxyFields}" << endl; + if (isEnum) + { + t << "\\end{DoxyEnumFields}" << endl; + } + else + { + t << "\\end{DoxyFields}" << endl; + } } void LatexGenerator::startInlineMemberType() diff --git a/src/latexgen.h b/src/latexgen.h index f2e4978..7b21ea4 100644 --- a/src/latexgen.h +++ b/src/latexgen.h @@ -259,23 +259,16 @@ class LatexGenerator : public OutputGenerator void startContents() {} void endContents() {} void writeNonBreakableSpace(int); - - void startDescTable(const char *title) - { startSimpleSect(EnumValues,0,0,title); - startDescForItem(); - t << "\\begin{description}" << endl; } - void endDescTable() - { t << "\\end{description}" << endl; - endDescForItem(); - endSimpleSect(); - } - void startDescTableTitle() - { t << "\\item[{\\em " << endl; } - void endDescTableTitle() - { t << "}]"; } - void startDescTableData() {} - void endDescTableData() {} - void lastIndexPage() {} + + void startDescTable(const char *title); + void endDescTable(); + void startDescTableRow(); + void endDescTableRow(); + void startDescTableTitle(); + void endDescTableTitle(); + void startDescTableData(); + void endDescTableData(); + void lastIndexPage(); void startDotGraph(); void endDotGraph(const DotClassGraph &); @@ -313,8 +306,8 @@ class LatexGenerator : public OutputGenerator void endConstraintDocs(); void endConstraintList(); - void startMemberDocSimple(); - void endMemberDocSimple(); + void startMemberDocSimple(bool); + void endMemberDocSimple(bool); void startInlineMemberType(); void endInlineMemberType(); void startInlineMemberName(); diff --git a/src/mangen.cpp b/src/mangen.cpp index 34ce0c1..963f66c 100644 --- a/src/mangen.cpp +++ b/src/mangen.cpp @@ -762,19 +762,26 @@ void ManGenerator::endInlineHeader() firstCol = FALSE; } -void ManGenerator::startMemberDocSimple() +void ManGenerator::startMemberDocSimple(bool isEnum) { if (!firstCol) { t << endl << ".PP" << endl; } t << "\\fB"; - docify(theTranslator->trCompoundMembers()); + if (isEnum) + { + docify(theTranslator->trEnumerationValues()); + } + else + { + docify(theTranslator->trCompoundMembers()); + } t << ":\\fP" << endl; t << ".RS 4" << endl; } -void ManGenerator::endMemberDocSimple() +void ManGenerator::endMemberDocSimple(bool) { if (!firstCol) t << endl; t << ".RE" << endl; diff --git a/src/mangen.h b/src/mangen.h index 021f475..daaae0c 100644 --- a/src/mangen.h +++ b/src/mangen.h @@ -199,6 +199,8 @@ class ManGenerator : public OutputGenerator void startDescTable(const char *t) { startSimpleSect(EnumValues,0,0,t); startDescForItem(); } void endDescTable() { endDescForItem(); endSimpleSect(); } + void startDescTableRow() {} + void endDescTableRow() {} void startDescTableTitle() { startItemListItem(); startBold(); startEmphasis(); endItemListItem(); } void endDescTableTitle() { endEmphasis(); endBold(); } void startDescTableData() { t << endl; firstCol=TRUE; } @@ -244,8 +246,8 @@ class ManGenerator : public OutputGenerator void endConstraintDocs(); void endConstraintList(); - void startMemberDocSimple(); - void endMemberDocSimple(); + void startMemberDocSimple(bool); + void endMemberDocSimple(bool); void startInlineMemberType(); void endInlineMemberType(); void startInlineMemberName(); diff --git a/src/memberdef.cpp b/src/memberdef.cpp index 1c78ab9..952be64 100644 --- a/src/memberdef.cpp +++ b/src/memberdef.cpp @@ -2342,6 +2342,7 @@ void MemberDef::_writeEnumValues(OutputList &ol,Definition *container, ol.startDescTable(theTranslator->trEnumerationValues()); } + ol.startDescTableRow(); ol.addIndexItem(fmd->name(),ciname); ol.addIndexItem(ciname,fmd->name()); @@ -2391,6 +2392,7 @@ void MemberDef::_writeEnumValues(OutputList &ol,Definition *container, fmd,fmd->documentation()+"\n",TRUE,FALSE); } ol.endDescTableData(); + ol.endDescTableRow(); } } } @@ -3118,43 +3120,47 @@ void MemberDef::writeMemberDocSimple(OutputList &ol, Definition *container) ClassDef *cd = m_impl->accessorClass; //printf("===> %s::anonymous: %s\n",name().data(),cd?cd->name().data():""); - ol.startInlineMemberType(); - ol.startDoxyAnchor(cfname,cname,memAnchor,doxyName,doxyArgs); + if (container && container->definitionType()==Definition::TypeClass && + !((ClassDef*)container)->isJavaEnum()) + { + ol.startInlineMemberType(); + ol.startDoxyAnchor(cfname,cname,memAnchor,doxyName,doxyArgs); - QCString ts = fieldType(); + QCString ts = fieldType(); - if (cd) // cd points to an anonymous struct pointed to by this member - // so we add a link to it from the type column. - { - int i=0; - const char *prefixes[] = { "struct ","union ","class ", 0 }; - const char **p = prefixes; - while (*p) + if (cd) // cd points to an anonymous struct pointed to by this member + // so we add a link to it from the type column. { - int l=qstrlen(*p); - if (ts.left(l)==*p) + int i=0; + const char *prefixes[] = { "struct ","union ","class ", 0 }; + const char **p = prefixes; + while (*p) { - ol.writeString(*p); - i=l; + int l=qstrlen(*p); + if (ts.left(l)==*p) + { + ol.writeString(*p); + i=l; + } + p++; } - p++; + ol.writeObjectLink(cd->getReference(), + cd->getOutputFileBase(), + cd->anchor(),ts.mid(i)); } - ol.writeObjectLink(cd->getReference(), - cd->getOutputFileBase(), - cd->anchor(),ts.mid(i)); - } - else // use standard auto linking - { - linkifyText(TextGeneratorOLImpl(ol), // out - scope, // scope - getBodyDef(), // fileScope - this, // self - ts, // text - TRUE // autoBreak - ); + else // use standard auto linking + { + linkifyText(TextGeneratorOLImpl(ol), // out + scope, // scope + getBodyDef(), // fileScope + this, // self + ts, // text + TRUE // autoBreak + ); + } + ol.endDoxyAnchor(cfname,memAnchor); + ol.endInlineMemberType(); } - ol.endDoxyAnchor(cfname,memAnchor); - ol.endInlineMemberType(); ol.startInlineMemberName(); ol.docify(doxyName); diff --git a/src/memberlist.cpp b/src/memberlist.cpp index 7cd65bf..5349030 100644 --- a/src/memberlist.cpp +++ b/src/memberlist.cpp @@ -748,14 +748,19 @@ void MemberList::writeSimpleDocumentation(OutputList &ol, //printf("MemberList count=%d\n",numDocMembers()); if (numDocMembers()==0) return; - ol.startMemberDocSimple(); + ClassDef *cd = 0; + if (container && container->definitionType()==Definition::TypeClass) + { + cd = (ClassDef*)container; + } + ol.startMemberDocSimple(cd && cd->isJavaEnum()); MemberListIterator mli(*this); MemberDef *md; for ( ; (md=mli.current()) ; ++mli) { md->writeMemberDocSimple(ol,container); } - ol.endMemberDocSimple(); + ol.endMemberDocSimple(cd && cd->isJavaEnum()); } // separate member pages diff --git a/src/outputgen.h b/src/outputgen.h index 24d1acc..830fd49 100644 --- a/src/outputgen.h +++ b/src/outputgen.h @@ -299,6 +299,8 @@ class BaseOutputDocInterface : public CodeOutputInterface virtual void writeNonBreakableSpace(int) = 0; virtual void startDescTable(const char *title) = 0; virtual void endDescTable() = 0; + virtual void startDescTableRow() = 0; + virtual void endDescTableRow() = 0; virtual void startDescTableTitle() = 0; virtual void endDescTableTitle() = 0; virtual void startDescTableData() = 0; @@ -468,8 +470,8 @@ class OutputGenerator : public BaseOutputDocInterface virtual void endConstraintDocs() = 0; virtual void endConstraintList() = 0; - virtual void startMemberDocSimple() = 0; - virtual void endMemberDocSimple() = 0; + virtual void startMemberDocSimple(bool) = 0; + virtual void endMemberDocSimple(bool) = 0; virtual void startInlineMemberType() = 0; virtual void endInlineMemberType() = 0; virtual void startInlineMemberName() = 0; diff --git a/src/outputlist.h b/src/outputlist.h index cb67250..78a2ea0 100644 --- a/src/outputlist.h +++ b/src/outputlist.h @@ -372,6 +372,10 @@ class OutputList : public OutputDocInterface { forall(&OutputGenerator::startDescTable,title); } void endDescTable() { forall(&OutputGenerator::endDescTable); } + void startDescTableRow() + { forall(&OutputGenerator::startDescTableRow); } + void endDescTableRow() + { forall(&OutputGenerator::endDescTableRow); } void startDescTableTitle() { forall(&OutputGenerator::startDescTableTitle); } void endDescTableTitle() @@ -448,10 +452,10 @@ class OutputList : public OutputDocInterface void endConstraintList() { forall(&OutputGenerator::endConstraintList); } - void startMemberDocSimple() - { forall(&OutputGenerator::startMemberDocSimple); } - void endMemberDocSimple() - { forall(&OutputGenerator::endMemberDocSimple); } + void startMemberDocSimple(bool b) + { forall(&OutputGenerator::startMemberDocSimple,b); } + void endMemberDocSimple(bool b) + { forall(&OutputGenerator::endMemberDocSimple,b); } void startInlineMemberType() { forall(&OutputGenerator::startInlineMemberType); } void endInlineMemberType() diff --git a/src/rtfgen.cpp b/src/rtfgen.cpp index a3f157f..053d450 100644 --- a/src/rtfgen.cpp +++ b/src/rtfgen.cpp @@ -1986,50 +1986,67 @@ void RTFGenerator::endMemberList() void RTFGenerator::startDescTable(const char *title) { DBG_RTF(t << "{\\comment (startDescTable) }" << endl) - startSimpleSect(EnumValues,0,0,title); - startDescForItem(); - //t << "{" << endl; - //incrementIndentLevel(); - //t << rtf_Style_Reset << rtf_CList_DepthStyle(); + t << "{\\par" << endl; + t << "{" << rtf_Style["Heading5"]->reference << endl; + docify(title); + t << ":\\par}" << endl; + t << rtf_Style_Reset << rtf_DList_DepthStyle(); + t << "\\trowd \\trgaph108\\trleft426\\tblind426" + "\\trbrdrt\\brdrs\\brdrw10\\brdrcf15 " + "\\trbrdrl\\brdrs\\brdrw10\\brdrcf15 " + "\\trbrdrb\\brdrs\\brdrw10\\brdrcf15 " + "\\trbrdrr\\brdrs\\brdrw10\\brdrcf15 " + "\\trbrdrh\\brdrs\\brdrw10\\brdrcf15 " + "\\trbrdrv\\brdrs\\brdrw10\\brdrcf15 "<< endl; + int i,columnPos[2] = { 25, 100 }; + for (i=0;i<2;i++) + { + t << "\\clvertalt\\clbrdrt\\brdrs\\brdrw10\\brdrcf15 " + "\\clbrdrl\\brdrs\\brdrw10\\brdrcf15 " + "\\clbrdrb\\brdrs\\brdrw10\\brdrcf15 " + "\\clbrdrr \\brdrs\\brdrw10\\brdrcf15 " + "\\cltxlrtb " + "\\cellx" << (rtf_pageWidth*columnPos[i]/100) << endl; + } + t << "\\pard \\widctlpar\\intbl\\adjustright" << endl; } void RTFGenerator::endDescTable() { - //decrementIndentLevel(); DBG_RTF(t << "{\\comment (endDescTable)}" << endl) - endDescForItem(); - endSimpleSect(); - //t << "}" << endl; - //t << rtf_Style_Reset << styleStack.top(); + t << "}" << endl; +} + +void RTFGenerator::startDescTableRow() +{ +} + +void RTFGenerator::endDescTableRow() +{ } void RTFGenerator::startDescTableTitle() { - //t << rtf_BList_DepthStyle() << endl; DBG_RTF(t << "{\\comment (startDescTableTitle) }" << endl) - startBold(); - startEmphasis(); + t << "{\\qr "; } void RTFGenerator::endDescTableTitle() { DBG_RTF(t << "{\\comment (endDescTableTitle) }" << endl) - endEmphasis(); - endBold(); - t << " "; + t << "\\cell }"; } void RTFGenerator::startDescTableData() { DBG_RTF(t << "{\\comment (startDescTableData) }" << endl) - m_omitParagraph = FALSE; + t << "{"; } void RTFGenerator::endDescTableData() { DBG_RTF(t << "{\\comment (endDescTableData) }" << endl) - newParagraph(); - m_omitParagraph = TRUE; + t << "\\cell }{\\row }" << endl; } // a style for list formatted as a "bulleted list" @@ -2906,12 +2923,20 @@ void RTFGenerator::endInlineHeader() t << "}" << endl; } -void RTFGenerator::startMemberDocSimple() +void RTFGenerator::startMemberDocSimple(bool isEnum) { DBG_RTF(t << "{\\comment (startMemberDocSimple)}" << endl) t << "{\\par" << endl; t << "{" << rtf_Style["Heading5"]->reference << endl; - t << theTranslator->trCompoundMembers() << ":\\par}" << endl; + if (isEnum) + { + t << theTranslator->trEnumerationValues(); + } + else + { + t << theTranslator->trCompoundMembers(); + } + t << ":\\par}" << endl; t << rtf_Style_Reset << rtf_DList_DepthStyle(); t << "\\trowd \\trgaph108\\trleft426\\tblind426" "\\trbrdrt\\brdrs\\brdrw10\\brdrcf15 " @@ -2920,8 +2945,14 @@ void RTFGenerator::startMemberDocSimple() "\\trbrdrr\\brdrs\\brdrw10\\brdrcf15 " "\\trbrdrh\\brdrs\\brdrw10\\brdrcf15 " "\\trbrdrv\\brdrs\\brdrw10\\brdrcf15 "<< endl; - int i,columnPos[3] = { 25, 50, 100 }; - for (i=0;i<3;i++) + int i,n=3,columnPos[3] = { 25, 50, 100 }; + if (isEnum) + { + columnPos[0]=30; + columnPos[1]=100; + n=2; + } + for (i=0;i