Skip to content

Commit 2b12b1e

Browse files
author
jlinoff
committed
Update to 0.8.3 - added --font-size and --font-name
1 parent 9cfa39d commit 2b12b1e

File tree

2 files changed

+29
-2
lines changed

2 files changed

+29
-2
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,7 @@ test/test*.dot.html
88
test/test*.dot.png
99
test/test*.dot.svg
1010
test/test*.html
11+
test/test*.difflog
12+
test/test*.log
13+
test/test*.filter
1114

git2dot.py

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@
9999
import sys
100100

101101

102-
VERSION = '0.8.2'
102+
VERSION = '0.8.3'
103103
DEFAULT_GITCMD = 'git log --format="|Record:|%h|%p|%d|%ci%n%b"' # --gitcmd
104104
DEFAULT_RANGE = '--all --topo-order' # --range
105105

@@ -704,6 +704,10 @@ def gendot(opts):
704704

705705
ofp.write('digraph G {\n')
706706
for v in opts.dot_option:
707+
if len(opts.font_size) and 'fontsize=' in v:
708+
v = re.sub(r'(fontsize=)[^,]+,', r'\1"' + opts.font_size + r'",' , v)
709+
if len(opts.font_name) and 'fontsize=' in v:
710+
v = re.sub(r'(fontsize=[^,]+),', r'\1, fontname="' + opts.font_name + r'",', v)
707711
ofp.write(' {}'.format(v))
708712
if v[-1] != ';':
709713
ofp.write(';')
@@ -1043,6 +1047,10 @@ def gettext(s):
10431047
origin/1.0.0, origin/1.0.1 and origin/1.1.0
10441048
$ {0} --choose-branch origin/1.0.0 --choose-branch origin/1.0.1 --choose-branch origin/1.1.0 git01.dot
10451049
1050+
# Example 11. change the font name and size for the graph, nodes
1051+
# and edges.
1052+
$ {0} --png --font-name helvetica --font-size 14.0 git.dot
1053+
10461054
COPYRIGHT:
10471055
Copyright (c) 2017 Joe Linoff, all rights reserved
10481056
@@ -1193,7 +1201,7 @@ def gettext(s):
11931201
nodes by dot in large graphs.
11941202
''')
11951203

1196-
x = ['graph[rankdir="LR", bgcolor="white"]',
1204+
x = ['graph[rankdir="LR", fontsize=10.0, bgcolor="white"]',
11971205
'node[shape=ellipse, fontsize=10.0, style="filled"]',
11981206
'edge[weight=2, penwidth=1.0, fontsize=10.0, arrowtail="open", dir="back"]']
11991207
parser.add_argument('-d', '--dot-option',
@@ -1245,6 +1253,22 @@ def gettext(s):
12451253
contains @FOO which is probably not what you want.
12461254
'''.replace('%', '%%'))
12471255

1256+
parser.add_argument('--font-name',
1257+
action='store',
1258+
type=str,
1259+
default='',
1260+
help='''Change the font name of graph, node and edge objects.
1261+
Here is an example: --font-name helvetica.
1262+
''')
1263+
1264+
parser.add_argument('--font-size',
1265+
action='store',
1266+
type=str,
1267+
default='',
1268+
help='''Change the font size of graph, node and edge objects.
1269+
Here is an example: --font-size 14.0.
1270+
''')
1271+
12481272
parser.add_argument('-g', '--gitcmd',
12491273
action='store',
12501274
type=str,

0 commit comments

Comments
 (0)