More modules API ref formatting fixes (#8344)

Fix broken formatting in `RM_Call` and `RM_CreateDataType`,
`RM_SubscribeToServerEvent` (nested lists, etc. in list items).

Unhide docs of `RM_LoadDataTypeFromString` and
`RM_SaveDataTypeToString` by removing blank line between docs and
function.

Clarification added to `RM__Assert`: Recommentation to use the
`RedisModule_Assert` macro instead.

All names containing underscores (variable and macro names) are
wrapped in backticks (if not already wrapped in backticks). This
prevents underscore from being interpreted as italics in some
cases.

Names including a wildcard star, e.g. RM_Defrag*(), is wrapped in
backticks (and RM replaced by RedisModule in this case). This
prevents the * from being interpreted as an italics marker.

A list item with a sublist, a paragraph and another sublist is a
combination which seems impossible to achieve with RedCarped
markdown, so the one occurrence of this is rewritten.

Various trivial changes (typos, backticks, etc.).

Ruby script:

* Replace `RM_Xyz` with `RedisModule_Xyz` in docs. (RM is correct
  when refering to the C code but RedisModule is correct in the
  API docs.)
* Automatic backquotes around C functions like `malloc()`.
* Turn URLs into links. The link text is the URL itself.
* Don't add backticks inside bold (**...**)
This commit is contained in:
Viktor Söderqvist 2021-01-20 10:47:06 +01:00 committed by GitHub
parent 6401920d70
commit 16258f21d1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 183 additions and 176 deletions

View File

@ -478,8 +478,8 @@ void *RM_PoolAlloc(RedisModuleCtx *ctx, size_t bytes) {
* Helpers for modules API implementation * Helpers for modules API implementation
* -------------------------------------------------------------------------- */ * -------------------------------------------------------------------------- */
/* Create an empty key of the specified type. 'kp' must point to a key object /* Create an empty key of the specified type. `key` must point to a key object
* opened for writing where the .value member is set to NULL because the * opened for writing where the `.value` member is set to NULL because the
* key was found to be non existing. * key was found to be non existing.
* *
* On success REDISMODULE_OK is returned and the key is populated with * On success REDISMODULE_OK is returned and the key is populated with
@ -1322,7 +1322,7 @@ int RM_StringAppendBuffer(RedisModuleCtx *ctx, RedisModuleString *str, const cha
* -------------------------------------------------------------------------- */ * -------------------------------------------------------------------------- */
/* Send an error about the number of arguments given to the command, /* Send an error about the number of arguments given to the command,
* citing the command name in the error message. * citing the command name in the error message. Returns REDISMODULE_OK.
* *
* Example: * Example:
* *
@ -1394,7 +1394,7 @@ int RM_ReplyWithError(RedisModuleCtx *ctx, const char *err) {
return REDISMODULE_OK; return REDISMODULE_OK;
} }
/* Reply with a simple string (+... \r\n in RESP protocol). This replies /* Reply with a simple string (`+... \r\n` in RESP protocol). This replies
* are suitable only when sending a small non-binary string with small * are suitable only when sending a small non-binary string with small
* overhead, like "OK" or similar replies. * overhead, like "OK" or similar replies.
* *
@ -3348,20 +3348,19 @@ fmterr:
* *
* * **cmdname**: The Redis command to call. * * **cmdname**: The Redis command to call.
* * **fmt**: A format specifier string for the command's arguments. Each * * **fmt**: A format specifier string for the command's arguments. Each
* of the arguments should be specified by a valid type specification: * of the arguments should be specified by a valid type specification. The
* format specifier can also contain the modifiers `!`, `A` and `R` which
* don't have a corresponding argument.
* *
* * b: The argument is a buffer and is immediately followed by another * * `b` -- The argument is a buffer and is immediately followed by another
* argument that is the buffer's length. * argument that is the buffer's length.
* * c: The argument is a pointer to a plain C string (null-terminated). * * `c` -- The argument is a pointer to a plain C string (null-terminated).
* * l: The argument is long long integer. * * `l` -- The argument is long long integer.
* * s: The argument is a RedisModuleString. * * `s` -- The argument is a RedisModuleString.
* * v: The argument(s) is a vector of RedisModuleString. * * `v` -- The argument(s) is a vector of RedisModuleString.
* * * `!` -- Sends the Redis command and its arguments to replicas and AOF.
* The format specifier can also include modifiers: * * `A` -- Suppress AOF propagation, send only to replicas (requires `!`).
* * * `R` -- Suppress replicas propagation, send only to AOF (requires `!`).
* * !: Sends the Redis command and its arguments to replicas and AOF.
* * A: Suppress AOF propagation, send only to replicas (requires `!`).
* * R: Suppress replicas propagation, send only to AOF (requires `!`).
* * **...**: The actual arguments to the Redis command. * * **...**: The actual arguments to the Redis command.
* *
* On success a RedisModuleCallReply object is returned, otherwise * On success a RedisModuleCallReply object is returned, otherwise
@ -3685,27 +3684,28 @@ robj *moduleTypeDupOrReply(client *c, robj *fromkey, robj *tokey, robj *value) {
* still load old data produced by an older version if the rdb_load * still load old data produced by an older version if the rdb_load
* callback is able to check the encver value and act accordingly. * callback is able to check the encver value and act accordingly.
* The encver must be a positive value between 0 and 1023. * The encver must be a positive value between 0 and 1023.
*
* * **typemethods_ptr** is a pointer to a RedisModuleTypeMethods structure * * **typemethods_ptr** is a pointer to a RedisModuleTypeMethods structure
* that should be populated with the methods callbacks and structure * that should be populated with the methods callbacks and structure
* version, like in the following example: * version, like in the following example:
* *
* RedisModuleTypeMethods tm = { * RedisModuleTypeMethods tm = {
* .version = REDISMODULE_TYPE_METHOD_VERSION, * .version = REDISMODULE_TYPE_METHOD_VERSION,
* .rdb_load = myType_RDBLoadCallBack, * .rdb_load = myType_RDBLoadCallBack,
* .rdb_save = myType_RDBSaveCallBack, * .rdb_save = myType_RDBSaveCallBack,
* .aof_rewrite = myType_AOFRewriteCallBack, * .aof_rewrite = myType_AOFRewriteCallBack,
* .free = myType_FreeCallBack, * .free = myType_FreeCallBack,
* *
* // Optional fields * // Optional fields
* .digest = myType_DigestCallBack, * .digest = myType_DigestCallBack,
* .mem_usage = myType_MemUsageCallBack, * .mem_usage = myType_MemUsageCallBack,
* .aux_load = myType_AuxRDBLoadCallBack, * .aux_load = myType_AuxRDBLoadCallBack,
* .aux_save = myType_AuxRDBSaveCallBack, * .aux_save = myType_AuxRDBSaveCallBack,
* .free_effort = myType_FreeEffortCallBack, * .free_effort = myType_FreeEffortCallBack,
* .unlink = myType_UnlinkCallBack, * .unlink = myType_UnlinkCallBack,
* .copy = myType_CopyCallback, * .copy = myType_CopyCallback,
* .defrag = myType_DefragCallback * .defrag = myType_DefragCallback
* } * }
* *
* * **rdb_load**: A callback function pointer that loads data from RDB files. * * **rdb_load**: A callback function pointer that loads data from RDB files.
* * **rdb_save**: A callback function pointer that saves data to RDB files. * * **rdb_save**: A callback function pointer that saves data to RDB files.
@ -3743,7 +3743,7 @@ robj *moduleTypeDupOrReply(client *c, robj *fromkey, robj *tokey, robj *value) {
* a time limit and provides cursor support is used only for keys that are determined * a time limit and provides cursor support is used only for keys that are determined
* to have significant internal complexity. To determine this, the defrag mechanism * to have significant internal complexity. To determine this, the defrag mechanism
* uses the free_effort callback and the 'active-defrag-max-scan-fields' config directive. * uses the free_effort callback and the 'active-defrag-max-scan-fields' config directive.
* NOTE: The value is passed as a void** and the function is expected to update the * NOTE: The value is passed as a `void**` and the function is expected to update the
* pointer if the top-level value pointer is defragmented and consequentially changes. * pointer if the top-level value pointer is defragmented and consequentially changes.
* *
* Note: the module name "AAAAAAAAA" is reserved and produces an error, it * Note: the module name "AAAAAAAAA" is reserved and produces an error, it
@ -3903,7 +3903,7 @@ int moduleAllDatatypesHandleErrors() {
} }
/* Returns true if any previous IO API failed. /* Returns true if any previous IO API failed.
* for Load* APIs the REDISMODULE_OPTIONS_HANDLE_IO_ERRORS flag must be set with * for `Load*` APIs the REDISMODULE_OPTIONS_HANDLE_IO_ERRORS flag must be set with
* RedisModule_SetModuleOptions first. */ * RedisModule_SetModuleOptions first. */
int RM_IsIOError(RedisModuleIO *io) { int RM_IsIOError(RedisModuleIO *io) {
return io->error; return io->error;
@ -3929,7 +3929,7 @@ saveerr:
} }
/* Load an unsigned 64 bit value from the RDB file. This function should only /* Load an unsigned 64 bit value from the RDB file. This function should only
* be called in the context of the rdb_load method of modules implementing * be called in the context of the `rdb_load` method of modules implementing
* new data types. */ * new data types. */
uint64_t RM_LoadUnsigned(RedisModuleIO *io) { uint64_t RM_LoadUnsigned(RedisModuleIO *io) {
if (io->error) return 0; if (io->error) return 0;
@ -4245,7 +4245,6 @@ void RM_DigestEndSequence(RedisModuleDigest *md) {
* If this is NOT done, Redis will handle corrupted (or just truncated) serialized * If this is NOT done, Redis will handle corrupted (or just truncated) serialized
* data by producing an error message and terminating the process. * data by producing an error message and terminating the process.
*/ */
void *RM_LoadDataTypeFromString(const RedisModuleString *str, const moduleType *mt) { void *RM_LoadDataTypeFromString(const RedisModuleString *str, const moduleType *mt) {
rio payload; rio payload;
RedisModuleIO io; RedisModuleIO io;
@ -4273,7 +4272,6 @@ void *RM_LoadDataTypeFromString(const RedisModuleString *str, const moduleType *
* implement in order to allow a module to arbitrarily serialize/de-serialize * implement in order to allow a module to arbitrarily serialize/de-serialize
* keys, similar to how the Redis 'DUMP' and 'RESTORE' commands are implemented. * keys, similar to how the Redis 'DUMP' and 'RESTORE' commands are implemented.
*/ */
RedisModuleString *RM_SaveDataTypeToString(RedisModuleCtx *ctx, void *data, const moduleType *mt) { RedisModuleString *RM_SaveDataTypeToString(RedisModuleCtx *ctx, void *data, const moduleType *mt) {
rio payload; rio payload;
RedisModuleIO io; RedisModuleIO io;
@ -4371,7 +4369,7 @@ const RedisModuleString *RM_GetKeyNameFromIO(RedisModuleIO *io) {
return io->key; return io->key;
} }
/* Returns a RedisModuleString with the name of the key from RedisModuleKey */ /* Returns a RedisModuleString with the name of the key from RedisModuleKey. */
const RedisModuleString *RM_GetKeyNameFromModuleKey(RedisModuleKey *key) { const RedisModuleString *RM_GetKeyNameFromModuleKey(RedisModuleKey *key) {
return key ? key->key : NULL; return key ? key->key : NULL;
} }
@ -4442,6 +4440,9 @@ void RM_LogIOError(RedisModuleIO *io, const char *levelstr, const char *fmt, ...
} }
/* Redis-like assert function. /* Redis-like assert function.
*
* The macro `RedisModule_Assert(expression)` is recommended, rather than
* calling this function directly.
* *
* A failed assertion will shut down the server and produce logging information * A failed assertion will shut down the server and produce logging information
* that looks identical to information generated by Redis itself. * that looks identical to information generated by Redis itself.
@ -4676,7 +4677,7 @@ RedisModuleBlockedClient *RM_BlockClient(RedisModuleCtx *ctx, RedisModuleCmdFunc
* key, or a client in queue before this one can be served, modifying the key * key, or a client in queue before this one can be served, modifying the key
* as well and making it empty again. So when a client is blocked with * as well and making it empty again. So when a client is blocked with
* RedisModule_BlockClientOnKeys() the reply callback is not called after * RedisModule_BlockClientOnKeys() the reply callback is not called after
* RM_UnblockCLient() is called, but every time a key is signaled as ready: * RM_UnblockClient() is called, but every time a key is signaled as ready:
* if the reply callback can serve the client, it returns REDISMODULE_OK * if the reply callback can serve the client, it returns REDISMODULE_OK
* and the client is unblocked, otherwise it will return REDISMODULE_ERR * and the client is unblocked, otherwise it will return REDISMODULE_ERR
* and we'll try again later. * and we'll try again later.
@ -7189,199 +7190,197 @@ void ModuleForkDoneHandler(int exitcode, int bysignal) {
* *
* * RedisModuleEvent_ReplicationRoleChanged: * * RedisModuleEvent_ReplicationRoleChanged:
* *
* This event is called when the instance switches from master * This event is called when the instance switches from master
* to replica or the other way around, however the event is * to replica or the other way around, however the event is
* also called when the replica remains a replica but starts to * also called when the replica remains a replica but starts to
* replicate with a different master. * replicate with a different master.
* *
* The following sub events are available: * The following sub events are available:
* *
* * REDISMODULE_SUBEVENT_REPLROLECHANGED_NOW_MASTER * * `REDISMODULE_SUBEVENT_REPLROLECHANGED_NOW_MASTER`
* * REDISMODULE_SUBEVENT_REPLROLECHANGED_NOW_REPLICA * * `REDISMODULE_SUBEVENT_REPLROLECHANGED_NOW_REPLICA`
* *
* The 'data' field can be casted by the callback to a * The 'data' field can be casted by the callback to a
* RedisModuleReplicationInfo structure with the following fields: * `RedisModuleReplicationInfo` structure with the following fields:
* *
* int master; // true if master, false if replica * int master; // true if master, false if replica
* char *masterhost; // master instance hostname for NOW_REPLICA * char *masterhost; // master instance hostname for NOW_REPLICA
* int masterport; // master instance port for NOW_REPLICA * int masterport; // master instance port for NOW_REPLICA
* char *replid1; // Main replication ID * char *replid1; // Main replication ID
* char *replid2; // Secondary replication ID * char *replid2; // Secondary replication ID
* uint64_t repl1_offset; // Main replication offset * uint64_t repl1_offset; // Main replication offset
* uint64_t repl2_offset; // Offset of replid2 validity * uint64_t repl2_offset; // Offset of replid2 validity
* *
* * RedisModuleEvent_Persistence * * RedisModuleEvent_Persistence
* *
* This event is called when RDB saving or AOF rewriting starts * This event is called when RDB saving or AOF rewriting starts
* and ends. The following sub events are available: * and ends. The following sub events are available:
* *
* * REDISMODULE_SUBEVENT_PERSISTENCE_RDB_START * * `REDISMODULE_SUBEVENT_PERSISTENCE_RDB_START`
* * REDISMODULE_SUBEVENT_PERSISTENCE_AOF_START * * `REDISMODULE_SUBEVENT_PERSISTENCE_AOF_START`
* * REDISMODULE_SUBEVENT_PERSISTENCE_SYNC_RDB_START * * `REDISMODULE_SUBEVENT_PERSISTENCE_SYNC_RDB_START`
* * REDISMODULE_SUBEVENT_PERSISTENCE_ENDED * * `REDISMODULE_SUBEVENT_PERSISTENCE_ENDED`
* * REDISMODULE_SUBEVENT_PERSISTENCE_FAILED * * `REDISMODULE_SUBEVENT_PERSISTENCE_FAILED`
* *
* The above events are triggered not just when the user calls the * The above events are triggered not just when the user calls the
* relevant commands like BGSAVE, but also when a saving operation * relevant commands like BGSAVE, but also when a saving operation
* or AOF rewriting occurs because of internal server triggers. * or AOF rewriting occurs because of internal server triggers.
* The SYNC_RDB_START sub events are happening in the forground due to * The SYNC_RDB_START sub events are happening in the forground due to
* SAVE command, FLUSHALL, or server shutdown, and the other RDB and * SAVE command, FLUSHALL, or server shutdown, and the other RDB and
* AOF sub events are executed in a background fork child, so any * AOF sub events are executed in a background fork child, so any
* action the module takes can only affect the generated AOF or RDB, * action the module takes can only affect the generated AOF or RDB,
* but will not be reflected in the parent process and affect connected * but will not be reflected in the parent process and affect connected
* clients and commands. Also note that the AOF_START sub event may end * clients and commands. Also note that the AOF_START sub event may end
* up saving RDB content in case of an AOF with rdb-preamble. * up saving RDB content in case of an AOF with rdb-preamble.
* *
* * RedisModuleEvent_FlushDB * * RedisModuleEvent_FlushDB
* *
* The FLUSHALL, FLUSHDB or an internal flush (for instance * The FLUSHALL, FLUSHDB or an internal flush (for instance
* because of replication, after the replica synchronization) * because of replication, after the replica synchronization)
* happened. The following sub events are available: * happened. The following sub events are available:
* *
* * REDISMODULE_SUBEVENT_FLUSHDB_START * * `REDISMODULE_SUBEVENT_FLUSHDB_START`
* * REDISMODULE_SUBEVENT_FLUSHDB_END * * `REDISMODULE_SUBEVENT_FLUSHDB_END`
* *
* The data pointer can be casted to a RedisModuleFlushInfo * The data pointer can be casted to a RedisModuleFlushInfo
* structure with the following fields: * structure with the following fields:
* *
* int32_t async; // True if the flush is done in a thread. * int32_t async; // True if the flush is done in a thread.
* // See for instance FLUSHALL ASYNC. * // See for instance FLUSHALL ASYNC.
* // In this case the END callback is invoked * // In this case the END callback is invoked
* // immediately after the database is put * // immediately after the database is put
* // in the free list of the thread. * // in the free list of the thread.
* int32_t dbnum; // Flushed database number, -1 for all the DBs * int32_t dbnum; // Flushed database number, -1 for all the DBs
* // in the case of the FLUSHALL operation. * // in the case of the FLUSHALL operation.
* *
* The start event is called *before* the operation is initated, thus * The start event is called *before* the operation is initated, thus
* allowing the callback to call DBSIZE or other operation on the * allowing the callback to call DBSIZE or other operation on the
* yet-to-free keyspace. * yet-to-free keyspace.
* *
* * RedisModuleEvent_Loading * * RedisModuleEvent_Loading
* *
* Called on loading operations: at startup when the server is * Called on loading operations: at startup when the server is
* started, but also after a first synchronization when the * started, but also after a first synchronization when the
* replica is loading the RDB file from the master. * replica is loading the RDB file from the master.
* The following sub events are available: * The following sub events are available:
* *
* * REDISMODULE_SUBEVENT_LOADING_RDB_START * * `REDISMODULE_SUBEVENT_LOADING_RDB_START`
* * REDISMODULE_SUBEVENT_LOADING_AOF_START * * `REDISMODULE_SUBEVENT_LOADING_AOF_START`
* * REDISMODULE_SUBEVENT_LOADING_REPL_START * * `REDISMODULE_SUBEVENT_LOADING_REPL_START`
* * REDISMODULE_SUBEVENT_LOADING_ENDED * * `REDISMODULE_SUBEVENT_LOADING_ENDED`
* * REDISMODULE_SUBEVENT_LOADING_FAILED * * `REDISMODULE_SUBEVENT_LOADING_FAILED`
*
* Note that AOF loading may start with an RDB data in case of
* rdb-preamble, in which case you'll only receive an AOF_START event.
* *
* Note that AOF loading may start with an RDB data in case of
* rdb-preamble, in which case you'll only receive an AOF_START event.
* *
* * RedisModuleEvent_ClientChange * * RedisModuleEvent_ClientChange
* *
* Called when a client connects or disconnects. * Called when a client connects or disconnects.
* The data pointer can be casted to a RedisModuleClientInfo * The data pointer can be casted to a RedisModuleClientInfo
* structure, documented in RedisModule_GetClientInfoById(). * structure, documented in RedisModule_GetClientInfoById().
* The following sub events are available: * The following sub events are available:
* *
* * REDISMODULE_SUBEVENT_CLIENT_CHANGE_CONNECTED * * `REDISMODULE_SUBEVENT_CLIENT_CHANGE_CONNECTED`
* * REDISMODULE_SUBEVENT_CLIENT_CHANGE_DISCONNECTED * * `REDISMODULE_SUBEVENT_CLIENT_CHANGE_DISCONNECTED`
* *
* * RedisModuleEvent_Shutdown * * RedisModuleEvent_Shutdown
* *
* The server is shutting down. No subevents are available. * The server is shutting down. No subevents are available.
* *
* * RedisModuleEvent_ReplicaChange * * RedisModuleEvent_ReplicaChange
* *
* This event is called when the instance (that can be both a * This event is called when the instance (that can be both a
* master or a replica) get a new online replica, or lose a * master or a replica) get a new online replica, or lose a
* replica since it gets disconnected. * replica since it gets disconnected.
* The following sub events are available: * The following sub events are available:
* *
* * REDISMODULE_SUBEVENT_REPLICA_CHANGE_ONLINE * * `REDISMODULE_SUBEVENT_REPLICA_CHANGE_ONLINE`
* * REDISMODULE_SUBEVENT_REPLICA_CHANGE_OFFLINE * * `REDISMODULE_SUBEVENT_REPLICA_CHANGE_OFFLINE`
* *
* No additional information is available so far: future versions * No additional information is available so far: future versions
* of Redis will have an API in order to enumerate the replicas * of Redis will have an API in order to enumerate the replicas
* connected and their state. * connected and their state.
* *
* * RedisModuleEvent_CronLoop * * RedisModuleEvent_CronLoop
* *
* This event is called every time Redis calls the serverCron() * This event is called every time Redis calls the serverCron()
* function in order to do certain bookkeeping. Modules that are * function in order to do certain bookkeeping. Modules that are
* required to do operations from time to time may use this callback. * required to do operations from time to time may use this callback.
* Normally Redis calls this function 10 times per second, but * Normally Redis calls this function 10 times per second, but
* this changes depending on the "hz" configuration. * this changes depending on the "hz" configuration.
* No sub events are available. * No sub events are available.
* *
* The data pointer can be casted to a RedisModuleCronLoop * The data pointer can be casted to a RedisModuleCronLoop
* structure with the following fields: * structure with the following fields:
* *
* int32_t hz; // Approximate number of events per second. * int32_t hz; // Approximate number of events per second.
* *
* * RedisModuleEvent_MasterLinkChange * * RedisModuleEvent_MasterLinkChange
* *
* This is called for replicas in order to notify when the * This is called for replicas in order to notify when the
* replication link becomes functional (up) with our master, * replication link becomes functional (up) with our master,
* or when it goes down. Note that the link is not considered * or when it goes down. Note that the link is not considered
* up when we just connected to the master, but only if the * up when we just connected to the master, but only if the
* replication is happening correctly. * replication is happening correctly.
* The following sub events are available: * The following sub events are available:
* *
* * REDISMODULE_SUBEVENT_MASTER_LINK_UP * * `REDISMODULE_SUBEVENT_MASTER_LINK_UP`
* * REDISMODULE_SUBEVENT_MASTER_LINK_DOWN * * `REDISMODULE_SUBEVENT_MASTER_LINK_DOWN`
* *
* * RedisModuleEvent_ModuleChange * * RedisModuleEvent_ModuleChange
* *
* This event is called when a new module is loaded or one is unloaded. * This event is called when a new module is loaded or one is unloaded.
* The following sub events are available: * The following sub events are available:
* *
* * REDISMODULE_SUBEVENT_MODULE_LOADED * * `REDISMODULE_SUBEVENT_MODULE_LOADED`
* * REDISMODULE_SUBEVENT_MODULE_UNLOADED * * `REDISMODULE_SUBEVENT_MODULE_UNLOADED`
* *
* The data pointer can be casted to a RedisModuleModuleChange * The data pointer can be casted to a RedisModuleModuleChange
* structure with the following fields: * structure with the following fields:
* *
* const char* module_name; // Name of module loaded or unloaded. * const char* module_name; // Name of module loaded or unloaded.
* int32_t module_version; // Module version. * int32_t module_version; // Module version.
* *
* * RedisModuleEvent_LoadingProgress * * RedisModuleEvent_LoadingProgress
* *
* This event is called repeatedly called while an RDB or AOF file * This event is called repeatedly called while an RDB or AOF file
* is being loaded. * is being loaded.
* The following sub events are availble: * The following sub events are availble:
* *
* * REDISMODULE_SUBEVENT_LOADING_PROGRESS_RDB * * `REDISMODULE_SUBEVENT_LOADING_PROGRESS_RDB`
* * REDISMODULE_SUBEVENT_LOADING_PROGRESS_AOF * * `REDISMODULE_SUBEVENT_LOADING_PROGRESS_AOF`
* *
* The data pointer can be casted to a RedisModuleLoadingProgress * The data pointer can be casted to a RedisModuleLoadingProgress
* structure with the following fields: * structure with the following fields:
* *
* int32_t hz; // Approximate number of events per second. * int32_t hz; // Approximate number of events per second.
* int32_t progress; // Approximate progress between 0 and 1024, * int32_t progress; // Approximate progress between 0 and 1024,
* or -1 if unknown. * // or -1 if unknown.
* *
* * RedisModuleEvent_SwapDB * * RedisModuleEvent_SwapDB
* *
* This event is called when a SWAPDB command has been successfully * This event is called when a SWAPDB command has been successfully
* Executed. * Executed.
* For this event call currently there is no subevents available. * For this event call currently there is no subevents available.
* *
* The data pointer can be casted to a RedisModuleSwapDbInfo * The data pointer can be casted to a RedisModuleSwapDbInfo
* structure with the following fields: * structure with the following fields:
* *
* int32_t dbnum_first; // Swap Db first dbnum * int32_t dbnum_first; // Swap Db first dbnum
* int32_t dbnum_second; // Swap Db second dbnum * int32_t dbnum_second; // Swap Db second dbnum
* *
* * RedisModuleEvent_ReplBackup * * RedisModuleEvent_ReplBackup
* *
* Called when diskless-repl-load config is set to swapdb, * Called when diskless-repl-load config is set to swapdb,
* And redis needs to backup the the current database for the * And redis needs to backup the the current database for the
* possibility to be restored later. A module with global data and * possibility to be restored later. A module with global data and
* maybe with aux_load and aux_save callbacks may need to use this * maybe with aux_load and aux_save callbacks may need to use this
* notification to backup / restore / discard its globals. * notification to backup / restore / discard its globals.
* The following sub events are available: * The following sub events are available:
*
* * REDISMODULE_SUBEVENT_REPL_BACKUP_CREATE
* * REDISMODULE_SUBEVENT_REPL_BACKUP_RESTORE
* * REDISMODULE_SUBEVENT_REPL_BACKUP_DISCARD
* *
* * `REDISMODULE_SUBEVENT_REPL_BACKUP_CREATE`
* * `REDISMODULE_SUBEVENT_REPL_BACKUP_RESTORE`
* * `REDISMODULE_SUBEVENT_REPL_BACKUP_DISCARD`
* *
* The function returns REDISMODULE_OK if the module was successfully subscribed * The function returns REDISMODULE_OK if the module was successfully subscribed
* for the specified event. If the API is called from a wrong context or unsupported event * for the specified event. If the API is called from a wrong context or unsupported event
@ -8291,7 +8290,7 @@ int RM_DefragCursorSet(RedisModuleDefragCtx *ctx, unsigned long cursor) {
/* Fetch a cursor value that has been previously stored using RM_DefragCursorSet(). /* Fetch a cursor value that has been previously stored using RM_DefragCursorSet().
* *
* If not called for a late defrag operation, REDISMODULE_ERR will be returned and * If not called for a late defrag operation, REDISMODULE_ERR will be returned and
* the cursor should be ignored. See DM_DefragCursorSet() for more details on * the cursor should be ignored. See RM_DefragCursorSet() for more details on
* defrag cursors. * defrag cursors.
*/ */
int RM_DefragCursorGet(RedisModuleDefragCtx *ctx, unsigned long *cursor) { int RM_DefragCursorGet(RedisModuleDefragCtx *ctx, unsigned long *cursor) {

View File

@ -9,13 +9,21 @@ def markdown(s)
s.chop! while s[-1] == "\n" || s[-1] == " " s.chop! while s[-1] == "\n" || s[-1] == " "
lines = s.split("\n") lines = s.split("\n")
newlines = [] newlines = []
# Backquote function, macro and type names, except if already backquoted and # Fix some markdown, except in code blocks indented by 4 spaces.
# in code blocks indented by 4 spaces.
lines.each{|l| lines.each{|l|
if not l.start_with?(' ') if not l.start_with?(' ')
l = l.gsub(/(?<!`)RM_[A-z()]+/){|x| "`#{x}`"} # Rewrite RM_Xyz() to `RedisModule_Xyz()`. The () suffix is
l = l.gsub(/(?<!`)RedisModule[A-z()]+/){|x| "`#{x}`"} # optional. Even RM_Xyz*() with * as wildcard is handled.
l = l.gsub(/(?<!`)REDISMODULE_[A-z]+/){|x| "`#{x}`"} l = l.gsub(/(?<!`)RM_([A-z]+(?:\*?\(\))?)/, '`RedisModule_\1`')
# Add backquotes around RedisModule functions and type where missing.
l = l.gsub(/(?<!`)RedisModule[A-z]+(?:\*?\(\))?/){|x| "`#{x}`"}
# Add backquotes around c functions like malloc() where missing.
l = l.gsub(/(?<![`A-z])[a-z_]+\(\)/, '`\0`')
# Add backquotes around macro and var names containing underscores.
l = l.gsub(/(?<![`A-z\*])[A-Za-z]+_[A-Za-z0-9_]+/){|x| "`#{x}`"}
# Link URLs preceded by space (i.e. when not already linked)
l = l.gsub(/ (https?:\/\/[A-Za-z0-9_\/\.\-]+[A-Za-z0-9\/])/,
' [\1](\1)')
end end
newlines << l newlines << l
} }