]> git.donarmstrong.com Git - lilypond.git/blobdiff - scripts/lilypond-book.py
Merge branch 'lilypond/translation' of ssh://trettig@git.sv.gnu.org/srv/git/lilypond...
[lilypond.git] / scripts / lilypond-book.py
index 81cb7845509c1b4f6a9c2602bfb45436d7ec2449..8e14256ccb8a96712a83b05ab235f1d389a7c26d 100644 (file)
@@ -136,8 +136,8 @@ def get_option_parser ():
                   action='store', dest='info_images_dir',
                   default='')
 
-    p.add_option ('--latex',
-                  help=_ ("Run executable PROG instead of latex"),
+    p.add_option ('--latex-program',
+                  help=_ ("run executable PROG instead of latex"),
                   metavar=_ ("PROG"),
                   action='store', dest='latex_program',
                   default='latex')
@@ -183,11 +183,6 @@ def get_option_parser ():
                   help=_ ("create PDF files for use with PDFTeX"),
                   default=False)
 
-    p.add_option ('', '--psfonts', action="store_true", dest="psfonts",
-                  help=_ ('''extract all PostScript fonts into INPUT.psfonts for LaTeX
-must use this with dvips -h INPUT.psfonts'''),
-                  default=None)
-
     p.add_option ('-V', '--verbose', help=_ ("be verbose"),
                   action="store_true",
                   default=False,
@@ -240,6 +235,7 @@ LILYQUOTE = 'lilyquote'
 NOFRAGMENT = 'nofragment'
 NOINDENT = 'noindent'
 NOQUOTE = 'noquote'
+NORAGGED_RIGHT = 'noragged-right'
 NOTES = 'body'
 NOTIME = 'notime'
 OUTPUT = 'output'
@@ -252,6 +248,7 @@ QUOTE = 'quote'
 RAGGED_RIGHT = 'ragged-right'
 RELATIVE = 'relative'
 STAFFSIZE = 'staffsize'
+DOCTITLE = 'doctitle'
 TEXIDOC = 'texidoc'
 TEXINFO = 'texinfo'
 VERBATIM = 'verbatim'
@@ -538,6 +535,7 @@ simple_options = [
     NOFRAGMENT,
     NOINDENT,
     PRINTFILENAME,
+    DOCTITLE,
     TEXIDOC,
     LANG,
     VERBATIM,
@@ -565,6 +563,8 @@ ly_options = {
 
         RAGGED_RIGHT: r'''ragged-right = ##t''',
 
+        NORAGGED_RIGHT: r'''ragged-right = ##f''',
+
         PACKED: r'''packed = ##t''',
     },
 
@@ -996,6 +996,12 @@ class LilypondSnippet (Snippet):
             if k not in self.option_dict:
                 self.option_dict[k] = default_ly_options[k]
 
+        # RELATIVE does not work without FRAGMENT;
+        # make RELATIVE imply FRAGMENT
+        has_relative = self.option_dict.has_key (RELATIVE)
+        if has_relative and not self.option_dict.has_key (FRAGMENT):
+            self.option_dict[FRAGMENT] = None
+
         if not has_line_width:
             if type == 'lilypond' or FRAGMENT in self.option_dict:
                 self.option_dict[RAGGED_RIGHT] = None
@@ -1202,12 +1208,22 @@ class LilypondSnippet (Snippet):
         if not skip_lily:
             require_file (base + '-systems.count')
 
+        if 'ddump-profile' in global_options.process_cmd:
+            require_file (base + '.profile')
+        if 'dseparate-log-file' in global_options.process_cmd:
+            require_file (base + '.log')
+
         map (consider_file, [base + '.tex',
                              base + '.eps',
                              base + '.texidoc',
+                             base + '.doctitle',
                              base + '-systems.texi',
                              base + '-systems.tex',
                              base + '-systems.pdftexi'])
+        if document_language:
+            map (consider_file,
+                 [base + '.texidoc' + document_language,
+                  base + '.doctitle' + document_language])
 
         # UGH - junk global_options
         if (base + '.eps' in result and self.format in (HTML, TEXINFO)
@@ -1222,11 +1238,18 @@ class LilypondSnippet (Snippet):
         system_count = 0
         if not skip_lily and not missing:
             system_count = int(file (full + '-systems.count').read())
+
         for number in range(1, system_count + 1):
             systemfile = '%s-%d' % (base, number)
             require_file (systemfile + '.eps')
             consider_file (systemfile + '.pdf')
-        
+
+            # We can't require signatures, since books and toplevel
+            # markups do not output a signature.
+            if 'ddump-signature' in global_options.process_cmd:
+                consider_file (systemfile + '.signature')
+             
+       
         return (result, missing)
     
     def is_outdated (self, output_dir, current_files):
@@ -1350,6 +1373,13 @@ class LilypondSnippet (Snippet):
     def output_texinfo (self):
         str = self.output_print_filename (TEXINFO)
         base = self.basename ()
+        if DOCTITLE in self.option_dict:
+            doctitle = base + '.doctitle'
+            translated_doctitle = doctitle + document_language
+            if os.path.exists (translated_doctitle):
+                str += '@lydoctitle %s\n' % open (translated_doctitle).read ()
+            elif os.path.exists (doctitle):
+                str += '@lydoctitle %s\n' % open (doctitle).read ()
         if TEXIDOC in self.option_dict:
             texidoc = base + '.texidoc'
             translated_texidoc = texidoc + document_language
@@ -1747,9 +1777,14 @@ def write_if_updated (file_name, lines):
             # this prevents make from always rerunning lilypond-book:
             # output file must be touched in order to be up to date
             os.utime (file_name, None)
+            return
     except:
         pass
 
+    output_dir = os.path.dirname (file_name)
+    if not os.path.exists (output_dir):
+        os.makedirs (output_dir)
+
     progress (_ ("Writing `%s'...") % file_name)
     file (file_name, 'w').writelines (lines)
     progress ('\n')
@@ -1768,7 +1803,7 @@ def samefile (f1, f2):
         f2 = re.sub ("//*", "/", f2)
         return f1 == f2
 
-def do_file (input_filename):
+def do_file (input_filename, included=False):
     # Ugh.
     if not input_filename or input_filename == '-':
         in_handle = sys.stdin
@@ -1786,6 +1821,8 @@ def do_file (input_filename):
 
     if input_filename == '-':
         input_base = 'stdin'
+    elif included:
+        input_base = os.path.splitext (input_filename)[0]
     else:
         input_base = os.path.basename (
             os.path.splitext (input_filename)[0])
@@ -1856,7 +1893,7 @@ def do_file (input_filename):
             name = snippet.substring ('filename')
             progress (_ ("Processing include: %s") % name)
             progress ('\n')
-            return do_file (name)
+            return do_file (name, included=True)
 
         include_chunks = map (process_include,
                               filter (lambda x: isinstance (x, IncludeSnippet),
@@ -1908,8 +1945,13 @@ def main ():
                                       + ' --formats=%s -dbackend=eps ' % formats)
 
     if global_options.process_cmd:
-        global_options.process_cmd += ' '.join ([(' -I %s' % ly.mkarg (p))
-                                                 for p in global_options.include_path])
+        includes = global_options.include_path
+        if global_options.lily_output_dir:
+            # This must be first, so lilypond prefers to read .ly
+            # files in the other lybookdb dir.
+            includes = [os.path.abspath(global_options.lily_output_dir)] + includes
+        global_options.process_cmd += ' '.join ([' -I %s' % ly.mkarg (p)
+                                                 for p in includes])
 
     if global_options.format in (TEXINFO, LATEX):
         ## prevent PDF from being switched on by default.