summaryrefslogtreecommitdiff
path: root/src/modules/gendoc.rb
diff options
context:
space:
mode:
authorantirez <antirez@gmail.com>2017-07-14 11:29:28 +0200
committerantirez <antirez@gmail.com>2017-07-14 11:29:31 +0200
commit43aaf96163ecc32c1d57834bbc1c7029986ae1cb (patch)
tree54854520bfe6d160859a05fc97311a495a66f9ff /src/modules/gendoc.rb
parente74f0aa6d1ca4a7d0626125a7d9b5eb9cb713947 (diff)
downloadredis-43aaf96163ecc32c1d57834bbc1c7029986ae1cb.tar.gz
Markdown generation of Redis Modules API reference improved.
Diffstat (limited to 'src/modules/gendoc.rb')
-rw-r--r--src/modules/gendoc.rb22
1 files changed, 15 insertions, 7 deletions
diff --git a/src/modules/gendoc.rb b/src/modules/gendoc.rb
index b3dbf1ca7..516f5d795 100644
--- a/src/modules/gendoc.rb
+++ b/src/modules/gendoc.rb
@@ -6,21 +6,29 @@ def markdown(s)
s = s.gsub(/\*\/$/,"")
s = s.gsub(/^ \* {0,1}/,"")
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] == " "
- 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
# Given the source code array and the index at which an exported symbol was
# detected, extracts and outputs the documentation.
def docufy(src,i)
m = /RM_[A-z0-9]+/.match(src[i])
+ name = m[0]
+ name = name.sub("RM_","RedisModule_")
proto = src[i].sub("{","").strip+";\n"
- puts "## `#{m[0]}`\n\n"
+ proto = proto.sub("RM_","RedisModule_")
+ puts "## `#{name}`\n\n"
puts " #{proto}\n"
comment = ""
while true