7 * Add @nodes, plit at sections?
8 * Less kludged first introduction file
18 program_name = 'lys-to-tely'
21 sys.stdout.write (r"""Usage: lys-to-tely [OPTIONS]... LY-FILE...
22 Construct tely doc from LY-FILEs.
25 -h, --help print this help
26 -n, --name=NAME write tely doc to NAME
27 -t, --title=TITLE set tely doc title TITLE
28 -i, --introduction=FILE use FILE as intruduction at the top
29 -f, --footer=FILE use FILE as footer on the bottom of the page
34 (options, files) = getopt.getopt(sys.argv[1:], 'hn:t:i:f:', [
35 'help', 'name=', 'title=', 'introduction=', 'footer='])
44 if o == '-h' or o == '--help':
46 elif o == '-n' or o == '--name':
48 elif o == '-t' or o == '--title':
50 elif o == '-i' or o == '--introduction':
52 elif o == '-f' or o == '--footer':
55 raise 'unknown opt ', o
57 def strip_extension (f, ext):
58 (p, e) = os.path.splitext (f)
64 dir = os.path.dirname (name)
67 name = strip_extension (os.path.basename (name), ".tely")
73 @documentencoding utf-8
78 @finalout @c we do not want black boxes.
82 @author Han-Wen Nienhuys and Jan Nieuwenhuizen
87 ''' % (name, title, title)
90 header_text = open (header).read ()
104 s += "\n\n@lilypondfile[printfilename,texidoc]{%s}" % n
107 s = s + string.join (map (lambda x: name2line (x), files), "\n")
110 footer_text = open (footer).read ()
114 f = "%s/%s.tely" % (dir, name)
115 sys.stderr.write ("%s: writing %s..." % (program_name, f))
119 sys.stderr.write ('\n')
121 # not Unix philosophy, but hey, at least we notice when
122 # we don't distribute any .ly files.
123 sys.stderr.write ("No files specified. Doing nothing")