From 930f89827dee19d648abd524bfbf7f76ebbb70fc Mon Sep 17 00:00:00 2001 From: skyjake Date: Mon, 29 Jul 2013 13:08:49 +0300 Subject: [PATCH] Codex|Fixed: HTML5 correctness, CSS instead of deprecated attributes, br tags Also rounding the authorship percentages better now. --- doomsday/build/scripts/codex.py | 34 ++++++++++++++++++++------------- 1 file changed, 21 insertions(+), 13 deletions(-) diff --git a/doomsday/build/scripts/codex.py b/doomsday/build/scripts/codex.py index c4c3fb401a..31c7d258cb 100755 --- a/doomsday/build/scripts/codex.py +++ b/doomsday/build/scripts/codex.py @@ -292,13 +292,18 @@ def tag_filename(tag): def print_header(out, pageTitle): print >> out, '' print >> out, '' - print >> out, '%s - %s' % (pageTitle, TITLE) - print >> out, '' + print >> out, '' + print >> out, '' + print >> out, '%s - %s' % (pageTitle, TITLE) print >> out, '' print >> out, '' print >> out, '' @@ -312,8 +317,8 @@ def print_footer(out): def print_table(out, cells, cell_printer, numCols=4, tdStyle='', separateByFirstLetter=False, letterFunc=None): colSize = (len(cells) + numCols - 1) / numCols - tdElem = '' % (100/numCols, tdStyle) - print >> out, '' + tdElem + tdElem = '
' % (100/numCols, tdStyle) + print >> out, '' + tdElem idx = 0 inCol = 0 @@ -349,7 +354,7 @@ def alpha_index_cell(out, tag): style = 'color: #aaa' else: style = '' - print >> out, '%s (%i)
' % ( + print >> out, '%s (%i)
' % ( tag_filename(tag), style, tag, count) print_table(out, sortedTags, alpha_index_cell, separateByFirstLetter=True, @@ -374,7 +379,7 @@ def size_index_cell(out, tag): style = 'color: #aaa' else: style = '' - print >> out, '%i %s
' % ( + print >> out, '%i %s
' % ( tag_filename(tag), style, count, tag) print_table(out, sorted(byTag.keys(), cmp=tag_size_comp), size_index_cell) @@ -401,11 +406,11 @@ def print_tags(out, com, tag, linkSuffix=''): print >> out, '%s' % (linkSuffix, tag_filename(other), other) def print_commit(out, com, tag, linkSuffix=''): - print >> out, trElem + '
' % com.link + com.date[:10] + ' ' - print >> out, '' + print >> out, trElem + '' % com.link + com.date[:10] + ' ' + print >> out, '' print_tags(out, com, tag, linkSuffix) - print >> out, ':' - print >> out, ('' % com.link + encoded_text(com.subject)[:250] + '').encode('utf8') + print >> out, ':' + print >> out, ('' % com.link + encoded_text(com.subject)[:250] + '').encode('utf8') colors = ['#f00', '#0a0', '#00f', '#ed0', '#f80', '#0ce', @@ -426,7 +431,7 @@ def print_date_sorted_commits(out, coms, tag, linkSuffix='', colorIdx=None): 'September', 'October', 'November', 'December'] curDate = '' dateSorted = sorted(coms, key=lambda c: c.date, reverse=True) - print >> out, '' + print >> out, '
' for com in dateSorted: # Monthly headers. if curDate == '' or curDate != com.date[:7]: @@ -490,6 +495,9 @@ def print_related_tags(out, tag, style=''): for t in rels], ', ') print >> out, '

' +def percentage(part, total): + return int(round(float(part)/float(total) * 100)) + def print_authorship(out, tag): authors = {} total = len(byTag[tag]) @@ -499,7 +507,7 @@ def print_authorship(out, tag): else: authors[commit.author] = 1 sortedAuthors = sorted(authors.keys(), key=lambda a: authors[a], reverse=True) - print >> out, '

Authorship:', string.join(['%i%% %s' % (100 * authors[a] / total, a) + print >> out, '

Authorship:', string.join(['%i%% %s' % (percentage(authors[a], total), a) for a in sortedAuthors], ', ').encode('utf8'), '

' # @@ -554,7 +562,7 @@ def __init__(self): def __call__(self, out, tag): print >> out, '' + color_box(self.color) self.color += 1 - print >> out, '%s (%i)
' % (tag_filename(tag), + print >> out, '%s (%i)
' % (tag_filename(tag), tag, len(present[tag])) print_table(out, presentSorted, SkipTagPrinter(), numCols=5, tdStyle='line-height:150%')