X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=buildscripts%2Flys-to-tely.py;h=e74c7145034e26f715bb73dfb04da015aef57c39;hb=5c14a087ca6cbd665fd631452b7b1283ba0387c3;hp=236aacb920130babef18b9ac09d0ad2c38b0ca37;hpb=7e00360a3fa89bcecaacfe00f5fbe3ea13e21037;p=lilypond.git diff --git a/buildscripts/lys-to-tely.py b/buildscripts/lys-to-tely.py old mode 100644 new mode 100755 index 236aacb920..e74c714503 --- a/buildscripts/lys-to-tely.py +++ b/buildscripts/lys-to-tely.py @@ -17,9 +17,7 @@ program_name = 'lys-to-tely' include_snippets = '@lysnippets' fragment_options = 'printfilename,texidoc' - -def help (): - sys.stdout.write (r"""Usage: %(program_name)s [OPTIONS]... LY-FILE... +help_text = r"""Usage: %(program_name)s [OPTIONS]... LY-FILE... Construct tely doc from LY-FILEs. Options: @@ -32,7 +30,10 @@ Options: instead of standard template; TEMPLATE should contain a command '%(include_snippets)s' to tell where to insert LY-FILEs. When this option is used, NAME and TITLE are ignored. -""" % vars ()) +""" + +def help (text): + sys.stdout.write ( text) sys.exit (0) (options, files) = getopt.getopt (sys.argv[1:], 'f:hn:t:', @@ -42,7 +43,7 @@ name = "ly-doc" title = "Ly Doc" template = '''\input texinfo @setfilename %%(name)s.info -@settitle %%(name)s +@settitle %%(title)s @documentencoding utf-8 @iftex @@ -58,6 +59,7 @@ template = '''\input texinfo @end ignore @node Top, , , (dir) +@top %%(title)s %s @@ -68,7 +70,10 @@ for opt in options: o = opt[0] a = opt[1] if o == '-h' or o == '--help': - help () + # We can't use vars () inside a function, as that only contains all + # local variables and none of the global variables! Thus we have to + # generate the help text here and pass it to the function... + help (help_text % vars ()) elif o == '-n' or o == '--name': name = a elif o == '-t' or o == '--title': @@ -80,24 +85,16 @@ for opt in options: else: raise Exception ('unknown option: ' + o) -def shorten_file_name (n): - # ugh, regtests file names appear as full paths in GUB builds - # we try to do something here - b = os.path.basename (n) - if os path.exists (b): - return b - return n - def name2line (n): - # UGR s = r""" @ifhtml @html - + @end html @end ifhtml -@lilypondfile[%s]{%s}""" % (n, fragment_options, n) +@lilypondfile[%s]{%s} +""" % (os.path.basename (n), fragment_options, n) return s if files: @@ -106,7 +103,6 @@ if files: name = os.path.basename (name) template = template % vars () - files = map (shorten_file_name, files) files.sort () s = "\n".join (map (name2line, files)) s = template.replace (include_snippets, s, 1)