X Tutup
Skip to content

Commit 942251c

Browse files
author
p12
committed
Images: store graph settings of all dot files in one location
Dot doesn't support file inclusion. Add a separate preprocessing step to paste the graph settings into each file before running dot.
1 parent 5746244 commit 942251c

34 files changed

+135
-273
lines changed

images/generate.sh

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,17 +24,21 @@ do
2424
outfile="output/$i.svg"
2525
mapfile="output/$i.map"
2626
wikimapfile="output/$i.wikimap"
27-
tmpfile="output/$i.tmp"
28-
dot -Tsvg -o$tmpfile $infile
29-
xsltproc --novalid fix_svg-dot.xsl $tmpfile > $outfile
30-
dot -Timap $infile | sed 1d | awk '{sub(/,/, " ", $3); sub(/,/, " ", $4); print $1" "$3" "$4" [["$2"]]"; };' > $mapfile
27+
tmpsvgfile="output/$i.tmpsvg"
28+
tmpdotfile="output/$i.tmpdot"
29+
30+
python preprocess.py $infile $tmpdotfile
31+
dot -Tsvg -o$tmpsvgfile $tmpdotfile
32+
xsltproc --novalid fix_svg-dot.xsl $tmpsvgfile > $outfile
33+
dot -Timap $tmpdotfile | sed 1d | awk '{sub(/,/, " ", $3); sub(/,/, " ", $4); print $1" "$3" "$4" [["$2"]]"; };' > $mapfile
3134

3235
wikiimage=$(echo $i | sed 's/\.\///' | sed 's/\.dot//')
3336
echo "{{inheritance diagram|image=$wikiimage.svg|map=" > $wikimapfile
3437
cat $mapfile >> $wikimapfile
3538
echo "}}" >> $wikimapfile
3639

37-
rm $tmpfile
40+
rm $tmpsvgfile
41+
rm $tmpdotfile
3842
done
3943

4044
python math.py

images/preprocess.py

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
#!/usr/bin/env python
2+
# -*- coding: utf-8 -*-
3+
# Copyright (C) 2011, 2012 p12 <tir5c3@yahoo.co.uk>
4+
#
5+
# This file is part of cppreference-doc
6+
#
7+
# This program is free software: you can redistribute it and/or modify
8+
# it under the terms of the GNU General Public License as published by
9+
# the Free Software Foundation, either version 3 of the License, or
10+
# (at your option) any later version.
11+
#
12+
# This program is distributed in the hope that it will be useful,
13+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
14+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15+
# GNU General Public License for more details.
16+
#
17+
# You should have received a copy of the GNU General Public License
18+
# along with this program. If not, see http://www.gnu.org/licenses/.
19+
20+
import re
21+
import sys
22+
23+
if len(sys.argv) != 3:
24+
print "Wrong usage"
25+
sys.exit(-1)
26+
27+
inf = open(sys.argv[1], 'r')
28+
outf = open(sys.argv[2], 'w')
29+
30+
setf = open('settings-dot', 'r')
31+
32+
itext = inf.read()
33+
inf.close()
34+
35+
stext = setf.read()
36+
setf.close()
37+
38+
# strip comments
39+
stext = re.sub('\/\*.*?\*\/', '', stext, flags=re.MULTILINE)
40+
stext = re.sub('^#.*$', '', stext)
41+
42+
# replace
43+
itext = re.sub('@SETTINGS@', stext, itext)
44+
45+
outf.write(itext)

images/settings-dot

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
/*
2+
Copyright (C) 2012 p12 <tir5c3@yahoo.co.uk>
3+
4+
This file is part of cppreference-doc
5+
6+
This program is free software: you can redistribute it and/or modify
7+
it under the terms of the GNU General Public License as published by
8+
the Free Software Foundation, either version 3 of the License, or
9+
(at your option) any later version.
10+
11+
This program is distributed in the hope that it will be useful,
12+
but WITHOUT ANY WARRANTY; without even the implied warranty of
13+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14+
GNU General Public License for more details.
15+
16+
You should have received a copy of the GNU General Public License
17+
along with this program. If not, see http://www.gnu.org/licenses/.
18+
*/
19+
20+
# this file contains the default graph options inserted by preprocess.py
21+
rankdir=LR
22+
23+
graph [dpi = 65, bgcolor=transparent];
24+
node [
25+
shape = box,
26+
fontname="DejaVu Sans, verdana, sans-serif", fontsize=14,
27+
width=1.6, height=0.5,
28+
style=filled, fillcolor=white
29+
];

