yard-blame 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitignore +4 -0
- data/Gemfile +4 -0
- data/Rakefile +1 -0
- data/lib/yard-blame.rb +3 -0
- data/lib/yard-blame/version.rb +5 -0
- data/template/default/fulldoc/html/css/blame.css +11 -0
- data/template/default/layout/html/setup.rb +3 -0
- data/template/default/method_details/html/blame.erb +25 -0
- data/template/default/method_details/html/setup.rb +35 -0
- data/yard-blame.gemspec +24 -0
- metadata +74 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
data/lib/yard-blame.rb
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
<table class="source_code blame">
|
2
|
+
<caption><span class="info file"># File '<%= h object.file %>'<% if object.line %>, line <%= object.line %><% end %></span></caption>
|
3
|
+
<tr>
|
4
|
+
<td>
|
5
|
+
<table>
|
6
|
+
<% blames = git_blame(object.file)%>
|
7
|
+
<% html_syntax_highlight(object.source).split("\n").each_with_index do |source_line, num| %>
|
8
|
+
<% blame = blames[object.line + num] %>
|
9
|
+
<tr>
|
10
|
+
<% if blame.author %>
|
11
|
+
<td class="author"><a href="mailto:<%= blame.mail %>"><%= h blame.author %></a></td>
|
12
|
+
<% else %>
|
13
|
+
<td class="author">No committed</td>
|
14
|
+
<% end%>
|
15
|
+
<td class="date"><%= h blame.time.strftime("%Y-%m-%d %H:%M:%S") %></td>
|
16
|
+
<td class="commit"><a title="<%= h blame.summary %>"><%= h blame.sha.slice(0,8) %></a><td>
|
17
|
+
<td class="lines"><%= object.line + num %></td>
|
18
|
+
<td><pre class="code"><%= source_line %></pre></td>
|
19
|
+
</tr>
|
20
|
+
<% end %>
|
21
|
+
</table>
|
22
|
+
</td>
|
23
|
+
<td>
|
24
|
+
</tr>
|
25
|
+
</table>
|
@@ -0,0 +1,35 @@
|
|
1
|
+
def init
|
2
|
+
super
|
3
|
+
sections.last.delete(:source)
|
4
|
+
sections.last.push(:blame)
|
5
|
+
end
|
6
|
+
|
7
|
+
def git_blame(file)
|
8
|
+
git_bin = "git" # TODO: configurability?
|
9
|
+
cmd = "#{git_bin} blame -p #{file}"
|
10
|
+
puts cmd
|
11
|
+
output = %x{#{cmd}}
|
12
|
+
commits = {}
|
13
|
+
blames = []
|
14
|
+
output.split("\n").each do |line|
|
15
|
+
if md = line.match(/^([0-9a-f]{39,40})\s\d+\s(\d+).*/)
|
16
|
+
line_no = md[2].to_i
|
17
|
+
sha = md[1].match(/^0+$/) ? "-" : md[1]
|
18
|
+
|
19
|
+
commits[sha] ||= Commit.new(sha)
|
20
|
+
blames[line_no - 1] = commits[sha]
|
21
|
+
elsif line =~ /^author (.*)/
|
22
|
+
blames.last.author = $1 unless $1 == "Not Committed Yet"
|
23
|
+
elsif line =~ /^author-mail (.*)/
|
24
|
+
blames.last.mail = $1 unless $1 == "<not.committed.yet>"
|
25
|
+
elsif line =~ /^author-time (\d*)/
|
26
|
+
blames.last.time = Time.at($1.to_i)
|
27
|
+
elsif line =~ /^summary (.*)/
|
28
|
+
blames.last.summary = $1
|
29
|
+
end
|
30
|
+
end
|
31
|
+
blames
|
32
|
+
end
|
33
|
+
|
34
|
+
class Commit < Struct.new(:sha, :author, :mail, :time, :summary)
|
35
|
+
end
|
data/yard-blame.gemspec
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "yard-blame/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = "yard-blame"
|
7
|
+
s.version = Yard::Blame::VERSION
|
8
|
+
s.authors = ["Andrew O'Brien"]
|
9
|
+
s.email = ["obrien.andrew@gmail.com"]
|
10
|
+
s.homepage = "http://github.com/AndrewO/yard-blame"
|
11
|
+
s.summary = %q{Adds git-blame output to YARD docs}
|
12
|
+
s.description = %q{Who wrote that code? When? Why? Theses are all things we often ask when reading documentation. yard-blame makes it easy to ask.}
|
13
|
+
|
14
|
+
s.rubyforge_project = "yard-blame"
|
15
|
+
|
16
|
+
s.files = `git ls-files`.split("\n")
|
17
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
18
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
19
|
+
s.require_paths = ["lib"]
|
20
|
+
|
21
|
+
# specify any dependencies here; for example:
|
22
|
+
# s.add_development_dependency "rspec"
|
23
|
+
s.add_runtime_dependency "yard"
|
24
|
+
end
|
metadata
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: yard-blame
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease:
|
5
|
+
version: 0.0.1
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Andrew O'Brien
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
|
13
|
+
date: 2011-09-20 00:00:00 Z
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: yard
|
17
|
+
prerelease: false
|
18
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
19
|
+
none: false
|
20
|
+
requirements:
|
21
|
+
- - ">="
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: "0"
|
24
|
+
type: :runtime
|
25
|
+
version_requirements: *id001
|
26
|
+
description: Who wrote that code? When? Why? Theses are all things we often ask when reading documentation. yard-blame makes it easy to ask.
|
27
|
+
email:
|
28
|
+
- obrien.andrew@gmail.com
|
29
|
+
executables: []
|
30
|
+
|
31
|
+
extensions: []
|
32
|
+
|
33
|
+
extra_rdoc_files: []
|
34
|
+
|
35
|
+
files:
|
36
|
+
- .gitignore
|
37
|
+
- Gemfile
|
38
|
+
- Rakefile
|
39
|
+
- lib/yard-blame.rb
|
40
|
+
- lib/yard-blame/version.rb
|
41
|
+
- template/default/fulldoc/html/css/blame.css
|
42
|
+
- template/default/layout/html/setup.rb
|
43
|
+
- template/default/method_details/html/blame.erb
|
44
|
+
- template/default/method_details/html/setup.rb
|
45
|
+
- yard-blame.gemspec
|
46
|
+
homepage: http://github.com/AndrewO/yard-blame
|
47
|
+
licenses: []
|
48
|
+
|
49
|
+
post_install_message:
|
50
|
+
rdoc_options: []
|
51
|
+
|
52
|
+
require_paths:
|
53
|
+
- lib
|
54
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
55
|
+
none: false
|
56
|
+
requirements:
|
57
|
+
- - ">="
|
58
|
+
- !ruby/object:Gem::Version
|
59
|
+
version: "0"
|
60
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
61
|
+
none: false
|
62
|
+
requirements:
|
63
|
+
- - ">="
|
64
|
+
- !ruby/object:Gem::Version
|
65
|
+
version: "0"
|
66
|
+
requirements: []
|
67
|
+
|
68
|
+
rubyforge_project: yard-blame
|
69
|
+
rubygems_version: 1.8.8
|
70
|
+
signing_key:
|
71
|
+
specification_version: 3
|
72
|
+
summary: Adds git-blame output to YARD docs
|
73
|
+
test_files: []
|
74
|
+
|