Commit ca489427 authored by Gustavo Padovan's avatar Gustavo Padovan

contribution-stats: add html output

parent 22f8b2d6
......@@ -34,6 +34,7 @@ Options:
* `-s, --summary`: show only a summary with the numbers for each person, but no details
* `-o, --output`: output result to a file instead of stdout
* `--html`: output as html with link to commits
### Generating HTML tree view
......
#! /usr/bin/env python
import argparse
import csv
import jinja2
import os
import sys
import re
......@@ -73,6 +74,14 @@ def print_all(results, args):
if f is not sys.stdout:
f.close()
def generate_html(results, args):
env = jinja2.Environment(loader=jinja2.FileSystemLoader('{}/templates'.format(sys.path[0])))
template = env.get_template('contribution-stats.html.j2')
content = template.render(results=results, contributors=contributors, summary=args.summary)
with open(args.html, 'w') as html_file:
html_file.write(content)
if __name__ == "__main__":
parser = argparse.ArgumentParser()
parser.set_defaults(func=lambda x: parser.print_help())
......@@ -80,6 +89,8 @@ if __name__ == "__main__":
help="enable details for each section")
parser.add_argument('-o', '--output', metavar="FILE",
help="output to a file instead of stdout")
parser.add_argument('--html', metavar="FILE",
help="output to a html instead of stdout")
args = parser.parse_args(sys.argv[1:])
repo = Repository(os.getcwd())
......@@ -111,6 +122,7 @@ if __name__ == "__main__":
add_commit(tag[1], m[1], commit)
results = []
# XXX order dicts here
results.append(("Authored ({}):".format(total_commits(authored)), authored))
results.append(("Maintainer Committed ({}):".format(total_commits(committed)), committed))
results.append(("Signed-off-by ({}):".format(total_commits(signed)), signed))
......@@ -118,4 +130,7 @@ if __name__ == "__main__":
for tag in OTHER_TAGS:
results.append(("{} ({}):".format(tag[0],total_commits(tag[1])), tag[1]))
print_all(results, args)
if args.html:
generate_html(results, args)
else:
print_all(results, args)
{% for r in results %}
<h4>{{ r[0] }}</h4>
{% for email, data in r[1].items() %}
<strong>{{ contributors[email] }} {{ email }} ({{ data[0]}}):</strong><br />
{% if not summary %}
<ul>
{% for commit in data[1] %}
<li>
<a href="https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/?id={{ commit[0] }}">{{ commit[1] }}</a>
</li>
{% endfor %}
</ul>
{% endif %}
{% endfor %}
{% endfor %}
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment