Skip to content

Commit f766415

Browse files
committed
issue #8256 Possible to get enum values in the Enumeration Type documentation
Instead of steering the showing of the enum values by mean is the `MAX_INIT_LINES` it is now, more flexible, steered by the setting `SHOW_ENUM_VALUES` and the commands `\showenumvalues` and `\hideenumvalues`.
1 parent 080d31e commit f766415

File tree

8 files changed

+83
-5
lines changed

8 files changed

+83
-5
lines changed

doc/commands.doc

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@ documentation:
123123
\refitem cmdhidecallgraph \\hidecallgraph
124124
\refitem cmdhidecollaborationgraph \\hidecollaborationgraph
125125
\refitem cmdhidedirectorygraph \\hidedirectorygraph
126+
\refitem cmdhideenumvalues \\hideenumvalues
126127
\refitem cmdhidegroupgraph \\hidegroupgraph
127128
\refitem cmdhideincludedbygraph \\hideincludedbygraph
128129
\refitem cmdhideincludegraph \\hideincludegraph
@@ -208,6 +209,7 @@ documentation:
208209
\refitem cmdsee \\see
209210
\refitem cmdshort \\short
210211
\refitem cmdshowdate \\showdate
212+
\refitem cmdshowenumvalues \\showenumvalues
211213
\refitem cmdshowinitializer \\showinitializer
212214
\refitem cmdshowinlinesource \\showinlinesource
213215
\refitem cmdshowrefby \\showrefby
@@ -625,6 +627,28 @@ Structural indicators
625627
\sa section \ref cmdgroupgraph "\\groupgraph",
626628
option \ref cfg_group_graphs "GROUP_GRAPHS"
627629

630+
<hr>
631+
\section cmdshowenumvalues \\showenumvalues
632+
633+
\addindex \\showenumvalues
634+
When this command is put in a comment block of an enum
635+
then doxygen will show the specified enum values for that enum,
636+
regardless of the value of \ref cfg_show_enum_values "SHOW_ENUM_VALUES".
637+
638+
\sa section \ref cmdhideenumvalues "\\hideenumvalues",
639+
option \ref cfg_show_enum_values "SHOW_ENUM_VALUES"
640+
641+
<hr>
642+
\section cmdhideenumvalues \\hideenumvalues
643+
644+
\addindex \\hideenumvalues
645+
When this command is put in a comment block of an enum
646+
then doxygen will not show the specified enum values for that enum,
647+
regardless of the value of \ref cfg_show_enum_values "SHOW_ENUM_VALUES".
648+
649+
\sa section \ref cmdshowenumvalues "\\showenumvalues",
650+
option \ref cfg_show_enum_values "SHOW_ENUM_VALUES"
651+
628652
<hr>
629653
\section cmdqualifier \\qualifier <label> | "(text)"
630654

src/commentscan.l

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,8 @@ static bool handleCallergraph(yyscan_t yyscanner,const QCString &, const StringV
126126
static bool handleHideCallergraph(yyscan_t yyscanner,const QCString &, const StringVector &);
127127
static bool handleIncludegraph(yyscan_t yyscanner,const QCString &, const StringVector &);
128128
static bool handleIncludedBygraph(yyscan_t yyscanner,const QCString &, const StringVector &);
129+
static bool handleShowEnumValues(yyscan_t yyscanner,const QCString &, const StringVector &);
130+
static bool handleHideEnumValues(yyscan_t yyscanner,const QCString &, const StringVector &);
129131
static bool handleShowInlineSource(yyscan_t yyscanner,const QCString &, const StringVector &);
130132
static bool handleHideInlineSource(yyscan_t yyscanner,const QCString &, const StringVector &);
131133
static bool handleHideIncludegraph(yyscan_t yyscanner,const QCString &, const StringVector &);
@@ -242,6 +244,7 @@ static const std::map< std::string, DocCmdMap > docCmdMap =
242244
{ "hidecallgraph", { &handleHideCallgraph, CommandSpacing::Invisible }},
243245
{ "hidecollaborationgraph", { &handleHideCollaborationgraph, CommandSpacing::Invisible }},
244246
{ "hidedirectorygraph", { &handleHideDirectoryGraph, CommandSpacing::Invisible }},
247+
{ "hideenumvalues", { &handleHideEnumValues, CommandSpacing::Invisible }},
245248
{ "hidegroupgraph", { &handleHideGroupgraph, CommandSpacing::Invisible }},
246249
{ "hideincludedbygraph", { &handleHideIncludedBygraph, CommandSpacing::Invisible }},
247250
{ "hideincludegraph", { &handleHideIncludegraph, CommandSpacing::Invisible }},
@@ -319,6 +322,7 @@ static const std::map< std::string, DocCmdMap > docCmdMap =
319322
{ "section", { &handleSection, CommandSpacing::Block }},
320323
{ "see", { 0, CommandSpacing::Block }},
321324
{ "short", { &handleBrief, CommandSpacing::Invisible }},
325+
{ "showenumvalues", { &handleShowEnumValues, CommandSpacing::Invisible }},
322326
{ "showinitializer", { &handleShowInitializer, CommandSpacing::Invisible }},
323327
{ "showinlinesource",{ &handleShowInlineSource, CommandSpacing::Invisible }},
324328
{ "showrefby", { &handleReferencedByRelation, CommandSpacing::Invisible }},
@@ -3101,6 +3105,20 @@ static bool handleHideCallergraph(yyscan_t yyscanner,const QCString &, const Str
31013105
return FALSE;
31023106
}
31033107

3108+
static bool handleShowEnumValues(yyscan_t yyscanner,const QCString &, const StringVector &)
3109+
{
3110+
struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
3111+
yyextra->current->enumValues = TRUE; // ON
3112+
return FALSE;
3113+
}
3114+
3115+
static bool handleHideEnumValues(yyscan_t yyscanner,const QCString &, const StringVector &)
3116+
{
3117+
struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
3118+
yyextra->current->enumValues = FALSE; // OFF
3119+
return FALSE;
3120+
}
3121+
31043122
static bool handleShowInlineSource(yyscan_t yyscanner,const QCString &, const StringVector &)
31053123
{
31063124
struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;

src/config.xml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2604,6 +2604,14 @@ The \c DOCSET_PUBLISHER_NAME tag identifies the documentation publisher.
26042604
that doxygen will group on one line in the generated HTML documentation.
26052605
<br>Note that a value of 0 will completely suppress the enum values from
26062606
appearing in the overview section.
2607+
]]>
2608+
</docs>
2609+
</option>
2610+
<option type='bool' id='SHOW_ENUM_VALUES' defval='0'>
2611+
<docs>
2612+
<![CDATA[
2613+
When the \c SHOW_ENUM_VALUES tag is set doxygen will show the specified enumeration values
2614+
besides the enumeration mnemonics.
26072615
]]>
26082616
</docs>
26092617
</option>

