Markdown generation of Redis Modules API reference improved.

This commit is contained in:
antirez 2017-07-14 11:29:28 +02:00
parent e74f0aa6d1
commit 43aaf96163
2 changed files with 83 additions and 74 deletions

View File

@ -1003,11 +1003,11 @@ int replyWithStatus(RedisModuleCtx *ctx, const char *msg, char *prefix) {
* the initial error code. The function only provides the initial "-", so * the initial error code. The function only provides the initial "-", so
* the usage is, for example: * the usage is, for example:
* *
* RM_ReplyWithError(ctx,"ERR Wrong Type"); * RedisModule_ReplyWithError(ctx,"ERR Wrong Type");
* *
* and not just: * and not just:
* *
* RM_ReplyWithError(ctx,"Wrong Type"); * RedisModule_ReplyWithError(ctx,"Wrong Type");
* *
* The function always returns REDISMODULE_OK. * The function always returns REDISMODULE_OK.
*/ */
@ -3238,8 +3238,7 @@ void RM_LogRaw(RedisModule *module, const char *levelstr, const char *fmt, va_li
serverLogRaw(level,msg); serverLogRaw(level,msg);
} }
/* /* Produces a log message to the standard Redis log, the format accepts
* Produces a log message to the standard Redis log, the format accepts
* printf-alike specifiers, while level is a string describing the log * printf-alike specifiers, while level is a string describing the log
* level to use when emitting the log, and must be one of the following: * level to use when emitting the log, and must be one of the following:
* *
@ -3318,10 +3317,12 @@ void unblockClientFromModule(client *c) {
* *
* The callbacks are called in the following contexts: * The callbacks are called in the following contexts:
* *
* reply_callback: called after a successful RedisModule_UnblockClient() call * reply_callback: called after a successful RedisModule_UnblockClient()
* in order to reply to the client and unblock it. * call in order to reply to the client and unblock it.
*
* reply_timeout: called when the timeout is reached in order to send an * reply_timeout: called when the timeout is reached in order to send an
* error to the client. * error to the client.
*
* free_privdata: called in order to free the privata data that is passed * free_privdata: called in order to free the privata data that is passed
* by RedisModule_UnblockClient() call. * by RedisModule_UnblockClient() call.
*/ */
@ -3683,8 +3684,8 @@ int moduleLoad(const char *path, void **module_argv, int module_argc) {
* C_OK is returned, otherwise C_ERR is returned and errno is set * C_OK is returned, otherwise C_ERR is returned and errno is set
* to the following values depending on the type of error: * to the following values depending on the type of error:
* *
* ENONET: No such module having the specified name. * * ENONET: No such module having the specified name.
* EBUSY: The module exports a new data type and can only be reloaded. */ * * EBUSY: The module exports a new data type and can only be reloaded. */
int moduleUnload(sds name) { int moduleUnload(sds name) {
struct RedisModule *module = dictFetchValue(modules,name); struct RedisModule *module = dictFetchValue(modules,name);

View File

@ -6,21 +6,29 @@ def markdown(s)
s = s.gsub(/\*\/$/,"") s = s.gsub(/\*\/$/,"")
s = s.gsub(/^ \* {0,1}/,"") s = s.gsub(/^ \* {0,1}/,"")
s = s.gsub(/^\/\* /,"") s = s.gsub(/^\/\* /,"")
if s[0] != ' '
s = s.gsub(/RM_[A-z()]+/){|x| "`#{x}`"}
s = s.gsub(/RedisModule_[A-z()]+/){|x| "`#{x}`"}
s = s.gsub(/REDISMODULE_[A-z]+/){|x| "`#{x}`"}
end
s.chop! while s[-1] == "\n" || s[-1] == " " s.chop! while s[-1] == "\n" || s[-1] == " "
return s lines = s.split("\n")
newlines = []
lines.each{|l|
if l[0] != ' '
l = l.gsub(/RM_[A-z()]+/){|x| "`#{x}`"}
l = l.gsub(/RedisModule_[A-z()]+/){|x| "`#{x}`"}
l = l.gsub(/REDISMODULE_[A-z]+/){|x| "`#{x}`"}
end
newlines << l
}
return newlines.join("\n")
end end
# Given the source code array and the index at which an exported symbol was # Given the source code array and the index at which an exported symbol was
# detected, extracts and outputs the documentation. # detected, extracts and outputs the documentation.
def docufy(src,i) def docufy(src,i)
m = /RM_[A-z0-9]+/.match(src[i]) m = /RM_[A-z0-9]+/.match(src[i])
name = m[0]
name = name.sub("RM_","RedisModule_")
proto = src[i].sub("{","").strip+";\n" proto = src[i].sub("{","").strip+";\n"
puts "## `#{m[0]}`\n\n" proto = proto.sub("RM_","RedisModule_")
puts "## `#{name}`\n\n"
puts " #{proto}\n" puts " #{proto}\n"
comment = "" comment = ""
while true while true