]> git.donarmstrong.com Git - lilypond.git/blobdiff - scripts/auxiliar/translations-status.py
translations-status.py: produce .texi that compiles. Use it.
[lilypond.git] / scripts / auxiliar / translations-status.py
index f4ca62c0b90abbad37bdcc75fe6136119f4282d1..7337a4f43c137eff07d2588f9353913c28555ef2 100755 (executable)
@@ -3,12 +3,6 @@
 '''
 USAGE: cd Documentation && translations-status.py
 
-TODO:
-   * layout tweaks for TexiMarkup
-     - set html table border
-     - collapse first column
-   * switch to using TexiMarkup (see #markup = ..)
-
   Write:
     translations.itexi
     <LANG>/translations.itexi
@@ -16,6 +10,15 @@ TODO:
 
   Update word counts in:
     contributor/doc-translation-list.itexi
+
+TODO:
+   * decide if we really want this in printed output:
+     - the PDF output of TexiMarkup () is useless
+     - the INFO output of TexiMarkup() is useless
+     - using markup = HTMLMarkup (), we get nice <td title="FILENAME">
+       popups -- do we want that with texi output? -- how?
+       or possibly links to the git archive?
+
 '''
 
 import sys
@@ -184,6 +187,24 @@ def tely_word_count (tely_doc):
     return [len (space_re.split (n)) for n in nodes]
 
 class HTMLMarkup (object):
+    texi_header = '''@c -*- coding: utf-8; mode: texinfo; -*-
+@c This file was generated by translation-status.py -- DO NOT EDIT!
+@ignore
+    Translation of GIT committish: 0
+@end ignore
+
+'''
+    texi_footer = '''
+'''
+    def texi (self, string):
+        return (self.texi_header
+                + '''
+@ifnothtml
+Translation status currently only available in HTML.
+@end ifnothtml
+'''
+                + self.html (string)
+                + self.texi_footer)
     def entity (self, name, string='', attributes=[]):
         attr_list = ''.join ([' %s="%s"' % x for x in attributes])
         return '<%(name)s%(attr_list)s>%(string)s</%(name)s>' % locals ()
@@ -208,6 +229,20 @@ class HTMLMarkup (object):
         return self.entity ('em', string, attributes)
 
 class TexiMarkup (HTMLMarkup):
+    def texi (self, string):
+        return (self.texi_header
+                + self.html ('''
+<style type="text/css"><!--
+th { border: 1px solid black; text-align: center; }
+td { border: 1px solid black; text-align: center; }
+!--></style>
+''')
+                + (string
+                   .replace ('''item \n@tab ''', '''item
+''')
+                   .replace ('@multitable',
+                             '@multitable @columnfractions' + ' 0' * 10))
+                + self.texi_footer)
     def entity (self, name, string='', attributes=[]):
         return '''
 @%(name)s
@@ -219,9 +254,7 @@ class TexiMarkup (HTMLMarkup):
     def table (self, string):
         # Ugh, makeinfo is fine without @columnfractions
         # but texi2html 1.82 barfs: `empty multicolumn'
-        return (self.entity ('multitable', string)
-                .replace ('@multitable',
-                          '@multitable @columnfractions' + ' .1' * 10))
+        return (self.entity ('multitable', string))
     def headrow (self, string, attributes=[]):
         return '''
 @headitem ''' + string
@@ -233,14 +266,19 @@ class TexiMarkup (HTMLMarkup):
 @tab ''' + string
     headcell = cell
     def newline (self):
-        return ''' @*
+        return '''
+@*
 '''
     def html (self, string):
         return self.entity ('ifhtml', self.entity ('html', string))
+    def nothtml (self, string):
+        return self.entity ('ifnothtml', string)
     def span (self, string, attributes=[]):
-        return self.html (HTMLMarkup ().span (string, attributes))
+        return (self.html (HTMLMarkup ().span (string, attributes))
+                + self.nothtml (string))
     def small (self, string, attributes=[]):
-        return self.html (HTMLMarkup ().small (string, attributes))
+        return (self.html (HTMLMarkup ().small (string, attributes))
+                + self.nothtml (string))
     def command (self, name, string):
         return '@%(name)s{%(string)s}' % locals ()
     def emph (self, string, attributes=[]):
@@ -657,39 +695,12 @@ date_time = buildlib.read_pipe ('LANG= date -u')[0]
 
 # TEXI output sort of works
 # TODO: table border, td-titles :-)
-#markup = HTMLMarkup ()
+# markup = HTMLMarkup ()
 markup = TexiMarkup ()
 
 main_status_body = markup.paragraph (markup.emph (last_updated_string % date_time))
 main_status_body += '\n'.join ([doc.texi_status (markup) for doc in master_docs])
-
-texi_header = '''@c -*- coding: utf-8; mode: texinfo; -*-
-@c This file was generated by translation-status.py -- DO NOT EDIT!
-@ignore
-    Translation of GIT committish: 0
-@end ignore
-
-'''
-
-if not isinstance (markup, TexiMarkup):
-    texi_header += '''
-@ifnothtml
-Translation status currently only available in HTML.
-@end ifnothtml
-@ifhtml
-@html
-'''
-
-texi_footer = '''
-'''
-
-if not isinstance (markup, TexiMarkup):
-    texi_footer += '''
-@end html
-@end ifhtml
-'''
-
-main_status_page = texi_header % locals () + main_status_body + texi_footer
+main_status_page = markup.texi (main_status_body)
 
 open ('translations.itexi', 'w').write (main_status_page)
 
@@ -699,7 +710,7 @@ for l in enabled_languages:
     texi_status = '\n'.join ([doc.translations[l].texi_status (markup)
                               for doc in master_docs
                               if l in doc.translations])
-    lang_status_page = texi_header + updated + texi_status + texi_footer
+    lang_status_page = markup.texi (updated + texi_status)
     open (os.path.join (l, 'translations.itexi'), 'w').write (lang_status_page)
 
 main_status_txt = '''Documentation translations status