[mapguide-commits] r8160 - in trunk/MgDev/BuildTools/WebTools/IMake: . Win32

svn_mapguide at osgeo.org svn_mapguide at osgeo.org
Mon May 26 07:17:09 PDT 2014


Author: jng
Date: 2014-05-26 07:17:09 -0700 (Mon, 26 May 2014)
New Revision: 8160

Modified:
   trunk/MgDev/BuildTools/WebTools/IMake/IMake.cpp
   trunk/MgDev/BuildTools/WebTools/IMake/Win32/IMake.exe
Log:
IMake updates:
 - Strip any HTML in comments for .net XML documentation
 - #2452: Add disclaimer note to any processed documentation that in under EXTERNAL_API

Modified: trunk/MgDev/BuildTools/WebTools/IMake/IMake.cpp
===================================================================
--- trunk/MgDev/BuildTools/WebTools/IMake/IMake.cpp	2014-05-26 10:29:52 UTC (rev 8159)
+++ trunk/MgDev/BuildTools/WebTools/IMake/IMake.cpp	2014-05-26 14:17:09 UTC (rev 8160)
@@ -12,7 +12,8 @@
     java
 };
 
-static char version[] = "1.2.1";
+static char version[] = "1.2.2";
+static char EXTERNAL_API_DOCUMENTATION[] = "(NOTE: This API is not officially supported and may be subject to removal in a future release without warning. Use with caution.)";
 
 static string module;
 static string customPath;
@@ -549,6 +550,17 @@
     return true;
 }
 
+void stripHtml(string& str)
+{
+    //NOTE: We're only stripping tags known to exist in some bits of API documentation
+    stringReplace(str, "<p>", "");
+    stringReplace(str, "<b>", "");
+    stringReplace(str, "<c>", "");
+    stringReplace(str, "</p>", "");
+    stringReplace(str, "</b>", "");
+    stringReplace(str, "</c>", "");
+}
+
 void xmlEscapeString(string& str)
 {
     stringReplace(str, "&", "&");
@@ -573,6 +585,7 @@
         //interfere with doxygen directive translation
         if (item == "\\link" || item == "\\endlink")
             continue;
+        stripHtml(item);
         xmlEscapeString(item);
         elems.push_back(item);
     }
@@ -684,7 +697,7 @@
     return output;
 }
 
