Commit 28fcee4d authored by Joseph Mirabel's avatar Joseph Mirabel
Browse files

[Python][Doc] Handle class attributes.

parent 1536e0f7
...@@ -17,6 +17,10 @@ static inline const char* run () ...@@ -17,6 +17,10 @@ static inline const char* run ()
{ {
return ""; return "";
} }
static inline const char* attribute (const char*)
{
return "";
}
}; };
template <typename _class> template <typename _class>
...@@ -25,6 +29,12 @@ inline const char* class_doc () ...@@ -25,6 +29,12 @@ inline const char* class_doc ()
return class_doc_impl<_class>::run(); return class_doc_impl<_class>::run();
} }
template <typename _class>
inline const char* class_attrib_doc (const char* name)
{
return class_doc_impl<_class>::attribute(name);
}
template <typename FuncPtr> template <typename FuncPtr>
inline const char* member_func_doc (FuncPtr) inline const char* member_func_doc (FuncPtr)
{ {
......
...@@ -26,7 +26,16 @@ static inline const char* run () ...@@ -26,7 +26,16 @@ static inline const char* run ()
{{ {{
return "{docstring}"; return "{docstring}";
}} }}
static inline const char* attribute (const char* attrib)
{{{attributes}
(void)attrib; // turn off unused parameter warning.
return "";
}}
}};""" }};"""
template_class_attribute_body = \
"""
if (strcmp(attrib, "{attribute}") == 0)
return "{docstring}";"""
template_constructor_doc = \ template_constructor_doc = \
""" """
template <{tplargs}> template <{tplargs}>
...@@ -352,11 +361,23 @@ class ClassCompound (CompoundBase): ...@@ -352,11 +361,23 @@ class ClassCompound (CompoundBase):
self.definition.find('briefdescription'), self.definition.find('briefdescription'),
self.definition.find('detaileddescription'), self.definition.find('detaileddescription'),
self.index.output) self.index.output)
if len(docstring) == 0: return attribute_docstrings = ""
for member in self.attributes:
_dc = self.index.xml_docstring.getDocString(
member.find('briefdescription'),
member.find('detaileddescription'),
self.index.output)
if len(_dc) == 0: continue
attribute_docstrings += template_class_attribute_body.format (
attribute = member.find('name').text,
docstring = _dc,
)
if len(docstring) == 0 and len(attribute_docstrings) == 0: return
output.out (template_class_doc.format ( output.out (template_class_doc.format (
tplargs = self._templateDecl(), tplargs = self._templateDecl(),
classname = self._className(), classname = self._className(),
docstring = docstring, docstring = docstring,
attributes = attribute_docstrings,
)) ))
def write (self, output): def write (self, output):
......
...@@ -173,8 +173,8 @@ void exposeShapes () ...@@ -173,8 +173,8 @@ void exposeShapes ()
; ;
class_ <Sphere, bases<ShapeBase>, shared_ptr<Sphere> > class_ <Sphere, bases<ShapeBase>, shared_ptr<Sphere> >
("Sphere", doxygen::class_doc<Sphere>(), init<FCL_REAL>()) ("Sphere", doxygen::class_doc<Sphere>(), init<FCL_REAL>(doxygen::constructor_doc<Sphere>()))
.def_readwrite ("radius", &Sphere::radius) .def_readwrite ("radius", &Sphere::radius, doxygen::class_attrib_doc<Sphere>("radius"))
; ;
class_ <TriangleP, bases<ShapeBase>, shared_ptr<TriangleP> > class_ <TriangleP, bases<ShapeBase>, shared_ptr<TriangleP> >
......
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