]> git.donarmstrong.com Git - lilypond.git/blob - Documentation/user/SConscript
fd2359b523eee606c48493d22b1e08fd0fe3d162
[lilypond.git] / Documentation / user / SConscript
1 # -*-python-*-
2
3 import os
4 import string
5
6 Import ('env')
7 sources = env['src_glob'] (env, '*.tely')
8 pngs = env['src_glob'] (env, '*.png')
9
10 mfbuild = os.path.join (env['absbuild'], 'mf', env['out'])
11 lilybuild = os.path.join (env['absbuild'], 'lily', env['out'])
12 userbuild = os.path.join (env['absbuild'], 'Documentation/user', env['out'])
13
14 env.Depends ('lilypond.texi', env['LILYPOND_BIN'])
15 env.Depends ('lilypond.texi', 'lilypond-internals.texi')
16 env.Depends ('doc', mfbuild)
17
18 png_stems = map (lambda x: os.path.splitext (x)[0], pngs)
19 epss = map (env.Png2eps, png_stems)
20 env.Depends ('lilypond.texi', epss)
21
22 lydir = Dir ('.').srcnode ().abspath + '/../../ly'
23 env.Command ('lilypond-internals.texi', env['LILYPOND_BIN'],
24              'cd ${TARGET.dir} \
25              && LILYPONDPREFIX=$LILYPONDPREFIX $LILYPOND_BIN $__verbose \
26              $lydir/generate-documentation')
27
28 doc_stems = map (lambda x: os.path.splitext (x)[0], sources)
29 texis = map (env.Tely2texi, doc_stems)
30 dvis = map (env.Texi2dvi, doc_stems)
31 pss = map (env.PostScript, map (lambda x: x + '.dvi', doc_stems))
32 pdfs = map (env.Dvi2pdf, doc_stems)
33
34
35 def file_subst (file_name, find, subst):
36         s = open (file_name).read ()
37         t = string.replace (find, subst, s)
38         if s != t:
39                 os.rename (file_name, file_name + '~')
40                 h = open (file_name, "w")
41                 h.write (t)
42                 h.close ()
43
44 e = env.Copy ()
45 e['usersrc'] = Dir ('.').srcnode ().abspath
46 def url_fixup (target, source, env):
47         file_subst (str (target[0]),
48                     '\.\./lilypond-internals', 'lilypond-internals/')
49 a = ['$MAKEINFO -I$usersrc -I${SOURCE.dir} --html \
50 --css-include=$usersrc/../texinfo.css $__verbose \
51 --output=${TARGET.dir} $SOURCE',
52      '$MAKEINFO -I$usersrc -I${SOURCE.dir} --html --no-split --no-headers \
53      --css-include=$usersrc/../texinfo.css $__verbose \
54      --output=$TARGET $SOURCE',
55      url_fixup,
56      'ln -f ${SOURCE.dir}/*.png ${SOURCE.dir}/*.ly ${TARGET.dir}/']
57      
58 e.Command ('lilypond/lilypond.html', 'lilypond.texi', a)
59 e.Command ('lilypond-internals/lilypond-internals.html',
60              'lilypond-internals.texi', a)
61
62 env.Alias ('doc', texis)
63 env.Alias ('doc', dvis)
64 env.Alias ('doc', pss)
65 env.Alias ('doc', pdfs)
66
67 env.Alias ('doc', 'lilypond/lilypond.html')
68 env.Alias ('doc', 'lilypond-internals/lilypond-internals.html')