diff --git a/src/modules/gendoc.rb b/utils/generate-module-api-doc.rb similarity index 86% rename from src/modules/gendoc.rb rename to utils/generate-module-api-doc.rb index f83b1ad9d..8a16751b9 100644 --- a/src/modules/gendoc.rb +++ b/utils/generate-module-api-doc.rb @@ -78,6 +78,7 @@ def docufy(src,i) puts "\n\n" puts "### `#{name}`\n\n" puts " #{proto}\n" + puts "**Available since:** #{$since[name]}\n\n" if $since[name] comment = "" while true i = i-1 @@ -135,8 +136,9 @@ def is_func_line(src, i) end puts "# Modules API reference\n\n" -puts "\n\n" -src = File.open(File.dirname(__FILE__) ++ "/../module.c").to_a +puts "\n\n" +src = File.open(File.dirname(__FILE__) ++ "/../src/module.c").to_a # Build function index $index = {} @@ -148,6 +150,24 @@ src.each_with_index do |line,i| end end +# Populate the 'since' map (name => version) if we're in a git repo. +$since = {} +git_dir = File.dirname(__FILE__) ++ "/../.git" +if File.directory?(git_dir) && `which git` != "" + `git --git-dir="#{git_dir}" tag --sort=v:refname`.each_line do |version| + next if version !~ /^(\d+)\.\d+\.\d+?$/ || $1.to_i < 4 + version.chomp! + `git --git-dir="#{git_dir}" cat-file blob "#{version}:src/module.c"`.each_line do |line| + if line =~ /^\w.*[ \*]RM_([A-z0-9]+)/ + name = "RedisModule_#{$1}" + if ! $since[name] + $since[name] = version + end + end + end + end +end + # Print TOC puts "## Sections\n\n" src.each_with_index do |_line,i|