-string doxygenToJavaDoc(const string& commentStr)
+string doxygenToJavaDoc(const string& commentStr, bool isPublished)
 {
     // Doxygen documentation translation overview:
     //
@@ -829,6 +842,11 @@
     std::string javaDoc = "\n/**\n";
 
     if (descriptionParts.size() > 0) {
+        if (!isPublished) {
+            javaDoc.append(" * ");
+            javaDoc.append(EXTERNAL_API_DOCUMENTATION);
+            javaDoc.append("\n");
+        }
         for (int i = 0; i < descriptionParts.size(); i++) {
             javaDoc.append(" *");
             javaDoc.append(linkifyJavaDocFragment(descriptionParts[i]));    
@@ -836,7 +854,13 @@
         }
         javaDoc.append(" *\n");
     } else {
-        javaDoc.append(" * TODO: API Documentation is missing or failed to translate doxygen brief directive (message inserted by IMake.exe)\n");
+        if (!isPublished) {
+            javaDoc.append(" * ");
+            javaDoc.append(EXTERNAL_API_DOCUMENTATION);
+            javaDoc.append("\n");
+        } else {
+            javaDoc.append(" * TODO: API Documentation is missing or failed to translate doxygen brief directive (message inserted by IMake.exe)\n");
+        }
     }
 
     if (paramParts.size() > 0) {
@@ -877,7 +901,7 @@
     return javaDoc;
 }
 
-string doxygenToCsharpDoc(const string& commentStr)
+string doxygenToCsharpDoc(const string& commentStr, bool isPublished)
 {
     //See doxygenToJavaDoc for how we do this sorcery
 
@@ -980,6 +1004,11 @@
     std::string csharpDoc = "\n///<summary>\n";
 
     if (descriptionParts.size() > 0) {
+        if (!isPublished) {
+            csharpDoc.append("/// ");
+            csharpDoc.append(EXTERNAL_API_DOCUMENTATION);
+            csharpDoc.append("\n");
+        }
         for (int i = 0; i < descriptionParts.size(); i++) {
             csharpDoc.append("///");
             csharpDoc.append(linkifyCSharpDocFragment(descriptionParts[i]));    
@@ -987,13 +1016,23 @@
         }
         csharpDoc.append("///</summary>\n");
     } else {
-        csharpDoc.append("///TODO: API Documentation is missing or failed to translate doxygen brief directive (message inserted by IMake.exe)\n///</summary>\n");
+        if (!isPublished) {
+            csharpDoc.append("/// ");
+            csharpDoc.append(EXTERNAL_API_DOCUMENTATION);
+            csharpDoc.append("\n");
+        } else {
+            csharpDoc.append("///TODO: API Documentation is missing or failed to translate doxygen brief directive (message inserted by IMake.exe)\n///</summary>\n");
+        }
     }
 
     if (paramParts.size() > 0) {
         for (int i = 0; i < paramParts.size(); i++) {
+            std::string paramPart = paramParts[i];
+            stripHtml(paramPart);
+            xmlEscapeString(paramPart);
+
             std::vector<std::string> pelems;
-            std::stringstream pss(linkifyCSharpDocFragment(paramParts[i]));
+            std::stringstream pss(linkifyCSharpDocFragment(paramPart));
             std::string pitem;
             while(std::getline(pss, pitem, ' ')) {
                 if (!pitem.empty())
@@ -1017,7 +1056,9 @@
     if (returnParts.size() > 0) {
         csharpDoc.append("///<returns>");
         for (int i = 0; i < returnParts.size(); i++) {
-            csharpDoc.append(linkifyCSharpDocFragment(returnParts[i]));
+            string retPart = returnParts[i];
+            stripHtml(retPart);
+            csharpDoc.append(linkifyCSharpDocFragment(retPart));
             if (i < returnParts.size() - 1)
                 csharpDoc.append("\n/// ");
         }
@@ -1054,7 +1095,7 @@
     }
 
     // ---------------------- csharpDoc END ------------------------ //
-    csharpDoc.append("///\n");
+    //csharpDoc.append("///\n");
     if (isDeprecated)
         csharpDoc.append("[Obsolete(\"This method is deprecated\")]\n");
     return csharpDoc;
@@ -1068,15 +1109,15 @@
 
     string convertedDoc;
     if (language == java) {
-        convertedDoc = doxygenToJavaDoc(commentStr);
+        convertedDoc = doxygenToJavaDoc(commentStr, true); //EXTERNAL_API only applies to class members, so treat this fragment as PUBLISHED_API
         fprintf(docOutFile, "\n%%typemap(javaclassmodifiers) %s %%{%s public%%}\n", className.c_str(), convertedDoc.c_str());
     } else if(language == csharp) {
-        convertedDoc = doxygenToCsharpDoc(commentStr);
+        convertedDoc = doxygenToCsharpDoc(commentStr, true); //EXTERNAL_API only applies to class members, so treat this fragment as PUBLISHED_API
         fprintf(docOutFile, "\n%%typemap(csclassmodifiers) %s %%{%s public%%}\n", className.c_str(), convertedDoc.c_str());
     }
 }
 
-void outputMethodDoc(const string& className, const string& methodDecl, const string& commentStr)
+void outputMethodDoc(const string& className, const string& methodDecl, const string& commentStr, bool isPublished)
 {
     //Nothing for PHP
     if (language == php)
@@ -1132,15 +1173,15 @@
     swigMethodDecl += methodName;
 
     if (language == java) {
-        convertedDoc = doxygenToJavaDoc(commentStr);
+        convertedDoc = doxygenToJavaDoc(commentStr, isPublished);
         fprintf(docOutFile, "\n%%javamethodmodifiers %s %%{%s public%%}\n", swigMethodDecl.c_str(), convertedDoc.c_str());
     } else if(language == csharp) {
-        convertedDoc = doxygenToCsharpDoc(commentStr);
+        convertedDoc = doxygenToCsharpDoc(commentStr, isPublished);
         fprintf(docOutFile, "\n%%csmethodmodifiers %s %%{%s public%%}\n", swigMethodDecl.c_str(), convertedDoc.c_str());
     }
 }
 
-void processExternalApiSection(string& className, vector<string>& tokens, int begin, int end)
+void processExternalApiSection(string& className, vector<string>& tokens, int begin, int end, bool isPublished)
 {
     //until we find a problem with that, we output whatever we find in this section. In the
     //process we perform type substitution if required
@@ -1223,10 +1264,10 @@
                 {
                     string convertedDoc;
                     if (language == java) {
-                        convertedDoc = doxygenToJavaDoc(commentStr);
+                        convertedDoc = doxygenToJavaDoc(commentStr, isPublished);
                         fprintf(outfile, "%s\n   ", convertedDoc.c_str());
                     } else if (language == csharp) {
-                        convertedDoc = doxygenToCsharpDoc(commentStr);
+                        convertedDoc = doxygenToCsharpDoc(commentStr, isPublished);
                         fprintf(outfile, "%s\n   ", convertedDoc.c_str());
                     }
                     commentStr.clear();
@@ -1385,7 +1426,7 @@
         if(token[0] == ';' || assignmentAdded)
         {
             if (!translateMode) {
-                outputMethodDoc(className, methodDecl, commentStr);
+                outputMethodDoc(className, methodDecl, commentStr, isPublished);
             }
             commentStr.clear();
             methodDecl.clear();
@@ -1504,10 +1545,10 @@
                 {
                     string convertedDoc;
                     if (language == java) {
-                        convertedDoc = doxygenToJavaDoc(commentStr);
+                        convertedDoc = doxygenToJavaDoc(commentStr, true);
                         fprintf(outfile, "%s", convertedDoc.c_str());
                     } else if (language == csharp) {
-                        convertedDoc = doxygenToCsharpDoc(commentStr);
+                        convertedDoc = doxygenToCsharpDoc(commentStr, true);
                         fprintf(outfile, "%s", convertedDoc.c_str());
                     }
                 }
@@ -1564,7 +1605,7 @@
         {
             string sectionName = tokens[sections[k] - 1];
             if(sectionName == "EXTERNAL_API" || sectionName == "PUBLISHED_API")
-                processExternalApiSection(className, tokens, sections[k] + 1, sections[k + 1] - (k < (int)sections.size() - 2? 2: 1));
+                processExternalApiSection(className, tokens, sections[k] + 1, sections[k + 1] - (k < (int)sections.size() - 2? 2: 1), (sectionName == "PUBLISHED_API"));
             else if(sectionName == "CLASS_ID" && !translateMode)
                 processClassIdSection(tokens, sections[k] + 1, sections[k + 1] - (k < (int)sections.size() - 2? 2: 1));
         }

Modified: trunk/MgDev/BuildTools/WebTools/IMake/Win32/IMake.exe
===================================================================
(Binary files differ)



More information about the mapguide-commits mailing list