Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r65321 - sandbox/geometry/other/programs/doxygen_xml2qbk
From: barend.gehrels_at_[hidden]
Date: 2010-09-06 11:53:56


Author: barendgehrels
Date: 2010-09-06 11:53:55 EDT (Mon, 06 Sep 2010)
New Revision: 65321
URL: http://svn.boost.org/trac/boost/changeset/65321

Log:
Other approach for similar function names (nullary/unary/binary etc)
Text files modified:
   sandbox/geometry/other/programs/doxygen_xml2qbk/doxygen_xml2qbk.cpp | 109 ++++++++++++++++++++++++++-------------
   sandbox/geometry/other/programs/doxygen_xml2qbk/doxygen_xml2qbk.vcproj | 4
   2 files changed, 74 insertions(+), 39 deletions(-)

Modified: sandbox/geometry/other/programs/doxygen_xml2qbk/doxygen_xml2qbk.cpp
==============================================================================
--- sandbox/geometry/other/programs/doxygen_xml2qbk/doxygen_xml2qbk.cpp (original)
+++ sandbox/geometry/other/programs/doxygen_xml2qbk/doxygen_xml2qbk.cpp 2010-09-06 11:53:55 EDT (Mon, 06 Sep 2010)
@@ -23,13 +23,9 @@
 
 // Aug 14/15: added classes, defines, various enhancements.
 
-
-#define _CRT_SECURE_NO_WARNINGS
-#define _SCL_SECURE_NO_WARNINGS
-#define _SCL_INSECURE_DEPRECATE
-
 #include <iostream>
 #include <fstream>
+#include <sstream>
 #include <vector>
 #include <map>
 
@@ -129,16 +125,25 @@
 
     std::vector<param> template_parameters;
     std::vector<param> parameters;
+
+ element()
+ : line(0)
+ {}
 };
 
-enum function_type { function_define, function_constructor, function_member, function_free };
+enum function_type { function_unknown, function_define, function_constructor, function_member, function_free };
 
 struct function : public element
 {
     function_type type;
     std::string definition, argsstring;
     std::string return_type, return_description;
- //std::string paragraphs;
+ bool unique;
+
+ function()
+ : unique(true)
+ , type(function_unknown)
+ {}
 
 };
 
@@ -277,11 +282,11 @@
             // Doxygen handles templateparamlist param's differently:
             //
             // Case 1:
- // <param><type>typename Geometry</type></param>
+ // <param><type>typename T</type></param>
             // -> no name, assign type to name, replace typename
             //
             // Case 2:
