remove self argument in python docstring for boost <1.35 compatibility allowing the removal of boost version checking - addresses #29

This commit is contained in:
Dane Springmeyer 2009-09-27 01:31:30 +00:00
parent 10dff4b8cf
commit 8fd907f8fc
6 changed files with 64 additions and 148 deletions

View file

@ -23,7 +23,6 @@
// boost // boost
#include <boost/python.hpp> #include <boost/python.hpp>
#include <boost/version.hpp>
//mapnik //mapnik
#include <mapnik/color.hpp> #include <mapnik/color.hpp>
@ -45,24 +44,18 @@ void export_color ()
{ {
using namespace boost::python; using namespace boost::python;
class_<color>("Color", init<int,int,int,int>( class_<color>("Color", init<int,int,int,int>(
#if BOOST_VERSION >= 103500 ( arg("r"), arg("g"), arg("b"), arg("a") ),
( arg("self"), arg("r"), arg("g"), arg("b"), arg("a") ),
#endif
"Creates a new color from its RGB components\n" "Creates a new color from its RGB components\n"
"and an alpha value.\n" "and an alpha value.\n"
"All values between 0 and 255.\n") "All values between 0 and 255.\n")
) )
.def(init<int,int,int>( .def(init<int,int,int>(
#if BOOST_VERSION >= 103500 ( arg("r"), arg("g"), arg("b") ),
( arg("self"), arg("r"), arg("g"), arg("b") ),
#endif
"Creates a new color from its RGB components.\n" "Creates a new color from its RGB components.\n"
"All values between 0 and 255.\n") "All values between 0 and 255.\n")
) )
.def(init<std::string>( .def(init<std::string>(
#if BOOST_VERSION >= 103500 ( arg("color_string") ),
( arg("self"), arg("color_string") ),
#endif
"Creates a new color from its CSS string representation.\n" "Creates a new color from its CSS string representation.\n"
"The string may be a CSS color name (e.g. 'blue')\n" "The string may be a CSS color name (e.g. 'blue')\n"
"or a hex color string (e.g. '#0000ff').\n") "or a hex color string (e.g. '#0000ff').\n")
@ -91,9 +84,6 @@ void export_color ()
.def_pickle(color_pickle_suite()) .def_pickle(color_pickle_suite())
.def("__str__",&color::to_string) .def("__str__",&color::to_string)
.def("to_hex_string",&color::to_hex_string, .def("to_hex_string",&color::to_hex_string,
#if BOOST_VERSION >= 103500
( arg("self") ),
#endif
"Returns the hexadecimal representation of this color.\n" "Returns the hexadecimal representation of this color.\n"
"\n" "\n"
"Example:\n" "Example:\n"
@ -102,4 +92,3 @@ void export_color ()
"'#0000ff'\n") "'#0000ff'\n")
; ;
} }

View file

@ -22,7 +22,6 @@
//$Id$ //$Id$
// boost // boost
#include <boost/version.hpp>
#include <boost/python.hpp> #include <boost/python.hpp>
// mapnik // mapnik
@ -43,19 +42,16 @@ struct coord_pickle_suite : boost::python::pickle_suite
void export_coord() void export_coord()
{ {
using namespace boost::python; using namespace boost::python;
class_<coord<double,2> > class_<coord<double,2> >("Coord",init<double, double>(
("Coord", // class docstring is in mapnik/__init__.py, class _Coord
// class docstring is in mapnik/__init__.py, class _Coord (arg("x"), arg("y")),
init<double, double>( "Constructs a new point with the given coordinates.\n")
#if BOOST_VERSION >= 103500 )
(arg("self"), arg("x"), arg("y")),
#endif
"Constructs a new point with the given coordinates."))
.def_pickle(coord_pickle_suite()) .def_pickle(coord_pickle_suite())
.def_readwrite("x", &coord<double,2>::x, .def_readwrite("x", &coord<double,2>::x,
"Gets or sets the x/lon coordinate of the point.") "Gets or sets the x/lon coordinate of the point.\n")
.def_readwrite("y", &coord<double,2>::y, .def_readwrite("y", &coord<double,2>::y,
"Gets or sets the y/lat coordinate of the point.") "Gets or sets the y/lat coordinate of the point.\n")
.def(self == self) // __eq__ .def(self == self) // __eq__
.def(self + self) // __add__ .def(self + self) // __add__
.def(self + float()) .def(self + float())

View file

@ -22,7 +22,6 @@
//$Id: mapnik_envelope.cc 27 2005-03-30 21:45:40Z pavlenko $ //$Id: mapnik_envelope.cc 27 2005-03-30 21:45:40Z pavlenko $
// boost // boost
#include <boost/version.hpp>
#include <boost/python.hpp> #include <boost/python.hpp>
// mapnik // mapnik
@ -69,25 +68,14 @@ void export_envelope()
using namespace boost::python; using namespace boost::python;
class_<Envelope<double> >("Envelope", class_<Envelope<double> >("Envelope",
// class docstring is in mapnik/__init__.py, class _Coord // class docstring is in mapnik/__init__.py, class _Coord
init<double,double,double,double> init<double,double,double,double>(
( (arg("minx"),arg("miny"),arg("maxx"),arg("maxy")),
#if BOOST_VERSION >= 103500
(arg("self"), arg("minx"), arg("miny"), arg("maxx"), arg("maxy")),
#endif
"Constructs a new envelope from the coordinates\n" "Constructs a new envelope from the coordinates\n"
"of its lower left and upper right corner points.")) "of its lower left and upper right corner points.\n"))
.def(init<> .def(init<>("Equivalent to Envelope(0, 0, -1, -1).\n"))
( .def(init<const coord<double,2>&, const coord<double,2>&>(
#if BOOST_VERSION >= 103500 (arg("ll"),arg("ur")),
(arg("self")), "Equivalent to Envelope(ll.x, ll.y, ur.x, ur.y).\n"))
#endif
"Equivalent to Envelope(0, 0, -1, -1)."))
.def(init<const coord<double,2>&, const coord<double,2>&>
(
#if BOOST_VERSION >= 103500
(arg("self"), arg("ll"), arg("ur")),
#endif
"Equivalent to Envelope(ll.x, ll.y, ur.x, ur.y)."))
.add_property("minx", &Envelope<double>::minx, .add_property("minx", &Envelope<double>::minx,
"X coordinate for the lower left corner") "X coordinate for the lower left corner")
.add_property("miny", &Envelope<double>::miny, .add_property("miny", &Envelope<double>::miny,
@ -97,19 +85,14 @@ void export_envelope()
.add_property("maxy", &Envelope<double>::maxy, .add_property("maxy", &Envelope<double>::maxy,
"Y coordinate for the upper right corner") "Y coordinate for the upper right corner")
.def("center", &Envelope<double>::center, .def("center", &Envelope<double>::center,
#if BOOST_VERSION >= 103500
(arg("self")),
#endif
"Returns the coordinates of the center of the bounding box.\n" "Returns the coordinates of the center of the bounding box.\n"
"\n" "\n"
"Example:\n" "Example:\n"
">>> e = Envelope(0, 0, 100, 100)\n" ">>> e = Envelope(0, 0, 100, 100)\n"
">>> e.center()\n" ">>> e.center()\n"
"Coord(50, 50)") "Coord(50, 50)\n")
.def("center", &Envelope<double>::re_center, .def("center", &Envelope<double>::re_center,
#if BOOST_VERSION >= 103500 (arg("x"), arg("y")),
(arg("self"), arg("x"), arg("y")),
#endif
"Moves the envelope so that the given coordinates become its new center.\n" "Moves the envelope so that the given coordinates become its new center.\n"
"The width and the height are preserved.\n" "The width and the height are preserved.\n"
"\n " "\n "
@ -121,12 +104,10 @@ void export_envelope()
">>> (e.width(), e.height())\n" ">>> (e.width(), e.height())\n"
"(100.0, 100.0)\n" "(100.0, 100.0)\n"
">>> e\n" ">>> e\n"
"Envelope(10.0, 10.0, 110.0, 110.0)" "Envelope(10.0, 10.0, 110.0, 110.0)\n"
) )
.def("width", width_p1, .def("width", width_p1,
#if BOOST_VERSION >= 103500 (arg("new_width")),
(arg("self"), arg("new_width")),
#endif
"Sets the width to new_width of the envelope preserving its center.\n" "Sets the width to new_width of the envelope preserving its center.\n"
"\n " "\n "
"Example:\n" "Example:\n"
@ -135,18 +116,13 @@ void export_envelope()
">>> e.center()\n" ">>> e.center()\n"
"Coord(50.0,50.0)\n" "Coord(50.0,50.0)\n"
">>> e\n" ">>> e\n"
"Envelope(-10.0, 0.0, 110.0, 100.0)" "Envelope(-10.0, 0.0, 110.0, 100.0)\n"
) )
.def("width", width_p2, .def("width", width_p2,
#if BOOST_VERSION >= 103500 "Returns the width of this envelope.\n"
(arg("self")),
#endif
"Returns the width of this envelope."
) )
.def("height", height_p1, .def("height", height_p1,
#if BOOST_VERSION >= 103500 (arg("new_height")),
(arg("self"), arg("new_height")),
#endif
"Sets the height to new_height of the envelope preserving its center.\n" "Sets the height to new_height of the envelope preserving its center.\n"
"\n " "\n "
"Example:\n" "Example:\n"
@ -155,80 +131,59 @@ void export_envelope()
">>> e.center()\n" ">>> e.center()\n"
"Coord(50.0,50.0)\n" "Coord(50.0,50.0)\n"
">>> e\n" ">>> e\n"
"Envelope(0.0, -10.0, 100.0, 110.0)" "Envelope(0.0, -10.0, 100.0, 110.0)\n"
) )
.def("height", height_p2, .def("height", height_p2,
#if BOOST_VERSION >= 103500 "Returns the height of this envelope.\n"
(arg("self")),
#endif
"Returns the height of this envelope."
) )
.def("expand_to_include",expand_to_include_p1, .def("expand_to_include",expand_to_include_p1,
#if BOOST_VERSION >= 103500 (arg("x"),arg("y")),
(arg("self"), arg("x"), arg("y")),
#endif
"Expands this envelope to include the point given by x and y.\n" "Expands this envelope to include the point given by x and y.\n"
"\n" "\n"
"Example:\n", "Example:\n",
">>> e = Envelope(0, 0, 100, 100)\n" ">>> e = Envelope(0, 0, 100, 100)\n"
">>> e.expand_to_include(110, 110)\n" ">>> e.expand_to_include(110, 110)\n"
">>> e\n" ">>> e\n"
"Envelope(0.0, 00.0, 110.0, 110.0)" "Envelope(0.0, 00.0, 110.0, 110.0)\n"
) )
.def("expand_to_include",expand_to_include_p2, .def("expand_to_include",expand_to_include_p2,
#if BOOST_VERSION >= 103500 (arg("p")),
(arg("self"), arg("p")), "Equivalent to expand_to_include(p.x, p.y)\n"
#endif
"Equivalent to expand_to_include(p.x, p.y)"
) )
.def("expand_to_include",expand_to_include_p3, .def("expand_to_include",expand_to_include_p3,
#if BOOST_VERSION >= 103500 (arg("other")),
(arg("self"), arg("other")),
#endif
"Equivalent to:\n" "Equivalent to:\n"
" expand_to_include(other.minx, other.miny)\n" " expand_to_include(other.minx, other.miny)\n"
" expand_to_include(other.maxx, other.maxy)" " expand_to_include(other.maxx, other.maxy)\n"
) )
.def("contains",contains_p1, .def("contains",contains_p1,
#if BOOST_VERSION >= 103500 (arg("x"),arg("y")),
(arg("self"), arg("x"), arg("y")),
#endif
"Returns True iff this envelope contains the point\n" "Returns True iff this envelope contains the point\n"
"given by x and y." "given by x and y.\n"
) )
.def("contains",contains_p2, .def("contains",contains_p2,
#if BOOST_VERSION >= 103500 (arg("p")),
(arg("self"), arg("p")), "Equivalent to contains(p.x, p.y)\n"
#endif
"Equivalent to contains(p.x, p.y)"
) )
.def("contains",contains_p3, .def("contains",contains_p3,
#if BOOST_VERSION >= 103500 (arg("other")),
(arg("self"), arg("other")),
#endif
"Equivalent to:\n" "Equivalent to:\n"
" contains(other.minx, other.miny) and contains(other.maxx, other.maxy)" " contains(other.minx, other.miny) and contains(other.maxx, other.maxy)\n"
) )
.def("intersects",intersects_p1, .def("intersects",intersects_p1,
#if BOOST_VERSION >= 103500 (arg("x"),arg("y")),
(arg("self"), arg("x"), arg("y")),
#endif
"Returns True iff this envelope intersects the point\n" "Returns True iff this envelope intersects the point\n"
"given by x and y.\n" "given by x and y.\n"
"\n" "\n"
"Note: For points, intersection is equivalent\n" "Note: For points, intersection is equivalent\n"
"to containment, i.e. the following holds:\n" "to containment, i.e. the following holds:\n"
" e.contains(x, y) == e.intersects(x, y)" " e.contains(x, y) == e.intersects(x, y)\n"
) )
.def("intersects",intersects_p2, .def("intersects",intersects_p2,
#if BOOST_VERSION >= 103500 (arg("p")),
(arg("self"), arg("p")), "Equivalent to contains(p.x, p.y)\n")
#endif
"Equivalent to contains(p.x, p.y)")
.def("intersects",intersects_p3, .def("intersects",intersects_p3,
#if BOOST_VERSION >= 103500 (arg("other")),
(arg("self"), arg("other")),
#endif
"Returns True iff this envelope intersects the other envelope,\n" "Returns True iff this envelope intersects the other envelope,\n"
"This relationship is symmetric." "This relationship is symmetric."
"\n" "\n"
@ -238,12 +193,10 @@ void export_envelope()
">>> e1.intersects(e2)\n" ">>> e1.intersects(e2)\n"
"True\n" "True\n"
">>> e1.contains(e2)\n" ">>> e1.contains(e2)\n"
"False" "False\n"
) )
.def("intersect",intersect, .def("intersect",intersect,
#if BOOST_VERSION >= 103500 (arg("other")),
(arg("self"), arg("other")),
#endif
"Returns the overlap of this envelope and the other envelope\n" "Returns the overlap of this envelope and the other envelope\n"
"as a new envelope.\n" "as a new envelope.\n"
"\n" "\n"
@ -251,7 +204,7 @@ void export_envelope()
">>> e1 = Envelope(0, 0, 100, 100)\n" ">>> e1 = Envelope(0, 0, 100, 100)\n"
">>> e2 = Envelope(50, 50, 150, 150)\n" ">>> e2 = Envelope(50, 50, 150, 150)\n"
">>> e1.intersect(e2)\n" ">>> e1.intersect(e2)\n"
"Envelope(50.0, 50.0, 100.0, 100.0)" "Envelope(50.0, 50.0, 100.0, 100.0)\n"
) )
.def(self == self) // __eq__ .def(self == self) // __eq__
.def(self + self) // __add__ .def(self + self) // __add__

View file

@ -23,7 +23,6 @@
// boost // boost
#include <boost/python.hpp> #include <boost/python.hpp>
#include <boost/version.hpp>
#include <boost/python/detail/api_placeholder.hpp> #include <boost/python/detail/api_placeholder.hpp>
#include <boost/python/suite/indexing/vector_indexing_suite.hpp> #include <boost/python/suite/indexing/vector_indexing_suite.hpp>
@ -147,9 +146,7 @@ void export_map()
; ;
class_<Map>("Map","The map object.",init<int,int,optional<std::string const&> >( class_<Map>("Map","The map object.",init<int,int,optional<std::string const&> >(
#if BOOST_VERSION >= 103500 ( arg("width"),arg("height"),arg("srs") ),
( arg("self"),arg("width"),arg("height"),arg("srs") ),
#endif
"Create a Map with a width and height as integers and, optionally,\n" "Create a Map with a width and height as integers and, optionally,\n"
"an srs string either with a Proj.4 epsg code ('+init=epsg:<code>')\n" "an srs string either with a Proj.4 epsg code ('+init=epsg:<code>')\n"
"or with a Proj.4 literal ('+proj=<literal>').\n" "or with a Proj.4 literal ('+proj=<literal>').\n"

View file

@ -22,7 +22,6 @@
//$Id$ //$Id$
//boost //boost
#include <boost/version.hpp>
#include <boost/python.hpp> #include <boost/python.hpp>
// mapnik // mapnik
@ -90,31 +89,24 @@ void export_projection ()
{ {
using namespace boost::python; using namespace boost::python;
class_<projection> class_<projection>("Projection", "Represents a map projection.",init<optional<std::string const&> >(
("Projection", "Represents a map projection.", (arg("proj4_string")),
init<optional<std::string const&> > "Constructs a new projection from its PROJ.4 string representation.\n"
( "\n"
#if BOOST_VERSION >= 103500 "The parameterless version of this constructor is equivalent to\n"
(arg("self"), arg("proj4_string")), " Projection('+proj=latlong +ellps=WGS84')\n"
#endif "\n"
"Constructs a new projection from its PROJ.4 string representation.\n" "The constructor will throw a RuntimeError in case the projection\n"
"\n" "cannot be initialized.\n"
"The parameterless version of this constructor is equivalent to\n" )
" Projection('+proj=latlong +ellps=WGS84')\n" )
"\n"
"The constructor will throw a RuntimeError in case the projection\n"
"cannot be initialized."))
.def_pickle(projection_pickle_suite()) .def_pickle(projection_pickle_suite())
.def ("params", make_function(&projection::params, .def ("params", make_function(&projection::params,
return_value_policy<copy_const_reference>() return_value_policy<copy_const_reference>()),
#if BOOST_VERSION >= 103500 "Returns the PROJ.4 string for this projection.\n")
, arg("self")
#endif
),
"Returns the PROJ.4 string for this projection.")
.add_property ("geographic", &projection::is_geographic, .add_property ("geographic", &projection::is_geographic,
"This property is True if the projection is a geographic projection\n" "This property is True if the projection is a geographic projection\n"
"(i.e. it uses lon/lat coordinates)") "(i.e. it uses lon/lat coordinates)\n")
; ;
def("forward_",&forward_pt); def("forward_",&forward_pt);

View file

@ -23,7 +23,6 @@
// boost // boost
#include <boost/python.hpp> #include <boost/python.hpp>
#include <boost/version.hpp>
// mapnik // mapnik
#include <mapnik/stroke.hpp> #include <mapnik/stroke.hpp>
@ -131,14 +130,9 @@ void export_stroke ()
; ;
class_<stroke>("Stroke",init<>( class_<stroke>("Stroke",init<>(
#if BOOST_VERSION >= 103500
( arg("self") ),
#endif
"Creates a new default black stroke with the width of 1.\n")) "Creates a new default black stroke with the width of 1.\n"))
.def(init<color,float>( .def(init<color,float>(
#if BOOST_VERSION >= 103500 (arg("color"),arg("width")),
( arg("self"), arg("color"), arg("width") ),
#endif
"Creates a new stroke object with a specified color and width.\n") "Creates a new stroke object with a specified color and width.\n")
) )
.def_pickle(stroke_pickle_suite()) .def_pickle(stroke_pickle_suite())
@ -166,14 +160,9 @@ void export_stroke ()
"Returns the line join mode of this stroke.\n") "Returns the line join mode of this stroke.\n")
// todo consider providing a single get/set property // todo consider providing a single get/set property
.def("add_dash",&stroke::add_dash, .def("add_dash",&stroke::add_dash,
#if BOOST_VERSION >= 103500 (arg("length"),arg("gap")),
( arg("self"), arg("length"), arg("gap") ),
#endif
"Adds a dash segment to the dash patterns of this stroke.\n") "Adds a dash segment to the dash patterns of this stroke.\n")
.def("get_dashes", get_dashes_list, .def("get_dashes", get_dashes_list,
#if BOOST_VERSION >= 103500
( arg("self") ),
#endif
"Returns the list of dash segments for this stroke.\n") "Returns the list of dash segments for this stroke.\n")
; ;
} }