Skip to content

Commit 431b612

Browse files
committed
Added documentation
1 parent b004745 commit 431b612

File tree

4 files changed

+459
-146
lines changed

4 files changed

+459
-146
lines changed
Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
11
entities.entity module
22
=======================
33

4-
.. automodule:: entities._base
4+
.. autoclass:: _entities._entity.BaseEntity
55
:members:
66
:undoc-members:
77
:show-inheritance:
8+
9+
.. automodule:: entities._base
10+
:members:
11+
:undoc-members:
12+
:show-inheritance:

addons/source-python/packages/source-python/entities/_base.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,9 @@ def set_color(self, color):
298298
# Set the "color" property for Entity
299299
color = property(
300300
get_color, set_color,
301-
doc="""Property to get/set the entity's color values.""")
301+
doc="""Property to get/set the entity's color values.
302+
303+
.. seealso:: :meth:`get_color` and :meth:`set_color`""")
302304

303305
def get_model(self):
304306
"""Return the entity's model.
@@ -318,7 +320,9 @@ def set_model(self, model):
318320

319321
model = property(
320322
get_model, set_model,
321-
doc="""Property to get/set the entity's model.""")
323+
doc="""Property to get/set the entity's model.
324+
325+
.. seealso:: :meth:`get_model` and :meth:`set_model`""")
322326

