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 ()
{
return "";
}
static inline const char* attribute (const char*)
{
return "";
}
};
template <typename _class>
......@@ -25,6 +29,12 @@ inline const char* class_doc ()
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>
inline const char* member_func_doc (FuncPtr)
{
......
......@@ -26,7 +26,16 @@ static inline const char* run ()
{{
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 <{tplargs}>
......@@ -352,11 +361,23 @@ class ClassCompound (CompoundBase):
self.definition.find('briefdescription'),
self.definition.find('detaileddescription'),
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 (
tplargs = self._templateDecl(),
classname = self._className(),
docstring = docstring,
attributes = attribute_docstrings,
))
def write (self, output):
......
......@@ -173,8 +173,8 @@ void exposeShapes ()
;
class_ <Sphere, bases<ShapeBase>, shared_ptr<Sphere> >
("Sphere", doxygen::class_doc<Sphere>(), init<FCL_REAL>())
.def_readwrite ("radius", &Sphere::radius)
("Sphere", doxygen::class_doc<Sphere>(), init<FCL_REAL>(doxygen::constructor_doc<Sphere>()))
.def_readwrite ("radius", &Sphere::radius, doxygen::class_attrib_doc<Sphere>("radius"))
;
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