]> git.donarmstrong.com Git - lilypond.git/blobdiff - buildscripts/texi-langutils.py
Doc-de: updates from master
[lilypond.git] / buildscripts / texi-langutils.py
index d949662206dc1a888674572edf70c8f5e177392c..720b520a2e8aa8e33c647c6909d86e0723cec170 100644 (file)
@@ -26,9 +26,9 @@ make_gettext = ('--gettext', '') in optlist   # --gettext    generate a node lis
 make_skeleton = ('--skeleton', '') in optlist # --skeleton   extract the node tree from a Texinfo source
 
 output_file = 'doc.pot'
-node_blurb = '''@ifhtml
-UNTRANSLATED NODE: IGNORE ME
-@end ifhtml
+
+# @untranslated should be defined as a macro in Texinfo source
+node_blurb = '''@untranslated
 '''
 doclang = ''
 head_committish = read_pipe ('git-rev-parse HEAD')
@@ -61,8 +61,9 @@ texinfo_with_menus_re = re.compile (r"^(\*) +([^:\n]+)::.*?$|^@(include|menu|end
 
 texinfo_re = re.compile (r"^@(include|node|(?:unnumbered|appendix)(?:(?:sub){0,2}sec)?|top|chapter|(?:sub){0,2}section|(?:major|chap|(?:sub){0,2})heading) *(.+?)$|@(rglos){(.+?)}", re.M)
 
-ly_string_re = re.compile (r'^([a-zA-Z]+)[\t ]*=|%+[\t ]*(.*)$')
-verbatim_ly_re = re.compile (r'@lilypond\[.*?verbatim')
+ly_string_re = re.compile (r'^([a-zA-Z]+)[\t ]*=|%+[\t ]*(.*)$|\\(?:new|context)\s+(?:[a-zA-Z]*?(?:Staff(?:Group)?|Voice|FiguredBass|FretBoards|Names|Devnull))\s+=\s+"?([a-zA-Z]+)"?\s+')
+lsr_verbatim_ly_re = re.compile (r'% begin verbatim$')
+texinfo_verbatim_ly_re = re.compile (r'^@lilypond\[.*?verbatim')
 
 def process_texi (texifilename, i_blurb, n_blurb, write_skeleton, topfile, output_file=None, scan_ly=False):
     try:
@@ -73,23 +74,32 @@ def process_texi (texifilename, i_blurb, n_blurb, write_skeleton, topfile, outpu
         includes = []
 
         # process ly var names and comments
-        if output_file and scan_ly:
+        if output_file and (scan_ly or texifilename.endswith ('.ly')):
             lines = texifile.splitlines ()
             i = 0
             in_verb_ly_block = False
+            if texifilename.endswith ('.ly'):
+                verbatim_ly_re = lsr_verbatim_ly_re
+            else:
+                verbatim_ly_re = texinfo_verbatim_ly_re
             for i in range (len (lines)):
-                if verbatim_ly_re.match (lines[i]):
+                if verbatim_ly_re.search (lines[i]):
                     in_verb_ly_block = True
                 elif lines[i].startswith ('@end lilypond'):
                     in_verb_ly_block = False
                 elif in_verb_ly_block:
-                    for (var, comment) in ly_string_re.findall (lines[i]):
+                    for (var, comment, context_id) in ly_string_re.findall (lines[i]):
                         if var:
                             output_file.write ('# ' + printedfilename + ':' + \
                                                str (i + 1) + ' (variable)\n_(r"' + var + '")\n')
                         elif comment:
                             output_file.write ('# ' + printedfilename + ':' + \
-                                               str (i + 1) + ' (comment)\n_(r"' + comment + '")\n')
+                                               str (i + 1) + ' (comment)\n_(r"' + \
+                                               comment.replace ('"', '\\"') + '")\n')
+                        elif context_id:
+                            output_file.write ('# ' + printedfilename + ':' + \
+                                               str (i + 1) + ' (context id)\n_(r"' + \
+                                               context_id + '")\n')
 
         # process Texinfo node names and section titles
         if write_skeleton:
@@ -139,7 +149,7 @@ def process_texi (texifilename, i_blurb, n_blurb, write_skeleton, topfile, outpu
             for item in includes:
                 process_texi (os.path.join (dir, item.strip ()), i_blurb, n_blurb, write_skeleton, topfile, output_file, scan_ly)
     except IOError, (errno, strerror):
-        sys.stderr.write ("I/O error(%s): %s: %s" % (errno, texifilename, strerror))
+        sys.stderr.write ("I/O error(%s): %s: %s\n" % (errno, texifilename, strerror))
 
 
 if intro_blurb != '':