src/doxygen.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7089,6 +7089,7 @@ static void findEnums(const Entry *root)
70897089
mmd->enableReferencesRelation(root->referencesRelation);
70907090
mmd->enableInlineSource(root->inlineSource);
70917091
mmd->addQualifiers(root->qualifiers);
7092+
mmd->enableEnumValues(root->enumValues);
70927093
//printf("%s::setRefItems(%zu)\n",qPrint(md->name()),root->sli.size());
70937094
mmd->setRefItems(root->sli);
70947095
//printf("found enum %s nd=%p\n",qPrint(md->name()),nd);

src/entry.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ Entry::Entry(const Entry &e) : section(e.section)
7373
referencedByRelation = e.referencedByRelation;
7474
referencesRelation = e.referencesRelation;
7575
inlineSource = e.inlineSource;
76+
enumValues = e.enumValues;
7677
exported = e.exported;
7778
virt = e.virt;
7879
args = e.args;
@@ -201,6 +202,7 @@ void Entry::reset()
201202
bool entryCollaborationGraph = Config_getBool(COLLABORATION_GRAPH);
202203
CLASS_GRAPH_t entryInheritanceGraph = Config_getBool(CLASS_GRAPH);
203204
bool entryGroupGraph = Config_getBool(GROUP_GRAPHS);
205+
bool entryEnumValues = Config_getBool(SHOW_ENUM_VALUES);
204206
//printf("Entry::reset()\n");
205207
name.resize(0);
206208
type.resize(0);
@@ -242,6 +244,7 @@ void Entry::reset()
242244
referencedByRelation = entryReferencedByRelation;
243245
referencesRelation = entryReferencesRelation;
244246
inlineSource = entryInlineSource;
247+
enumValues = entryEnumValues;
245248
exported = false;
246249
section = EntryType::makeEmpty();
247250
mtype = MethodTypes::Method;

src/entry.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,7 @@ class Entry
198198
bool includedByGraph; //!< do we need to draw the included by graph?
199199
bool directoryGraph; //!< do we need to draw the directory graph?
200200
bool collaborationGraph; //!< do we need to draw the collaboration graph?
201+
bool enumValues; //!< do we need to show the enum values besides the mnemonics?
201202
CLASS_GRAPH_t inheritanceGraph; //!< type of inheritance graph?
202203
bool groupGraph; //!< do we need to draw the group graph?
203204
bool exported; //!< is the symbol exported from a C++20 module

