Skip to content

Commit fbf476d

Browse files
committed
issue #8256 Possible to get enum values in the Enumeration Type documentation
Create to possibility to show also the initial values of the enumerators, when explicitly specified and the initializers have not been disabled by means of the configuration setting MAX_INITIALIZER_LINES.
1 parent 0d1ddb7 commit fbf476d

File tree

15 files changed

+133
-33
lines changed

15 files changed

+133
-33
lines changed

src/docbookgen.cpp

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1028,17 +1028,17 @@ DB_GEN_C
10281028
addIndexTerm(t, prim, sec);
10291029
}
10301030

1031-
void DocbookGenerator::startDescTable(const char *title)
1031+
void DocbookGenerator::startDescTable(const char *title,const bool hasInits)
10321032
{
10331033
DB_GEN_C
1034-
int ncols = 2;
1034+
int ncols = (hasInits?3:2);
10351035
t << "<informaltable frame=\"all\">" << endl;
10361036
if (title)t << "<title>" << convertToDocBook(title) << "</title>" << endl;
10371037
t << " <tgroup cols=\"" << ncols << "\" align=\"left\" colsep=\"1\" rowsep=\"1\">" << endl;
1038-
for (int i = 0; i < ncols; i++)
1039-
{
1040-
t << " <colspec colname='c" << i+1 << "'/>\n";
1041-
}
1038+
int i = 1;
1039+
t << " <colspec colname='c" << i++ << "'/>\n";
1040+
if (hasInits) t << " <colspec colname='c" << i++ << "' align='right'/>\n";
1041+
t << " <colspec colname='c" << i++ << "'/>\n";
10421042
t << "<tbody>\n";
10431043
m_descTable = TRUE;
10441044
}
@@ -1075,6 +1075,17 @@ void DocbookGenerator::endDescTableTitle()
10751075
DB_GEN_C
10761076
}
10771077

1078+
void DocbookGenerator::startDescTableInit()
1079+
{
1080+
DB_GEN_C
1081+
t << "</entry><entry>";
1082+
}
1083+
1084+
void DocbookGenerator::endDescTableInit()
1085+
{
1086+
DB_GEN_C
1087+
}
1088+
10781089
void DocbookGenerator::startDescTableData()
10791090
{
10801091
DB_GEN_C

src/docbookgen.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,12 +206,14 @@ class DocbookGenerator : public OutputGenerator
206206
void lineBreak(const char *);
207207
void addIndexItem(const char *,const char *);
208208
void writeNonBreakableSpace(int);
209-
void startDescTable(const char *);
209+
void startDescTable(const char *,const bool hasInits);
210210
void endDescTable();
211211
void startDescTableRow();
212212
void endDescTableRow();
213213
void startDescTableTitle();
214214
void endDescTableTitle();
215+
void startDescTableInit();
216+
void endDescTableInit();
215217
void startDescTableData();
216218
void endDescTableData();
217219
void startTextLink(const char *,const char *){DB_GEN_NEW};

src/htmlgen.cpp

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2199,10 +2199,10 @@ void HtmlGenerator::writeNonBreakableSpace(int n)
21992199
}
22002200
}
22012201

2202-
void HtmlGenerator::startDescTable(const char *title)
2202+
void HtmlGenerator::startDescTable(const char *title,const bool hasInits)
22032203
{
22042204
t << "<table class=\"fieldtable\">" << endl
2205-
<< "<tr><th colspan=\"2\">" << title << "</th></tr>";
2205+
<< "<tr><th colspan=\"" << (hasInits?3:2) << "\">" << title << "</th></tr>";
22062206
}
22072207
void HtmlGenerator::endDescTable()
22082208
{
@@ -2229,6 +2229,16 @@ void HtmlGenerator::endDescTableTitle()
22292229
t << "&#160;</td>";
22302230
}
22312231

