X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/31dc7e4995ae83221268b24488ac724ab291b7fb..90f3fe56ee58fec86d7f938f9c630c0745f0a2dc:/utils/HelpGen/src/HelpGen.cpp

diff --git a/utils/HelpGen/src/HelpGen.cpp b/utils/HelpGen/src/HelpGen.cpp
index 28e9d4460c..4bf5e4418f 100644
--- a/utils/HelpGen/src/HelpGen.cpp
+++ b/utils/HelpGen/src/HelpGen.cpp
@@ -64,6 +64,7 @@
 
 #include "wx/file.h"
 #include "wx/regex.h"
+#include "wx/hash.h"
 
 // C++ parsing classes
 #include "cjparser.h"
@@ -893,13 +894,43 @@ void HelpGenVisitor::CloseFunction()
 
 void HelpGenVisitor::CloseClass()
 {
+	CloseFunction();
+
     if ( m_inClass ) {
         size_t count = m_arrayFuncDocs.GetCount();
         if ( count ) {
+			size_t n;
             FunctionDocEntry::classname = m_classname;
+
             m_arrayFuncDocs.Sort(FunctionDocEntry::Compare);
 
-            for ( size_t n = 0; n < count; n++ ) {
+			// Now examine each first line and if it's been seen, cut it
+			// off (it's a duplicate \membersection)
+			wxHashTable membersections(wxKEY_STRING);
+
+            for ( n = 0; n < count; n++ )
+			{
+                wxString section(m_arrayFuncDocs[n].text);
+
+				// Strip leading whitespace
+				int pos = section.Find("\\membersection");
+				if (pos > -1)
+				{
+					section = section.Mid(pos);
+				}
+
+				wxString ms(section.BeforeFirst(wxT('\n')));
+				if (membersections.Get(ms))
+				{
+					m_arrayFuncDocs[n].text = section.AfterFirst(wxT('\n'));
+				}
+				else
+				{
+					membersections.Put(ms, & membersections);
+				}
+            }
+
+            for ( n = 0; n < count; n++ ) {
                 m_file.WriteTeX(m_arrayFuncDocs[n].text);
             }
 
@@ -909,6 +940,7 @@ void HelpGenVisitor::CloseClass()
         m_inClass = FALSE;
         m_classname.clear();
     }
+	m_file.FlushAll();
 }
 
 void HelpGenVisitor::EndVisit()
@@ -920,6 +952,11 @@ void HelpGenVisitor::EndVisit()
     m_fileHeader.Empty();
 
     m_file.FlushAll();
+	if (m_file.IsOpened())
+	{
+		m_file.Flush();
+		m_file.Close();
+	}
 
     wxLogVerbose("%s: finished generating for the current file.",
                  GetCurrentTime("%H:%M:%S"));
@@ -936,6 +973,12 @@ void HelpGenVisitor::VisitClass( spClass& cl )
 {
     CloseClass();
 
+	if (m_file.IsOpened())
+	{
+		m_file.Flush();
+		m_file.Close();
+	}
+
     wxString name = cl.GetName();
 
     if ( m_ignoreNames.IgnoreClass(name) ) {
@@ -1097,6 +1140,12 @@ void HelpGenVisitor::VisitClass( spClass& cl )
     }
     totalText << derived << "\n\n";
 
+    // include file section
+    wxString includeFile = "\\wxheading{Include files}\n\n";
+    includeFile << "<" << m_fileHeader << ">";
+
+    totalText << includeFile << "\n\n";
+
     // write all this to file
     m_file.WriteTeX(totalText);
 
@@ -1104,6 +1153,8 @@ void HelpGenVisitor::VisitClass( spClass& cl )
     InsertDataStructuresHeader();
     InsertTypedefDocs();
     InsertEnumDocs();
+
+	//m_file.Flush();
 }
 
 void HelpGenVisitor::VisitEnumeration( spEnumeration& en )
@@ -1250,16 +1301,19 @@ void HelpGenVisitor::VisitOperation( spOperation& op )
         funcname = dtor;
     }
 
-    m_textFunc.Printf("\n"
-                      "\\membersection{%s::%s}\\label{%s}\n"
-                      "\n"
+	m_textFunc.Printf("\n"
+		"\\membersection{%s::%s}\\label{%s}\n",
+		m_classname.c_str(), funcname.c_str(),
+		MakeLabel(m_classname, funcname).c_str());
+
+	wxString func;
+	func.Printf("\n"
                       "\\%sfunc{%s%s}{%s}{",
-                      m_classname.c_str(), funcname.c_str(),
-                      MakeLabel(m_classname, funcname).c_str(),
                       op.mIsConstant ? "const" : "",
                       op.mIsVirtual ? "virtual " : "",
                       op.mRetType.c_str(),
                       funcname.c_str());
+	m_textFunc += func;
 }
 
 void HelpGenVisitor::VisitParameter( spParameter& param )
@@ -2149,6 +2203,20 @@ static const wxString GetVersionString()
 
 /*
    $Log$
+   Revision 1.22  2002/01/21 21:18:50  JS
+   Now adds 'include file' heading
+
+   Revision 1.21  2002/01/04 11:06:09  JS
+   Fixed missing membersections bug and also bug with functions not being written
+   in the right class
+
+   Revision 1.20  2002/01/03 14:23:33  JS
+   Added code to make it not duplicate membersections for overloaded functions
+
+   Revision 1.19  2002/01/03 13:34:12  JS
+   Added FlushAll to CloseClass, otherwise text was only flushed right at the end,
+   and appeared in one file.
+
    Revision 1.18  2002/01/03 12:02:47  JS
    Added main() and corrected VC++ project settings