# gendoc.rb -- Converts the top-comments inside module.c to modules API # reference documentation in markdown format. # Convert the C comment to markdown def markdown(s) s = s.gsub(/\*\/$/,"") s = s.gsub(/^ ?\* ?/,"") s = s.gsub(/^\/\*\*? ?/,"") s.chop! while s[-1] == "\n" || s[-1] == " " lines = s.split("\n") newlines = [] # Fix some markdown, except in code blocks indented by 4 spaces. lines.each{|l| if not l.start_with?(' ') # Rewrite RM_Xyz() to `RedisModule_Xyz()`. The () suffix is # optional. Even RM_Xyz*() with * as wildcard is handled. l = l.gsub(/(?\n\n" src = File.open("../module.c").to_a src.each_with_index{|line,i| if line =~ /RM_/ && line[0] != ' ' && line[0] != '#' && line[0] != '/' if src[i-1] =~ /\*\// docufy(src,i) end end }