Add docstrings to socket module
This commit is contained in:
parent
c905809197
commit
6746ccf001
@ -373,17 +373,48 @@ KrkValue krk_module_onload_socket(void) {
|
|||||||
|
|
||||||
KrkClass * socket = krk_makeClass(module, &SocketClass, "socket", vm.baseClasses->objectClass);
|
KrkClass * socket = krk_makeClass(module, &SocketClass, "socket", vm.baseClasses->objectClass);
|
||||||
SocketClass->allocSize = sizeof(struct socket);
|
SocketClass->allocSize = sizeof(struct socket);
|
||||||
BIND_METHOD(socket,__init__);
|
KRK_DOC(BIND_METHOD(socket,__init__),
|
||||||
|
"@brief Create a socket object.\n"
|
||||||
|
"@arguments family=AF_INET,type=SOCK_STREAM,proto=0\n\n"
|
||||||
|
"Creates a new socket object for the given address family and type.");
|
||||||
BIND_METHOD(socket,__repr__);
|
BIND_METHOD(socket,__repr__);
|
||||||
BIND_METHOD(socket,bind);
|
KRK_DOC(BIND_METHOD(socket,bind),
|
||||||
BIND_METHOD(socket,listen);
|
"@brief Bind a socket to an address.\n"
|
||||||
BIND_METHOD(socket,accept);
|
"@arguments address\n\n"
|
||||||
BIND_METHOD(socket,connect);
|
"The format of @p address varies by address family. For @c AF_INET, @p address should be a "
|
||||||
BIND_METHOD(socket,shutdown);
|
"two-tuple of a string domain name and integer port number.");
|
||||||
BIND_METHOD(socket,recv);
|
KRK_DOC(BIND_METHOD(socket,listen),
|
||||||
BIND_METHOD(socket,send);
|
"@brief Set a bound socket to listen.\n"
|
||||||
BIND_METHOD(socket,fileno);
|
"@arguments backlog=0\n\n"
|
||||||
BIND_METHOD(socket,setsockopt);
|
"Begin listening on a bound socket, keeping @p backlog connections in a queue.");
|
||||||
|
KRK_DOC(BIND_METHOD(socket,accept),
|
||||||
|
"@brief Accept a connection on a listening socket.\n\n"
|
||||||
|
"Accepts one connection and returns a two-tuple with a new socket object and "
|
||||||
|
"the address of the remote host.");
|
||||||
|
KRK_DOC(BIND_METHOD(socket,connect),
|
||||||
|
"@brief Connect a socket to a remote endpoint.\n"
|
||||||
|
"@arguments address\n\n"
|
||||||
|
"As with @ref socket_bind, the format of @p address varies.");
|
||||||
|
KRK_DOC(BIND_METHOD(socket,shutdown),
|
||||||
|
"@brief Shut down an active socket.\n"
|
||||||
|
"@arguments how\n\n"
|
||||||
|
"Gracefully closes an open socket.");
|
||||||
|
KRK_DOC(BIND_METHOD(socket,recv),
|
||||||
|
"@brief Receive data from a connected socket.\n"
|
||||||
|
"@arguments bufsize,[flags]\n\n"
|
||||||
|
"Receive up to @p bufsize bytes of data, which is returned as a @ref bytes object.");
|
||||||
|
KRK_DOC(BIND_METHOD(socket,send),
|
||||||
|
"@brief Send data to a connected socket.\n"
|
||||||
|
"@arguments buf,[flags]\n\n"
|
||||||
|
"Send the data in the @ref bytes object @p buf to the socket. Returns the number "
|
||||||
|
"of bytes written to the socket.");
|
||||||
|
KRK_DOC(BIND_METHOD(socket,fileno),
|
||||||
|
"@brief Get the file descriptor number for the underlying socket.");
|
||||||
|
KRK_DOC(BIND_METHOD(socket,setsockopt),
|
||||||
|
"@brief Set socket options.\n"
|
||||||
|
"@arguments level,optname,value\n\n"
|
||||||
|
"@p level and @p optname should be integer values defined by @c SOL and @c SO options. "
|
||||||
|
"@p value must be either an @ref int or a @ref bytes object.");
|
||||||
krk_defineNative(&socket->methods,".__str__", FUNC_NAME(socket,__repr__));
|
krk_defineNative(&socket->methods,".__str__", FUNC_NAME(socket,__repr__));
|
||||||
krk_finalizeClass(SocketClass);
|
krk_finalizeClass(SocketClass);
|
||||||
|
|
||||||
|
@ -69,6 +69,7 @@ let modules = [
|
|||||||
'dis',
|
'dis',
|
||||||
'fileio',
|
'fileio',
|
||||||
'time',
|
'time',
|
||||||
|
'socket',
|
||||||
|
|
||||||
# Stuff from modules/
|
# Stuff from modules/
|
||||||
'json',
|
'json',
|
||||||
|
Loading…
Reference in New Issue
Block a user