Skip to content

Commit b43b67a

Browse files
committed
Added more documentation
1 parent e6f8ded commit b43b67a

3 files changed

Lines changed: 64 additions & 31 deletions

File tree

‎addons/source-python/docs/source-python/source/developing/modules/cvars.rst‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,12 @@ Module contents
1818
:members:
1919
:undoc-members:
2020
:show-inheritance:
21+
22+
.. autoclass:: cvars._Cvar
23+
:members:
24+
:undoc-members:
25+
:show-inheritance:
26+
27+
.. data:: cvar
28+
29+
The singleton instance for :class:`cvars._Cvar`.

‎addons/source-python/packages/source-python/cvars/__init__.py‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
# Source.Python Imports
99
# Cvars
1010
from _cvars import ConVar
11+
from _cvars import _Cvar
1112
from cvars.flags import ConVarFlags
1213

1314

‎src/core/modules/cvars/cvars_wrap.cpp‎

Lines changed: 54 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -74,49 +74,59 @@ void export_cvar_interface(scope _cvars)
7474
class_<ICvar, boost::noncopyable>("_Cvar", no_init)
7575
.def("register_base",
7676
&ICvar::RegisterConCommand,
77-
"Registers a console command.",
78-
args("con_command")
77+
"Register a console command.",
78+
arg("con_command")
7979
)
8080

8181
.def("unregister_base",
8282
&ICvar::UnregisterConCommand,
83-
"Unregisters a console command.",
84-
args("con_command")
83+
"Unregister a console command.",
84+
arg("con_command")
8585
)
8686

8787
.def("find_base",
8888
GET_METHOD(ConCommandBase *, ICvar, FindCommandBase, const char *),
89-
"Returns a ConCommandBase instance for the given command or variable, if it exists.",
90-
args("name"),
89+
"Find the ConCommandBase instance of a server command or console variable.\n\n"
90+
":return: Return ``None`` if the command or variable was not found.\n"
91+
":rtype: ConCommandBase",
92+
arg("name"),
9193
reference_existing_object_policy()
9294
)
9395

9496
.def("find_command",
9597
GET_METHOD(ConCommand*, ICvar, FindCommand, const char *),
96-
"Returns a ConCommand instance for the given command, if it exists.",
97-
args("name"),
98+
"Find the ConCommand instance of a server command.\n\n"
99+
":return: Return ``None`` if the command was not found.\n"
100+
":rtype: ConCommand",
101+
arg("name"),
98102
reference_existing_object_policy()
99103
)
100104

101105
.def("find_var",
102106
GET_METHOD(ConVar*, ICvar, FindVar, const char *),
103-
"Returns a ConVar instance for the given variable, if it exists.",
104-
args("name"),
107+
"Find the ConVar instance of console variable.\n\n"
108+
":return: Return ``None`` if the console variable was not found.\n"
109+
":rtype: ConVar",
110+
arg("name"),
105111
reference_existing_object_policy()
106112
)
107113

108114
.def("call_global_change_callbacks",
109115
&ICvar::CallGlobalChangeCallbacks,
110-
"Calls global change callbacks.",
111-
args("cvar", "old_string", "old_float")
116+
"Call all global change callbacks.\n\n"
117+
":param ConVar cvar: The console variable that has changed.\n"
118+
":param str old_string: The old value of the variable as a string.\n"
119+
":param float old_value: The old value of the variable as a float.",
120+
(arg("cvar"), arg("old_string"), arg("old_float"))
112121
)
113122

114123
.add_property("commands",
115124
make_function(
116125
ICVarExt::GetCommands,
117126
reference_existing_object_policy()
118127
),
119-
"Get first ConCommandBase to allow iteration."
128+
"Return the first ConCommandBase instance that can be used to iterate through all ConCommandBase instances\n\n."
129+
":rtype: ConCommandBase"
120130
)
121131

122132
ADD_MEM_TOOLS(ICvar)
@@ -217,89 +227,102 @@ void export_convar(scope _cvars)
217227

218228
.def("get_float",
219229
&ConVar::GetFloat,
220-
"Returns the value as a float."
230+
"Return the value as a float.\n\n"
231+
":rtype: float"
221232
)
222233

223234
.def("get_int",
224235
&ConVar::GetInt,
225-
"Returns the value as an int."
236+
"Return the value as an int.\n\n"
237+
":rtype: int"
226238
)
227239

228240
.def("get_bool",
229241
&ConVar::GetBool,
230-
"Returns the value as a bool."
242+
"Return the value as a bool.\n\n"
243+
":rtype: bool"
231244
)
232245

233246
.def("get_string",
234247
&ConVar::GetString,
235-
"Returns the value as a string."
248+
"Return the value as a string.\n\n"
249+
":rtype: str"
236250
)
237251

238252
.def("revert",
239253
&ConVar::Revert,
240-
"Resets to default value."
254+
"Reset the console variable to its default value."
241255
)
242256

243257
.add_property("default",
244258
&ConVar::GetDefault,
245-
"Returns the default value."
259+
"Return the default value.\n\n"
260+
":rtype: str"
246261
)
247262

248263
.def("has_min",
249264
&ConVarExt::HasMin,
250-
"Returns wether the ConVar has a minimum value."
265+
"Return wether the ConVar has a minimum value.\n\n"
266+
":rtype: bool"
251267
)
252268

253269
.def("has_max",
254270
&ConVarExt::HasMax,
255-
"Returns wether the ConVar has a maximum value."
271+
"Returns wether the ConVar has a maximum value.\n\n"
272+
":rtype: bool"
256273
)
257274

258275
.add_property("min",
259276
&ConVarExt::GetMin,
260-
"Returns the minimum value."
277+
"Return the minimum value.\n\n"
278+
":rtype: float"
261279
)
262280

263281
.add_property("max",
264282
&ConVarExt::GetMax,
265-
"Returns the maximum value."
283+
"Return the maximum value.\n\n"
284+
":rtype: float"
266285
)
267286

268287
.def("set_bool",
269288
&ConVarExt::SetValue,
270-
"Sets a bool value.",
271-
args("value")
289+
"Set the console variable to a boolean value.",
290+
arg("value")
272291
)
273292

274293
.def("make_public",
275294
&ConVarExt::MakePublic,
276-
"Set the notify flag and makes the cvar public."
295+
"Set the notify flag and make the console variable public."
277296
)
278297

279298
.def("remove_public",
280299
&ConVarExt::RemovePublic,
281-
"Remove the notify flag and makes the cvar no longer public."
300+
"Remove the notify flag and make the console variable no longer public."
282301
)
283302

284303
// Special methods...
285304
.def("__float__",
286305
&ConVar::GetFloat,
287-
"Returns the value as a float."
306+
"Return the value as a float.\n\n"
307+
":rtype: float"
288308
)
289309

290310
.def("__int__",
291311
&ConVar::GetInt,
292-
"Returns the value as an int."
312+
"Return the value as an int.\n\n"
313+
":rtype: int"
293314
)
294315

295316
.def("__bool__",
296317
&ConVar::GetBool,
297-
"Returns the value as a bool."
318+
"Return the value as a bool.\n\n"
319+
":rtype: bool"
298320
)
299321

300322
.def("__str__",
301323
&ConVar::GetString,
302-
"Returns the value as a string."
324+
"Return the value as a string.\n\n"
325+
":rtype: str"
303326
)
304327

305328
ADD_MEM_TOOLS(ConVar)

0 commit comments

Comments
 (0)