323327
def get_parent(self):
324328
"""Return the entity's parent.
@@ -350,7 +354,9 @@ def _set_parent(self, parent):
350354

351355
parent = property(
352356
get_parent, _set_parent,
353-
doc="""Property to get/set the parent of the entity.""")
357+
doc="""Property to get/set the parent of the entity.
358+
359+
.. seealso:: :meth:`get_parent` and :meth:`set_parent`""")
354360

355361
@property
356362
def model_header(self):

src/core/modules/entities/entities_datamaps_wrap.cpp

Lines changed: 181 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -86,10 +86,23 @@ void export_datamap(scope _datamaps)
8686
class_<datamap_t, datamap_t *> DataMap("DataMap", no_init);
8787

8888
// Properties...
89-
DataMap.def_readonly("description", &datamap_t::dataDesc);
90-
DataMap.def_readonly("length", &datamap_t::dataNumFields);
91-
DataMap.def_readonly("class_name", &datamap_t::dataClassName);
92-
DataMap.def_readonly("base", &datamap_t::baseMap);
89+
DataMap.def_readonly(
90+
"length",
91+
&datamap_t::dataNumFields,
92+
"Return the number of type descriptions hold by this data map.\n\n"
93+
":rtype: int");
94+
95+
DataMap.def_readonly(
96+
"class_name",
97+
&datamap_t::dataClassName,
98+
"Return the name of the class described by this data map.\n\n"
99+
":rtype: str");
100+
101+
DataMap.def_readonly(
102+
"base",
103+
&datamap_t::baseMap,
104+
"Return the next data map in the class hierarchy.\n\n"
105+
":rtype: DataMap");
93106

94107
// CS:GO properties...
95108
DataMap.NOT_IMPLEMENTED_ATTR("optimized_datamap");
@@ -99,19 +112,31 @@ void export_datamap(scope _datamaps)
99112
DataMap.NOT_IMPLEMENTED_ATTR("packed_offsets_computed");
100113

101114
// Special methods...
102-
DataMap.def("__len__", make_getter(&datamap_t::dataNumFields));
103-
DataMap.def("__getitem__", &DataMapSharedExt::__getitem__, reference_existing_object_policy());
115+
DataMap.def(
116+
"__len__",
117+
make_getter(&datamap_t::dataNumFields),
118+
"Return the number of type descriptions hold by this data map.\n\n"
119+
"rtype: int");
120+
121+
DataMap.def(
122+
"__getitem__",
123+
&DataMapSharedExt::__getitem__,
124+
reference_existing_object_policy(),
125+
"Return the type description at the given index.\n\n"
126+
":rtype: TypeDescription");
104127

105128
// Helper methods...
106129
DataMap.def("find",
107130
&DataMapSharedExt::find,
108-
reference_existing_object_policy()
109-
);
131+
reference_existing_object_policy(),
132+
"Find a type description based on its field name or external name.\n\n"
133+
":rtype: TypeDescription");
110134

111135
DataMap.def("find_offset",
112136
&DataMapSharedExt::find_offset,
113137
args("name"),
114-
"Return the offset of a named property. Return -1 if the property wasn't found."
138+
"Return the offset of a type description by searching for its name. Return -1 if the property wasn't found.\n\n"
139+
":rtype: int"
115140
);
116141

117142
// Engine specific stuff...
@@ -132,16 +157,52 @@ void export_type_description(scope _datamaps)
132157
class_<typedescription_t, typedescription_t *> TypeDescription("TypeDescription", no_init);
133158

134159
// Properties...
135-
TypeDescription.add_property("offset", &TypeDescriptionExt::get_offset);
136-
TypeDescription.def_readonly("type", &typedescription_t::fieldType);
137-
TypeDescription.def_readonly("name", &typedescription_t::fieldName);
138-
TypeDescription.def_readonly("size", &typedescription_t::fieldSize);
139-
TypeDescription.def_readonly("flags", &typedescription_t::flags);
140-
TypeDescription.def_readonly("external_name", &typedescription_t::externalName);
141-
TypeDescription.add_property("input_function", &TypeDescriptionSharedExt::get_input_function);
142-
TypeDescription.add_property("function",
143-
make_function(&TypeDescriptionSharedExt::get_function, return_by_value_policy())
144-
);
160+
TypeDescription.add_property(
161+
"offset",
162+
&TypeDescriptionExt::get_offset,
163+
"Return the offset of the field.\n\n"
164+
":rtype: int");
165+
166+
TypeDescription.def_readonly(
167+
"type",
168+
&typedescription_t::fieldType,
169+
"Return the type of the field.\n\n"
170+
":rtype: FieldType");
171+
172+
TypeDescription.def_readonly(
173+
"name",
174+
&typedescription_t::fieldName,
175+
"Return the name of the field.\n\n"
176+
":rtype: str");
177+
178+
TypeDescription.def_readonly(
179+
"size",
180+
&typedescription_t::fieldSize,
181+
"Return the size of the field.\n\n"
182+
":rtype: int");
183+
184+
TypeDescription.def_readonly(
185+
"flags",
186+
&typedescription_t::flags,
187+
"Return the flags of the field.\n\n"
188+
":rtype: int");
189+
190+
TypeDescription.def_readonly(
191+
"external_name",
192+
&typedescription_t::externalName,
193+
"Return the external name of the field.\n\n"
194+
":rtype: str");
195+
196+
TypeDescription.add_property(
197+
"input_function",
198+
&TypeDescriptionSharedExt::get_input_function,
199+
"Return a callable function if the field is an input function.");
200+
201+
TypeDescription.add_property(
202+
"function",
203+
make_function(&TypeDescriptionSharedExt::get_function, return_by_value_policy()),
204+
"Return the input function as a pointer.\n\n"
205+
":rtype: Pointer");
145206

146207
// CS:GO properties...
147208
TypeDescription.NOT_IMPLEMENTED_ATTR("flat_offset");
@@ -175,11 +236,29 @@ void export_input_data(scope _datamaps)
175236
InputData.def("__init__", make_constructor(&InputDataExt::__init__));
176237

177238
// Properties...
178-
InputData.def_readwrite("activator", &inputdata_t::pActivator);
179-
InputData.def_readwrite("caller", &inputdata_t::pCaller);
180-
181-
InputData.def_readwrite("value", &inputdata_t::value);
182-
InputData.def_readwrite("output_index", &inputdata_t::nOutputID);
239+
InputData.def_readwrite(
240+
"activator",
241+
&inputdata_t::pActivator,
242+
"Return the activator.\n\n"
243+
":rtype: BaseEntity");
244+
245+
InputData.def_readwrite(
246+
"caller",
247+
&inputdata_t::pCaller,
248+
"Return the caller.\n\n"
249+
":rtype: BaseEntity");
250+
251+
InputData.def_readwrite(
252+
"value",
253+
&inputdata_t::value,
254+
"Return the value.\n\n"
255+
":rtype: Variant");
256+
257+
InputData.def_readwrite(
258+
"output_index",
259+
&inputdata_t::nOutputID,
260+
"Return the output index.\n\n"
261+
":rtype: int");
183262

184263
// Add memory tools...
185264
InputData ADD_MEM_TOOLS(inputdata_t);
@@ -194,30 +273,91 @@ void export_variant(scope _datamaps)
194273
class_<variant_t, variant_t *> Variant("Variant");
195274

196275
// Properties...
197-
Variant.add_property("type", &variant_t::FieldType);
276+
Variant.add_property(
277+
"type",
278+
&variant_t::FieldType,
279+
"Return the type of the value.\n\n"
280+
":rtype: FieldType");
198281

199282
// Getters...
200-
Variant.def("get_bool", &variant_t::Bool);
201-
Variant.def("get_string", &VariantExt::get_string);
202-
Variant.def("get_int", &variant_t::Int);
203-
Variant.def("get_float", &variant_t::Float);
283+
Variant.def(
284+
"get_bool",
285+
&variant_t::Bool,
286+
"Return the value as a boolean.\n\n"
287+
":rtype: bool");
288+
289+
Variant.def(
290+
"get_string",
291+
&VariantExt::get_string,
292+
"Return the value as a string.\n\n"
293+
":rtype: str");
294+
295+
Variant.def(
296+
"get_int",
297+
&variant_t::Int,
298+
"Return the value as an integer.\n\n"
299+
":rtype: int");
300+
301+
Variant.def(
302+
"get_float",
303+
&variant_t::Float,
304+
"Return the value as a floating value.\n\n"
305+
":rtype: float");
204306

205307
Variant.def("get_color",
206308
&VariantExt::get_color,
207-
manage_new_object_policy()
208-
);
209-
210-
Variant.def("get_vector", &VariantExt::get_vector);
211-
Variant.def("get_entity", &variant_t::Entity, reference_existing_object_policy());
309+
manage_new_object_policy(),
310+
"Return the value as a color.\n\n"
311+
":rtype: Color");
312+
313+
Variant.def(
314+
"get_vector",
315+
&VariantExt::get_vector,
316+
"Return the value as a vector.\n\n"
317+
":rtype: Value");
318+
319+
Variant.def(
320+
"get_entity",
321+
&variant_t::Entity,
322+
reference_existing_object_policy(),
323+
"Return the value as a handle.\n\n"
324+
":rtype: BaseHandle");
212325

213326
// Setters...
214-
Variant.def("set_bool", &variant_t::SetBool);
215-
Variant.def("set_string", &VariantExt::set_string);
216-
Variant.def("set_int", &variant_t::SetInt);
217-
Variant.def("set_float", &variant_t::SetFloat);
218-
Variant.def("set_color", &VariantExt::set_color);
219-
Variant.def("set_vector", &variant_t::SetVector3D);
220-
Variant.def("set_entity", &variant_t::SetEntity);
327+
Variant.def(
328+
"set_bool",
329+
&variant_t::SetBool,
330+
"Set the value as a boolean.");
331+
332+
Variant.def(
333+
"set_string",
334+
&VariantExt::set_string,
335+
"Set the value as a string.");
336+
337+
Variant.def(
338+
"set_int",
339+
&variant_t::SetInt,
340+
"Set the value as an integer.");
341+
342+
Variant.def(
343+
"set_float",
344+
&variant_t::SetFloat,
345+
"Set the value as a floating value.");
346+
347+
Variant.def(
348+
"set_color",
349+
&VariantExt::set_color,
350+
"Set the value as a color.");
351+
352+
Variant.def(
353+
"set_vector",
354+
&variant_t::SetVector3D,
355+
"Set the value as a Vector.");
356+
357+
Variant.def(
358+
"set_entity",
359+
&variant_t::SetEntity,
360+
"Set the value as an entity.");
221361

222362
// Add memory tools...
223363
Variant ADD_MEM_TOOLS(variant_t);

0 commit comments

Comments
 (0)