images/std-bad_alloc-inheritance.dot

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,8 @@
1717
along with this program. If not, see http://www.gnu.org/licenses/.
1818
*/
1919
digraph inheritance {
20-
rankdir=LR
21-
22-
graph [dpi = 65, bgcolor=transparent];
23-
node [
24-
shape = box,
25-
fontname="DejaVu Sans, verdana, sans-serif", fontsize=14,
26-
width=1.6, height=0.5,
27-
style=filled, fillcolor=white
28-
];
20+
21+
@SETTINGS@
2922

3023
e1 [
3124
label = "exception",

images/std-bad_array_new_length-inheritance.dot

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,8 @@
1717
along with this program. If not, see http://www.gnu.org/licenses/.
1818
*/
1919
digraph inheritance {
20-
rankdir=LR
21-
22-
graph [dpi = 65, bgcolor=transparent];
23-
node [
24-
shape = box,
25-
fontname="DejaVu Sans, verdana, sans-serif", fontsize=14,
26-
width=1.6, height=0.5,
27-
style=filled, fillcolor=white
28-
];
20+
21+
@SETTINGS@
2922

3023
e1 [
3124
label = "exception",

images/std-bad_cast-inheritance.dot

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,8 @@
1717
along with this program. If not, see http://www.gnu.org/licenses/.
1818
*/
1919
digraph inheritance {
20-
rankdir=LR
21-
22-
graph [dpi = 65, bgcolor=transparent];
23-
node [
24-
shape = box,
25-
fontname="DejaVu Sans, verdana, sans-serif", fontsize=14,
26-
width=1.6, height=0.5,
27-
style=filled, fillcolor=white
28-
];
20+
21+
@SETTINGS@
2922

3023
e1 [
3124
label = "exception",

images/std-bad_exception-inheritance.dot

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,8 @@
1717
along with this program. If not, see http://www.gnu.org/licenses/.
1818
*/
1919
digraph inheritance {
20-
rankdir=LR
21-
22-
graph [dpi = 65, bgcolor=transparent];
23-
node [
24-
shape = box,
25-
fontname="DejaVu Sans, verdana, sans-serif", fontsize=14,
26-
width=1.6, height=0.5,
27-
style=filled, fillcolor=white
28-
];
20+
21+
@SETTINGS@
2922

3023
e1 [
3124
label = "exception",

images/std-bad_typeid-inheritance.dot

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,8 @@
1717
along with this program. If not, see http://www.gnu.org/licenses/.
1818
*/
1919
digraph inheritance {
20-
rankdir=LR
21-
22-
graph [dpi = 65, bgcolor=transparent];
23-
node [
24-
shape = box,
25-
fontname="DejaVu Sans, verdana, sans-serif", fontsize=14,
26-
width=1.6, height=0.5,
27-
style=filled, fillcolor=white
28-
];
20+
21+
@SETTINGS@
2922

3023
e1 [
3124
label = "exception",

images/std-bad_weak_ptr-inheritance.dot

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,8 @@
1717
along with this program. If not, see http://www.gnu.org/licenses/.
1818
*/
1919
digraph inheritance {
20-
rankdir=LR
21-
22-
graph [dpi = 65, bgcolor=transparent];
23-
node [
24-
shape = box,
25-
fontname="DejaVu Sans, verdana, sans-serif", fontsize=14,
26-
width=1.6, height=0.5,
27-
style=filled, fillcolor=white
28-
];
20+
21+
@SETTINGS@
2922

3023
e1 [
3124
label = "exception",

images/std-basic_fstream-inheritance.dot

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,8 @@
1717
along with this program. If not, see http://www.gnu.org/licenses/.
1818
*/
1919
digraph inheritance {
20-
rankdir=LR
2120

22-
graph [dpi = 65, bgcolor=transparent];
23-
node [
24-
shape = box,
25-
fontname="DejaVu Sans, verdana, sans-serif", fontsize=14,
26-
width=1.6, height=0.5,
27-
style=filled, fillcolor=white
28-
];
21+
@SETTINGS@
2922

3023
base [
3124
label = "ios_base",

0 commit comments

Comments
 (0)
X Tutup