Commit 1536e0f7 authored by Joseph Mirabel's avatar Joseph Mirabel
Browse files

Add doxygen -> C++ generation file.

parent f40713a2
#ifndef DOXYGEN_BOOST_DOC_HH
#define DOXYGEN_BOOST_DOC_HH
#ifndef DOXYGEN_DOC_HH
# error "You should have included doxygen.hh first."
#endif // DOXYGEN_DOC_HH
#include <boost/python.hpp>
namespace doxygen
{
namespace visitor
{
template <typename function_type>
struct member_func_impl : boost::python::def_visitor<member_func_impl<function_type> >
{
member_func_impl(const char* n, function_type f) : name(n), function(f) {}
template <class classT>
inline void visit(classT& c) const
{
c.def(name, function, doxygen::member_func_doc(function));
}
const char* name;
function_type function;
};
// TODO surprisingly, this does not work when defined here but it works when
// defined after the generated files are included.
template <typename function_type>
inline member_func_impl<function_type> member_func (const char* name, function_type function)
{
return member_func_impl<function_type>(name, function);
}
} // namespace visitor
} // namespace doxygen
#endif // DOXYGEN_BOOST_DOC_HH
#ifndef DOXYGEN_DOC_HH
#define DOXYGEN_DOC_HH
#include <boost/preprocessor/repetition.hpp>
#include <boost/preprocessor/punctuation/comma_if.hpp>
#ifndef DOXYGEN_DOC_MAX_NUMBER_OF_ARGUMENTS_IN_CONSTRUCTOR
#define DOXYGEN_DOC_MAX_NUMBER_OF_ARGUMENTS_IN_CONSTRUCTOR 10
#endif
namespace doxygen
{
template <typename _class>
struct class_doc_impl
{
static inline const char* run ()
{
return "";
}
};
template <typename _class>
inline const char* class_doc ()
{
return class_doc_impl<_class>::run();
}
template <typename FuncPtr>
inline const char* member_func_doc (FuncPtr)
{
return "";
}
#define DOXYGEN_DOC_DECLARE_CONSTRUCTOR(z,nargs,unused) \
template < \
typename Class \
BOOST_PP_COMMA_IF(nargs) \
BOOST_PP_ENUM_PARAMS(nargs, class Arg)> \
struct constructor_doc_##nargs##_impl { \
static inline const char* run () \
{ \
return ""; \
} \
}; \
\
template < \
typename Class \
BOOST_PP_COMMA_IF(nargs) \
BOOST_PP_ENUM_PARAMS(nargs, class Arg)> \
inline const char* constructor_doc () \
{ \
return constructor_doc_##nargs##_impl< \
Class \
BOOST_PP_COMMA_IF(nargs) \
BOOST_PP_ENUM_PARAMS(nargs, Arg)>::run(); \
}
BOOST_PP_REPEAT(DOXYGEN_DOC_MAX_NUMBER_OF_ARGUMENTS_IN_CONSTRUCTOR, DOXYGEN_DOC_DECLARE_CONSTRUCTOR, ~)
/*
template <typename Class>
inline const char* constructor_doc ()
{
return "";
}
*/
template <typename Class>
struct destructor_doc_impl
{
static inline const char* run ()
{
return "";
}
};
template <typename Class>
inline const char* destructor_doc ()
{
return destructor_doc_impl<Class>::run();
}
/* TODO class attribute can be handled by
template <typename Class, typename AttributeType>
const char* attribute_doc (AttributeType Class::* ptr)
{
// Body looks like
// if (ptr == &Class::attributeName)
// return "attrib documentation";
return "undocumented";
}
*/
} // namespace doxygen
#endif // DOXYGEN_DOC_HH
This diff is collapsed.
class XmlDocString (object):
def __init__ (self, index):
self.index = index
self.tags = {
"para": self.para,
"ref": self.ref,
"briefdescription": self.otherTags,
"detaileddescription": self.otherTags,
"parameterlist": self.parameterlist,
"parameterdescription": self.otherTags,
"emphasis": self.emphasis,
"simplesect": self.simplesect,
}
self.unkwownTags = set()
self.unkwownReferences = dict()
self._linesep = "\\n\"\n\""
def clear (self):
self.lines = []
self.unkwownTags.clear()
self.unkwownReferences.clear()
def writeErrors (self, output):
ret = False
for t in self.unkwownTags:
output.warn ("Unknown tag: ", t)
ret = True
for ref,node in self.unkwownReferences.items():
output.warn ("Unknown reference: ", ref, node.text)
ret = True
return ret
def _write (self, str):
nlines=str.split(sep="\n")
if len(self.lines)==0:
self.lines += nlines
else:
self.lines[-1] += nlines[0]
self.lines += nlines[1:]
#self.lines += nlines[1:]
def _newline (self,n=1):
self.lines.extend (["",] * n)
def _clean(self):
s = 0
for l in self.lines:
if len(l.strip())==0: s+=1
else: break
e = len(self.lines)
for l in reversed(self.lines):
if len(l.strip())==0: e-=1
else: break
self.lines = self.lines[s:e]
def getDocString (self, brief, detailled, output):
self.clear()
if brief is not None:
self.visit (brief)
if detailled is not None and len(detailled.getchildren()) > 0:
if brief is not None: self._newline ()
self.visit (detailled)
from sys import stdout, stderr
self.writeErrors(output)
self._clean()
return self._linesep.join(self.lines)
def visit (self, node):
assert isinstance(node.tag, str)
tag = node.tag
if tag not in self.tags:
self.unknownTag (node)
else:
self.tags[tag](node)
def unknownTag (self, node):
self.unkwownTags.add (node.tag)
self.otherTags (node)
def otherTags (self, node):
if node.text:
self._write (node.text.strip())
for c in node.iterchildren():
self.visit (c)
if c.tail: self._write (c.tail.strip())
def emphasis (self, node):
self._write ("*")
self.otherTags(node)
self._write ("*")
def simplesect (self, node):
self._write (node.attrib["kind"].title()+": ")
self.otherTags (node)
def para (self, node):
if node.text: self._write (node.text)
for c in node.iterchildren():
self.visit (c)
if c.tail: self._write (c.tail)
self._newline()
def ref (self, node):
refid = node.attrib["refid"]
if self.index.hasref(refid):
self._write (self.index.getref(refid).name)
else:
self.unkwownReferences[refid] = node
self._write (node.text)
assert len(node.getchildren()) == 0
def parameterlist (self, node):
self._newline()
self._write (node.attrib["kind"].title())
self._newline()
for item in node.iterchildren("parameteritem"):
self.parameteritem (item)
def parameteritem (self, node):
indent = " "
self._write (indent + "- ")
# should contain two children
assert len(node.getchildren()) == 2
namelist = node.find ("parameternamelist")
desc = node.find ("parameterdescription")
sep = ""
for name in namelist.iterchildren("parametername"):
self._write (sep + name.text)
sep = ", "
self._write (" ")
self.visit (desc)
......@@ -44,7 +44,7 @@ INCLUDE_DIRECTORIES("${CMAKE_SOURCE_DIR}/src")
INCLUDE_DIRECTORIES("${CMAKE_CURRENT_BINARY_DIR}")
ADD_CUSTOM_TARGET(generate_doxygen_cpp_doc
COMMAND ${CMAKE_SOURCE_DIR}/cmake/doxygen/doxygen_xml_parser.py
COMMAND ${CMAKE_SOURCE_DIR}/doc/python/doxygen_xml_parser.py
${CMAKE_BINARY_DIR}/doc/doxygen-xml/index.xml
${CMAKE_CURRENT_BINARY_DIR}/doxygen_autodoc > ${CMAKE_CURRENT_BINARY_DIR}/doxygen_autodoc.log
BYPRODUCTS
......@@ -57,7 +57,7 @@ ADD_DEPENDENCIES(generate_doxygen_cpp_doc doc)
SET(${LIBRARY_NAME}_HEADERS
${CMAKE_CURRENT_BINARY_DIR}/doxygen_autodoc/doxygen_xml_parser_for_cmake.hh
fcl.hh
)
)
SET(${LIBRARY_NAME}_SOURCES
version.cc
......
......@@ -44,7 +44,7 @@
#include "doxygen_autodoc/hpp/fcl/math/transform.h"
#include "../cmake/doxygen/doxygen-boost.hh"
#include "../doc/python/doxygen-boost.hh"
using namespace boost::python;
using namespace hpp::fcl;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment