Skip to content

Commit a52bb90

Browse files
committed
Add docstrings
1 parent 6c8e15a commit a52bb90

File tree

1 file changed

+39
-17
lines changed

1 file changed

+39
-17
lines changed

SEPythonModule/src/lib/SePyMain.cpp

Lines changed: 39 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -57,48 +57,68 @@ BOOST_PYTHON_MODULE(_SEPythonModule) {
5757
np::initialize();
5858
py::object None;
5959

60+
// show_user_defined=true, show_py_signatures=true, show_cpp_signatures=false
61+
py::docstring_options docstring_options(true, true, false);
62+
6063
py::class_<Context, boost::noncopyable>(
61-
"Context", py::init<py::dict, py::object>((py::arg("config"), py::arg("measurement_config") = py::object())))
62-
.def("get_properties", &Context::get_properties)
63-
.def("__enter__", &Context::enter)
64-
.def("__exit__", &Context::exit);
64+
"Context", "Required context for a sourcextractor++ run",
65+
py::init<py::dict, py::object>(
66+
(py::arg("config"), py::arg("measurement_config") = py::object()),
67+
"config: Dictionary with key/value configuration (as sourcextractor .config file)\nmeasurement_config: An "
68+
"instance of `sourcextractor.config.MeasurementConfig`"))
69+
.def("get_properties", &Context::get_properties, "Get the available properties")
70+
.def("__enter__", &Context::enter, "Activate the Context as default")
71+
.def("__exit__", &Context::exit, "Clear the default context");
6572
py::register_ptr_to_python<std::shared_ptr<Context>>();
6673

67-
py::class_<DetachedSource>("DetachedSource")
68-
.def("__repr__", &DetachedSource::repr)
74+
py::class_<DetachedSource>("DetachedSource", "Source detached from the sourcextractor++ runtime")
75+
.def("__repr__", &DetachedSource::repr, "Human-readable representation")
6976
.def("__getattr__", &DetachedSource::attribute)
7077
.def("__dir__", &DetachedSource::attributes)
7178
.def_pickle(PickleDetachedSource());
7279

73-
py::class_<AttachedSource, boost::noncopyable>("Source", py::no_init)
80+
py::class_<AttachedSource, boost::noncopyable>("Source", "Source managed by the sourcextractor++ runtime",
81+
py::no_init)
7482
.def("__getattr__", &AttachedSource::attribute)
75-
.def("detach", &AttachedSource::detach);
83+
.def("detach", &AttachedSource::detach,
84+
"Generate a `DetachedSource` containing its *current* computed properties");
7685
py::register_ptr_to_python<std::shared_ptr<AttachedSource>>();
7786

78-
py::class_<OwnedSource, py::bases<AttachedSource>, boost::noncopyable>("OwnedSource", py::no_init)
87+
py::class_<OwnedSource, py::bases<AttachedSource>, boost::noncopyable>(
88+
"OwnedSource", "Source managed by the sourcextractor++ runtime but owned by the callee", py::no_init)
7989
.def("__repr__", &OwnedSource::repr);
8090
py::register_ptr_to_python<std::shared_ptr<OwnedSource>>();
8191

82-
py::class_<EntangledSource, py::bases<AttachedSource>, boost::noncopyable>("EntangledSource", py::no_init)
92+
py::class_<EntangledSource, py::bases<AttachedSource>, boost::noncopyable>(
93+
"EntangledSource",
94+
"Source managed by the sourcextractor++ runtime and tied to a Group. Their content is *undefined except when "
95+
"iterating* a group",
96+
py::no_init)
8397
.def("__repr__", &EntangledSource::repr);
8498

8599
py::register_ptr_to_python<std::shared_ptr<EntangledSource>>();
86100

87101
py::class_<SourceGroup::Iterator>("GroupIterator", py::no_init).def("__next__", &SourceGroup::Iterator::next);
88102

89-
py::class_<SourceGroup, boost::noncopyable>("Group", py::no_init)
103+
py::class_<SourceGroup, boost::noncopyable>(
104+
"Group", "Source group, managed by the sourcextractor++ runtime. Iterable.", py::no_init)
90105
.def("__repr__", &SourceGroup::repr)
91106
.def("__getattr__", &SourceGroup::attribute)
92107
.def("__len__", &SourceGroup::size)
93108
.def("__iter__", &SourceGroup::iter);
94109
py::register_ptr_to_python<std::shared_ptr<SourceGroup>>();
95110

96-
py::class_<ProcessSourcesEvent>("ProcessSourcesEvent", py::no_init).def("__repr__", &ProcessSourcesEvent::repr);
111+
py::class_<ProcessSourcesEvent>(
112+
"ProcessSourcesEvent",
113+
"Signals processing events, as line flushes (i.e., for grouping when `segmentation-lutz-window-size` is enabled)",
114+
py::no_init)
115+
.def("__repr__", &ProcessSourcesEvent::repr);
97116

98117
py::class_<SourceReceiverIfce, boost::noncopyable>("SourceReceiver", py::no_init);
99118
py::class_<GroupReceiverIfce, boost::noncopyable>("GroupReceiverIfce", py::no_init);
100119

101-
py::class_<Segmentation>("Segmentation", py::init<std::shared_ptr<Context>>((py::arg("context") = None)))
120+
py::class_<Segmentation>("Segmentation", "First stage of the pipeline",
121+
py::init<std::shared_ptr<Context>>((py::arg("context") = None)))
102122
.def("__repr__", &Segmentation::repr)
103123
.def("set_next_stage", &Segmentation::setNextStage)
104124
.def("__call__", &Segmentation::call);
@@ -128,16 +148,18 @@ BOOST_PYTHON_MODULE(_SEPythonModule) {
128148
.def("__call__", &Measurement::call);
129149

130150
py::class_<NumpyOutput, py::bases<GroupReceiverIfce>, boost::noncopyable>(
131-
"NumpyOutput", py::init<std::shared_ptr<Context>>((py::arg("Context") = None)))
151+
"NumpyOutput", "Generate a numpy structured array with the computed properties",
152+
py::init<std::shared_ptr<Context>>((py::arg("Context") = None)))
132153
.def("__repr__", &NumpyOutput::repr)
133154
.def("__call__", &NumpyOutput::call)
134-
.def("get", &NumpyOutput::getTable);
155+
.def("get", &NumpyOutput::getTable, "Wait for the end of processing and return a numpy structured array");
135156

136157
py::class_<FitsOutput, py::bases<GroupReceiverIfce>, boost::noncopyable>(
137-
"FitsOutput", py::init<std::shared_ptr<Context>>((py::arg("Context") = None)))
158+
"FitsOutput", "Generate a FITS catalog with the computed properties",
159+
py::init<std::shared_ptr<Context>>((py::arg("Context") = None)))
138160
.def("__repr__", &FitsOutput::repr)
139161
.def("__call__", &FitsOutput::call)
140-
.def("get", &FitsOutput::get);
162+
.def("get", &FitsOutput::get, "Wait for the end of processing. Always returns None.");
141163

142164
#if PY_MAJOR_VERSION >= 3
143165
PyObject* pyston = PyInit_pyston();

0 commit comments

Comments
 (0)