summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
ba9fe1a)
* buildscripts/texi-gettext.py: gettext @ref's properly by eating
trailing spaces and newlines.
* buildscripts/texi-gettext.py, make/doclang-targets.make: write
gettexted *.texi to *.pdftexi to avoid makeinfo generate unwanted
filenames.
* make/doclang-targets.make(local-WWW): use mass-link.py for merging
output.
#!@PYTHON@
# mass-link.py
#!@PYTHON@
# mass-link.py
-# USAGE: mass-link.py symbolic | hard SOURCEDIR DESTDIR FILES
+# USAGE: mass-link.py [--prepend-suffix SUFFIX] symbolic | hard SOURCEDIR DESTDIR FILES
#
# create hard or symbolic links to SOURCEDIR/FILES in DESTDIR
#
#
# create hard or symbolic links to SOURCEDIR/FILES in DESTDIR
#
+# if --prepend-suffix is specified, link to foo.bar will be called fooSUFFIX.bar
# shell-wildcard expansion is performed on FILES.
print "mass_link.py"
# shell-wildcard expansion is performed on FILES.
print "mass_link.py"
import sys
import os
import glob
import sys
import os
import glob
-
-link_type, source_dir, dest_dir = sys.argv[1:4]
-files = sys.argv[4:]
+import getopt
+
+optlist, args = getopt.getopt (sys.argv[1:], '', ['prepend-suffix='])
+link_type, source_dir, dest_dir = args[0:3]
+files = args[3:]
+
+prepended_suffix = ''
+for x in optlist:
+ if x[0] == '--prepend-suffix':
+ prepended_suffix = x[1]
+
+if prepended_suffix:
+ def insert_suffix (p):
+ l = p.split ('.')
+ if len (l) >= 2:
+ l[-2] += prepended_suffix
+ return '.'.join (l)
+ return p + prepended_suffix
+else:
+ insert_suffix = lambda p: p
if link_type == 'symbolic':
link = os.symlink
if link_type == 'symbolic':
link = os.symlink
for pattern in files:
sourcefiles += (glob.glob (os.path.join (source_dir, pattern)))
for pattern in files:
sourcefiles += (glob.glob (os.path.join (source_dir, pattern)))
-destfiles = map (lambda f: os.path.join (dest_dir, os.path.basename (f)), sourcefiles)
+destfiles = map (lambda f: os.path.join (dest_dir, insert_suffix (os.path.basename (f))), sourcefiles)
def force_link (src,dest):
if os.path.exists (dest):
def force_link (src,dest):
if os.path.exists (dest):
# USAGE: texi-gettext.py [-o OUTDIR] BUILDSCRIPT-DIR LOCALEDIR LANG FILES
#
# USAGE: texi-gettext.py [-o OUTDIR] BUILDSCRIPT-DIR LOCALEDIR LANG FILES
#
-# -o OUTDIR specifies that output files should be written in OUTDIR
-# rather than be overwritten
+# -o OUTDIR specifies that output files should rather be written in OUTDIR
#
print "texi_gettext.py"
#
print "texi_gettext.py"
import getopt
import gettext
import getopt
import gettext
-optlist, args = getopt.getopt(sys.argv[1:],'o:')
+optlist, args = getopt.getopt (sys.argv[1:],'o:')
buildscript_dir, localedir, lang = args[0:3]
outdir = '.'
buildscript_dir, localedir, lang = args[0:3]
outdir = '.'
t = gettext.translation('lilypond-doc', localedir, [lang])
_doc = t.gettext
t = gettext.translation('lilypond-doc', localedir, [lang])
_doc = t.gettext
-include_re = re.compile (r'@include (.*?)$', re.M)
+include_re = re.compile (r'@include ((?!lily-).*?)\.texi$', re.M)
+whitespaces = re.compile (r'\s+')
+ref_re = re.compile (r'(?ms)@(rglos|ref)(\{)(.*?)(\})')
+node_section_re = re.compile (r'@(node|(?:unnumbered|appendix)(?:(?:sub){0,2}sec)?|top|chapter|(?:sub){0,2}section|(?:major|chap|(?:sub){0,2})heading)( )(.*?)(\n)')
+menu_entry_re = re.compile (r'\* (.*?)::')
# Why not use recode?
# - well, it would add one more dependency...
# Why not use recode?
# - well, it would add one more dependency...
- return '@' + m.group (1) + m.group (2) + _doc (m.group (3)) + m.group (4)
+ if m.group (2) == '{':
+ r = whitespaces.sub (' ', m.group (3))
+ else:
+ r = m.group (3)
+ return '@' + m.group (1) + m.group (2) + _doc (r) + m.group (4)
def menu_entry_gettext (m):
return '* ' + _doc (m.group (1)) + '::'
def menu_entry_gettext (m):
return '* ' + _doc (m.group (1)) + '::'
+def include_replace (m, filename):
+ if os.path.exists (os.path.join (os.path.dirname (filename), m.group(1)) + '.texi'):
+ return '@include ' + m.group(1) + '.pdftexi'
+ return m.group(0)
+
def process_file (filename):
print "Processing %s" % filename
f = open (filename, 'r')
page = f.read ()
f.close()
def process_file (filename):
print "Processing %s" % filename
f = open (filename, 'r')
page = f.read ()
f.close()
- page = re.sub (r'@(node|(?:unnumbered|appendix)(?:(?:sub){0,2}sec)?|top|chapter|(?:sub){0,2}section|(?:major|chap|(?:sub){0,2})heading)( )(.*?)(\n)', title_gettext, page)
- page = re.sub (r'(?L)@(rglos|ref)(\{)(.*?)(\})', title_gettext, page)
- page = re.sub (r'\* (.*?)::', menu_entry_gettext, page)
+ page = node_section_re.sub (title_gettext, page)
+ page = ref_re.sub (title_gettext, page)
+ page = menu_entry_re.sub (menu_entry_gettext, page)
page = page.replace ("""-- SKELETON FILE --
When you actually translate this file, please remove these lines as
well as all `UNTRANSLATED NODE: IGNORE ME' lines.""", '')
page = page.replace ('UNTRANSLATED NODE: IGNORE ME', _doc ("This section has not been translated yet; please refer to the manual in English."))
page = page.replace ("""-- SKELETON FILE --
When you actually translate this file, please remove these lines as
well as all `UNTRANSLATED NODE: IGNORE ME' lines.""", '')
page = page.replace ('UNTRANSLATED NODE: IGNORE ME', _doc ("This section has not been translated yet; please refer to the manual in English."))
+ includes = include_re.findall (page)
+ page = include_re.sub (lambda m: include_replace (m, filename), page)
for (u_char, texiaccent_char) in accents2texi:
page = page.replace (u_char, texiaccent_char)
for (u_char, texiaccent_char) in accents2texi:
page = page.replace (u_char, texiaccent_char)
- p = os.path.join (outdir, filename)
+ p = os.path.join (outdir, filename) [:-4] + 'pdftexi'
f = open (p, 'w')
f.write (page)
f.close ()
dir = os.path.dirname (filename)
f = open (p, 'w')
f.write (page)
f.close ()
dir = os.path.dirname (filename)
- for file in include_re.findall (page):
- p = os.path.join (dir, file)
+ for file in includes:
+ p = os.path.join (dir, file) + '.texi'
if os.path.exists (p):
process_file (p)
if os.path.exists (p):
process_file (p)
MAKEINFO = LANG=$(ISOLANG) $(MAKEINFO_PROGRAM) --force
MAKEINFO = LANG=$(ISOLANG) $(MAKEINFO_PROGRAM) --force
-$(outdir)/lilypond/index.html: $(outdir)/lilypond.nexi user-ln doc-po
+$(outdir)/lilypond/index.html: $(outdir)/lilypond.nexi $(outdir)/user-ln doc-po
mkdir -p $(dir $@)
-$(MAKEINFO) -I$(outdir) --output=$(outdir)/lilypond --css-include=$(top-src-dir)/Documentation/texinfo.css --html $<
find $(outdir) -name '*.html' | xargs grep -L 'UNTRANSLATED NODE: IGNORE ME' | xargs $(PYTHON) $(buildscript-dir)/html-gettext.py $(buildscript-dir) $(top-build-dir)/Documentation/po/$(outdir) $(ISOLANG)
mkdir -p $(dir $@)
-$(MAKEINFO) -I$(outdir) --output=$(outdir)/lilypond --css-include=$(top-src-dir)/Documentation/texinfo.css --html $<
find $(outdir) -name '*.html' | xargs grep -L 'UNTRANSLATED NODE: IGNORE ME' | xargs $(PYTHON) $(buildscript-dir)/html-gettext.py $(buildscript-dir) $(top-build-dir)/Documentation/po/$(outdir) $(ISOLANG)
#$(outdir)/lilypond.html: $(outdir)/lilypond.nexi
# -$(MAKEINFO) -I$(outdir) --output=$@ --css-include=$(top-src-dir)/Documentation/texinfo.css --html --no-split --no-headers $<
#$(outdir)/lilypond.html: $(outdir)/lilypond.nexi
# -$(MAKEINFO) -I$(outdir) --output=$@ --css-include=$(top-src-dir)/Documentation/texinfo.css --html --no-split --no-headers $<
-$(outdir)/%.pdf: $(outdir)/%.texi user-ln doc-po
+$(outdir)/%.pdf: $(outdir)/%.texi $(outdir)/user-ln doc-po
$(PYTHON) $(buildscript-dir)/texi-gettext.py $(buildscript-dir) $(top-build-dir)/Documentation/po/$(outdir) $(ISOLANG) $<
$(PYTHON) $(buildscript-dir)/texi-gettext.py $(buildscript-dir) $(top-build-dir)/Documentation/po/$(outdir) $(ISOLANG) $<
- cp $< $(<)~
- cd $(outdir); texi2pdf --batch $(TEXINFO_PAPERSIZE_OPTION) $(<F)
+ cd $(outdir); texi2pdf --batch $(TEXINFO_PAPERSIZE_OPTION) $(notdir $*).pdftexi
local-WWW: $(outdir)/lilypond.pdf $(outdir)/lilypond/index.html
local-WWW: $(outdir)/lilypond.pdf $(outdir)/lilypond/index.html
- $(foreach i, $(shell find $(outdir) -name '*.html' | xargs grep -L --label="" 'UNTRANSLATED NODE: IGNORE ME'), ln -f $(i) $(i:$(outdir)/%.html=$(depth)/Documentation/user/$(outdir)/%.$(ISOLANG).html) &&) ln -f $(outdir)/lilypond.pdf $(depth)/Documentation/user/$(outdir)/lilypond.$(ISOLANG).pdf && true
+ find $(outdir) -name '*.html' | xargs grep -L --label="" 'UNTRANSLATED NODE: IGNORE ME' | xargs $(PYTHON) $(buildscript-dir)/mass-link.py --prepend-suffix .$(ISOLANG) hard . $(depth)/Documentation/user/$(outdir) $(outdir)/lilypond.pdf
+# ugh, this is not enough to avoid wasting build time, $(outdir)/user-ln should be touched for all languages
+ touch -mr $(top-build-dir)/Documentation/user/$(outdir) $(outdir)/user-ln
LINKED_PNGS = henle-flat-gray.png baer-flat-gray.png lily-flat-bw.png
LINKED_PNGS = henle-flat-gray.png baer-flat-gray.png lily-flat-bw.png
# lilypond-book -I flag seems broken too, and texi2pdf -I flag confuses
# pdfetex with .aux and other files from English manual
# symlinking lily-*...
# lilypond-book -I flag seems broken too, and texi2pdf -I flag confuses
# pdfetex with .aux and other files from English manual
# symlinking lily-*...
+$(outdir)/user-ln: $(top-build-dir)/Documentation/user/$(outdir)
+ touch -mr $(top-build-dir)/Documentation/user/$(outdir) $@
mkdir -p $(outdir)/lilypond
$(PYTHON) $(buildscript-dir)/mass-link.py symbolic $(top-build-dir)/Documentation/user/$(outdir) $(outdir) 'lily-*.pdf' 'lily-*.tex' 'lily-*.texi' 'lily-*.ly' 'lily-*.txt' 'lily-*.png' 'henle-flat-gray.*' 'baer-flat-gray.*' 'lily-flat-bw.*'
cd $(outdir)/lilypond && $(foreach i, $(LINKED_PNGS), ln -sf ../../$(depth)/Documentation/user/$(i) $(i) &&) true
mkdir -p $(outdir)/lilypond
$(PYTHON) $(buildscript-dir)/mass-link.py symbolic $(top-build-dir)/Documentation/user/$(outdir) $(outdir) 'lily-*.pdf' 'lily-*.tex' 'lily-*.texi' 'lily-*.ly' 'lily-*.txt' 'lily-*.png' 'henle-flat-gray.*' 'baer-flat-gray.*' 'lily-flat-bw.*'
cd $(outdir)/lilypond && $(foreach i, $(LINKED_PNGS), ln -sf ../../$(depth)/Documentation/user/$(i) $(i) &&) true