2232+
void HtmlGenerator::startDescTableInit()
2233+
{
2234+
t << "<td class=\"fieldinit\">";
2235+
}
2236+
2237+
void HtmlGenerator::endDescTableInit()
2238+
{
2239+
t << "&#160;</td>";
2240+
}
2241+
22322242
void HtmlGenerator::startDescTableData()
22332243
{
22342244
t << "<td class=\"fielddoc\">";

src/htmlgen.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -270,11 +270,13 @@ class HtmlGenerator : public OutputGenerator
270270
void endPageDoc();
271271
void writeNonBreakableSpace(int);
272272

273-
void startDescTable(const char *title);
273+
void startDescTable(const char *title,const bool hasInits);
274274
void endDescTable();
275275
void startDescTableRow();
276276
void endDescTableRow();
277277
void startDescTableTitle();
278+
void endDescTableInit();
279+
void startDescTableInit();
278280
void endDescTableTitle();
279281
void startDescTableData();
280282
void endDescTableData();

src/latexgen.cpp

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1956,10 +1956,10 @@ void LatexGenerator::writeNonBreakableSpace(int)
19561956
// - endDescTableRow()
19571957
// endDescTable()
19581958

1959-
void LatexGenerator::startDescTable(const char *title)
1959+
void LatexGenerator::startDescTable(const char *title,const bool hasInits)
19601960
{
19611961
m_codeGen.incUsedTableLevel();
1962-
t << "\\begin{DoxyEnumFields}{" << title << "}" << endl;
1962+
t << "\\begin{DoxyEnumFields}[" << (hasInits?3:2) << "]{" << title << "}" << endl;
19631963
}
19641964

19651965
void LatexGenerator::endDescTable()
@@ -1988,6 +1988,15 @@ void LatexGenerator::endDescTableTitle()
19881988
{
19891989
}
19901990

1991+
void LatexGenerator::startDescTableInit()
1992+
{
1993+
t << "&";
1994+
}
1995+
1996+
void LatexGenerator::endDescTableInit()
1997+
{
1998+
}
1999+
19912000
void LatexGenerator::startDescTableData()
19922001
{
19932002
t << "&";

src/latexgen.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -267,12 +267,14 @@ class LatexGenerator : public OutputGenerator
267267
void endContents() {}
268268
void writeNonBreakableSpace(int);
269269

270-
void startDescTable(const char *title);
270+
void startDescTable(const char *title,const bool hasInits);
271271
void endDescTable();
272272
void startDescTableRow();
273273
void endDescTableRow();
274274
void startDescTableTitle();
275275
void endDescTableTitle();
276+
void startDescTableInit();
277+
void endDescTableInit();
276278
void startDescTableData();
277279
void endDescTableData();
278280
void lastIndexPage();

src/mangen.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -658,7 +658,7 @@ void ManGenerator::endExamples()
658658
{
659659
}
660660

661-
void ManGenerator::startDescTable(const char *title)
661+
void ManGenerator::startDescTable(const char *title,const bool hasInits)
662662
{
663663
if (!m_firstCol)
664664
{ t << endl << ".PP" << endl;

src/mangen.h

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,8 @@ class ManGenerator : public OutputGenerator
132132
void endEmphasis() { t << "\\fP"; m_firstCol=FALSE; }
133133
void startBold() { t << "\\fB"; m_firstCol=FALSE; }
134134
void endBold() { t << "\\fP"; m_firstCol=FALSE; }
135+
void startBoldEmphasis() { t << "\\f(BI"; m_firstCol=FALSE; }
136+
void endBoldEmphasis() { t << "\\fP"; m_firstCol=FALSE; }
135137
void startDescription() {}
136138
void endDescription() {}
137139
void startDescItem();
@@ -190,12 +192,14 @@ class ManGenerator : public OutputGenerator
190192
void endContents() {}
191193
void writeNonBreakableSpace(int n) { int i; for (i=0;i<n;i++) t << " "; }
192194

193-
void startDescTable(const char *t);
195+
void startDescTable(const char *t,const bool hasInits);
194196
void endDescTable();
195197
void startDescTableRow() {}
196198
void endDescTableRow() {}
197-
void startDescTableTitle() { startItemListItem(); startBold(); startEmphasis(); endItemListItem(); }
198-
void endDescTableTitle() { endEmphasis(); endBold(); }
199+
void startDescTableTitle() { startItemListItem(); startBoldEmphasis(); endItemListItem(); }
200+
void endDescTableTitle() { endBoldEmphasis(); }
201+
void startDescTableInit(){};
202+
void endDescTableInit(){};
199203
void startDescTableData() { t << endl; m_firstCol=TRUE; }
200204
void endDescTableData() {}
201205

src/memberdef.cpp

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3024,14 +3024,25 @@ void MemberDefImpl::_writeEnumValues(OutputList &ol,const Definition *container,
30243024
{
30253025
MemberListIterator it(*fmdl);
30263026
MemberDef *fmd;
3027-
for (;(fmd=it.current());++it)
3027+
bool hasInits = false;
3028+
if (Config_getInt(MAX_INITIALIZER_LINES) > 0)
3029+
{
3030+
for (;(fmd=it.current());++it)
3031+
{
3032+
if (fmd->isLinkable())
3033+
{
3034+
if (hasInits = !fmd->initializer().isEmpty()) break;
3035+
}
3036+
}
3037+
}
3038+
for (it.toFirst();(fmd=it.current());++it)
30283039
{
30293040
//printf("Enum %p: isLinkable()=%d\n",fmd,fmd->isLinkable());
30303041
if (fmd->isLinkable())
30313042
{
30323043
if (first)
30333044
{
3034-
ol.startDescTable(theTranslator->trEnumerationValues());
3045+
ol.startDescTable(theTranslator->trEnumerationValues(),hasInits);
30353046
}
30363047

30373048
ol.startDescTableRow();
@@ -3049,6 +3060,23 @@ void MemberDefImpl::_writeEnumValues(OutputList &ol,const Definition *container,
30493060
ol.enableAll();
30503061
ol.endDoxyAnchor(cfname,fmd->anchor());
30513062
ol.endDescTableTitle();
3063+
if (hasInits)
3064+
{
3065+
ol.startDescTableInit();
3066+
if (!fmd->initializer().isEmpty())
3067+
{
3068+
QCString initStr = fmd->initializer().stripWhiteSpace();
3069+
if (initStr.startsWith("=")) initStr = initStr.mid(1).stripWhiteSpace();
3070+
ol.disableAllBut(OutputGenerator::Man);
3071+
ol.writeString("(");
3072+
ol.enableAll();
3073+
ol.docify(initStr);
3074+
ol.disableAllBut(OutputGenerator::Man);
3075+
ol.writeString(")");
3076+
ol.enableAll();
3077+
}
3078+
ol.endDescTableInit();
3079+
}
30523080
ol.startDescTableData();
30533081

30543082
bool hasBrief = !fmd->briefDescription().isEmpty();

src/outputgen.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -297,12 +297,14 @@ class BaseOutputDocInterface : public CodeOutputInterface
297297
virtual void addIndexItem(const char *s1,const char *s2) = 0;
298298

299299
virtual void writeNonBreakableSpace(int) = 0;
300-
virtual void startDescTable(const char *title) = 0;
300+
virtual void startDescTable(const char *title,const bool hasInits) = 0;
301301
virtual void endDescTable() = 0;
302302
virtual void startDescTableRow() = 0;
303303
virtual void endDescTableRow() = 0;
304304
virtual void startDescTableTitle() = 0;
305305
virtual void endDescTableTitle() = 0;
306+
virtual void startDescTableInit() = 0;
307+
virtual void endDescTableInit() = 0;
306308
virtual void startDescTableData() = 0;
307309
virtual void endDescTableData() = 0;
308310
virtual void startTextLink(const char *file,const char *anchor) = 0;

0 commit comments

Comments
 (0)