Permalink
Browse files

add signature history to project data

  • Loading branch information...
1 parent a8a782b commit 8e6ac325767340a75d1f353f0be9b7c199af23c5 @schacon schacon committed Jun 13, 2011
Showing with 24 additions and 7 deletions.
  1. +24 −1 lib/docurium.rb
  2. +0 −6 test/repo_test.rb
View
@@ -6,11 +6,12 @@
class Docurium
Version = VERSION = '0.0.1'
- attr_accessor :header_dir, :branch, :output_dir, :data
+ attr_accessor :branch, :output_dir, :data
def initialize(config_file)
raise "You need to specify a config file" if !config_file
raise "You need to specify a valid config file" if !valid_config(config_file)
+ @sigs = {}
clear_data
end
@@ -46,6 +47,7 @@ def generate_docs
checkout(version, workdir)
puts "parsing headers"
parse_headers
+ tally_sigs(version)
File.open(File.join(outdir, "#{version}.json"), 'w+') do |f|
f.write(@data.to_json)
end
@@ -56,6 +58,7 @@ def generate_docs
project = {
:versions => versions.reverse,
:github => @options['github'],
+ :signatures => @sigs
}
File.open("project.json", 'w+') do |f|
f.write(project.to_json)
@@ -88,6 +91,21 @@ def parse_headers
private
+ def tally_sigs(version)
+ @lastsigs ||= {}
+ @data[:functions].each do |fun_name, fun_data|
+ if !@sigs[fun_name]
+ @sigs[fun_name] ||= {:exists => [], :changes => []}
+ else
+ if @lastsigs[fun_name] != fun_data[:sig]
+ @sigs[fun_name][:changes] << version
+ end
+ end
+ @sigs[fun_name][:exists] << version
+ @lastsigs[fun_name] = fun_data[:sig]
+ end
+ end
+
def git(command)
out = ''
Dir.chdir(@project_dir) do
@@ -336,6 +354,10 @@ def extract_functions(file, data)
{:type => type.strip, :name => var, :comment => desc}
end
+ sig = args.map do |arg|
+ arg[:type].to_s
+ end.join('::')
+
return_comment = ''
comments.gsub!(/\@return ([^@]*)/m) do |m|
return_comment = $1.gsub("\n", ' ').gsub("\t", ' ').strip
@@ -361,6 +383,7 @@ def extract_functions(file, data)
:line => block[:line],
:lineto => block[:lineto],
:comments => comments,
+ :sig => sig,
:rawComments => rawComments
}
funcs << fun
View
@@ -41,12 +41,6 @@
assert_equal 39, oid[1][:used][:needs].size
end
- test "can detect signature changes" do
- #oid = @data[:functions].assoc('git_oid')
- #assert_equal 10, oid[1][:used][:returns].size
- #assert_equal 39, oid[1][:used][:needs].size
- end
-
test "can parse normal functions" do
func = @data[:functions]['git_blob_rawcontent']
assert_equal 'Get a read-only buffer with the raw content of a blob.', func[:description]

0 comments on commit 8e6ac32

Please sign in to comment.