lib/docurium.rb in docurium-0.2.1 vs lib/docurium.rb in docurium-0.2.2

- old
+ new

@@ -7,10 +7,14 @@ require 'docurium/cparser' require 'pp' require 'rugged' require 'redcarpet' +# Markdown expects the old redcarpet compat API, so let's tell it what +# to use +Rocco::Markdown = RedcarpetCompat + class Docurium attr_accessor :branch, :output_dir, :data def initialize(config_file) raise "You need to specify a config file" if !config_file @@ -337,11 +341,16 @@ file_map[r[:file]][:functions] << r[:name] when :define, :macro @data[:globals][r[:decl]] ||= {} wanted[:globals].each do |k| - @data[:globals][r[:decl]][k] = r[k] if r.has_key?(k) + next unless r.has_key? k + if k == :description || k == :comments + @data[:globals][r[:decl]][k] = md.render r[k] + else + @data[:globals][r[:decl]][k] = r[k] + end end when :file wanted[:meta].each do |k| file_map[r[:file]][:meta][k] = r[k] if r.has_key?(k) @@ -351,31 +360,42 @@ if !r[:name] # Explode unnamed enum into multiple global defines r[:decl].each do |n| @data[:globals][n] ||= { :file => r[:file], :line => r[:line], - :value => "", :comments => r[:comments], + :value => "", :comments => md.render(r[:comments]), } m = /#{Regexp.quote(n)}/.match(r[:body]) if m @data[:globals][n][:line] += m.pre_match.scan("\n").length if m.post_match =~ /\s*=\s*([^,\}]+)/ @data[:globals][n][:value] = $1 end end end - else + else # enum has name @data[:types][r[:name]] ||= {} wanted[:types].each do |k| - @data[:types][r[:name]][k] = r[k] if r.has_key?(k) + next unless r.has_key? k + if k == :comments + contents = md.render r[k] + else + contents = r[k] + end + @data[:types][r[:name]][k] = contents end end when :struct, :fnptr @data[:types][r[:name]] ||= {} r[:value] ||= r[:name] wanted[:types].each do |k| - @data[:types][r[:name]][k] = r[k] if r.has_key?(k) + next unless r.has_key? k + if k == :comments + @data[:types][r[:name]][k] = md.render r[k] + else + @data[:types][r[:name]][k] = r[k] + end end if r[:type] == :fnptr @data[:types][r[:name]][:type] = "function pointer" end