Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion doc/configure.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,13 @@ def _xmlDirFromPkgConfig(pkg):

nsToPackage = {
"hpp::core": _xmlDirFromPkgConfig("hpp-core"),
"hpp::core::path": _xmlDirFromPkgConfig("hpp-core"),
"hpp::constraints": _xmlDirFromPkgConfig("hpp-constraints"),
"hpp::constraints::solver": _xmlDirFromPkgConfig("hpp-constraints"),
"hpp::pinocchio": _xmlDirFromPkgConfig("hpp-pinocchio"),
"hpp::manipulation": _xmlDirFromPkgConfig("hpp-manipulation"),
"hpp::manipulation::graph": _xmlDirFromPkgConfig("hpp-manipulation"),
"hpp::manipulation::pathPlanner": _xmlDirFromPkgConfig("hpp-manipulation"),
}


Expand All @@ -142,7 +148,7 @@ def make_doc_string(brief, detailled):


def make_args_string(args):
return "(" + ",".join(['arg("' + a + '")' for a in args]) + ")"
return "(" + ",".join(['boost::python::arg("' + a + '")' for a in args]) + ")"


def substitute(istr, ostr):
Expand Down
115 changes: 90 additions & 25 deletions doc/doxygen_xml_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,18 @@ def _getCompound(self, kind, name):

def classDoc(self, name):
el = self._getCompound("class", name)
return ClassDoc(path.join(self.directory, el.get("refid") + ".xml"))
return ClassDoc(
path.join(self.directory, el.get("refid") + ".xml"), self.directory
)


class ClassDoc:
def __init__(self, filename):
def __init__(self, filename, directory=None):
self.tree = etree.parse(filename)
self.compound = self.tree.find("./compounddef")
self.classname = self.compound.find("compoundname").text.strip()
self.directory = directory if directory else path.dirname(filename)
self._group_cache = {}

@staticmethod
def _getDoc(el):
Expand All @@ -33,30 +37,91 @@ def _getDoc(el):
detailed = d.text.strip() if d.text else ""
return brief, detailed

def _getMemberFromGroup(self, memberDefKind, name):
"""Look for memberdef in a group file via member refid."""
members = self.compound.xpath(
"sectiondef/member[@kind='" + memberDefKind + "' and name='" + name + "']"
)
if not members:
return None
member = members[0]
refid = member.get("refid")
if not refid:
return None
group_id = refid.rsplit("_1", 1)[0]
if group_id not in self._group_cache:
group_file = path.join(self.directory, group_id + ".xml")
if not path.isfile(group_file):
return None
self._group_cache[group_id] = etree.parse(group_file)
group_tree = self._group_cache[group_id]
memberdefs = group_tree.xpath(
"//memberdef[@id='" + refid + "' and @kind='" + memberDefKind + "']"
)
if memberdefs:
return memberdefs[0]
return None

def _getMemberFromInherited(self, memberDefKind, name):
"""Look for memberdef in base class XML via listofallmembers member refid."""
members = self.compound.xpath("listofallmembers/member[name='" + name + "']")
if not members:
return None
member = members[0]
refid = member.get("refid")
if not refid:
return None
# Extract base class file from refid
# e.g., "classhpp_1_1pinocchio_1_1AbstractDevice_1a312..." -> "classhpp_1_1pinocchio_1_1AbstractDevice"
parts = refid.rsplit("_1", 1)
if len(parts) < 2:
return None
base_class_id = parts[0]
base_class_file = path.join(self.directory, base_class_id + ".xml")
if not path.isfile(base_class_file):
return None
if base_class_id not in self._group_cache:
self._group_cache[base_class_id] = etree.parse(base_class_file)
base_tree = self._group_cache[base_class_id]
memberdefs = base_tree.xpath(
"//memberdef[@id='" + refid + "' and @kind='" + memberDefKind + "']"
)
if memberdefs:
return memberdefs[0]
return None

def _getMember(self, sectionKind, memberDefKind, name):
# return self.compound.xpath ("sectiondef[@kind='" + sectionKind
try:
return self.compound.xpath(
"sectiondef[re:test(@kind,'"
+ sectionKind
+ "')]/memberdef[@kind='"
+ memberDefKind
+ "' and name='"
+ name
+ "']",
namespaces={"re": "http://exslt.org/regular-expressions"},
)[0]
except IndexError as e:
msg = (
"Error: Could not find member ("
+ sectionKind
+ ") "
+ name
+ " of class "
+ self.classname
)
print(msg + "\n" + str(e), file=sys.stderr)
raise IndexError(msg)
# First try to find memberdef directly in class XML
results = self.compound.xpath(
"sectiondef[re:test(@kind,'"
+ sectionKind
+ "')]/memberdef[@kind='"
+ memberDefKind
+ "' and name='"
+ name
+ "']",
namespaces={"re": "http://exslt.org/regular-expressions"},
)
if results:
return results[0]
# Fall back to looking in group files (for @ingroup documented classes)
memberdef = self._getMemberFromGroup(memberDefKind, name)
if memberdef is not None:
return memberdef
# Fall back to looking in base class files (for inherited methods)
memberdef = self._getMemberFromInherited(memberDefKind, name)
if memberdef is not None:
return memberdef
msg = (
"Error: Could not find member ("
+ sectionKind
+ ") "
+ name
+ " of class "
+ self.classname
)
print(msg, file=sys.stderr)
raise IndexError(msg)