src/memberdef.cpp

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,7 @@ class MemberDefImpl : public DefinitionMixin<MemberDefMutable>
220220
virtual bool hasReferencesRelation() const override;
221221
virtual bool hasReferencedByRelation() const override;
222222
virtual bool hasInlineSource() const override;
223+
virtual bool hasEnumValues() const override;
223224
virtual const MemberDef *templateMaster() const override;
224225
virtual QCString getScopeString() const override;
225226
virtual ClassDef *getClassDefOfAnonymousType() const override;
@@ -303,6 +304,7 @@ class MemberDefImpl : public DefinitionMixin<MemberDefMutable>
303304
virtual void mergeEnableReferencesRelation(bool other) override;
304305
virtual void enableInlineSource(bool e) override;
305306
virtual void mergeEnableInlineSource(bool other) override;
307+
virtual void enableEnumValues(bool e) override;
306308
virtual void setTemplateMaster(MemberDef *mt) override;
307309
virtual void addListReference(Definition *d) override;
308310
virtual void setDocsForDefinition(bool b) override;
@@ -494,6 +496,7 @@ class MemberDefImpl : public DefinitionMixin<MemberDefMutable>
494496
bool m_hasReferencedByRelation = false;
495497
bool m_hasReferencesRelation = false;
496498
bool m_hasInlineSource = false;
499+
bool m_hasEnumValues = false;
497500
bool m_explExt = false; // member was explicitly declared external
498501
bool m_tspec = false; // member is a template specialization
499502
bool m_groupHasDocs = false; // true if the entry that caused the grouping was documented
@@ -855,6 +858,8 @@ class MemberDefAliasImpl : public DefinitionAliasMixin<MemberDef>
855858
{ return getMdAlias()->hasReferencedByRelation(); }
856859
virtual bool hasInlineSource() const
857860
{ return getMdAlias()->hasInlineSource(); }
861+
virtual bool hasEnumValues() const
862+
{ return getMdAlias()->hasEnumValues(); }
858863
virtual StringVector getQualifiers() const
859864
{ return getMdAlias()->getQualifiers(); }
860865
virtual const MemberDef *templateMaster() const
@@ -1331,6 +1336,7 @@ void MemberDefImpl::init(Definition *d,
13311336
m_hasReferencedByRelation = FALSE;
13321337
m_hasReferencesRelation = FALSE;
13331338
m_hasInlineSource = FALSE;
1339+
m_hasEnumValues = FALSE;
13341340
m_initLines=0;
13351341
m_type=t;
13361342
if (mt==MemberType_Typedef) m_type.stripPrefix("typedef ");
@@ -1508,6 +1514,7 @@ MemberDefImpl::MemberDefImpl(const MemberDefImpl &md) : DefinitionMixin(md)
15081514
m_hasReferencedByRelation = md.m_hasReferencedByRelation ;
15091515
m_hasReferencesRelation = md.m_hasReferencesRelation ;
15101516
m_hasInlineSource = md.m_hasInlineSource ;
1517+
m_hasEnumValues = md.m_hasEnumValues ;
15111518
m_explExt = md.m_explExt ;
15121519
m_tspec = md.m_tspec ;
15131520
m_groupHasDocs = md.m_groupHasDocs ;
@@ -3179,14 +3186,17 @@ void MemberDefImpl::_writeEnumValues(OutputList &ol,const Definition *container,
31793186
bool first=true;
31803187
//printf("** %s: enum values=%zu\n",qPrint(name()),enumFieldList().size());
31813188
bool hasInits = false;
3182-
for (const auto &fmd : enumFieldList())
3189+
if (hasEnumValues())
31833190
{
3184-
if (fmd->isLinkable())
3191+
for (const auto &fmd : enumFieldList())
31853192
{
3186-
if (!fmd->initializer().isEmpty())
3193+
if (fmd->isLinkable())
31873194
{
3188-
hasInits = true;
3189-
break;
3195+
if (!fmd->initializer().isEmpty())
3196+
{
3197+
hasInits = true;
3198+
break;
3199+
}
31903200
}
31913201
}
31923202
}
@@ -4934,6 +4944,11 @@ void MemberDefImpl::mergeEnableInlineSource(bool other)
49344944
}
49354945
}
49364946

4947+
void MemberDefImpl::enableEnumValues(bool e)
4948+
{
4949+
m_hasEnumValues=e;
4950+
}
4951+
49374952
bool MemberDefImpl::isObjCMethod() const
49384953
{
49394954
if (getClassDef() && getClassDef()->isObjectiveC() && isFunction()) return TRUE;
@@ -5676,6 +5691,11 @@ bool MemberDefImpl::hasInlineSource() const
56765691
return m_hasInlineSource;
56775692
}
56785693

5694+
bool MemberDefImpl::hasEnumValues() const
5695+
{
5696+
return m_hasEnumValues;
5697+
}
5698+
56795699
const MemberDef *MemberDefImpl::templateMaster() const
56805700
{
56815701
return m_templateMaster;

src/memberdef.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,7 @@ class MemberDef : public Definition
245245
virtual bool hasReferencedByRelation() const = 0;
246246

247247
virtual bool hasInlineSource() const = 0;
248+
virtual bool hasEnumValues() const = 0;
248249

249250
virtual const MemberDef *templateMaster() const = 0;
250251
virtual QCString getScopeString() const = 0;
@@ -394,6 +395,8 @@ class MemberDefMutable : public DefinitionMutable, public MemberDef
394395
virtual void enableInlineSource(bool e) = 0;
395396
virtual void mergeEnableInlineSource(bool other) = 0;
396397

398+
virtual void enableEnumValues(bool e) = 0;
399+
397400
virtual void setTemplateMaster(MemberDef *mt) = 0;
398401
virtual void addListReference(Definition *d) = 0;
399402
virtual void setDocsForDefinition(bool b) = 0;

0 commit comments

Comments
 (0)