Przeglądaj źródła

Output fragment (#) links for all headers.

Headers are now created using html_header() function.
Heikki Hokkanen 18 lat temu
rodzic
commit
9da6a926b7
3 zmienionych plików z 31 dodań i 13 usunięć
  1. 0
    1
      doc/TODO.txt
  2. 19
    12
      gitstats
  3. 12
    0
      gitstats.css

+ 0
- 1
doc/TODO.txt Wyświetl plik

@@ -1,5 +1,4 @@
1 1
 []
2
-- BUG git repo broken again
3 2
 - Files
4 3
 	- (T) File count by date
5 4
 

+ 19
- 12
gitstats Wyświetl plik

@@ -233,6 +233,7 @@ class GitDataCollector(DataCollector):
233 233
 
234 234
 			self.extensions[ext]['files'] += 1
235 235
 			try:
236
+				# FIXME filenames with spaces or special characters are broken
236 237
 				self.extensions[ext]['lines'] += int(getoutput('wc -l < %s' % line, quiet = True))
237 238
 			except:
238 239
 				print 'Warning: Could not count lines for file "%s"' % line
@@ -296,6 +297,13 @@ class ReportCreator:
296 297
 		self.data = data
297 298
 		self.path = path
298 299
 
300
+def html_linkify(text):
301
+	return text.lower().replace(' ', '_')
302
+
303
+def html_header(level, text):
304
+	name = html_linkify(text)
305
+	return '\n<h%d><a href="#%s" name="%s">%s</a></h%d>\n\n' % (level, name, name, text, level)
306
+
299 307
 class HTMLReportCreator(ReportCreator):
300 308
 	def create(self, data, path):
301 309
 		ReportCreator.create(self, data, path)
@@ -337,7 +345,7 @@ class HTMLReportCreator(ReportCreator):
337 345
 		f.write('<h2>Last 12 months</h2>')
338 346
 
339 347
 		# Hour of Day
340
-		f.write('\n<h2>Hour of Day</h2>\n\n')
348
+		f.write(html_header(2, 'Hour of Day'))
341 349
 		hour_of_day = data.getActivityByHourOfDay()
342 350
 		f.write('<table><tr><th>Hour</th>')
343 351
 		for i in range(1, 25):
@@ -370,7 +378,7 @@ class HTMLReportCreator(ReportCreator):
370 378
 		fg.close()
371 379
 
372 380
 		# Day of Week
373
-		f.write('\n<h2>Day of Week</h2>\n\n')
381
+		f.write(html_header(2, 'Day of Week'))
374 382
 		day_of_week = data.getActivityByDayOfWeek()
375 383
 		f.write('<div class="vtable"><table>')
376 384
 		f.write('<tr><th>Day</th><th>Total (%)</th></tr>')
@@ -389,7 +397,7 @@ class HTMLReportCreator(ReportCreator):
389 397
 		fp.close()
390 398
 
391 399
 		# Hour of Week
392
-		f.write('\n<h2>Hour of Week</h2>\n\n')
400
+		f.write(html_header(2, 'Hour of Week'))
393 401
 		f.write('<table>')
394 402
 
395 403
 		f.write('<tr><th>Weekday</th>')
@@ -413,7 +421,7 @@ class HTMLReportCreator(ReportCreator):
413 421
 		f.write('</table>')
414 422
 
415 423
 		# Month of Year
416
-		f.write('\n<h2>Month of Year</h2>\n\n')
424
+		f.write(html_header(2, 'Month of Year'))
417 425
 		f.write('<div class="vtable"><table>')
418 426
 		f.write('<tr><th>Month</th><th>Commits (%)</th></tr>')
419 427
 		fp = open (path + '/month_of_year.dat', 'w')
@@ -428,7 +436,7 @@ class HTMLReportCreator(ReportCreator):
428 436
 		f.write('<img src="month_of_year.png" alt="Month of Year" />')
429 437
 
430 438
 		# Commits by year/month
431
-		f.write('<h2>Commits by year/month</h2>')
439
+		f.write(html_header(2, 'Commits by year/month'))
432 440
 		f.write('<div class="vtable"><table><tr><th>Month</th><th>Commits</th></tr>')
433 441
 		for yymm in reversed(sorted(data.commits_by_month.keys())):
434 442
 			f.write('<tr><td>%s</td><td>%d</td></tr>' % (yymm, data.commits_by_month[yymm]))
@@ -440,7 +448,7 @@ class HTMLReportCreator(ReportCreator):
440 448
 		fg.close()
441 449
 
442 450
 		# Commits by year
443
-		f.write('<h2>Commits by year</h2>')
451
+		f.write(html_header(2, 'Commits by Year'))
444 452
 		f.write('<div class="vtable"><table><tr><th>Year</th><th>Commits (% of all)</th></tr>')
445 453
 		for yy in reversed(sorted(data.commits_by_year.keys())):
446 454
 			f.write('<tr><td>%s</td><td>%d (%.2f%%)</td></tr>' % (yy, data.commits_by_year[yy], (100.0 * data.commits_by_year[yy]) / data.getTotalCommits()))
@@ -463,7 +471,7 @@ class HTMLReportCreator(ReportCreator):
463 471
 		self.printNav(f)
464 472
 
465 473
 		# Authors :: List of authors
466
-		f.write('\n<h2>List of authors</h2>\n\n')
474
+		f.write(html_header(2, 'List of Authors'))
467 475
 
468 476
 		f.write('<table class="authors">')
469 477
 		f.write('<tr><th>Author</th><th>Commits (%)</th><th>First commit</th><th>Last commit</th><th>Age</th></tr>')
@@ -473,7 +481,7 @@ class HTMLReportCreator(ReportCreator):
473 481
 		f.write('</table>')
474 482
 
475 483
 		# Authors :: Author of Month
476
-		f.write('\n<h2>Author of Month</h2>\n\n')
484
+		f.write(html_header(2, 'Author of Month'))
477 485
 		f.write('<table>')
478 486
 		f.write('<tr><th>Month</th><th>Author</th><th>Commits (%)</th></tr>')
479 487
 		for yymm in reversed(sorted(data.author_of_month.keys())):
@@ -485,7 +493,7 @@ class HTMLReportCreator(ReportCreator):
485 493
 
486 494
 		f.write('</table>')
487 495
 
488
-		f.write('\n<h2>Author of Year</h2>\n\n')
496
+		f.write(html_header(2, 'Author of Year'))
489 497
 		f.write('<table><tr><th>Year</th><th>Author</th><th>Commits (%)</th></tr>')
490 498
 		for yy in reversed(sorted(data.author_of_year.keys())):
491 499
 			authordict = data.author_of_year[yy]
@@ -512,7 +520,7 @@ class HTMLReportCreator(ReportCreator):
512 520
 		f.write('</dl>\n')
513 521
 
514 522
 		# Files :: File count by date
515
-		f.write('<h2>File count by date</h2>')
523
+		f.write(html_header(2, 'File count by date'))
516 524
 
517 525
 		fg = open(path + '/files_by_date.dat', 'w')
518 526
 		for stamp in sorted(data.files_by_stamp.keys()):
@@ -524,7 +532,7 @@ class HTMLReportCreator(ReportCreator):
524 532
 		#f.write('<h2>Average file size by date</h2>')
525 533
 
526 534
 		# Files :: Extensions
527
-		f.write('\n<h2>Extensions</h2>\n\n')
535
+		f.write(html_header(2, 'Extensions'))
528 536
 		f.write('<table><tr><th>Extension</th><th>Files (%)</th><th>Lines (%)</th><th>Lines/file</th></tr>')
529 537
 		for ext in sorted(data.extensions.keys()):
530 538
 			files = data.extensions[ext]['files']
@@ -734,4 +742,3 @@ print 'Generating report...'
734 742
 report = HTMLReportCreator()
735 743
 report.create(data, outputpath)
736 744
 
737
-

+ 12
- 0
gitstats.css Wyświetl plik

@@ -83,3 +83,15 @@ img {
83 83
 	clear: both;
84 84
 	font-size: 90%;
85 85
 }
86
+
87
+h1 a, h2 a {
88
+	color: black;
89
+	text-decoration: none;
90
+}
91
+
92
+h1:hover a:after,
93
+h2:hover a:after {
94
+	content: '¶';
95
+	color: #555;
96
+}
97
+