def getClassDoc(self):
return self._getDoc(self.compound)
Expand Down
4 changes: 2 additions & 2 deletions src/pyhpp/constraints/by-substitution.cc
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
#include <hpp/constraints/solver/by-substitution.hh>
#include <pyhpp/constraints/fwd.hh>

// DocNamespace(hpp::constraints)
// DocNamespace(hpp::constraints::solver)

using namespace boost::python;

Expand All @@ -54,7 +54,7 @@ void exposeBySubstitution() {
.value("INFEASIBLE", HierarchicalIterative::INFEASIBLE)
.value("SUCCESS", HierarchicalIterative::SUCCESS);

// DocClass(solver::BySubstitution)
// DocClass(BySubstitution)
class_<BySubstitution, bases<HierarchicalIterative> >(
"BySubstitution", init<LiegroupSpacePtr_t>())
.def("explicitConstraintSetHasChanged",
Expand Down
3 changes: 3 additions & 0 deletions src/pyhpp/constraints/explicit.cc
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@
#include <hpp/constraints/explicit.hh>
#include <pinocchio/multibody/fwd.hpp>

// DocNamespace(hpp::constraints)

using namespace boost::python;

namespace pyhpp {
Expand Down Expand Up @@ -61,6 +63,7 @@ ExplicitPtr_t createExplicit(const LiegroupSpacePtr_t& configSpace,
}

void exposeExplicit() {
// DocClass(Explicit)
class_<Explicit, ExplicitPtr_t, boost::noncopyable>("Explicit", no_init)
.def("create", &createExplicit)
.staticmethod("create");
Expand Down
2 changes: 2 additions & 0 deletions src/pyhpp/constraints/generic-transformation.cc
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@
#include <hpp/constraints/generic-transformation.hh>
#include <pyhpp/constraints/fwd.hh>

// DocNamespace(hpp::constraints)

using namespace boost::python;

namespace pyhpp {
Expand Down
2 changes: 1 addition & 1 deletion src/pyhpp/constraints/implicit.cc
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ void exposeImplicit() {
.def("comparisonType",
static_cast<const ComparisonTypes_t& (Implicit::*)() const>(
&Implicit::comparisonType),
return_internal_reference<>())
return_internal_reference<>(), DocClassMethod(comparisonType))
.def("comparisonType",
static_cast<void (Implicit::*)(const ComparisonTypes_t&)>(
&Implicit::comparisonType))
Expand Down
2 changes: 2 additions & 0 deletions src/pyhpp/constraints/locked-joint.cc
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
#include <hpp/pinocchio/liegroup-element.hh>
#include <pyhpp/constraints/fwd.hh>

// DocNamespace(hpp::constraints)

using namespace boost::python;

namespace pyhpp {
Expand Down
6 changes: 5 additions & 1 deletion src/pyhpp/constraints/relative-com.cc
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@
#include <hpp/pinocchio/device.hh>
#include <pyhpp/core/fwd.hh>
#include <pyhpp/util.hh>

// DocNamespace(hpp::constraints)

using namespace boost::python;

namespace pyhpp {
Expand Down Expand Up @@ -64,9 +67,10 @@ static RelativeComPtr_t create3(const std::string& name,
}

void exposeRelativeCom() {
// DocClass(RelativeCom)
class_<RelativeCom, RelativeComPtr_t, bases<DifferentiableFunction>,
boost::noncopyable>("RelativeCom", no_init)
.def("create", &create1)
.def("create", &create1, DocClassMethod(create))
.def("create", &create2)
.def("create", &create3)
.staticmethod("create");
Expand Down
2 changes: 1 addition & 1 deletion src/pyhpp/core/config-validation.cc
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ void exposeConfigValidation() {
.PYHPP_DEFINE_METHOD2(ConfigValidations, add, DocClassMethod(add))
.PYHPP_DEFINE_METHOD2(ConfigValidations, numberConfigValidations,
DocClassMethod(numberConfigValidations))
.PYHPP_DEFINE_METHOD2(ConfigValidations, clear, DocClassMethod(clear));
.def("clear", &ConfigValidations::clear);
}
} // namespace core
} // namespace pyhpp
5 changes: 4 additions & 1 deletion src/pyhpp/core/configuration-shooter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@
#include <pyhpp/core/fwd.hh>
#include <pyhpp/util.hh>

// DocNamespace(hpp::core)

using namespace boost::python;

namespace pyhpp {
Expand All @@ -43,9 +45,10 @@ struct CSWrapper {
};

void exposeConfigurationShooter() {
// DocClass(ConfigurationShooter)
class_<ConfigurationShooter, ConfigurationShooterPtr_t, boost::noncopyable>(
"ConfigurationShooter", no_init)
.def("shoot", &CSWrapper::shoot);
.def("shoot", &CSWrapper::shoot, DocClassMethod(shoot));
}
} // namespace core
} // namespace pyhpp
10 changes: 7 additions & 3 deletions src/pyhpp/core/connected-component.cc
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@
#include <pyhpp/core/fwd.hh>
#include <pyhpp/util.hh>

// DocNamespace(hpp::core)

using namespace boost::python;

namespace pyhpp {
Expand Down Expand Up @@ -73,11 +75,13 @@ struct CCWrapper {
}
};
void exposeConnectedComponent() {
// DocClass(ConnectedComponent)
class_<ConnectedComponent, ConnectedComponentPtr_t, boost::noncopyable>(
"ConnectedComponent", no_init)
.def("nodes", &CCWrapper::nodes)
.def("reachableFrom", &CCWrapper::reachableFrom)
.def("reachableTo", &CCWrapper::reachableTo)
.def("nodes", &CCWrapper::nodes, DocClassMethod(nodes))
.def("reachableFrom", &CCWrapper::reachableFrom,
DocClassMethod(reachableFrom))
.def("reachableTo", &CCWrapper::reachableTo, DocClassMethod(reachableTo))
.def("__eq__", &CCWrapper::equality);
}
} // namespace core
Expand Down
7 changes: 6 additions & 1 deletion src/pyhpp/core/distance.cc
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@
#include <pyhpp/core/fwd.hh>
#include <pyhpp/util.hh>

// DocNamespace(hpp::core)

using namespace boost::python;

namespace pyhpp {
Expand All @@ -55,8 +57,11 @@ struct DistanceWrapper {
};

void exposeDistance() {
// DocClass(Distance)
class_<Distance, DistancePtr_t, boost::noncopyable>("Distance", no_init)
.def("compute", &DistanceWrapper::compute);
.def("compute", &DistanceWrapper::compute, DocClassMethod(compute));

// DocClass(WeighedDistance)
class_<WeighedDistance, bases<Distance>, WeighedDistancePtr_t,
boost::noncopyable>("WeighedDistance", no_init)
.def("__init__", make_constructor(&WeighedDistance::create))
Expand Down
3 changes: 3 additions & 0 deletions src/pyhpp/core/parameter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@
#include <pyhpp/core/fwd.hh>
#include <pyhpp/util.hh>

// DocNamespace(hpp::core)

using namespace boost::python;

namespace pyhpp {
Expand Down Expand Up @@ -80,6 +82,7 @@ Parameter create(object param) {
Parameter createBool(bool param) { return Parameter(param); }

void exposeParameter() {
// DocClass(Parameter)
class_<Parameter>("Parameter", no_init)
.def("create", &create)
.staticmethod("create")
Expand Down
14 changes: 9 additions & 5 deletions src/pyhpp/core/path-optimizer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -40,20 +40,24 @@
#include <hpp/core/problem.hh>
#include <pyhpp/core/fwd.hh>

// DocNamespace(hpp::core)

using namespace boost::python;

namespace pyhpp {
namespace core {
using namespace hpp::core;

void exposePathOptimizer() {
// DocClass(PathOptimizer)
class_<PathOptimizer, PathOptimizerPtr_t, boost::noncopyable>("PathOptimizer",
no_init)
.def("problem", &PathOptimizer::problem)
.def("optimize", &PathOptimizer::optimize)
.def("interrupt", &PathOptimizer::interrupt)
.def("maxIterations", &PathOptimizer::maxIterations)
.def("timeOut", &PathOptimizer::timeOut);
.def("problem", &PathOptimizer::problem, DocClassMethod(problem))
.def("optimize", &PathOptimizer::optimize, DocClassMethod(optimize))
.def("interrupt", &PathOptimizer::interrupt, DocClassMethod(interrupt))
.def("maxIterations", &PathOptimizer::maxIterations,
DocClassMethod(maxIterations))
.def("timeOut", &PathOptimizer::timeOut, DocClassMethod(timeOut));

class_<pathOptimization::RandomShortcut,
std::shared_ptr<pathOptimization::RandomShortcut>,
Expand Down
Loading