]> git.donarmstrong.com Git - lilypond.git/blobdiff - scripts/build/lys-to-tely.py
lys-to-tely.py: read from a file instead of stdin
[lilypond.git] / scripts / build / lys-to-tely.py
index f0de9cd66b0b320e1614254bc3c1ddad594ca691..a911e02aa2e02d5b99b42b21476f65b0eee62046 100644 (file)
@@ -6,6 +6,7 @@ TODO:
 
  * Add @nodes, split at sections?
 
+ * -o --output   listed in help is not implemented?!
 '''
 
 
@@ -26,6 +27,7 @@ Options:
  -f, --fragment-options=OPTIONS use OPTIONS as lilypond-book fragment
    options
  -o, --output=NAME              write tely doc to NAME
+ -i, --input-filenames=NAME     read list of files from a file instead of stdin
  -t, --title=TITLE              set tely doc title TITLE
  -a, --author=AUTHOR            set tely author AUTHOR
      --template=TEMPLATE        use TEMPLATE as Texinfo template file,
@@ -39,11 +41,14 @@ def help (text):
     sys.exit (0)
 
 (options, files) = getopt.getopt (sys.argv[1:], 'f:hn:t:',
-                     ['fragment-options=', 'help', 'name=', 'title=', 'author=', 'template='])
+                     ['fragment-options=', 'help', 'name=',
+                     'title=', 'author=', 'template=',
+                     'input-filenames='])
 
 name = "ly-doc"
 title = "Ly Doc"
 author = "Han-Wen Nienhuys and Jan Nieuwenhuizen"
+input_filename = ""
 template = '''\input texinfo
 @setfilename %%(name)s.info
 @settitle %%(title)s
@@ -83,6 +88,8 @@ for opt in options:
         title = a
     elif o == '-a' or o == '--author':
         author = a
+    elif o == '-i' or o == '--input-filenames':
+        input_filename = a
     elif o == '-f' or o == '--fragment-options':
         fragment_options = a
     elif o == '--template':
@@ -92,12 +99,16 @@ for opt in options:
 
 texi_file_re = re.compile ('.*\.i?te(ly|xi)$')
 html_file_re = re.compile ('.*\.i?htm(l)?$')
+xml_file_re = re.compile ('.*\.i?(xm|mx)l$')
+tex_file_re = re.compile ('.*\.i?(la)?tex$')
+pdf_file_re = re.compile ('.*\.i?pdf$')
 
 def name2line (n):
     if texi_file_re.match (n):
         # We have a texi include file, simply include it:
         s = r"@include %s" % os.path.basename (n)
-    if html_file_re.match (n):
+    elif (html_file_re.match (n) or pdf_file_re.match (n) or
+          tex_file_re.match (n)):
         s = r"""
 @ifhtml
 @html
@@ -106,7 +117,19 @@ def name2line (n):
 @end html
 @end ifhtml
 """ % (os.path.basename (n), os.path.basename (n))
-        return s
+
+    elif (xml_file_re.match (n)):
+        # Assume it's a MusicXML file -> convert, create image etc.
+        s = r"""
+@ifhtml
+@html
+<a name="%s"></a>
+@end html
+@end ifhtml
+
+@musicxmlfile[%s]{%s}
+""" % (os.path.basename (n), fragment_options, n)
+
     else:
         # Assume it's a lilypond file -> create image etc.
         s = r"""
@@ -120,6 +143,9 @@ def name2line (n):
 """ % (os.path.basename (n), fragment_options, n)
     return s
 
+if input_filename:
+    files = open(input_filename).read().splitlines()
+
 if files:
     dir = os.path.dirname (name) or "."
 # don't strip .tely extension, Documentation/snippets uses .itely