7 * Add @nodes, split at sections?
16 program_name = 'lys-to-tely'
18 include_snippets = '@lysnippets'
19 fragment_options = 'printfilename,texidoc'
20 help_text = r"""Usage: %(program_name)s [OPTIONS]... LY-FILE...
21 Construct tely doc from LY-FILEs.
24 -h, --help print this help
25 -f, --fragment-options=OPTIONS use OPTIONS as lilypond-book fragment
27 -o, --output=NAME write tely doc to NAME
28 -t, --title=TITLE set tely doc title TITLE
29 --template=TEMPLATE use TEMPLATE as Texinfo template file,
30 instead of standard template; TEMPLATE should contain a command
31 '%(include_snippets)s' to tell where to insert LY-FILEs. When this
32 option is used, NAME and TITLE are ignored.
36 sys.stdout.write ( text)
39 (options, files) = getopt.getopt (sys.argv[1:], 'f:hn:t:',
40 ['fragment-options=', 'help', 'name=', 'title=', 'template='])
44 template = '''\input texinfo
45 @setfilename %%(name)s.info
48 @documentencoding utf-8
53 @finalout @c we do not want black boxes.
57 @author Han-Wen Nienhuys and Jan Nieuwenhuizen
66 ''' % include_snippets
71 if o == '-h' or o == '--help':
72 # We can't use vars () inside a function, as that only contains all
73 # local variables and none of the global variables! Thus we have to
74 # generate the help text here and pass it to the function...
75 help (help_text % vars ())
76 elif o == '-n' or o == '--name':
78 elif o == '-t' or o == '--title':
80 elif o == '-f' or o == '--fragment-options':
82 elif o == '--template':
83 template = open (a, 'r').read ()
85 raise Exception ('unknown option: ' + o)
96 """ % (os.path.basename (n), fragment_options, n)
100 dir = os.path.dirname (name) or "."
101 # don't strip .tely extension, input/lsr uses .itely
102 name = os.path.basename (name)
103 template = template % vars ()
106 s = "\n".join (map (name2line, files))
107 s = template.replace (include_snippets, s, 1)
108 f = "%s/%s" % (dir, name)
109 sys.stderr.write ("%s: writing %s..." % (program_name, f))
113 sys.stderr.write ('\n')
115 # not Unix philosophy, but hey, at least we notice when
116 # we don't distribute any .ly files.
117 sys.stderr.write ("No files specified. Doing nothing")