- // <type>typename</type><declname>CoordinateType</declname><defname>CoordinateType</defname>
+ // <type>typename</type><declname>T</declname><defname>T</defname>
             // -> set full type
             if (p.name.empty())
             {
@@ -318,6 +323,7 @@
         else if (full == ".location")
         {
             std::string loc = get_attribute(node, "file");
+ // Boost.Geometry specific, to make generic: make this path-start configurable
             std::size_t pos = loc.rfind("/boost/geometry/");
             if (pos != std::string::npos)
             {
@@ -377,6 +383,7 @@
         else if (full == ".definition")
         {
             f.definition = node->value();
+ // Boost.Geometry specific, to make generic: make this namespace-to-be-skipped configurable
             boost::replace_all(f.definition, "boost::geometry::", "");
         }
         else if (full == ".param")
@@ -438,7 +445,7 @@
             }
             if (kind == "define" )
             {
- // Get define or Boost.Geometry registration macro
+ // Get define or registration macro
                 recurse = true;
             }
             else if (kind == "public-static-func" || kind == "public-func")
@@ -633,30 +640,49 @@
 }
 
 
-void quickbook_output(function const& f, bool use_arity, std::ostream& out)
+void quickbook_output(function const& f, std::ostream& out)
 {
     // Write the parsed function
     int arity = (int)f.parameters.size();
- bool has_strategy = false;
- BOOST_FOREACH(param const& p, f.parameters)
+
+ std::string additional_description;
+
+ if (! f.unique)
+ {
+ BOOST_FOREACH(param const& p, f.parameters)
+ {
+ // Boost.Geometry specific, if there is a Strategy parameter,
+ // rename the description to " with Strategy"
+ // TODO: get this from somewhere
+ if (boost::contains(p.type, "Strategy"))
+ {
+ additional_description = " (with strategy)";
+ }
+ }
+ }
+ if (! f.unique && additional_description.empty())
     {
- if (p.type == "Strategy")
+ // http://en.wikipedia.org/wiki/Arity
+ static std::string const descriptions[] = {"nullary", "unary", "binary", "ternary"
+ , "quaternary", "quinary", "senary", "septenary", "octary", "nonary"};
+ static int const n = sizeof(descriptions) / sizeof(descriptions[0]);
+ if (arity < n)
         {
- has_strategy = true;
+ std::ostringstream out;
+ out << " (" << descriptions[arity] << ")";
+ additional_description = out.str();
+
         }
     }
 
     out << "[section:" << f.name;
- if (use_arity)
+ if (! f.unique)
     {
         out << "_" << arity;
     }
- out << " " << f.name;
- if (has_strategy)
- {
- out << " (with strategy)";
- }
- out << "]" << std::endl
+ out << " " << f.name
+ << additional_description
+ << "]" << std::endl
         << std::endl;
 
     out << f.brief_description << std::endl;
@@ -867,16 +893,15 @@
 
 int main(int argc, char** argv)
 {
- std::string filename =
- argc > 1
- ? argv[1]
- //: "../../../libs/geometry/doc/doxygen_output/xml/structboost_1_1geometry_1_1strategy_1_1distance_1_1pythagoras.xml";
- //: "../../../libs/geometry/doc/doxygen_output/xml/classboost_1_1geometry_1_1point.xml";
- //: "../../../libs/geometry/doc/doxygen_output/xml/group__simplify.xml";
- //: "../../../libs/geometry/doc/doxygen_output/xml/group__centroid.xml";
- //: "../../../libs/geometry/doc/doxygen_output/xml/group__register.xml";
- : "../../../libs/geometry/doc/doxygen_output/xml/group__intersection.xml";
+ if (argc < 2)
+ {
+ std::cerr
+ << "Usage: doxygen_xml2qbk [XML-filename]" << std::endl
+ << " where the XML refers to an XML written by Doxygen" << std::endl;
+ return 1;
+ }
 
+ std::string filename = argv[1];
     std::string xml_string = file_to_string(filename);
 
     xml_doc xml(xml_string.c_str());
@@ -884,16 +909,18 @@
     documentation doc;
     parse(xml.first_node(), doc);
 
- // Boost.Geometry specific
- // Copy behaviors if empty and function has same name
- BOOST_FOREACH(function& f1, doc.functions)
+ for (std::size_t i = 0; i < doc.functions.size(); i++)
     {
- BOOST_FOREACH(function const& f2, doc.functions)
+ function& f1 = doc.functions[i];
+ for (std::size_t j = i + 1; j < doc.functions.size(); j++)
         {
+ function& f2 = doc.functions[j];
             if (f1.name == f2.name
                 || equal_ignore_fix(f1.name, f2.name, "make_")
                 || equal_ignore_fix(f1.name, f2.name, "_inserter"))
             {
+ // Boost.Geometry specific
+ // Copy behaviors if empty and function has same name
                 if (f1.behaviors.empty() && !f2.behaviors.empty())
                 {
                     f1.behaviors = f2.behaviors;
@@ -903,6 +930,14 @@
                     f1.complexity = f2.complexity;
                 }
             }
+
+ if (f1.name == f2.name)
+ {
+ // It is not a unique function, so e.g. an overload,
+ // so a description must distinguish them.
+ f1.unique = false;
+ f2.unique = false;
+ }
         }
     }
 
@@ -912,11 +947,11 @@
 
     BOOST_FOREACH(function const& f, doc.functions)
     {
- quickbook_output(f, doc.functions.size() > 1, std::cout);
+ quickbook_output(f, std::cout);
     }
     BOOST_FOREACH(function const& f, doc.defines)
     {
- quickbook_output(f, true, std::cout);
+ quickbook_output(f, std::cout);
     }
 
     if (! doc.cos.name.empty())

Modified: sandbox/geometry/other/programs/doxygen_xml2qbk/doxygen_xml2qbk.vcproj
==============================================================================
--- sandbox/geometry/other/programs/doxygen_xml2qbk/doxygen_xml2qbk.vcproj (original)
+++ sandbox/geometry/other/programs/doxygen_xml2qbk/doxygen_xml2qbk.vcproj 2010-09-06 11:53:55 EDT (Mon, 06 Sep 2010)
@@ -39,7 +39,7 @@
                                 Name="VCCLCompilerTool"
                                 Optimization="0"
                                 AdditionalIncludeDirectories=".;contrib/rapidxml-1.13"
- PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;"
+ PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;_SCL_SECURE_NO_DEPRECATE;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS"
                                 MinimalRebuild="true"
                                 BasicRuntimeChecks="3"
                                 RuntimeLibrary="3"
@@ -113,7 +113,7 @@
                         <Tool
                                 Name="VCCLCompilerTool"
                                 AdditionalIncludeDirectories=".;contrib/rapidxml-1.13"
- PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;"
+ PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;_SCL_SECURE_NO_DEPRECATE;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS"
                                 RuntimeLibrary="2"
                                 UsePrecompiledHeader="0"
                                 WarningLevel="3"


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk