[PATCH] Add config options for putting constructors first

Michael Leupold <[email protected]>
Newsgroups gmane.text.doxygen.devel
Message-ID <[email protected]>
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi there,

on KDE we use sorted member docs which is mostly great except for the fact 
that ctors/dtors get sorted with all of the other members while I'd really 
like them to be on top of the list.

As I couldn't find a way to put them on top, I added a new config option:
SORT_MEMBERS_CONSTRUCTORS_FIRST
which will always put constructors first, destructors after and all other 
members below. The option concerns brief-doc as well as detailed-doc sorting 
but will be ignored for either if SORT_BRIEF_DOCS=NO or SORT_MEMBER_DOCS=NO.

I couldn't find any coding style guide, so I hope I mimicked the style I 
found properly. Please tell me if you want me to change or have further 
suggestions for improvement.

Regards,
Michael Leupold
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)

iD8DBQFKb2zclfpzINIAlVsRApWgAJ0aCn8RNILCFBiZCmnvB+jdEV+XiACfb4j6
V2w1t+sNaUukc4aRlI2Fa0I=
=jNrG
-----END PGP SIGNATURE-----

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with 
Crystal Reports now.  http://p.sf.net/sfu/bobj-july

_______________________________________________
Doxygen-develop mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/doxygen-develop
doxygen-constructors-first.diff (text/x-patch, 4.2 KB)
Index: src/config.xml
===================================================================
--- src/config.xml	(Revision 700)
+++ src/config.xml	(Arbeitskopie)
@@ -393,6 +393,14 @@
 by member name. If set to NO (the default) the members will appear in 
 declaration order. 
 ' defval='0'/>
+    <option type='bool' id='SORT_MEMBERS_CONSTRUCTORS_FIRST' docs='
+If the SORT_MEMBERS_CONSTRUCTORS_FIRST tag is set to YES then doxygen
+will sort the (brief and detailed) documentation of class members so that
+constructors and destructors are listed first. If set to NO (the default)
+the constructors will appear in the respective orders defined by
+SORT_MEMBER_DOCS and SORT_BRIEF_DOCS.
+This tag will be ignored for brief docs if SORT_BRIEF_DOCS is set to NO
+and ignored for detailed docs if SORT_MEMBER_DOCS is set to NO.' defval='0'/>
     <option type='bool' id='SORT_GROUP_NAMES' docs='
 If the SORT_GROUP_NAMES tag is set to YES then doxygen will sort the 
 hierarchy of group names into alphabetical order. If set to NO (the default) 
Index: src/memberlist.cpp
===================================================================
--- src/memberlist.cpp	(Revision 700)
+++ src/memberlist.cpp	(Arbeitskopie)
@@ -48,8 +48,17 @@
 
 int MemberList::compareItems(GCI item1, GCI item2)
 {
+  static bool sortConstructorsFirst = Config_getBool("SORT_MEMBERS_CONSTRUCTORS_FIRST");
   MemberDef *c1=(MemberDef *)item1;
   MemberDef *c2=(MemberDef *)item2;
+  if (sortConstructorsFirst) {
+    int ord1 = c1->isConstructor() ? 2 : (c1->isDestructor() ? 1 : 0);
+    int ord2 = c2->isConstructor() ? 2 : (c2->isDestructor() ? 1 : 0);
+    if (ord1 > ord2)
+      return -1;
+    else if (ord2 > ord1)
+      return 1;
+  }
   return stricmp(c1->name(),c2->name());
 }
 
Index: src/configoptions.cpp
===================================================================
--- src/configoptions.cpp	(Revision 700)
+++ src/configoptions.cpp	(Arbeitskopie)
@@ -560,6 +560,12 @@
                 );
   //----
   cb = cfg->addBool(
+                 "SORT_MEMBERS_CONSTRUCTORS_FIRST",
+                 "If the SORT_MEMBERS_CONSTRUCTORS_FIRST tag is set to YES then doxygen will sort the (brief and detailed) documentation of class members so that constructors and destructors are listed first. If set to NO (the default) the constructors will appear in the respective orders defined by SORT_MEMBER_DOCS and SORT_BRIEF_DOCS. This tag will be ignored for brief docs if SORT_BRIEF_DOCS is set to NO and ignored for detailed docs if SORT_MEMBER_DOCS is set to NO.",
+                 FALSE
+                );
+  //----
+  cb = cfg->addBool(
                  "SORT_GROUP_NAMES",
                  "If the SORT_GROUP_NAMES tag is set to YES then doxygen will sort the \n"
                  "hierarchy of group names into alphabetical order. If set to NO (the default) \n"
Index: doc/config.doc
===================================================================
--- doc/config.doc	(Revision 700)
+++ doc/config.doc	(Arbeitskopie)
@@ -223,6 +223,7 @@
 \refitem cfg_skip_function_macros SKIP_FUNCTION_MACROS
 \refitem cfg_sort_brief_docs SORT_BRIEF_DOCS
 \refitem cfg_sort_by_scope_name SORT_BY_SCOPE_NAME
+\refitem cfg_sort_members_constructors_first SORT_MEMBERS_CONSTRUCTORS_FIRST
 \refitem cfg_sort_group_names SORT_GROUP_NAMES
 \refitem cfg_sort_member_docs SORT_MEMBER_DOCS
 \refitem cfg_source_browser SOURCE_BROWSER
@@ -759,6 +760,18 @@
  @note This option applies only to the class list, not to the 
        alphabetical list.
 
+\anchor cfg_sort_members_constructors_first
+<dt>\c SORT_MEMBERS_CONSTRUCTORS_FIRST <dd>
+ \addindex SORT_MEMBERS_CONSTRUCTORS_FIRST
+ If the \c SORT_MEMBERS_CONSTRUCTORS_FIRST tag is set to \c YES then doxygen
+ will sort the (brief and detailed) documentation of class members so that
+ constructors and destructors are listed first. If set to NO (the default)
+ the constructors will appear in the respective orders defined by
+ \c SORT_MEMBER_DOCS and \c SORT_BRIEF_DOCS.
+ @note If \c SORT_BRIEF_DOCS is set to \c NO this option is ignored for
+       sorting brief member documentation.
+ @note If \c SORT_MEMBER_DOCS is set to \c NO this option is ignored for
+       sorting detailed member documentation.
 
 \anchor cfg_generate_deprecatedlist
 <dt>\c GENERATE_DEPRECATEDLIST <dd>
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.